commit 4cf54acb419b8e8424b68021ed14bb98259772dc
parent 30390de6e2f54a6e984065abe2cc9026ea659ed5
Author: Christian Grothoff <christian@grothoff.org>
Date: Thu, 25 Dec 2025 13:41:42 +0100
enable test_str_base64.c
Diffstat:
2 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/src/tests/unit/Makefile.am b/src/tests/unit/Makefile.am
@@ -31,15 +31,16 @@ endif
LDADD = $(MHD_LIBDEPS)
check_PROGRAMS = \
+ test_str_base64 \
+ test_str_bin_hex \
test_str_compare \
- test_str_to_value \
test_str_from_value \
test_str_quote \
+ test_str_to_value \
test_str_token \
test_str_token_remove \
test_str_tokens_remove \
test_str_pct \
- test_str_bin_hex \
unit_str
if MHD_SUPPORT_HTTP2
diff --git a/src/tests/unit/test_str_base64.c b/src/tests/unit/test_str_base64.c
@@ -23,11 +23,14 @@
* @author Karlson2k (Evgeny Grin)
*/
-#include "mhd_options.h"
+#include "mhd_sys_options.h"
#include <string.h>
#include <stdio.h>
-#include "mhd_str.h"
-#include "mhd_assert.h"
+#include "../mhd2/mhd_str.h"
+#include "../mhd2/mhd_str.c"
+#include "mhdt_checks.h"
+#include "mhdt_has_param.h"
+#include "../mhd2/mhd_assert.h"
#ifndef MHD_STATICSTR_LEN_
/**
@@ -58,19 +61,19 @@ expect_decoded_n (const char *const encoded, const size_t encoded_len,
ret = 0;
memset (buf, fill_chr, sizeof(buf)); /* Fill buffer with some character */
- res_size = MHD_base64_to_bin_n (encoded, encoded_len, buf, decoded_size);
+ res_size = mhd_base64_to_bin_n (encoded, encoded_len, buf, decoded_size);
if (res_size != decoded_size)
{
ret = 1;
fprintf (stderr,
- "'MHD_base64_to_bin_n ()' FAILED: Wrong returned value:\n");
+ "'mhd_base64_to_bin_n ()' FAILED: Wrong returned value:\n");
}
else if ((0 != decoded_size) && (0 != memcmp (buf, decoded, decoded_size)))
{
ret = 1;
fprintf (stderr,
- "'MHD_base64_to_bin_n ()' FAILED: Wrong output binary:\n");
+ "'mhd_base64_to_bin_n ()' FAILED: Wrong output binary:\n");
}
if (0 != ret)
{
@@ -79,27 +82,27 @@ expect_decoded_n (const char *const encoded, const size_t encoded_len,
if (TEST_BIN_MAX_SIZE <= res_size * 2)
{
fprintf (stderr,
- "\tRESULT : MHD_base64_to_bin_n ('%.*s', %u, ->(too long), %u)"
+ "\tRESULT : mhd_base64_to_bin_n ('%.*s', %u, ->(too long), %u)"
" -> %u\n",
(int) encoded_len, encoded, (unsigned) encoded_len,
(unsigned) decoded_size, (unsigned) res_size);
}
else
{
- prnt_size = MHD_bin_to_hex_z (buf, res_size, prnt);
+ prnt_size = mhd_bin_to_hex_z (buf, res_size, prnt);
mhd_assert (2 * res_size == prnt_size);
fprintf (stderr,
- "\tRESULT : MHD_base64_to_bin_n ('%.*s', %u, ->%.*sh, %u)"
+ "\tRESULT : mhd_base64_to_bin_n ('%.*s', %u, ->%.*sh, %u)"
" -> %u\n",
(int) encoded_len, encoded, (unsigned) encoded_len,
(int) prnt_size, prnt, (unsigned) decoded_size,
(unsigned) res_size);
}
- prnt_size = MHD_bin_to_hex_z (decoded, decoded_size, prnt);
+ prnt_size = mhd_bin_to_hex_z (decoded, decoded_size, prnt);
mhd_assert (2 * decoded_size == prnt_size);
fprintf (stderr,
- "\tEXPECTED: MHD_base64_to_bin_n ('%.*s', %u, ->%.*sh, %u)"
+ "\tEXPECTED: mhd_base64_to_bin_n ('%.*s', %u, ->%.*sh, %u)"
" -> %u\n",
(int) encoded_len, encoded, (unsigned) encoded_len,
(int) prnt_size, prnt, (unsigned) decoded_size,
@@ -645,13 +648,13 @@ expect_fail_n (const char *const encoded, const size_t encoded_len,
ret = 0;
memset (buf, fill_chr, sizeof(buf)); /* Fill buffer with some character */
- res_size = MHD_base64_to_bin_n (encoded, encoded_len, buf, sizeof(buf));
+ res_size = mhd_base64_to_bin_n (encoded, encoded_len, buf, sizeof(buf));
if (res_size != 0)
{
ret = 1;
fprintf (stderr,
- "'MHD_base64_to_bin_n ()' FAILED: Wrong returned value:\n");
+ "'mhd_base64_to_bin_n ()' FAILED: Wrong returned value:\n");
}
if (0 != ret)
{
@@ -660,25 +663,25 @@ expect_fail_n (const char *const encoded, const size_t encoded_len,
if (TEST_BIN_MAX_SIZE <= res_size * 2)
{
fprintf (stderr,
- "\tRESULT : MHD_base64_to_bin_n ('%.*s', %u, ->(too long), %u)"
+ "\tRESULT : mhd_base64_to_bin_n ('%.*s', %u, ->(too long), %u)"
" -> %u\n",
(int) encoded_len, encoded, (unsigned) encoded_len,
(unsigned) sizeof(buf), (unsigned) res_size);
}
else
{
- prnt_size = MHD_bin_to_hex_z (buf, res_size, prnt);
+ prnt_size = mhd_bin_to_hex_z (buf, res_size, prnt);
mhd_assert (2 * res_size == prnt_size);
fprintf (stderr,
- "\tRESULT : MHD_base64_to_bin_n ('%.*s', %u, ->%.*sh, %u)"
+ "\tRESULT : mhd_base64_to_bin_n ('%.*s', %u, ->%.*sh, %u)"
" -> %u\n",
(int) encoded_len, encoded, (unsigned) encoded_len,
(int) prnt_size, prnt, (unsigned) sizeof(buf),
(unsigned) res_size);
}
fprintf (stderr,
- "\tEXPECTED: MHD_base64_to_bin_n ('%.*s', %u, ->(empty), %u)"
+ "\tEXPECTED: mhd_base64_to_bin_n ('%.*s', %u, ->(empty), %u)"
" -> 0\n",
(int) encoded_len, encoded, (unsigned) encoded_len,
(unsigned) sizeof(buf));