diff -r 26541c37b619 -r 42cdbf9bbd49 test/base64.c --- a/test/base64.c Tue Oct 14 21:02:26 2025 +0200 +++ b/test/base64.c Sat Nov 08 23:06:11 2025 +0100 @@ -35,18 +35,20 @@ #include #include -CX_TEST(test_util_base64decode) { +UCX_TEST(test_util_base64decode) { char *s1 = util_base64decode("YWJj"); char *s2 = util_base64decode("aGVsbG8gd29ybGQ="); char *s3 = util_base64decode("MA=="); char *s4 = util_base64decode("MHh4MQ=="); - 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")); - } + 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; free(s1); free(s2); @@ -54,7 +56,7 @@ free(s4); } -CX_TEST(test_util_base64decode_len) { +UCX_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 @@ -63,25 +65,27 @@ char *s5 = util_base64decode_len("YWJjLS0tLS0tM3g=", &len5); // 11 char *s6 = util_base64decode_len("YWJjZGVmZy4uLjs7MGhlbGxv", &len6); // 18 - 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); - } + 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; free(s1); free(s2); @@ -91,7 +95,7 @@ free(s6); } -CX_TEST(test_util_base64encode) { +UCX_TEST(test_util_base64encode) { char *str1 = "hello world"; char *str2 = "test string"; char *str3 = "01234567890123456789012345678901234567890123456789"; @@ -123,19 +127,21 @@ char *b9 = util_base64encode(str9, strlen(str9)); char *b10 = util_base64encode(str10, strlen(str10)); - 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")); - } + 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; free(b1); free(b2);