libmicrohttpd2

HTTP server C library (MHD 2.x, alpha)
Log | Files | Refs | README | LICENSE

commit 45f60a2d8a3140f14a3cc74bdac0ec919d7f3f20
parent 95c7cee1d7a4964604e51c7dc5185a37757acb32
Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
Date:   Thu, 25 Dec 2025 18:26:49 +0100

test_str_to_value.c: adapted to the new internal API

Diffstat:
Msrc/tests/unit/test_str_to_value.c | 302++++++++++++++++++++++++++++++++++++++++---------------------------------------
1 file changed, 153 insertions(+), 149 deletions(-)

diff --git a/src/tests/unit/test_str_to_value.c b/src/tests/unit/test_str_to_value.c @@ -24,10 +24,6 @@ */ #include "mhd_sys_options.h" -#include "../mhd2/mhd_str.h" -#include "../mhd2/mhd_str.c" -#include "mhdt_checks.h" -#include "mhdt_has_param.h" #include <stdio.h> #include <locale.h> @@ -35,16 +31,19 @@ #ifdef HAVE_INTTYPES_H #include <inttypes.h> #else /* ! HAVE_INTTYPES_H */ -#define PRIu64 "llu" -#define PRIuPTR "u" -#define PRIX64 "llX" +#define PRIuFAST64 "llu" +#define PRIuPTR "llu" +#define PRIXFAST64 "llX" #endif /* ! HAVE_INTTYPES_H */ #include <stdint.h> #ifdef HAVE_STDLIB_H #include <stdlib.h> #endif /* HAVE_STDLIB_H */ -#include "mhd_limits.h" + #include "mhd_str.h" +#include "mhd_str.c" +#include "mhdt_checks.h" +#include "mhdt_has_param.h" static int verbose = 0; /* verbose level (0-3)*/ @@ -316,7 +315,7 @@ struct str_with_value { const struct str_with_len str; const size_t num_of_digt; - const uint64_t val; + const uint_fast64_t val; }; /* valid string for conversion to unsigned integer value */ @@ -591,7 +590,7 @@ check_str_to_uint64_valid (void) set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { - uint64_t rv; + uint_fast64_t rv; size_t rs; const struct str_with_value *const t = dstrs_w_values + i; @@ -615,7 +614,8 @@ check_str_to_uint64_valid (void) t_failed++; c_failed[i] = ! 0; fprintf (stderr, - "FAILED: mhd_str_to_uint64(\"%s\", ->%" PRIu64 ") returned %" + "FAILED: mhd_str_to_uint64(\"%s\", ->%" PRIuFAST64 + ") returned %" PRIuPTR ", while expecting %d." " Locale: %s\n", n_prnt (t->str.str), rv, (uintptr_t) rs, @@ -626,15 +626,15 @@ check_str_to_uint64_valid (void) t_failed++; c_failed[i] = ! 0; fprintf (stderr, - "FAILED: mhd_str_to_uint64(\"%s\", ->%" PRIu64 + "FAILED: mhd_str_to_uint64(\"%s\", ->%" PRIuFAST64 ") converted string to value %" - PRIu64 "," - " while expecting result %" PRIu64 ". Locale: %s\n", + PRIuFAST64 "," + " while expecting result %" PRIuFAST64 ". Locale: %s\n", n_prnt (t->str.str), rv, rv, t->val, get_current_locale_str ()); } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) - printf ("PASSED: mhd_str_to_uint64(\"%s\", ->%" PRIu64 ") == %" \ + printf ("PASSED: mhd_str_to_uint64(\"%s\", ->%" PRIuFAST64 ") == %" \ PRIuPTR "\n", n_prnt (t->str.str), rv, rs); } @@ -656,12 +656,12 @@ check_str_to_uint64_all_chars (void) for (j = 0; j < locale_name_count; j++) { unsigned int c; - uint64_t test_val; + uint_fast64_t test_val; set_test_locale (j); /* setlocale() can be slow! */ for (c = 0; c < n_checks; c++) { - static const uint64_t rnd_val = 24941852; + static const uint_fast64_t rnd_val = 24941852; size_t rs; if ((c >= '0') && (c <= '9') ) continue; /* skip digits */ @@ -669,7 +669,7 @@ check_str_to_uint64_all_chars (void) rnd_val) { char test_str[] = "0123"; - uint64_t rv = test_val; + uint_fast64_t rv = test_val; test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ rs = mhd_str_to_uint64 (test_str, &rv); @@ -678,7 +678,7 @@ check_str_to_uint64_all_chars (void) t_failed++; c_failed[c] = ! 0; fprintf (stderr, - "FAILED: mhd_str_to_uint64(\"%s\", ->%" PRIu64 + "FAILED: mhd_str_to_uint64(\"%s\", ->%" PRIuFAST64 ") returned %" PRIuPTR ", while expecting zero." " Locale: %s\n", n_prnt (test_str), rv, (uintptr_t) rs, @@ -690,7 +690,7 @@ check_str_to_uint64_all_chars (void) c_failed[c] = ! 0; fprintf (stderr, "FAILED: mhd_str_to_uint64(\"%s\", &ret_val) modified value of ret_val" - " (before call: %" PRIu64 ", after call %" PRIu64 + " (before call: %" PRIuFAST64 ", after call %" PRIuFAST64 "). Locale: %s\n", n_prnt (test_str), test_val, rv, get_current_locale_str ()); } @@ -727,13 +727,13 @@ check_str_to_uint64_overflow (void) { size_t rs; const struct str_with_len *const t = str_ovflw + i; - static const uint64_t rnd_val = 2; - uint64_t test_val; + static const uint_fast64_t rnd_val = 2; + uint_fast64_t test_val; for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += rnd_val) { - uint64_t rv = test_val; + uint_fast64_t rv = test_val; rs = mhd_str_to_uint64 (t->str, &rv); if (rs != 0) @@ -741,7 +741,7 @@ check_str_to_uint64_overflow (void) t_failed++; c_failed[i] = ! 0; fprintf (stderr, - "FAILED: mhd_str_to_uint64(\"%s\", ->%" PRIu64 + "FAILED: mhd_str_to_uint64(\"%s\", ->%" PRIuFAST64 ") returned %" PRIuPTR ", while expecting zero." " Locale: %s\n", n_prnt (t->str), rv, (uintptr_t) rs, @@ -753,7 +753,7 @@ check_str_to_uint64_overflow (void) c_failed[i] = ! 0; fprintf (stderr, "FAILED: mhd_str_to_uint64(\"%s\", &ret_val) modified value of ret_val" - " (before call: %" PRIu64 ", after call %" PRIu64 + " (before call: %" PRIuFAST64 ", after call %" PRIuFAST64 "). Locale: %s\n", n_prnt (t->str), test_val, rv, get_current_locale_str ()); } @@ -785,13 +785,13 @@ check_str_to_uint64_no_val (void) { size_t rs; const struct str_with_len *const t = str_no_num + i; - static const uint64_t rnd_val = 74218431; - uint64_t test_val; + static const uint_fast64_t rnd_val = 74218431; + uint_fast64_t test_val; for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += rnd_val) { - uint64_t rv = test_val; + uint_fast64_t rv = test_val; rs = mhd_str_to_uint64 (t->str, &rv); if (rs != 0) @@ -799,7 +799,7 @@ check_str_to_uint64_no_val (void) t_failed++; c_failed[i] = ! 0; fprintf (stderr, - "FAILED: mhd_str_to_uint64(\"%s\", ->%" PRIu64 + "FAILED: mhd_str_to_uint64(\"%s\", ->%" PRIuFAST64 ") returned %" PRIuPTR ", while expecting zero." " Locale: %s\n", n_prnt (t->str), rv, (uintptr_t) rs, @@ -811,7 +811,7 @@ check_str_to_uint64_no_val (void) c_failed[i] = ! 0; fprintf (stderr, "FAILED: mhd_str_to_uint64(\"%s\", &ret_val) modified value of ret_val" - " (before call: %" PRIu64 ", after call %" PRIu64 + " (before call: %" PRIuFAST64 ", after call %" PRIuFAST64 "). Locale: %s\n", n_prnt (t->str), test_val, rv, get_current_locale_str ()); } @@ -842,7 +842,7 @@ check_str_to_uint64_n_valid (void) set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { - uint64_t rv = 1235572; /* some random value */ + uint_fast64_t rv = 1235572; /* some random value */ size_t rs = 0; size_t len; const struct str_with_value *const t = dstrs_w_values + i; @@ -866,7 +866,7 @@ check_str_to_uint64_n_valid (void) c_failed[i] = ! 0; fprintf (stderr, "FAILED: mhd_str_to_uint64_n(\"%s\", %" PRIuPTR ", ->%" - PRIu64 ")" + PRIuFAST64 ")" " returned %" PRIuPTR ", while expecting %d. Locale: %s\n", n_prnt (t->str.str), (uintptr_t) len, rv, (uintptr_t) rs, (int) t->num_of_digt, get_current_locale_str ()); @@ -877,9 +877,9 @@ check_str_to_uint64_n_valid (void) c_failed[i] = ! 0; fprintf (stderr, "FAILED: mhd_str_to_uint64_n(\"%s\", %" PRIuPTR ", ->%" - PRIu64 ")" - " converted string to value %" PRIu64 - ", while expecting result %" PRIu64 + PRIuFAST64 ")" + " converted string to value %" PRIuFAST64 + ", while expecting result %" PRIuFAST64 ". Locale: %s\n", n_prnt (t->str.str), (uintptr_t) len, rv, rv, t->val, get_current_locale_str ()); @@ -887,7 +887,7 @@ check_str_to_uint64_n_valid (void) } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: mhd_str_to_uint64_n(\"%s\", %" PRIuPTR "..%" - PRIuPTR ", ->%" PRIu64 ")" " == %" PRIuPTR "\n", + PRIuPTR ", ->%" PRIuFAST64 ")" " == %" PRIuPTR "\n", n_prnt (t->str.str), (uintptr_t) t->num_of_digt, (uintptr_t) t->str.len + 1, rv, rs); @@ -910,12 +910,12 @@ check_str_to_uint64_n_all_chars (void) for (j = 0; j < locale_name_count; j++) { unsigned int c; - uint64_t test_val; + uint_fast64_t test_val; set_test_locale (j); /* setlocale() can be slow! */ for (c = 0; c < n_checks; c++) { - static const uint64_t rnd_val = 98372558; + static const uint_fast64_t rnd_val = 98372558; size_t rs; size_t len; @@ -928,7 +928,7 @@ check_str_to_uint64_n_all_chars (void) rnd_val) { char test_str[] = "0123"; - uint64_t rv = test_val; + uint_fast64_t rv = test_val; test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ rs = mhd_str_to_uint64_n (test_str, len, &rv); @@ -938,7 +938,7 @@ check_str_to_uint64_n_all_chars (void) c_failed[c] = ! 0; fprintf (stderr, "FAILED: mhd_str_to_uint64_n(\"%s\", %" PRIuPTR ", ->%" - PRIu64 ")" + PRIuFAST64 ")" " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", n_prnt (test_str), (uintptr_t) len, rv, (uintptr_t) rs, @@ -951,8 +951,8 @@ check_str_to_uint64_n_all_chars (void) fprintf (stderr, "FAILED: mhd_str_to_uint64_n(\"%s\", %" PRIuPTR ", &ret_val)" - " modified value of ret_val (before call: %" PRIu64 - ", after call %" PRIu64 ")." + " modified value of ret_val (before call: %" PRIuFAST64 + ", after call %" PRIuFAST64 ")." " Locale: %s\n", n_prnt (test_str), (uintptr_t) len, test_val, rv, get_current_locale_str ()); @@ -991,16 +991,16 @@ check_str_to_uint64_n_overflow (void) { size_t rs; const struct str_with_len *const t = str_ovflw + i; - static const uint64_t rnd_val = 3; + static const uint_fast64_t rnd_val = 3; size_t len; for (len = t->len; len <= t->len + 1; len++) { - uint64_t test_val; + uint_fast64_t test_val; for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += rnd_val) { - uint64_t rv = test_val; + uint_fast64_t rv = test_val; rs = mhd_str_to_uint64_n (t->str, len, &rv); if (rs != 0) @@ -1009,7 +1009,7 @@ check_str_to_uint64_n_overflow (void) c_failed[i] = ! 0; fprintf (stderr, "FAILED: mhd_str_to_uint64_n(\"%s\", %" PRIuPTR ", ->%" - PRIu64 ")" + PRIuFAST64 ")" " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", n_prnt (t->str), (uintptr_t) len, rv, (uintptr_t) rs, @@ -1022,8 +1022,8 @@ check_str_to_uint64_n_overflow (void) fprintf (stderr, "FAILED: mhd_str_to_uint64_n(\"%s\", %" PRIuPTR ", &ret_val)" - " modified value of ret_val (before call: %" PRIu64 - ", after call %" PRIu64 ")." + " modified value of ret_val (before call: %" PRIuFAST64 + ", after call %" PRIuFAST64 ")." " Locale: %s\n", n_prnt (t->str), (uintptr_t) len, test_val, rv, get_current_locale_str ()); @@ -1059,16 +1059,16 @@ check_str_to_uint64_n_no_val (void) { size_t rs; const struct str_with_len *const t = str_no_num + i; - static const uint64_t rnd_val = 43255654342; + static const uint_fast64_t rnd_val = 43255654342; size_t len; for (len = 0; len <= t->len + 1; len++) { - uint64_t test_val; + uint_fast64_t test_val; for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += rnd_val) { - uint64_t rv = test_val; + uint_fast64_t rv = test_val; rs = mhd_str_to_uint64_n (t->str, len, &rv); if (rs != 0) @@ -1077,7 +1077,7 @@ check_str_to_uint64_n_no_val (void) c_failed[i] = ! 0; fprintf (stderr, "FAILED: mhd_str_to_uint64_n(\"%s\", %" PRIuPTR ", ->%" - PRIu64 ")" + PRIuFAST64 ")" " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", n_prnt (t->str), (uintptr_t) len, rv, (uintptr_t) rs, @@ -1090,8 +1090,8 @@ check_str_to_uint64_n_no_val (void) fprintf (stderr, "FAILED: mhd_str_to_uint64_n(\"%s\", %" PRIuPTR ", &ret_val)" - " modified value of ret_val (before call: %" PRIu64 - ", after call %" PRIu64 ")." + " modified value of ret_val (before call: %" PRIuFAST64 + ", after call %" PRIuFAST64 ")." " Locale: %s\n", n_prnt (t->str), (uintptr_t) len, test_val, rv, get_current_locale_str ()); @@ -1129,7 +1129,7 @@ check_strx_to_uint32_valid (void) size_t rs; const struct str_with_value *const t = xdstrs_w_values + i; - if (t->val > UINT32_MAX) + if (t->val != (uint_fast32_t) t->val) continue; /* number is too high for this function */ if (c_failed[i]) @@ -1152,11 +1152,11 @@ check_strx_to_uint32_valid (void) t_failed++; c_failed[i] = ! 0; fprintf (stderr, - "FAILED: mhd_strx_to_uint32(\"%s\", ->0x%" PRIX64 + "FAILED: mhd_strx_to_uint32(\"%s\", ->0x%" PRIXFAST64 ") returned %" PRIuPTR " digits, while expecting %d." " Locale: %s\n", - n_prnt (t->str.str), (uint64_t) rv, + n_prnt (t->str.str), (uint_fast64_t) rv, (uintptr_t) rs, (int) t->num_of_digt, get_current_locale_str ()); @@ -1166,17 +1166,17 @@ check_strx_to_uint32_valid (void) t_failed++; c_failed[i] = ! 0; fprintf (stderr, - "FAILED: mhd_strx_to_uint32(\"%s\", ->0x%" PRIX64 + "FAILED: mhd_strx_to_uint32(\"%s\", ->0x%" PRIXFAST64 ") converted string to value 0x%" - PRIX64 "," - " while expecting result 0x%" PRIX64 ". Locale: %s\n", - n_prnt (t->str.str), (uint64_t) rv, (uint64_t) rv, + PRIXFAST64 "," + " while expecting result 0x%" PRIXFAST64 ". Locale: %s\n", + n_prnt (t->str.str), (uint_fast64_t) rv, (uint_fast64_t) rv, t->val, get_current_locale_str ()); } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) - printf ("PASSED: mhd_strx_to_uint32(\"%s\", ->0x%" PRIX64 ") == %" + printf ("PASSED: mhd_strx_to_uint32(\"%s\", ->0x%" PRIXFAST64 ") == %" PRIuPTR "\n", - n_prnt (t->str.str), (uint64_t) rv, rs); + n_prnt (t->str.str), (uint_fast64_t) rv, rs); } } return t_failed; @@ -1220,10 +1220,10 @@ check_strx_to_uint32_all_chars (void) t_failed++; c_failed[c] = ! 0; fprintf (stderr, - "FAILED: mhd_strx_to_uint32(\"%s\", ->0x%" PRIX64 + "FAILED: mhd_strx_to_uint32(\"%s\", ->0x%" PRIXFAST64 ") returned %" PRIuPTR " digits, while expecting zero." - " Locale: %s\n", n_prnt (test_str), (uint64_t) rv, + " Locale: %s\n", n_prnt (test_str), (uint_fast64_t) rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) @@ -1232,9 +1232,10 @@ check_strx_to_uint32_all_chars (void) c_failed[c] = ! 0; fprintf (stderr, "FAILED: mhd_strx_to_uint32(\"%s\", &ret_val) modified value of ret_val" - " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 + " (before call: 0x%" PRIXFAST64 ", after call 0x%" PRIXFAST64 "). Locale: %s\n", - n_prnt (test_str), (uint64_t) test_val, (uint64_t) rv, + n_prnt (test_str), (uint_fast64_t) test_val, + (uint_fast64_t) rv, get_current_locale_str ()); } } @@ -1284,8 +1285,8 @@ check_strx_to_uint32_overflow (void) { const struct str_with_value *const t = xdstrs_w_values + (i - n_checks1); - if (t->val <= UINT32_MAX) - continue; /* check only strings that should overflow uint32_t */ + if (t->val == (uint_fast32_t) t->val) + continue; /* check only strings that should overflow uint_fast32_t */ str = t->str.str; } @@ -1301,10 +1302,11 @@ check_strx_to_uint32_overflow (void) t_failed++; c_failed[i] = ! 0; fprintf (stderr, - "FAILED: mhd_strx_to_uint32(\"%s\", ->0x%" PRIX64 + "FAILED: mhd_strx_to_uint32(\"%s\", ->0x%" PRIXFAST64 ") returned %" PRIuPTR ", while expecting zero." - " Locale: %s\n", n_prnt (str), (uint64_t) rv, (uintptr_t) rs, + " Locale: %s\n", n_prnt (str), (uint_fast64_t) rv, + (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) @@ -1313,9 +1315,9 @@ check_strx_to_uint32_overflow (void) c_failed[i] = ! 0; fprintf (stderr, "FAILED: mhd_strx_to_uint32(\"%s\", &ret_val) modified value of ret_val" - " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 + " (before call: 0x%" PRIXFAST64 ", after call 0x%" PRIXFAST64 "). Locale: %s\n", - n_prnt (str), (uint64_t) test_val, (uint64_t) rv, + n_prnt (str), (uint_fast64_t) test_val, (uint_fast64_t) rv, get_current_locale_str ()); } } @@ -1360,10 +1362,10 @@ check_strx_to_uint32_no_val (void) t_failed++; c_failed[i] = ! 0; fprintf (stderr, - "FAILED: mhd_strx_to_uint32(\"%s\", ->0x%" PRIX64 + "FAILED: mhd_strx_to_uint32(\"%s\", ->0x%" PRIXFAST64 ") returned %" PRIuPTR ", while expecting zero." - " Locale: %s\n", n_prnt (t->str), (uint64_t) rv, + " Locale: %s\n", n_prnt (t->str), (uint_fast64_t) rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) @@ -1372,9 +1374,10 @@ check_strx_to_uint32_no_val (void) c_failed[i] = ! 0; fprintf (stderr, "FAILED: mhd_strx_to_uint32(\"%s\", &ret_val) modified value of ret_val" - " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 + " (before call: 0x%" PRIXFAST64 ", after call 0x%" PRIXFAST64 "). Locale: %s\n", - n_prnt (t->str), (uint64_t) test_val, (uint64_t) rv, + n_prnt (t->str), (uint_fast64_t) test_val, + (uint_fast64_t) rv, get_current_locale_str ()); } } @@ -1409,7 +1412,7 @@ check_strx_to_uint32_n_valid (void) size_t len; const struct str_with_value *const t = xdstrs_w_values + i; - if (t->val > UINT32_MAX) + if (t->val != (uint_fast32_t) t->val) continue; /* number is too high for this function */ if (t->str.len < t->num_of_digt) @@ -1431,9 +1434,9 @@ check_strx_to_uint32_n_valid (void) c_failed[i] = ! 0; fprintf (stderr, "FAILED: mhd_strx_to_uint32_n(\"%s\", %" PRIuPTR ", ->0x%" - PRIX64 ")" + PRIXFAST64 ")" " returned %" PRIuPTR ", while expecting %d. Locale: %s\n", - n_prnt (t->str.str), (uintptr_t) len, (uint64_t) rv, + n_prnt (t->str.str), (uintptr_t) len, (uint_fast64_t) rv, (uintptr_t) rs, (int) t->num_of_digt, get_current_locale_str ()); } @@ -1443,11 +1446,11 @@ check_strx_to_uint32_n_valid (void) c_failed[i] = ! 0; fprintf (stderr, "FAILED: mhd_strx_to_uint32_n(\"%s\", %" PRIuPTR ", ->0x%" - PRIX64 ")" - " converted string to value 0x%" PRIX64 - ", while expecting result 0x%" PRIX64 + PRIXFAST64 ")" + " converted string to value 0x%" PRIXFAST64 + ", while expecting result 0x%" PRIXFAST64 ". Locale: %s\n", n_prnt (t->str.str), (uintptr_t) len, - (uint64_t) rv, (uint64_t) rv, + (uint_fast64_t) rv, (uint_fast64_t) rv, t->val, get_current_locale_str ()); } } @@ -1455,10 +1458,10 @@ check_strx_to_uint32_n_valid (void) printf ( "PASSED: mhd_strx_to_uint32_n(\"%s\", %" PRIuPTR "..%" PRIuPTR ", ->0x%" - PRIX64 ")" + PRIXFAST64 ")" " == %" PRIuPTR "\n", n_prnt (t->str.str), (uintptr_t) t->num_of_digt, - (uintptr_t) t->str.len + 1, (uint64_t) rv, rs); + (uintptr_t) t->str.len + 1, (uint_fast64_t) rv, rs); } } return t_failed; @@ -1508,11 +1511,11 @@ check_strx_to_uint32_n_all_chars (void) c_failed[c] = ! 0; fprintf (stderr, "FAILED: mhd_strx_to_uint32_n(\"%s\", %" PRIuPTR ", ->0x%" - PRIX64 + PRIXFAST64 ")" " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", - n_prnt (test_str), (uintptr_t) len, (uint64_t) rv, + n_prnt (test_str), (uintptr_t) len, (uint_fast64_t) rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) @@ -1522,11 +1525,12 @@ check_strx_to_uint32_n_all_chars (void) fprintf (stderr, "FAILED: mhd_strx_to_uint32_n(\"%s\", %" PRIuPTR ", &ret_val)" - " modified value of ret_val (before call: 0x%" PRIX64 - ", after call 0x%" PRIX64 ")." + " modified value of ret_val (before call: 0x%" PRIXFAST64 + ", after call 0x%" PRIXFAST64 ")." " Locale: %s\n", - n_prnt (test_str), (uintptr_t) len, (uint64_t) test_val, - (uint64_t) rv, get_current_locale_str ()); + n_prnt (test_str), (uintptr_t) len, + (uint_fast64_t) test_val, + (uint_fast64_t) rv, get_current_locale_str ()); } } } @@ -1579,8 +1583,8 @@ check_strx_to_uint32_n_overflow (void) { const struct str_with_value *const t = xdstrs_w_values + (i - n_checks1); - if (t->val <= UINT32_MAX) - continue; /* check only strings that should overflow uint32_t */ + if (t->val == (uint_fast32_t) t->val) + continue; /* check only strings that should overflow uint_fast32_t */ if (t->str.len < t->num_of_digt) { @@ -1612,11 +1616,11 @@ check_strx_to_uint32_n_overflow (void) c_failed[i] = ! 0; fprintf (stderr, "FAILED: mhd_strx_to_uint32_n(\"%s\", %" PRIuPTR ", ->0x%" - PRIX64 + PRIXFAST64 ")" " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", - n_prnt (str), (uintptr_t) len, (uint64_t) rv, + n_prnt (str), (uintptr_t) len, (uint_fast64_t) rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) @@ -1626,10 +1630,10 @@ check_strx_to_uint32_n_overflow (void) fprintf (stderr, "FAILED: mhd_strx_to_uint32_n(\"%s\", %" PRIuPTR ", &ret_val)" - " modified value of ret_val (before call: 0x%" PRIX64 - ", after call 0x%" PRIX64 ")." + " modified value of ret_val (before call: 0x%" PRIXFAST64 + ", after call 0x%" PRIXFAST64 ")." " Locale: %s\n", n_prnt (str), (uintptr_t) len, - (uint64_t) test_val, (uint64_t) rv, + (uint_fast64_t) test_val, (uint_fast64_t) rv, get_current_locale_str ()); } } @@ -1681,11 +1685,11 @@ check_strx_to_uint32_n_no_val (void) c_failed[i] = ! 0; fprintf (stderr, "FAILED: mhd_strx_to_uint32_n(\"%s\", %" PRIuPTR ", ->0x%" - PRIX64 + PRIXFAST64 ")" " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", - n_prnt (t->str), (uintptr_t) len, (uint64_t) rv, + n_prnt (t->str), (uintptr_t) len, (uint_fast64_t) rv, (uintptr_t) rs, get_current_locale_str ()); } else if (rv != test_val) @@ -1695,10 +1699,10 @@ check_strx_to_uint32_n_no_val (void) fprintf (stderr, "FAILED: mhd_strx_to_uint32_n(\"%s\", %" PRIuPTR ", &ret_val)" - " modified value of ret_val (before call: 0x%" PRIX64 - ", after call 0x%" PRIX64 ")." + " modified value of ret_val (before call: 0x%" PRIXFAST64 + ", after call 0x%" PRIXFAST64 ")." " Locale: %s\n", n_prnt (t->str), (uintptr_t) len, - (uint64_t) test_val, (uint64_t) rv, + (uint_fast64_t) test_val, (uint_fast64_t) rv, get_current_locale_str ()); } } @@ -1730,7 +1734,7 @@ check_strx_to_uint64_valid (void) set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { - uint64_t rv; + uint_fast64_t rv; size_t rs; const struct str_with_value *const t = xdstrs_w_values + i; @@ -1754,7 +1758,7 @@ check_strx_to_uint64_valid (void) t_failed++; c_failed[i] = ! 0; fprintf (stderr, - "FAILED: mhd_strx_to_uint64(\"%s\", ->0x%" PRIX64 + "FAILED: mhd_strx_to_uint64(\"%s\", ->0x%" PRIXFAST64 ") returned %" PRIuPTR ", while expecting %d." " Locale: %s\n", n_prnt (t->str.str), rv, (uintptr_t) rs, @@ -1765,15 +1769,15 @@ check_strx_to_uint64_valid (void) t_failed++; c_failed[i] = ! 0; fprintf (stderr, - "FAILED: mhd_strx_to_uint64(\"%s\", ->0x%" PRIX64 + "FAILED: mhd_strx_to_uint64(\"%s\", ->0x%" PRIXFAST64 ") converted string to value 0x%" - PRIX64 "," - " while expecting result 0x%" PRIX64 ". Locale: %s\n", + PRIXFAST64 "," + " while expecting result 0x%" PRIXFAST64 ". Locale: %s\n", n_prnt (t->str.str), rv, rv, t->val, get_current_locale_str ()); } if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) - printf ("PASSED: mhd_strx_to_uint64(\"%s\", ->0x%" PRIX64 ") == %" + printf ("PASSED: mhd_strx_to_uint64(\"%s\", ->0x%" PRIXFAST64 ") == %" PRIuPTR "\n", n_prnt (t->str.str), rv, rs); } @@ -1795,12 +1799,12 @@ check_strx_to_uint64_all_chars (void) for (j = 0; j < locale_name_count; j++) { unsigned int c; - uint64_t test_val; + uint_fast64_t test_val; set_test_locale (j); /* setlocale() can be slow! */ for (c = 0; c < n_checks; c++) { - static const uint64_t rnd_val = 234234; + static const uint_fast64_t rnd_val = 234234; size_t rs; if (( (c >= '0') && (c <= '9') ) || ( (c >= 'A') && (c <= 'F') ) @@ -1810,7 +1814,7 @@ check_strx_to_uint64_all_chars (void) rnd_val) { char test_str[] = "0123"; - uint64_t rv = test_val; + uint_fast64_t rv = test_val; test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ rs = mhd_strx_to_uint64 (test_str, &rv); @@ -1819,7 +1823,7 @@ check_strx_to_uint64_all_chars (void) t_failed++; c_failed[c] = ! 0; fprintf (stderr, - "FAILED: mhd_strx_to_uint64(\"%s\", ->0x%" PRIX64 + "FAILED: mhd_strx_to_uint64(\"%s\", ->0x%" PRIXFAST64 ") returned %" PRIuPTR ", while expecting zero." " Locale: %s\n", n_prnt (test_str), rv, (uintptr_t) rs, @@ -1831,7 +1835,7 @@ check_strx_to_uint64_all_chars (void) c_failed[c] = ! 0; fprintf (stderr, "FAILED: mhd_strx_to_uint64(\"%s\", &ret_val) modified value of ret_val" - " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 + " (before call: 0x%" PRIXFAST64 ", after call 0x%" PRIXFAST64 "). Locale: %s\n", n_prnt (test_str), test_val, rv, get_current_locale_str ()); } @@ -1868,13 +1872,13 @@ check_strx_to_uint64_overflow (void) { size_t rs; const struct str_with_len *const t = strx_ovflw + i; - static const uint64_t rnd_val = 74218431; - uint64_t test_val; + static const uint_fast64_t rnd_val = 74218431; + uint_fast64_t test_val; for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += rnd_val) { - uint64_t rv = test_val; + uint_fast64_t rv = test_val; rs = mhd_strx_to_uint64 (t->str, &rv); if (rs != 0) @@ -1882,7 +1886,7 @@ check_strx_to_uint64_overflow (void) t_failed++; c_failed[i] = ! 0; fprintf (stderr, - "FAILED: mhd_strx_to_uint64(\"%s\", ->0x%" PRIX64 + "FAILED: mhd_strx_to_uint64(\"%s\", ->0x%" PRIXFAST64 ") returned %" PRIuPTR ", while expecting zero." " Locale: %s\n", n_prnt (t->str), rv, (uintptr_t) rs, @@ -1894,7 +1898,7 @@ check_strx_to_uint64_overflow (void) c_failed[i] = ! 0; fprintf (stderr, "FAILED: mhd_strx_to_uint64(\"%s\", &ret_val) modified value of ret_val" - " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 + " (before call: 0x%" PRIXFAST64 ", after call 0x%" PRIXFAST64 "). Locale: %s\n", n_prnt (t->str), test_val, rv, get_current_locale_str ()); } @@ -1926,13 +1930,13 @@ check_strx_to_uint64_no_val (void) { size_t rs; const struct str_with_len *const t = str_no_num + i; - static const uint64_t rnd_val = 74218431; - uint64_t test_val; + static const uint_fast64_t rnd_val = 74218431; + uint_fast64_t test_val; for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += rnd_val) { - uint64_t rv = test_val; + uint_fast64_t rv = test_val; rs = mhd_strx_to_uint64 (t->str, &rv); if (rs != 0) @@ -1940,7 +1944,7 @@ check_strx_to_uint64_no_val (void) t_failed++; c_failed[i] = ! 0; fprintf (stderr, - "FAILED: mhd_strx_to_uint64(\"%s\", ->0x%" PRIX64 + "FAILED: mhd_strx_to_uint64(\"%s\", ->0x%" PRIXFAST64 ") returned %" PRIuPTR ", while expecting zero." " Locale: %s\n", n_prnt (t->str), rv, (uintptr_t) rs, @@ -1952,7 +1956,7 @@ check_strx_to_uint64_no_val (void) c_failed[i] = ! 0; fprintf (stderr, "FAILED: mhd_strx_to_uint64(\"%s\", &ret_val) modified value of ret_val" - " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 + " (before call: 0x%" PRIXFAST64 ", after call 0x%" PRIXFAST64 "). Locale: %s\n", n_prnt (t->str), test_val, rv, get_current_locale_str ()); } @@ -1982,7 +1986,7 @@ check_strx_to_uint64_n_valid (void) set_test_locale (j); /* setlocale() can be slow! */ for (i = 0; i < n_checks; i++) { - uint64_t rv = 2352932; /* some random value */ + uint_fast64_t rv = 2352932; /* some random value */ size_t rs = 0; size_t len; const struct str_with_value *const t = xdstrs_w_values + i; @@ -2006,7 +2010,7 @@ check_strx_to_uint64_n_valid (void) c_failed[i] = ! 0; fprintf (stderr, "FAILED: mhd_strx_to_uint64_n(\"%s\", %" PRIuPTR ", ->0x%" - PRIX64 ")" + PRIXFAST64 ")" " returned %" PRIuPTR ", while expecting %d. Locale: %s\n", n_prnt (t->str.str), (uintptr_t) len, rv, (uintptr_t) rs, (int) t->num_of_digt, get_current_locale_str ()); @@ -2017,9 +2021,9 @@ check_strx_to_uint64_n_valid (void) c_failed[i] = ! 0; fprintf (stderr, "FAILED: mhd_strx_to_uint64_n(\"%s\", %" PRIuPTR ", ->0x%" - PRIX64 ")" - " converted string to value 0x%" PRIX64 - ", while expecting result 0x%" PRIX64 + PRIXFAST64 ")" + " converted string to value 0x%" PRIXFAST64 + ", while expecting result 0x%" PRIXFAST64 ". Locale: %s\n", n_prnt (t->str.str), (uintptr_t) len, rv, rv, t->val, get_current_locale_str ()); @@ -2028,7 +2032,7 @@ check_strx_to_uint64_n_valid (void) if ((verbose > 1) && (j == locale_name_count - 1) && ! c_failed[i]) printf ("PASSED: mhd_strx_to_uint64_n(\"%s\", %" PRIuPTR "..%" PRIuPTR ", ->0x%" - PRIX64 ")" + PRIXFAST64 ")" " == %" PRIuPTR "\n", n_prnt (t->str.str), (uintptr_t) t->num_of_digt, (uintptr_t) t->str.len + 1, rv, rs); @@ -2051,12 +2055,12 @@ check_strx_to_uint64_n_all_chars (void) for (j = 0; j < locale_name_count; j++) { unsigned int c; - uint64_t test_val; + uint_fast64_t test_val; set_test_locale (j); /* setlocale() can be slow! */ for (c = 0; c < n_checks; c++) { - static const uint64_t rnd_val = 98372558; + static const uint_fast64_t rnd_val = 98372558; size_t rs; size_t len; @@ -2071,7 +2075,7 @@ check_strx_to_uint64_n_all_chars (void) rnd_val) { char test_str[] = "0123"; - uint64_t rv = test_val; + uint_fast64_t rv = test_val; test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ rs = mhd_strx_to_uint64_n (test_str, len, &rv); @@ -2081,7 +2085,7 @@ check_strx_to_uint64_n_all_chars (void) c_failed[c] = ! 0; fprintf (stderr, "FAILED: mhd_strx_to_uint64_n(\"%s\", %" PRIuPTR ", ->0x%" - PRIX64 + PRIXFAST64 ")" " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", @@ -2095,8 +2099,8 @@ check_strx_to_uint64_n_all_chars (void) fprintf (stderr, "FAILED: mhd_strx_to_uint64_n(\"%s\", %" PRIuPTR ", &ret_val)" - " modified value of ret_val (before call: 0x%" PRIX64 - ", after call 0x%" PRIX64 ")." + " modified value of ret_val (before call: 0x%" PRIXFAST64 + ", after call 0x%" PRIXFAST64 ")." " Locale: %s\n", n_prnt (test_str), (uintptr_t) len, test_val, rv, get_current_locale_str ()); @@ -2135,16 +2139,16 @@ check_strx_to_uint64_n_overflow (void) { size_t rs; const struct str_with_len *const t = strx_ovflw + i; - static const uint64_t rnd_val = 4; + static const uint_fast64_t rnd_val = 4; size_t len; for (len = t->len; len <= t->len + 1; len++) { - uint64_t test_val; + uint_fast64_t test_val; for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += rnd_val) { - uint64_t rv = test_val; + uint_fast64_t rv = test_val; rs = mhd_strx_to_uint64_n (t->str, len, &rv); if (rs != 0) @@ -2153,7 +2157,7 @@ check_strx_to_uint64_n_overflow (void) c_failed[i] = ! 0; fprintf (stderr, "FAILED: mhd_strx_to_uint64_n(\"%s\", %" PRIuPTR ", ->0x%" - PRIX64 + PRIXFAST64 ")" " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", @@ -2167,8 +2171,8 @@ check_strx_to_uint64_n_overflow (void) fprintf (stderr, "FAILED: mhd_strx_to_uint64_n(\"%s\", %" PRIuPTR ", &ret_val)" - " modified value of ret_val (before call: 0x%" PRIX64 - ", after call 0x%" PRIX64 ")." + " modified value of ret_val (before call: 0x%" PRIXFAST64 + ", after call 0x%" PRIXFAST64 ")." " Locale: %s\n", n_prnt (t->str), (uintptr_t) len, test_val, rv, get_current_locale_str ()); @@ -2204,16 +2208,16 @@ check_strx_to_uint64_n_no_val (void) { size_t rs; const struct str_with_len *const t = str_no_num + i; - static const uint64_t rnd_val = 3214314212UL; + static const uint_fast64_t rnd_val = 3214314212UL; size_t len; for (len = 0; len <= t->len + 1; len++) { - uint64_t test_val; + uint_fast64_t test_val; for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += rnd_val) { - uint64_t rv = test_val; + uint_fast64_t rv = test_val; rs = mhd_strx_to_uint64_n (t->str, len, &rv); if (rs != 0) @@ -2222,7 +2226,7 @@ check_strx_to_uint64_n_no_val (void) c_failed[i] = ! 0; fprintf (stderr, "FAILED: mhd_strx_to_uint64_n(\"%s\", %" PRIuPTR ", ->0x%" - PRIX64 + PRIXFAST64 ")" " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", @@ -2236,8 +2240,8 @@ check_strx_to_uint64_n_no_val (void) fprintf (stderr, "FAILED: mhd_strx_to_uint64_n(\"%s\", %" PRIuPTR ", &ret_val)" - " modified value of ret_val (before call: 0x%" PRIX64 - ", after call 0x%" PRIX64 ")." + " modified value of ret_val (before call: 0x%" PRIXFAST64 + ", after call 0x%" PRIXFAST64 ")." " Locale: %s\n", n_prnt (t->str), (uintptr_t) len, test_val, rv, get_current_locale_str ());