}
END_TEST
+START_TEST(str_base64_encode)
+{
+ /* All cases are taken from https://en.wikipedia.org/wiki/Base64 */
+
+ unsigned char *str = (unsigned char *)"any carnal pleasure.";
+ char *encoded;
+
+ encoded = eina_str_base64_encode(str, 20);
+ fail_unless(strcmp(encoded, "YW55IGNhcm5hbCBwbGVhc3VyZS4="));
+ free(encoded);
+
+ encoded = eina_str_base64_encode(str, 19);
+ fail_unless(strcmp(encoded, "YW55IGNhcm5hbCBwbGVhc3VyZQ=="));
+ free(encoded);
+
+ encoded = eina_str_base64_encode(str, 18);
+ fail_unless(strcmp(encoded, "YW55IGNhcm5hbCBwbGVhc3Vy"));
+ free(encoded);
+
+ encoded = eina_str_base64_encode(str, 17);
+ fail_unless(strcmp(encoded, "YW55IGNhcm5hbCBwbGVhc3U="));
+ free(encoded);
+
+ encoded = eina_str_base64_encode(str, 16);
+ fail_unless(strcmp(encoded, "YW55IGNhcm5hbCBwbGVhcw=="));
+ free(encoded);
+
+ encoded = eina_str_base64_encode((unsigned char *)"pleasure.", 9);
+ fail_unless(strcmp(encoded, "cGxlYXN1cmUu"));
+ free(encoded);
+
+ encoded = eina_str_base64_encode((unsigned char *)"leasure.", 8);
+ fail_unless(strcmp(encoded, "bGVhc3VyZS4="));
+ free(encoded);
+
+ encoded = eina_str_base64_encode((unsigned char *)"easure.", 7);
+ fail_unless(strcmp(encoded, "ZWFzdXJlLg=="));
+ free(encoded);
+
+ encoded = eina_str_base64_encode((unsigned char *)"asure.", 6);
+ fail_unless(strcmp(encoded, "YXN1cmUu"));
+ free(encoded);
+
+ encoded = eina_str_base64_encode((unsigned char *)"sure.", 5);
+ fail_unless(strcmp(encoded, "YXN1cmUu"));
+ free(encoded);
+}
+END_TEST
+
#ifdef HAVE_ICONV
START_TEST(str_convert)
{
tcase_add_test(tc, str_join_len);
tcase_add_test(tc, str_memdup);
tcase_add_test(tc, str_strftime);
+ tcase_add_test(tc, str_base64_encode);
#ifdef HAVE_ICONV
tcase_add_test(tc, str_convert);
#endif