libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit dce208464a89dfe8e72a4bc4e7aa6b0c8b2563bf
parent 4e8e5e653d7862378e4f3522905e2f4b4ed4067b
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Mon, 12 Jun 2023 20:23:25 +0300

tests: minor improvemnts

Diffstat:
Msrc/microhttpd/test_mhd_version.c | 25++++++++++++++++---------
Msrc/testcurl/test_long_header.c | 2++
2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/src/microhttpd/test_mhd_version.c b/src/microhttpd/test_mhd_version.c @@ -18,7 +18,7 @@ */ /** - * @file microhttpd/test_mhd_version.h + * @file microhttpd/test_mhd_version.с * @brief Tests for MHD versions identifiers * @author Karlson2k (Evgeny Grin) */ @@ -103,16 +103,22 @@ test_macro2_vs_func_str (void) static int test_func_str_vs_macro_bin (void) { -#ifdef HAVE_SNPRINTF - char bin_print[10]; + char bin_print[64]; int res; const char *str_func = MHD_get_version (); printf ("Checking MHD_get_version() function vs MHD_VERSION macro.\n"); +#ifdef HAVE_SNPRINTF res = snprintf (bin_print, sizeof(bin_print), "%X.%X.%X", (unsigned int) ((bin_macro >> 24) & 0xFF), (unsigned int) ((bin_macro >> 16) & 0xFF), (unsigned int) ((bin_macro >> 8) & 0xFF)); +#else /* ! HAVE_SNPRINTF */ + res = sprintf (bin_print, "%X.%X.%X", + (unsigned int) ((bin_macro >> 24) & 0xFF), + (unsigned int) ((bin_macro >> 16) & 0xFF), + (unsigned int) ((bin_macro >> 8) & 0xFF)); +#endif /* ! HAVE_SNPRINTF */ if ((9 < res) || (0 >= res)) { fprintf (stderr, "snprintf() error.\n"); @@ -132,11 +138,6 @@ test_func_str_vs_macro_bin (void) bin_macro, bin_print); return 0; -#else /* ! HAVE_SNPRINTF */ - fprintf (stderr, "snprintf() function is not available. " - "Cannot check binary/string match.\n"); - return 0; -#endif /* ! HAVE_SNPRINTF */ } @@ -219,5 +220,11 @@ main (void) res += test_macro_vs_func_bin (); res += test_func_bin_format (); - return 0 == res ? 0 : 1; + if (0 != res) + { + fprintf (stderr, "Test failed. Number of errors: %d\n", res); + return 1; + } + printf ("Test succeed.\n"); + return 0; } diff --git a/src/testcurl/test_long_header.c b/src/testcurl/test_long_header.c @@ -304,6 +304,8 @@ main (int argc, char *const *argv) errorCount += testLongHeaderGet (VERY_LONG / 2 + 1893); if (errorCount != 0) fprintf (stderr, "Error (code: %u)\n", errorCount); + else + printf ("Test succeed.\n"); curl_global_cleanup (); return (0 == errorCount) ? 0 : 1; /* 0 == pass */ }