--- a/test/base64.c Sun Sep 07 15:36:24 2025 +0200 +++ b/test/base64.c Sun Sep 07 15:57:36 2025 +0200 @@ -35,20 +35,18 @@ #include <cx/string.h> #include <libidav/utils.h> -UCX_TEST(test_util_base64decode) { +CX_TEST(test_util_base64decode) { char *s1 = util_base64decode("YWJj"); char *s2 = util_base64decode("aGVsbG8gd29ybGQ="); char *s3 = util_base64decode("MA=="); char *s4 = util_base64decode("MHh4MQ=="); - UCX_TEST_BEGIN; - - UCX_TEST_ASSERT(!strcmp(s1, "abc"), "s1 wrong"); - UCX_TEST_ASSERT(!strcmp(s2, "hello world"), "s2 wrong"); - UCX_TEST_ASSERT(!strcmp(s3, "0"), "s3 wrong"); - UCX_TEST_ASSERT(!strcmp(s4, "0xx1"), "s4 wrong"); - - UCX_TEST_END; + CX_TEST_DO { + CX_TEST_ASSERT(!strcmp(s1, "abc")); + CX_TEST_ASSERT(!strcmp(s2, "hello world")); + CX_TEST_ASSERT(!strcmp(s3, "0")); + CX_TEST_ASSERT(!strcmp(s4, "0xx1")); + } free(s1); free(s2); @@ -56,7 +54,7 @@ free(s4); } -UCX_TEST(test_util_base64decode_len) { +CX_TEST(test_util_base64decode_len) { int len1, len2, len3, len4, len5, len6; char *s1 = util_base64decode_len("aGVsbG8=", &len1); // 5 char *s2 = util_base64decode_len("MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5", &len2); // 30 @@ -65,27 +63,25 @@ char *s5 = util_base64decode_len("YWJjLS0tLS0tM3g=", &len5); // 11 char *s6 = util_base64decode_len("YWJjZGVmZy4uLjs7MGhlbGxv", &len6); // 18 - UCX_TEST_BEGIN; - - UCX_TEST_ASSERT(!strcmp(s1, "hello"), "s1 wrong"); - UCX_TEST_ASSERT(len1 == 5, "len1 wrong"); - - UCX_TEST_ASSERT(!strcmp(s2, "012345678901234567890123456789"), "s2 wrong"); - UCX_TEST_ASSERT(len2 == 30, "len2 wrong"); - - UCX_TEST_ASSERT(!strcmp(s3, "."), "s3 wrong"); - UCX_TEST_ASSERT(len3 == 1, "len3 wrong"); - - UCX_TEST_ASSERT(!strcmp(s4, "lol"), "s4 wrong"); - UCX_TEST_ASSERT(len4 == 3, "len4 wrong"); - - UCX_TEST_ASSERT(!strcmp(s5, "abc------3x"), "s5 wrong"); - UCX_TEST_ASSERT(len5 == 11, "len5 wrong"); - - UCX_TEST_ASSERT(!strcmp(s6, "abcdefg...;;0hello"), "s6 failed"); - UCX_TEST_ASSERT(len6 == 18, "len6 wrong"); - - UCX_TEST_END; + CX_TEST_DO { + CX_TEST_ASSERT(!strcmp(s1, "hello")); + CX_TEST_ASSERT(len1 == 5); + + CX_TEST_ASSERT(!strcmp(s2, "012345678901234567890123456789")); + CX_TEST_ASSERT(len2 == 30); + + CX_TEST_ASSERT(!strcmp(s3, ".")); + CX_TEST_ASSERT(len3 == 1); + + CX_TEST_ASSERT(!strcmp(s4, "lol")); + CX_TEST_ASSERT(len4 == 3); + + CX_TEST_ASSERT(!strcmp(s5, "abc------3x")); + CX_TEST_ASSERT(len5 == 11); + + CX_TEST_ASSERT(!strcmp(s6, "abcdefg...;;0hello")); + CX_TEST_ASSERT(len6 == 18); + } free(s1); free(s2); @@ -95,7 +91,7 @@ free(s6); } -UCX_TEST(test_util_base64encode) { +CX_TEST(test_util_base64encode) { char *str1 = "hello world"; char *str2 = "test string"; char *str3 = "01234567890123456789012345678901234567890123456789"; @@ -127,21 +123,19 @@ char *b9 = util_base64encode(str9, strlen(str9)); char *b10 = util_base64encode(str10, strlen(str10)); - UCX_TEST_BEGIN; - - UCX_TEST_ASSERT(!strcmp(b1, "aGVsbG8gd29ybGQ="), "b1 failed"); - UCX_TEST_ASSERT(!strcmp(b2, "dGVzdCBzdHJpbmc="), "b2 failed"); - UCX_TEST_ASSERT(!strcmp(b3, "MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODk="), "b3 failed"); - UCX_TEST_ASSERT(!strcmp(b4, "AAwDMgJuPwE="), "b4 failed"); - - UCX_TEST_ASSERT(!strcmp(b5, "YQ=="), "b5 failed"); - UCX_TEST_ASSERT(!strcmp(b6, "YWI="), "b6 failed"); - UCX_TEST_ASSERT(!strcmp(b7, "YWJj"), "b7 failed"); - UCX_TEST_ASSERT(!strcmp(b8, "YWJjZA=="), "b8 failed"); - UCX_TEST_ASSERT(!strcmp(b9, "YWJjZGU="), "b9 failed"); - UCX_TEST_ASSERT(!strcmp(b10, "YWJjZGVm"), "b10 failed"); - - UCX_TEST_END; + CX_TEST_DO { + CX_TEST_ASSERT(!strcmp(b1, "aGVsbG8gd29ybGQ=")); + CX_TEST_ASSERT(!strcmp(b2, "dGVzdCBzdHJpbmc=")); + CX_TEST_ASSERT(!strcmp(b3, "MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODk=")); + CX_TEST_ASSERT(!strcmp(b4, "AAwDMgJuPwE=")); + + CX_TEST_ASSERT(!strcmp(b5, "YQ==")); + CX_TEST_ASSERT(!strcmp(b6, "YWI=")); + CX_TEST_ASSERT(!strcmp(b7, "YWJj")); + CX_TEST_ASSERT(!strcmp(b8, "YWJjZA==")); + CX_TEST_ASSERT(!strcmp(b9, "YWJjZGU=")); + CX_TEST_ASSERT(!strcmp(b10, "YWJjZGVm")); + } free(b1); free(b2);