aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/test_str.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/test_str.c')
-rw-r--r--src/microhttpd/test_str.c403
1 files changed, 115 insertions, 288 deletions
diff --git a/src/microhttpd/test_str.c b/src/microhttpd/test_str.c
index 341585a2..75f8092b 100644
--- a/src/microhttpd/test_str.c
+++ b/src/microhttpd/test_str.c
@@ -35,6 +35,9 @@
35#define PRIX64 "llX" 35#define PRIX64 "llX"
36#endif /* ! HAVE_INTTYPES_H */ 36#endif /* ! HAVE_INTTYPES_H */
37#include <stdint.h> 37#include <stdint.h>
38#ifdef HAVE_STDLIB_H
39#include <stdlib.h>
40#endif /* HAVE_STDLIB_H */
38#include "mhd_limits.h" 41#include "mhd_limits.h"
39#include "mhd_str.h" 42#include "mhd_str.h"
40#include "test_helpers.h" 43#include "test_helpers.h"
@@ -208,11 +211,14 @@ static const unsigned int locale_name_count = sizeof(locale_names)
208 * Helper functions 211 * Helper functions
209 */ 212 */
210 213
211int 214static int
212set_test_locale (unsigned int num) 215set_test_locale (size_t num)
213{ 216{
214 if (num >= locale_name_count) 217 if (num >= locale_name_count)
215 return -1; 218 {
219 fprintf (stderr, "Unexpected number of locale.\n");
220 exit (99);
221 }
216 if (verbose > 2) 222 if (verbose > 2)
217 printf ("Setting locale \"%s\":", locale_names[num]); 223 printf ("Setting locale \"%s\":", locale_names[num]);
218 if (setlocale (LC_ALL, locale_names[num])) 224 if (setlocale (LC_ALL, locale_names[num]))
@@ -227,7 +233,7 @@ set_test_locale (unsigned int num)
227} 233}
228 234
229 235
230const char * 236static const char *
231get_current_locale_str (void) 237get_current_locale_str (void)
232{ 238{
233 char const *loc_str = setlocale (LC_ALL, NULL); 239 char const *loc_str = setlocale (LC_ALL, NULL);
@@ -239,7 +245,7 @@ static char tmp_bufs[4][4 * 1024]; /* should be enough for testing */
239static size_t buf_idx = 0; 245static size_t buf_idx = 0;
240 246
241/* print non-printable chars as char codes */ 247/* print non-printable chars as char codes */
242char * 248static char *
243n_prnt (const char *str) 249n_prnt (const char *str)
244{ 250{
245 static char *buf; /* should be enough for testing */ 251 static char *buf; /* should be enough for testing */
@@ -258,10 +264,10 @@ n_prnt (const char *str)
258 if (w_pos + 2 >= buf_size) 264 if (w_pos + 2 >= buf_size)
259 break; 265 break;
260 buf[w_pos++] = '\\'; 266 buf[w_pos++] = '\\';
261 buf[w_pos++] = c; 267 buf[w_pos++] = (char) c;
262 } 268 }
263 else if ((c >= 0x20) && (c <= 0x7E) ) 269 else if ((c >= 0x20) && (c <= 0x7E) )
264 buf[w_pos++] = c; 270 buf[w_pos++] = (char) c;
265 else 271 else
266 { 272 {
267 if (w_pos + 4 >= buf_size) 273 if (w_pos + 4 >= buf_size)
@@ -502,7 +508,7 @@ static const struct two_neq_strs neq_strings[] = {
502}; 508};
503 509
504 510
505int 511static size_t
506check_eq_strings (void) 512check_eq_strings (void)
507{ 513{
508 size_t t_failed = 0; 514 size_t t_failed = 0;
@@ -549,7 +555,7 @@ check_eq_strings (void)
549} 555}
550 556
551 557
552int 558static size_t
553check_neq_strings (void) 559check_neq_strings (void)
554{ 560{
555 size_t t_failed = 0; 561 size_t t_failed = 0;
@@ -596,7 +602,7 @@ check_neq_strings (void)
596} 602}
597 603
598 604
599int 605static size_t
600check_eq_strings_n (void) 606check_eq_strings_n (void)
601{ 607{
602 size_t t_failed = 0; 608 size_t t_failed = 0;
@@ -649,7 +655,7 @@ check_eq_strings_n (void)
649} 655}
650 656
651 657
652int 658static size_t
653check_neq_strings_n (void) 659check_neq_strings_n (void)
654{ 660{
655 size_t t_failed = 0; 661 size_t t_failed = 0;
@@ -675,7 +681,7 @@ check_neq_strings_n (void)
675 int) t-> 681 int) t->
676 dif_pos, 682 dif_pos,
677 (unsigned int) t->s1.len, (unsigned int) t->s2.len); 683 (unsigned int) t->s1.len, (unsigned int) t->s2.len);
678 return -1; 684 exit (99);
679 } 685 }
680 if (t->dif_pos > t->s1.len) 686 if (t->dif_pos > t->s1.len)
681 { 687 {
@@ -684,7 +690,7 @@ check_neq_strings_n (void)
684 "equal to s1.len (%u).\n", (unsigned int) i, (unsigned 690 "equal to s1.len (%u).\n", (unsigned int) i, (unsigned
685 int) t->dif_pos, 691 int) t->dif_pos,
686 (unsigned int) t->s1.len); 692 (unsigned int) t->s1.len);
687 return -1; 693 exit (99);
688 } 694 }
689 if (t->dif_pos > t->s2.len) 695 if (t->dif_pos > t->s2.len)
690 { 696 {
@@ -693,7 +699,7 @@ check_neq_strings_n (void)
693 "equal to s2.len (%u).\n", (unsigned int) i, (unsigned 699 "equal to s2.len (%u).\n", (unsigned int) i, (unsigned
694 int) t->dif_pos, 700 int) t->dif_pos,
695 (unsigned int) t->s2.len); 701 (unsigned int) t->s2.len);
696 return -1; 702 exit (99);
697 } 703 }
698 for (k = 0; k <= m_len + 1 && ! c_failed[i]; k++) 704 for (k = 0; k <= m_len + 1 && ! c_failed[i]; k++)
699 { 705 {
@@ -769,21 +775,16 @@ check_neq_strings_n (void)
769/* 775/*
770 * Run eq/neq strings tests 776 * Run eq/neq strings tests
771 */ 777 */
772int 778static int
773run_eq_neq_str_tests (void) 779run_eq_neq_str_tests (void)
774{ 780{
775 int str_equal_caseless_fails = 0; 781 size_t str_equal_caseless_fails = 0;
776 int str_equal_caseless_n_fails = 0; 782 size_t str_equal_caseless_n_fails = 0;
777 int res; 783 size_t res;
778 784
779 res = check_eq_strings (); 785 res = check_eq_strings ();
780 if (res != 0) 786 if (res != 0)
781 { 787 {
782 if (res < 0)
783 {
784 fprintf (stderr, "ERROR: test internal error in check_eq_strings().\n");
785 return 99;
786 }
787 str_equal_caseless_fails += res; 788 str_equal_caseless_fails += res;
788 fprintf (stderr, "FAILED: testcase check_eq_strings() failed.\n\n"); 789 fprintf (stderr, "FAILED: testcase check_eq_strings() failed.\n\n");
789 } 790 }
@@ -793,11 +794,6 @@ run_eq_neq_str_tests (void)
793 res = check_neq_strings (); 794 res = check_neq_strings ();
794 if (res != 0) 795 if (res != 0)
795 { 796 {
796 if (res < 0)
797 {
798 fprintf (stderr, "ERROR: test internal error in check_neq_strings().\n");
799 return 99;
800 }
801 str_equal_caseless_fails += res; 797 str_equal_caseless_fails += res;
802 fprintf (stderr, "FAILED: testcase check_neq_strings() failed.\n\n"); 798 fprintf (stderr, "FAILED: testcase check_neq_strings() failed.\n\n");
803 } 799 }
@@ -806,8 +802,9 @@ run_eq_neq_str_tests (void)
806 802
807 if (str_equal_caseless_fails) 803 if (str_equal_caseless_fails)
808 fprintf (stderr, 804 fprintf (stderr,
809 "FAILED: function MHD_str_equal_caseless_() failed %d time%s.\n\n", 805 "FAILED: function MHD_str_equal_caseless_() failed %lu time%s.\n\n",
810 str_equal_caseless_fails, str_equal_caseless_fails == 1 ? "" : 806 (unsigned long) str_equal_caseless_fails,
807 str_equal_caseless_fails == 1 ? "" :
811 "s"); 808 "s");
812 else if (verbose > 0) 809 else if (verbose > 0)
813 printf ( 810 printf (
@@ -816,11 +813,6 @@ run_eq_neq_str_tests (void)
816 res = check_eq_strings_n (); 813 res = check_eq_strings_n ();
817 if (res != 0) 814 if (res != 0)
818 { 815 {
819 if (res < 0)
820 {
821 fprintf (stderr, "ERROR: test internal error in check_eq_strings_n().\n");
822 return 99;
823 }
824 str_equal_caseless_n_fails += res; 816 str_equal_caseless_n_fails += res;
825 fprintf (stderr, "FAILED: testcase check_eq_strings_n() failed.\n\n"); 817 fprintf (stderr, "FAILED: testcase check_eq_strings_n() failed.\n\n");
826 } 818 }
@@ -830,12 +822,6 @@ run_eq_neq_str_tests (void)
830 res = check_neq_strings_n (); 822 res = check_neq_strings_n ();
831 if (res != 0) 823 if (res != 0)
832 { 824 {
833 if (res < 0)
834 {
835 fprintf (stderr,
836 "ERROR: test internal error in check_neq_strings_n().\n");
837 return 99;
838 }
839 str_equal_caseless_n_fails += res; 825 str_equal_caseless_n_fails += res;
840 fprintf (stderr, "FAILED: testcase check_neq_strings_n() failed.\n\n"); 826 fprintf (stderr, "FAILED: testcase check_neq_strings_n() failed.\n\n");
841 } 827 }
@@ -844,8 +830,9 @@ run_eq_neq_str_tests (void)
844 830
845 if (str_equal_caseless_n_fails) 831 if (str_equal_caseless_n_fails)
846 fprintf (stderr, 832 fprintf (stderr,
847 "FAILED: function MHD_str_equal_caseless_n_() failed %d time%s.\n\n", 833 "FAILED: function MHD_str_equal_caseless_n_() failed %lu time%s.\n\n",
848 str_equal_caseless_n_fails, str_equal_caseless_n_fails == 1 ? "" : 834 (unsigned long) str_equal_caseless_n_fails,
835 str_equal_caseless_n_fails == 1 ? "" :
849 "s"); 836 "s");
850 else if (verbose > 0) 837 else if (verbose > 0)
851 printf ( 838 printf (
@@ -1133,7 +1120,7 @@ const struct str_with_len strx_ovflw[] = {
1133}; 1120};
1134 1121
1135 1122
1136int 1123static size_t
1137check_str_to_uint64_valid (void) 1124check_str_to_uint64_valid (void)
1138{ 1125{
1139 size_t t_failed = 0; 1126 size_t t_failed = 0;
@@ -1164,7 +1151,7 @@ check_str_to_uint64_valid (void)
1164 (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned 1151 (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned
1165 int) t->str. 1152 int) t->str.
1166 len); 1153 len);
1167 return -1; 1154 exit (99);
1168 } 1155 }
1169 rv = 9435223; /* some random value */ 1156 rv = 9435223; /* some random value */
1170 rs = MHD_str_to_uint64_ (t->str.str, &rv); 1157 rs = MHD_str_to_uint64_ (t->str.str, &rv);
@@ -1201,7 +1188,7 @@ check_str_to_uint64_valid (void)
1201} 1188}
1202 1189
1203 1190
1204int 1191static size_t
1205check_str_to_uint64_all_chars (void) 1192check_str_to_uint64_all_chars (void)
1206{ 1193{
1207 static const size_t n_checks = 256; /* from 0 to 255 */ 1194 static const size_t n_checks = 256; /* from 0 to 255 */
@@ -1268,7 +1255,7 @@ check_str_to_uint64_all_chars (void)
1268} 1255}
1269 1256
1270 1257
1271int 1258static size_t
1272check_str_to_uint64_overflow (void) 1259check_str_to_uint64_overflow (void)
1273{ 1260{
1274 size_t t_failed = 0; 1261 size_t t_failed = 0;
@@ -1326,7 +1313,7 @@ check_str_to_uint64_overflow (void)
1326} 1313}
1327 1314
1328 1315
1329int 1316static size_t
1330check_str_to_uint64_no_val (void) 1317check_str_to_uint64_no_val (void)
1331{ 1318{
1332 size_t t_failed = 0; 1319 size_t t_failed = 0;
@@ -1384,7 +1371,7 @@ check_str_to_uint64_no_val (void)
1384} 1371}
1385 1372
1386 1373
1387int 1374static size_t
1388check_str_to_uint64_n_valid (void) 1375check_str_to_uint64_n_valid (void)
1389{ 1376{
1390 size_t t_failed = 0; 1377 size_t t_failed = 0;
@@ -1413,7 +1400,7 @@ check_str_to_uint64_n_valid (void)
1413 (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned 1400 (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned
1414 int) t->str. 1401 int) t->str.
1415 len); 1402 len);
1416 return -1; 1403 exit (99);
1417 } 1404 }
1418 for (len = t->num_of_digt; len <= t->str.len + 1 && ! c_failed[i]; len++) 1405 for (len = t->num_of_digt; len <= t->str.len + 1 && ! c_failed[i]; len++)
1419 { 1406 {
@@ -1456,7 +1443,7 @@ check_str_to_uint64_n_valid (void)
1456} 1443}
1457 1444
1458 1445
1459int 1446static size_t
1460check_str_to_uint64_n_all_chars (void) 1447check_str_to_uint64_n_all_chars (void)
1461{ 1448{
1462 static const size_t n_checks = 256; /* from 0 to 255 */ 1449 static const size_t n_checks = 256; /* from 0 to 255 */
@@ -1533,7 +1520,7 @@ check_str_to_uint64_n_all_chars (void)
1533} 1520}
1534 1521
1535 1522
1536int 1523static size_t
1537check_str_to_uint64_n_overflow (void) 1524check_str_to_uint64_n_overflow (void)
1538{ 1525{
1539 size_t t_failed = 0; 1526 size_t t_failed = 0;
@@ -1602,7 +1589,7 @@ check_str_to_uint64_n_overflow (void)
1602} 1589}
1603 1590
1604 1591
1605int 1592static size_t
1606check_str_to_uint64_n_no_val (void) 1593check_str_to_uint64_n_no_val (void)
1607{ 1594{
1608 size_t t_failed = 0; 1595 size_t t_failed = 0;
@@ -1670,7 +1657,7 @@ check_str_to_uint64_n_no_val (void)
1670} 1657}
1671 1658
1672 1659
1673int 1660static size_t
1674check_strx_to_uint32_valid (void) 1661check_strx_to_uint32_valid (void)
1675{ 1662{
1676 size_t t_failed = 0; 1663 size_t t_failed = 0;
@@ -1704,7 +1691,7 @@ check_strx_to_uint32_valid (void)
1704 (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned 1691 (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned
1705 int) t->str. 1692 int) t->str.
1706 len); 1693 len);
1707 return -1; 1694 exit (99);
1708 } 1695 }
1709 rv = 1458532; /* some random value */ 1696 rv = 1458532; /* some random value */
1710 rs = MHD_strx_to_uint32_ (t->str.str, &rv); 1697 rs = MHD_strx_to_uint32_ (t->str.str, &rv);
@@ -1743,7 +1730,7 @@ check_strx_to_uint32_valid (void)
1743} 1730}
1744 1731
1745 1732
1746int 1733static size_t
1747check_strx_to_uint32_all_chars (void) 1734check_strx_to_uint32_all_chars (void)
1748{ 1735{
1749 static const size_t n_checks = 256; /* from 0 to 255 */ 1736 static const size_t n_checks = 256; /* from 0 to 255 */
@@ -1815,7 +1802,7 @@ check_strx_to_uint32_all_chars (void)
1815} 1802}
1816 1803
1817 1804
1818int 1805static size_t
1819check_strx_to_uint32_overflow (void) 1806check_strx_to_uint32_overflow (void)
1820{ 1807{
1821 size_t t_failed = 0; 1808 size_t t_failed = 0;
@@ -1891,7 +1878,7 @@ check_strx_to_uint32_overflow (void)
1891} 1878}
1892 1879
1893 1880
1894int 1881static size_t
1895check_strx_to_uint32_no_val (void) 1882check_strx_to_uint32_no_val (void)
1896{ 1883{
1897 size_t t_failed = 0; 1884 size_t t_failed = 0;
@@ -1950,7 +1937,7 @@ check_strx_to_uint32_no_val (void)
1950} 1937}
1951 1938
1952 1939
1953int 1940static size_t
1954check_strx_to_uint32_n_valid (void) 1941check_strx_to_uint32_n_valid (void)
1955{ 1942{
1956 size_t t_failed = 0; 1943 size_t t_failed = 0;
@@ -1982,7 +1969,7 @@ check_strx_to_uint32_n_valid (void)
1982 (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned 1969 (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned
1983 int) t->str. 1970 int) t->str.
1984 len); 1971 len);
1985 return -1; 1972 exit (99);
1986 } 1973 }
1987 for (len = t->num_of_digt; len <= t->str.len + 1 && ! c_failed[i]; len++) 1974 for (len = t->num_of_digt; len <= t->str.len + 1 && ! c_failed[i]; len++)
1988 { 1975 {
@@ -2027,7 +2014,7 @@ check_strx_to_uint32_n_valid (void)
2027} 2014}
2028 2015
2029 2016
2030int 2017static size_t
2031check_strx_to_uint32_n_all_chars (void) 2018check_strx_to_uint32_n_all_chars (void)
2032{ 2019{
2033 static const size_t n_checks = 256; /* from 0 to 255 */ 2020 static const size_t n_checks = 256; /* from 0 to 255 */
@@ -2109,7 +2096,7 @@ check_strx_to_uint32_n_all_chars (void)
2109} 2096}
2110 2097
2111 2098
2112int 2099static size_t
2113check_strx_to_uint32_n_overflow (void) 2100check_strx_to_uint32_n_overflow (void)
2114{ 2101{
2115 size_t t_failed = 0; 2102 size_t t_failed = 0;
@@ -2154,7 +2141,7 @@ check_strx_to_uint32_n_overflow (void)
2154 (unsigned int) (i - n_checks1), (unsigned 2141 (unsigned int) (i - n_checks1), (unsigned
2155 int) t->num_of_digt, 2142 int) t->num_of_digt,
2156 (unsigned int) t->str.len); 2143 (unsigned int) t->str.len);
2157 return -1; 2144 exit (99);
2158 } 2145 }
2159 str = t->str.str; 2146 str = t->str.str;
2160 min_len = t->num_of_digt; 2147 min_len = t->num_of_digt;
@@ -2211,7 +2198,7 @@ check_strx_to_uint32_n_overflow (void)
2211} 2198}
2212 2199
2213 2200
2214int 2201static size_t
2215check_strx_to_uint32_n_no_val (void) 2202check_strx_to_uint32_n_no_val (void)
2216{ 2203{
2217 size_t t_failed = 0; 2204 size_t t_failed = 0;
@@ -2280,7 +2267,7 @@ check_strx_to_uint32_n_no_val (void)
2280} 2267}
2281 2268
2282 2269
2283int 2270static size_t
2284check_strx_to_uint64_valid (void) 2271check_strx_to_uint64_valid (void)
2285{ 2272{
2286 size_t t_failed = 0; 2273 size_t t_failed = 0;
@@ -2311,7 +2298,7 @@ check_strx_to_uint64_valid (void)
2311 (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned 2298 (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned
2312 int) t->str. 2299 int) t->str.
2313 len); 2300 len);
2314 return -1; 2301 exit (99);
2315 } 2302 }
2316 rv = 1458532; /* some random value */ 2303 rv = 1458532; /* some random value */
2317 rs = MHD_strx_to_uint64_ (t->str.str, &rv); 2304 rs = MHD_strx_to_uint64_ (t->str.str, &rv);
@@ -2349,7 +2336,7 @@ check_strx_to_uint64_valid (void)
2349} 2336}
2350 2337
2351 2338
2352int 2339static size_t
2353check_strx_to_uint64_all_chars (void) 2340check_strx_to_uint64_all_chars (void)
2354{ 2341{
2355 static const size_t n_checks = 256; /* from 0 to 255 */ 2342 static const size_t n_checks = 256; /* from 0 to 255 */
@@ -2420,7 +2407,7 @@ check_strx_to_uint64_all_chars (void)
2420} 2407}
2421 2408
2422 2409
2423int 2410static size_t
2424check_strx_to_uint64_overflow (void) 2411check_strx_to_uint64_overflow (void)
2425{ 2412{
2426 size_t t_failed = 0; 2413 size_t t_failed = 0;
@@ -2478,7 +2465,7 @@ check_strx_to_uint64_overflow (void)
2478} 2465}
2479 2466
2480 2467
2481int 2468static size_t
2482check_strx_to_uint64_no_val (void) 2469check_strx_to_uint64_no_val (void)
2483{ 2470{
2484 size_t t_failed = 0; 2471 size_t t_failed = 0;
@@ -2536,7 +2523,7 @@ check_strx_to_uint64_no_val (void)
2536} 2523}
2537 2524
2538 2525
2539int 2526static size_t
2540check_strx_to_uint64_n_valid (void) 2527check_strx_to_uint64_n_valid (void)
2541{ 2528{
2542 size_t t_failed = 0; 2529 size_t t_failed = 0;
@@ -2565,7 +2552,7 @@ check_strx_to_uint64_n_valid (void)
2565 (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned 2552 (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned
2566 int) t->str. 2553 int) t->str.
2567 len); 2554 len);
2568 return -1; 2555 exit (99);
2569 } 2556 }
2570 for (len = t->num_of_digt; len <= t->str.len + 1 && ! c_failed[i]; len++) 2557 for (len = t->num_of_digt; len <= t->str.len + 1 && ! c_failed[i]; len++)
2571 { 2558 {
@@ -2609,7 +2596,7 @@ check_strx_to_uint64_n_valid (void)
2609} 2596}
2610 2597
2611 2598
2612int 2599static size_t
2613check_strx_to_uint64_n_all_chars (void) 2600check_strx_to_uint64_n_all_chars (void)
2614{ 2601{
2615 static const size_t n_checks = 256; /* from 0 to 255 */ 2602 static const size_t n_checks = 256; /* from 0 to 255 */
@@ -2691,7 +2678,7 @@ check_strx_to_uint64_n_all_chars (void)
2691} 2678}
2692 2679
2693 2680
2694int 2681static size_t
2695check_strx_to_uint64_n_overflow (void) 2682check_strx_to_uint64_n_overflow (void)
2696{ 2683{
2697 size_t t_failed = 0; 2684 size_t t_failed = 0;
@@ -2761,7 +2748,7 @@ check_strx_to_uint64_n_overflow (void)
2761} 2748}
2762 2749
2763 2750
2764int 2751static size_t
2765check_strx_to_uint64_n_no_val (void) 2752check_strx_to_uint64_n_no_val (void)
2766{ 2753{
2767 size_t t_failed = 0; 2754 size_t t_failed = 0;
@@ -2830,26 +2817,20 @@ check_strx_to_uint64_n_no_val (void)
2830} 2817}
2831 2818
2832 2819
2833int 2820static int
2834run_str_to_X_tests (void) 2821run_str_to_X_tests (void)
2835{ 2822{
2836 int str_to_uint64_fails = 0; 2823 size_t str_to_uint64_fails = 0;
2837 int str_to_uint64_n_fails = 0; 2824 size_t str_to_uint64_n_fails = 0;
2838 int strx_to_uint32_fails = 0; 2825 size_t strx_to_uint32_fails = 0;
2839 int strx_to_uint32_n_fails = 0; 2826 size_t strx_to_uint32_n_fails = 0;
2840 int strx_to_uint64_fails = 0; 2827 size_t strx_to_uint64_fails = 0;
2841 int strx_to_uint64_n_fails = 0; 2828 size_t strx_to_uint64_n_fails = 0;
2842 int res; 2829 size_t res;
2843 2830
2844 res = check_str_to_uint64_valid (); 2831 res = check_str_to_uint64_valid ();
2845 if (res != 0) 2832 if (res != 0)
2846 { 2833 {
2847 if (res < 0)
2848 {
2849 fprintf (stderr,
2850 "ERROR: test internal error in check_str_to_uint64_valid().\n");
2851 return 99;
2852 }
2853 str_to_uint64_fails += res; 2834 str_to_uint64_fails += res;
2854 fprintf (stderr, 2835 fprintf (stderr,
2855 "FAILED: testcase check_str_to_uint64_valid() failed.\n\n"); 2836 "FAILED: testcase check_str_to_uint64_valid() failed.\n\n");
@@ -2861,12 +2842,6 @@ run_str_to_X_tests (void)
2861 res = check_str_to_uint64_all_chars (); 2842 res = check_str_to_uint64_all_chars ();
2862 if (res != 0) 2843 if (res != 0)
2863 { 2844 {
2864 if (res < 0)
2865 {
2866 fprintf (stderr,
2867 "ERROR: test internal error in check_str_to_uint64_all_chars().\n");
2868 return 99;
2869 }
2870 str_to_uint64_fails += res; 2845 str_to_uint64_fails += res;
2871 fprintf (stderr, 2846 fprintf (stderr,
2872 "FAILED: testcase check_str_to_uint64_all_chars() failed.\n\n"); 2847 "FAILED: testcase check_str_to_uint64_all_chars() failed.\n\n");
@@ -2878,12 +2853,6 @@ run_str_to_X_tests (void)
2878 res = check_str_to_uint64_overflow (); 2853 res = check_str_to_uint64_overflow ();
2879 if (res != 0) 2854 if (res != 0)
2880 { 2855 {
2881 if (res < 0)
2882 {
2883 fprintf (stderr,
2884 "ERROR: test internal error in check_str_to_uint64_overflow().\n");
2885 return 99;
2886 }
2887 str_to_uint64_fails += res; 2856 str_to_uint64_fails += res;
2888 fprintf (stderr, 2857 fprintf (stderr,
2889 "FAILED: testcase check_str_to_uint64_overflow() failed.\n\n"); 2858 "FAILED: testcase check_str_to_uint64_overflow() failed.\n\n");
@@ -2895,12 +2864,6 @@ run_str_to_X_tests (void)
2895 res = check_str_to_uint64_no_val (); 2864 res = check_str_to_uint64_no_val ();
2896 if (res != 0) 2865 if (res != 0)
2897 { 2866 {
2898 if (res < 0)
2899 {
2900 fprintf (stderr,
2901 "ERROR: test internal error in check_str_to_uint64_no_val().\n");
2902 return 99;
2903 }
2904 str_to_uint64_fails += res; 2867 str_to_uint64_fails += res;
2905 fprintf (stderr, 2868 fprintf (stderr,
2906 "FAILED: testcase check_str_to_uint64_no_val() failed.\n\n"); 2869 "FAILED: testcase check_str_to_uint64_no_val() failed.\n\n");
@@ -2911,8 +2874,9 @@ run_str_to_X_tests (void)
2911 2874
2912 if (str_to_uint64_fails) 2875 if (str_to_uint64_fails)
2913 fprintf (stderr, 2876 fprintf (stderr,
2914 "FAILED: function MHD_str_to_uint64_() failed %d time%s.\n\n", 2877 "FAILED: function MHD_str_to_uint64_() failed %lu time%s.\n\n",
2915 str_to_uint64_fails, str_to_uint64_fails == 1 ? "" : "s"); 2878 (unsigned long) str_to_uint64_fails,
2879 str_to_uint64_fails == 1 ? "" : "s");
2916 else if (verbose > 0) 2880 else if (verbose > 0)
2917 printf ( 2881 printf (
2918 "PASSED: function MHD_str_to_uint64_() successfully passed all checks.\n\n"); 2882 "PASSED: function MHD_str_to_uint64_() successfully passed all checks.\n\n");
@@ -2920,12 +2884,6 @@ run_str_to_X_tests (void)
2920 res = check_str_to_uint64_n_valid (); 2884 res = check_str_to_uint64_n_valid ();
2921 if (res != 0) 2885 if (res != 0)
2922 { 2886 {
2923 if (res < 0)
2924 {
2925 fprintf (stderr,
2926 "ERROR: test internal error in check_str_to_uint64_n_valid().\n");
2927 return 99;
2928 }
2929 str_to_uint64_n_fails += res; 2887 str_to_uint64_n_fails += res;
2930 fprintf (stderr, 2888 fprintf (stderr,
2931 "FAILED: testcase check_str_to_uint64_n_valid() failed.\n\n"); 2889 "FAILED: testcase check_str_to_uint64_n_valid() failed.\n\n");
@@ -2937,12 +2895,6 @@ run_str_to_X_tests (void)
2937 res = check_str_to_uint64_n_all_chars (); 2895 res = check_str_to_uint64_n_all_chars ();
2938 if (res != 0) 2896 if (res != 0)
2939 { 2897 {
2940 if (res < 0)
2941 {
2942 fprintf (stderr,
2943 "ERROR: test internal error in check_str_to_uint64_n_all_chars().\n");
2944 return 99;
2945 }
2946 str_to_uint64_n_fails += res; 2898 str_to_uint64_n_fails += res;
2947 fprintf (stderr, 2899 fprintf (stderr,
2948 "FAILED: testcase check_str_to_uint64_n_all_chars() failed.\n\n"); 2900 "FAILED: testcase check_str_to_uint64_n_all_chars() failed.\n\n");
@@ -2954,12 +2906,6 @@ run_str_to_X_tests (void)
2954 res = check_str_to_uint64_n_overflow (); 2906 res = check_str_to_uint64_n_overflow ();
2955 if (res != 0) 2907 if (res != 0)
2956 { 2908 {
2957 if (res < 0)
2958 {
2959 fprintf (stderr,
2960 "ERROR: test internal error in check_str_to_uint64_n_overflow().\n");
2961 return 99;
2962 }
2963 str_to_uint64_n_fails += res; 2909 str_to_uint64_n_fails += res;
2964 fprintf (stderr, 2910 fprintf (stderr,
2965 "FAILED: testcase check_str_to_uint64_n_overflow() failed.\n\n"); 2911 "FAILED: testcase check_str_to_uint64_n_overflow() failed.\n\n");
@@ -2971,12 +2917,6 @@ run_str_to_X_tests (void)
2971 res = check_str_to_uint64_n_no_val (); 2917 res = check_str_to_uint64_n_no_val ();
2972 if (res != 0) 2918 if (res != 0)
2973 { 2919 {
2974 if (res < 0)
2975 {
2976 fprintf (stderr,
2977 "ERROR: test internal error in check_str_to_uint64_n_no_val().\n");
2978 return 99;
2979 }
2980 str_to_uint64_n_fails += res; 2920 str_to_uint64_n_fails += res;
2981 fprintf (stderr, 2921 fprintf (stderr,
2982 "FAILED: testcase check_str_to_uint64_n_no_val() failed.\n\n"); 2922 "FAILED: testcase check_str_to_uint64_n_no_val() failed.\n\n");
@@ -2987,8 +2927,9 @@ run_str_to_X_tests (void)
2987 2927
2988 if (str_to_uint64_n_fails) 2928 if (str_to_uint64_n_fails)
2989 fprintf (stderr, 2929 fprintf (stderr,
2990 "FAILED: function MHD_str_to_uint64_n_() failed %d time%s.\n\n", 2930 "FAILED: function MHD_str_to_uint64_n_() failed %lu time%s.\n\n",
2991 str_to_uint64_n_fails, str_to_uint64_n_fails == 1 ? "" : "s"); 2931 (unsigned long) str_to_uint64_n_fails,
2932 str_to_uint64_n_fails == 1 ? "" : "s");
2992 else if (verbose > 0) 2933 else if (verbose > 0)
2993 printf ( 2934 printf (
2994 "PASSED: function MHD_str_to_uint64_n_() successfully passed all checks.\n\n"); 2935 "PASSED: function MHD_str_to_uint64_n_() successfully passed all checks.\n\n");
@@ -2996,12 +2937,6 @@ run_str_to_X_tests (void)
2996 res = check_strx_to_uint32_valid (); 2937 res = check_strx_to_uint32_valid ();
2997 if (res != 0) 2938 if (res != 0)
2998 { 2939 {
2999 if (res < 0)
3000 {
3001 fprintf (stderr,
3002 "ERROR: test internal error in check_strx_to_uint32_valid().\n");
3003 return 99;
3004 }
3005 strx_to_uint32_fails += res; 2940 strx_to_uint32_fails += res;
3006 fprintf (stderr, 2941 fprintf (stderr,
3007 "FAILED: testcase check_strx_to_uint32_valid() failed.\n\n"); 2942 "FAILED: testcase check_strx_to_uint32_valid() failed.\n\n");
@@ -3013,12 +2948,6 @@ run_str_to_X_tests (void)
3013 res = check_strx_to_uint32_all_chars (); 2948 res = check_strx_to_uint32_all_chars ();
3014 if (res != 0) 2949 if (res != 0)
3015 { 2950 {
3016 if (res < 0)
3017 {
3018 fprintf (stderr,
3019 "ERROR: test internal error in check_strx_to_uint32_all_chars().\n");
3020 return 99;
3021 }
3022 strx_to_uint32_fails += res; 2951 strx_to_uint32_fails += res;
3023 fprintf (stderr, 2952 fprintf (stderr,
3024 "FAILED: testcase check_strx_to_uint32_all_chars() failed.\n\n"); 2953 "FAILED: testcase check_strx_to_uint32_all_chars() failed.\n\n");
@@ -3030,12 +2959,6 @@ run_str_to_X_tests (void)
3030 res = check_strx_to_uint32_overflow (); 2959 res = check_strx_to_uint32_overflow ();
3031 if (res != 0) 2960 if (res != 0)
3032 { 2961 {
3033 if (res < 0)
3034 {
3035 fprintf (stderr,
3036 "ERROR: test internal error in check_strx_to_uint32_overflow().\n");
3037 return 99;
3038 }
3039 strx_to_uint32_fails += res; 2962 strx_to_uint32_fails += res;
3040 fprintf (stderr, 2963 fprintf (stderr,
3041 "FAILED: testcase check_strx_to_uint32_overflow() failed.\n\n"); 2964 "FAILED: testcase check_strx_to_uint32_overflow() failed.\n\n");
@@ -3047,12 +2970,6 @@ run_str_to_X_tests (void)
3047 res = check_strx_to_uint32_no_val (); 2970 res = check_strx_to_uint32_no_val ();
3048 if (res != 0) 2971 if (res != 0)
3049 { 2972 {
3050 if (res < 0)
3051 {
3052 fprintf (stderr,
3053 "ERROR: test internal error in check_strx_to_uint32_no_val().\n");
3054 return 99;
3055 }
3056 strx_to_uint32_fails += res; 2973 strx_to_uint32_fails += res;
3057 fprintf (stderr, 2974 fprintf (stderr,
3058 "FAILED: testcase check_strx_to_uint32_no_val() failed.\n\n"); 2975 "FAILED: testcase check_strx_to_uint32_no_val() failed.\n\n");
@@ -3063,8 +2980,9 @@ run_str_to_X_tests (void)
3063 2980
3064 if (strx_to_uint32_fails) 2981 if (strx_to_uint32_fails)
3065 fprintf (stderr, 2982 fprintf (stderr,
3066 "FAILED: function MHD_strx_to_uint32_() failed %d time%s.\n\n", 2983 "FAILED: function MHD_strx_to_uint32_() failed %lu time%s.\n\n",
3067 strx_to_uint32_fails, strx_to_uint32_fails == 1 ? "" : "s"); 2984 (unsigned long) strx_to_uint32_fails,
2985 strx_to_uint32_fails == 1 ? "" : "s");
3068 else if (verbose > 0) 2986 else if (verbose > 0)
3069 printf ( 2987 printf (
3070 "PASSED: function MHD_strx_to_uint32_() successfully passed all checks.\n\n"); 2988 "PASSED: function MHD_strx_to_uint32_() successfully passed all checks.\n\n");
@@ -3072,12 +2990,6 @@ run_str_to_X_tests (void)
3072 res = check_strx_to_uint32_n_valid (); 2990 res = check_strx_to_uint32_n_valid ();
3073 if (res != 0) 2991 if (res != 0)
3074 { 2992 {
3075 if (res < 0)
3076 {
3077 fprintf (stderr,
3078 "ERROR: test internal error in check_strx_to_uint32_n_valid().\n");
3079 return 99;
3080 }
3081 strx_to_uint32_n_fails += res; 2993 strx_to_uint32_n_fails += res;
3082 fprintf (stderr, 2994 fprintf (stderr,
3083 "FAILED: testcase check_strx_to_uint32_n_valid() failed.\n\n"); 2995 "FAILED: testcase check_strx_to_uint32_n_valid() failed.\n\n");
@@ -3089,12 +3001,6 @@ run_str_to_X_tests (void)
3089 res = check_strx_to_uint32_n_all_chars (); 3001 res = check_strx_to_uint32_n_all_chars ();
3090 if (res != 0) 3002 if (res != 0)
3091 { 3003 {
3092 if (res < 0)
3093 {
3094 fprintf (stderr,
3095 "ERROR: test internal error in check_strx_to_uint32_n_all_chars().\n");
3096 return 99;
3097 }
3098 strx_to_uint32_n_fails += res; 3004 strx_to_uint32_n_fails += res;
3099 fprintf (stderr, 3005 fprintf (stderr,
3100 "FAILED: testcase check_strx_to_uint32_n_all_chars() failed.\n\n"); 3006 "FAILED: testcase check_strx_to_uint32_n_all_chars() failed.\n\n");
@@ -3106,12 +3012,6 @@ run_str_to_X_tests (void)
3106 res = check_strx_to_uint32_n_overflow (); 3012 res = check_strx_to_uint32_n_overflow ();
3107 if (res != 0) 3013 if (res != 0)
3108 { 3014 {
3109 if (res < 0)
3110 {
3111 fprintf (stderr,
3112 "ERROR: test internal error in check_strx_to_uint32_n_overflow().\n");
3113 return 99;
3114 }
3115 strx_to_uint32_n_fails += res; 3015 strx_to_uint32_n_fails += res;
3116 fprintf (stderr, 3016 fprintf (stderr,
3117 "FAILED: testcase check_strx_to_uint32_n_overflow() failed.\n\n"); 3017 "FAILED: testcase check_strx_to_uint32_n_overflow() failed.\n\n");
@@ -3123,12 +3023,6 @@ run_str_to_X_tests (void)
3123 res = check_strx_to_uint32_n_no_val (); 3023 res = check_strx_to_uint32_n_no_val ();
3124 if (res != 0) 3024 if (res != 0)
3125 { 3025 {
3126 if (res < 0)
3127 {
3128 fprintf (stderr,
3129 "ERROR: test internal error in check_strx_to_uint32_n_no_val().\n");
3130 return 99;
3131 }
3132 strx_to_uint32_n_fails += res; 3026 strx_to_uint32_n_fails += res;
3133 fprintf (stderr, 3027 fprintf (stderr,
3134 "FAILED: testcase check_strx_to_uint32_n_no_val() failed.\n\n"); 3028 "FAILED: testcase check_strx_to_uint32_n_no_val() failed.\n\n");
@@ -3139,8 +3033,9 @@ run_str_to_X_tests (void)
3139 3033
3140 if (strx_to_uint32_n_fails) 3034 if (strx_to_uint32_n_fails)
3141 fprintf (stderr, 3035 fprintf (stderr,
3142 "FAILED: function MHD_strx_to_uint32_n_() failed %d time%s.\n\n", 3036 "FAILED: function MHD_strx_to_uint32_n_() failed %lu time%s.\n\n",
3143 strx_to_uint32_n_fails, strx_to_uint32_n_fails == 1 ? "" : "s"); 3037 (unsigned long) strx_to_uint32_n_fails,
3038 strx_to_uint32_n_fails == 1 ? "" : "s");
3144 else if (verbose > 0) 3039 else if (verbose > 0)
3145 printf ( 3040 printf (
3146 "PASSED: function MHD_strx_to_uint32_n_() successfully passed all checks.\n\n"); 3041 "PASSED: function MHD_strx_to_uint32_n_() successfully passed all checks.\n\n");
@@ -3148,12 +3043,6 @@ run_str_to_X_tests (void)
3148 res = check_strx_to_uint64_valid (); 3043 res = check_strx_to_uint64_valid ();
3149 if (res != 0) 3044 if (res != 0)
3150 { 3045 {
3151 if (res < 0)
3152 {
3153 fprintf (stderr,
3154 "ERROR: test internal error in check_strx_to_uint64_valid().\n");
3155 return 99;
3156 }
3157 strx_to_uint64_fails += res; 3046 strx_to_uint64_fails += res;
3158 fprintf (stderr, 3047 fprintf (stderr,
3159 "FAILED: testcase check_strx_to_uint64_valid() failed.\n\n"); 3048 "FAILED: testcase check_strx_to_uint64_valid() failed.\n\n");
@@ -3165,12 +3054,6 @@ run_str_to_X_tests (void)
3165 res = check_strx_to_uint64_all_chars (); 3054 res = check_strx_to_uint64_all_chars ();
3166 if (res != 0) 3055 if (res != 0)
3167 { 3056 {
3168 if (res < 0)
3169 {
3170 fprintf (stderr,
3171 "ERROR: test internal error in check_strx_to_uint64_all_chars().\n");
3172 return 99;
3173 }
3174 strx_to_uint64_fails += res; 3057 strx_to_uint64_fails += res;
3175 fprintf (stderr, 3058 fprintf (stderr,
3176 "FAILED: testcase check_strx_to_uint64_all_chars() failed.\n\n"); 3059 "FAILED: testcase check_strx_to_uint64_all_chars() failed.\n\n");
@@ -3182,12 +3065,6 @@ run_str_to_X_tests (void)
3182 res = check_strx_to_uint64_overflow (); 3065 res = check_strx_to_uint64_overflow ();
3183 if (res != 0) 3066 if (res != 0)
3184 { 3067 {
3185 if (res < 0)
3186 {
3187 fprintf (stderr,
3188 "ERROR: test internal error in check_strx_to_uint64_overflow().\n");
3189 return 99;
3190 }
3191 strx_to_uint64_fails += res; 3068 strx_to_uint64_fails += res;
3192 fprintf (stderr, 3069 fprintf (stderr,
3193 "FAILED: testcase check_strx_to_uint64_overflow() failed.\n\n"); 3070 "FAILED: testcase check_strx_to_uint64_overflow() failed.\n\n");
@@ -3199,12 +3076,6 @@ run_str_to_X_tests (void)
3199 res = check_strx_to_uint64_no_val (); 3076 res = check_strx_to_uint64_no_val ();
3200 if (res != 0) 3077 if (res != 0)
3201 { 3078 {
3202 if (res < 0)
3203 {
3204 fprintf (stderr,
3205 "ERROR: test internal error in check_strx_to_uint64_no_val().\n");
3206 return 99;
3207 }
3208 strx_to_uint64_fails += res; 3079 strx_to_uint64_fails += res;
3209 fprintf (stderr, 3080 fprintf (stderr,
3210 "FAILED: testcase check_strx_to_uint64_no_val() failed.\n\n"); 3081 "FAILED: testcase check_strx_to_uint64_no_val() failed.\n\n");
@@ -3215,8 +3086,9 @@ run_str_to_X_tests (void)
3215 3086
3216 if (strx_to_uint64_fails) 3087 if (strx_to_uint64_fails)
3217 fprintf (stderr, 3088 fprintf (stderr,
3218 "FAILED: function MHD_strx_to_uint64_() failed %d time%s.\n\n", 3089 "FAILED: function MHD_strx_to_uint64_() failed %lu time%s.\n\n",
3219 strx_to_uint64_fails, strx_to_uint64_fails == 1 ? "" : "s"); 3090 (unsigned long) strx_to_uint64_fails,
3091 strx_to_uint64_fails == 1 ? "" : "s");
3220 else if (verbose > 0) 3092 else if (verbose > 0)
3221 printf ( 3093 printf (
3222 "PASSED: function MHD_strx_to_uint64_() successfully passed all checks.\n\n"); 3094 "PASSED: function MHD_strx_to_uint64_() successfully passed all checks.\n\n");
@@ -3224,12 +3096,6 @@ run_str_to_X_tests (void)
3224 res = check_strx_to_uint64_n_valid (); 3096 res = check_strx_to_uint64_n_valid ();
3225 if (res != 0) 3097 if (res != 0)
3226 { 3098 {
3227 if (res < 0)
3228 {
3229 fprintf (stderr,
3230 "ERROR: test internal error in check_strx_to_uint64_n_valid().\n");
3231 return 99;
3232 }
3233 strx_to_uint64_n_fails += res; 3099 strx_to_uint64_n_fails += res;
3234 fprintf (stderr, 3100 fprintf (stderr,
3235 "FAILED: testcase check_strx_to_uint64_n_valid() failed.\n\n"); 3101 "FAILED: testcase check_strx_to_uint64_n_valid() failed.\n\n");
@@ -3241,12 +3107,6 @@ run_str_to_X_tests (void)
3241 res = check_strx_to_uint64_n_all_chars (); 3107 res = check_strx_to_uint64_n_all_chars ();
3242 if (res != 0) 3108 if (res != 0)
3243 { 3109 {
3244 if (res < 0)
3245 {
3246 fprintf (stderr,
3247 "ERROR: test internal error in check_strx_to_uint64_n_all_chars().\n");
3248 return 99;
3249 }
3250 strx_to_uint64_n_fails += res; 3110 strx_to_uint64_n_fails += res;
3251 fprintf (stderr, 3111 fprintf (stderr,
3252 "FAILED: testcase check_strx_to_uint64_n_all_chars() failed.\n\n"); 3112 "FAILED: testcase check_strx_to_uint64_n_all_chars() failed.\n\n");
@@ -3258,12 +3118,6 @@ run_str_to_X_tests (void)
3258 res = check_strx_to_uint64_n_overflow (); 3118 res = check_strx_to_uint64_n_overflow ();
3259 if (res != 0) 3119 if (res != 0)
3260 { 3120 {
3261 if (res < 0)
3262 {
3263 fprintf (stderr,
3264 "ERROR: test internal error in check_strx_to_uint64_n_overflow().\n");
3265 return 99;
3266 }
3267 strx_to_uint64_n_fails += res; 3121 strx_to_uint64_n_fails += res;
3268 fprintf (stderr, 3122 fprintf (stderr,
3269 "FAILED: testcase check_strx_to_uint64_n_overflow() failed.\n\n"); 3123 "FAILED: testcase check_strx_to_uint64_n_overflow() failed.\n\n");
@@ -3275,12 +3129,6 @@ run_str_to_X_tests (void)
3275 res = check_strx_to_uint64_n_no_val (); 3129 res = check_strx_to_uint64_n_no_val ();
3276 if (res != 0) 3130 if (res != 0)
3277 { 3131 {
3278 if (res < 0)
3279 {
3280 fprintf (stderr,
3281 "ERROR: test internal error in check_strx_to_uint64_n_no_val().\n");
3282 return 99;
3283 }
3284 strx_to_uint64_n_fails += res; 3132 strx_to_uint64_n_fails += res;
3285 fprintf (stderr, 3133 fprintf (stderr,
3286 "FAILED: testcase check_strx_to_uint64_n_no_val() failed.\n\n"); 3134 "FAILED: testcase check_strx_to_uint64_n_no_val() failed.\n\n");
@@ -3291,8 +3139,9 @@ run_str_to_X_tests (void)
3291 3139
3292 if (strx_to_uint64_n_fails) 3140 if (strx_to_uint64_n_fails)
3293 fprintf (stderr, 3141 fprintf (stderr,
3294 "FAILED: function MHD_strx_to_uint64_n_() failed %d time%s.\n\n", 3142 "FAILED: function MHD_strx_to_uint64_n_() failed %lu time%s.\n\n",
3295 strx_to_uint64_n_fails, strx_to_uint64_n_fails == 1 ? "" : "s"); 3143 (unsigned long) strx_to_uint64_n_fails,
3144 strx_to_uint64_n_fails == 1 ? "" : "s");
3296 else if (verbose > 0) 3145 else if (verbose > 0)
3297 printf ( 3146 printf (
3298 "PASSED: function MHD_strx_to_uint64_n_() successfully passed all checks.\n\n"); 3147 "PASSED: function MHD_strx_to_uint64_n_() successfully passed all checks.\n\n");
@@ -3314,7 +3163,7 @@ run_str_to_X_tests (void)
3314} 3163}
3315 3164
3316 3165
3317int 3166static size_t
3318check_str_from_uint16 (void) 3167check_str_from_uint16 (void)
3319{ 3168{
3320 size_t t_failed = 0; 3169 size_t t_failed = 0;
@@ -3350,7 +3199,7 @@ check_str_from_uint16 (void)
3350 (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned 3199 (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned
3351 int) t->str. 3200 int) t->str.
3352 len); 3201 len);
3353 return -1; 3202 exit (99);
3354 } 3203 }
3355 if ('0' == t->str.str[0]) 3204 if ('0' == t->str.str[0])
3356 continue; /* Skip strings prefixed with zeros */ 3205 continue; /* Skip strings prefixed with zeros */
@@ -3364,14 +3213,15 @@ check_str_from_uint16 (void)
3364 "ERROR: dstrs_w_values[%u] has too long (%u) string, " 3213 "ERROR: dstrs_w_values[%u] has too long (%u) string, "
3365 "size of 'buf' should be increased.\n", 3214 "size of 'buf' should be increased.\n",
3366 (unsigned int) i, (unsigned int) t->str.len); 3215 (unsigned int) i, (unsigned int) t->str.len);
3367 return -1; 3216 exit (99);
3368 } 3217 }
3218 rs = 0; /* Only to mute compiler warning */
3369 for (b_size = 0; b_size <= t->str.len + 1; ++b_size) 3219 for (b_size = 0; b_size <= t->str.len + 1; ++b_size)
3370 { 3220 {
3371 /* fill buffer with pseudo-random values */ 3221 /* fill buffer with pseudo-random values */
3372 memcpy (buf, erase, sizeof(buf)); 3222 memcpy (buf, erase, sizeof(buf));
3373 3223
3374 rs = MHD_uint16_to_str (t->val, buf, b_size); 3224 rs = MHD_uint16_to_str ((uint16_t) t->val, buf, b_size);
3375 3225
3376 if (t->num_of_digt > b_size) 3226 if (t->num_of_digt > b_size)
3377 { 3227 {
@@ -3438,7 +3288,7 @@ check_str_from_uint16 (void)
3438} 3288}
3439 3289
3440 3290
3441int 3291static size_t
3442check_str_from_uint64 (void) 3292check_str_from_uint64 (void)
3443{ 3293{
3444 size_t t_failed = 0; 3294 size_t t_failed = 0;
@@ -3474,7 +3324,7 @@ check_str_from_uint64 (void)
3474 (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned 3324 (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned
3475 int) t->str. 3325 int) t->str.
3476 len); 3326 len);
3477 return -1; 3327 exit (99);
3478 } 3328 }
3479 if ('0' == t->str.str[0]) 3329 if ('0' == t->str.str[0])
3480 continue; /* Skip strings prefixed with zeros */ 3330 continue; /* Skip strings prefixed with zeros */
@@ -3486,7 +3336,7 @@ check_str_from_uint64 (void)
3486 "ERROR: dstrs_w_values[%u] has too long (%u) string, " 3336 "ERROR: dstrs_w_values[%u] has too long (%u) string, "
3487 "size of 'buf' should be increased.\n", 3337 "size of 'buf' should be increased.\n",
3488 (unsigned int) i, (unsigned int) t->str.len); 3338 (unsigned int) i, (unsigned int) t->str.len);
3489 return -1; 3339 exit (99);
3490 } 3340 }
3491 for (b_size = 0; b_size <= t->str.len + 1; ++b_size) 3341 for (b_size = 0; b_size <= t->str.len + 1; ++b_size)
3492 { 3342 {
@@ -3560,7 +3410,7 @@ check_str_from_uint64 (void)
3560} 3410}
3561 3411
3562 3412
3563int 3413static size_t
3564check_strx_from_uint32 (void) 3414check_strx_from_uint32 (void)
3565{ 3415{
3566 size_t t_failed = 0; 3416 size_t t_failed = 0;
@@ -3596,7 +3446,7 @@ check_strx_from_uint32 (void)
3596 (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned 3446 (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned
3597 int) t->str. 3447 int) t->str.
3598 len); 3448 len);
3599 return -1; 3449 exit (99);
3600 } 3450 }
3601 if ('0' == t->str.str[0]) 3451 if ('0' == t->str.str[0])
3602 continue; /* Skip strings prefixed with zeros */ 3452 continue; /* Skip strings prefixed with zeros */
@@ -3610,14 +3460,15 @@ check_strx_from_uint32 (void)
3610 "ERROR: dstrs_w_values[%u] has too long (%u) string, " 3460 "ERROR: dstrs_w_values[%u] has too long (%u) string, "
3611 "size of 'buf' should be increased.\n", 3461 "size of 'buf' should be increased.\n",
3612 (unsigned int) i, (unsigned int) t->str.len); 3462 (unsigned int) i, (unsigned int) t->str.len);
3613 return -1; 3463 exit (99);
3614 } 3464 }
3465 rs = 0; /* Only to mute compiler warning */
3615 for (b_size = 0; b_size <= t->str.len + 1; ++b_size) 3466 for (b_size = 0; b_size <= t->str.len + 1; ++b_size)
3616 { 3467 {
3617 /* fill buffer with pseudo-random values */ 3468 /* fill buffer with pseudo-random values */
3618 memcpy (buf, erase, sizeof(buf)); 3469 memcpy (buf, erase, sizeof(buf));
3619 3470
3620 rs = MHD_uint32_to_strx (t->val, buf, b_size); 3471 rs = MHD_uint32_to_strx ((uint32_t) t->val, buf, b_size);
3621 3472
3622 if (t->num_of_digt > b_size) 3473 if (t->num_of_digt > b_size)
3623 { 3474 {
@@ -3667,7 +3518,7 @@ check_strx_from_uint32 (void)
3667 "ERROR: dstrs_w_values[%u] has string with too many" 3518 "ERROR: dstrs_w_values[%u] has string with too many"
3668 "(%u) digits, size of 'buf' should be increased.\n", 3519 "(%u) digits, size of 'buf' should be increased.\n",
3669 (unsigned int) i, (unsigned int) rs); 3520 (unsigned int) i, (unsigned int) rs);
3670 return -1; 3521 exit (99);
3671 } 3522 }
3672 else if (0 != memcmp (buf + rs, erase + rs, sizeof(buf) - rs)) 3523 else if (0 != memcmp (buf + rs, erase + rs, sizeof(buf) - rs))
3673 { 3524 {
@@ -4474,12 +4325,12 @@ static const struct str_with_value duint8_w_values_p3[] = {
4474static const struct str_with_value *duint8_w_values_p[3] = 4325static const struct str_with_value *duint8_w_values_p[3] =
4475{duint8_w_values_p1, duint8_w_values_p2, duint8_w_values_p3}; 4326{duint8_w_values_p1, duint8_w_values_p2, duint8_w_values_p3};
4476 4327
4477int 4328static size_t
4478check_str_from_uint8_pad (void) 4329check_str_from_uint8_pad (void)
4479{ 4330{
4480 int i; 4331 int i;
4481 int pad; 4332 uint8_t pad;
4482 int t_failed = 0; 4333 size_t t_failed = 0;
4483 4334
4484 if ((256 != sizeof(duint8_w_values_p1) / sizeof(duint8_w_values_p1[0])) || 4335 if ((256 != sizeof(duint8_w_values_p1) / sizeof(duint8_w_values_p1[0])) ||
4485 (256 != sizeof(duint8_w_values_p2) / sizeof(duint8_w_values_p2[0])) || 4336 (256 != sizeof(duint8_w_values_p2) / sizeof(duint8_w_values_p2[0])) ||
@@ -4487,11 +4338,11 @@ check_str_from_uint8_pad (void)
4487 { 4338 {
4488 fprintf (stderr, 4339 fprintf (stderr,
4489 "ERROR: wrong number of items in duint8_w_values_p*.\n"); 4340 "ERROR: wrong number of items in duint8_w_values_p*.\n");
4490 return -1; 4341 exit (99);
4491 } 4342 }
4492 for (pad = 0; pad <= 3; pad++) 4343 for (pad = 0; pad <= 3; pad++)
4493 { 4344 {
4494 int table_num = pad - 1; 4345 size_t table_num = pad - 1;
4495 if (0 == pad) 4346 if (0 == pad)
4496 table_num = 0; 4347 table_num = 0;
4497 4348
@@ -4510,7 +4361,7 @@ check_str_from_uint8_pad (void)
4510 (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned 4361 (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned
4511 int) t->str. 4362 int) t->str.
4512 len); 4363 len);
4513 return -1; 4364 exit (99);
4514 } 4365 }
4515 if (sizeof(buf) < t->str.len + 1) 4366 if (sizeof(buf) < t->str.len + 1)
4516 { 4367 {
@@ -4518,14 +4369,14 @@ check_str_from_uint8_pad (void)
4518 "ERROR: dstrs_w_values[%u] has too long (%u) string, " 4369 "ERROR: dstrs_w_values[%u] has too long (%u) string, "
4519 "size of 'buf' should be increased.\n", 4370 "size of 'buf' should be increased.\n",
4520 (unsigned int) i, (unsigned int) t->str.len); 4371 (unsigned int) i, (unsigned int) t->str.len);
4521 return -1; 4372 exit (99);
4522 } 4373 }
4523 for (b_size = 0; b_size <= t->str.len + 1; ++b_size) 4374 for (b_size = 0; b_size <= t->str.len + 1; ++b_size)
4524 { 4375 {
4525 /* fill buffer with pseudo-random values */ 4376 /* fill buffer with pseudo-random values */
4526 memset (buf, '#', sizeof(buf)); 4377 memset (buf, '#', sizeof(buf));
4527 4378
4528 rs = MHD_uint8_to_str_pad (t->val, pad, buf, b_size); 4379 rs = MHD_uint8_to_str_pad ((uint8_t) t->val, pad, buf, b_size);
4529 4380
4530 if (t->num_of_digt > b_size) 4381 if (t->num_of_digt > b_size)
4531 { 4382 {
@@ -4581,26 +4432,20 @@ check_str_from_uint8_pad (void)
4581} 4432}
4582 4433
4583 4434
4584int 4435static int
4585run_str_from_X_tests (void) 4436run_str_from_X_tests (void)
4586{ 4437{
4587 int str_from_uint16; 4438 size_t str_from_uint16;
4588 int str_from_uint64; 4439 size_t str_from_uint64;
4589 int strx_from_uint32; 4440 size_t strx_from_uint32;
4590 int str_from_uint8_pad; 4441 size_t str_from_uint8_pad;
4591 int failures; 4442 size_t failures;
4592 4443
4593 failures = 0; 4444 failures = 0;
4594 4445
4595 str_from_uint16 = check_str_from_uint16 (); 4446 str_from_uint16 = check_str_from_uint16 ();
4596 if (str_from_uint16 != 0) 4447 if (str_from_uint16 != 0)
4597 { 4448 {
4598 if (str_from_uint16 < 0)
4599 {
4600 fprintf (stderr,
4601 "ERROR: test internal error in check_str_from_uint16().\n");
4602 return 99;
4603 }
4604 fprintf (stderr, 4449 fprintf (stderr,
4605 "FAILED: testcase check_str_from_uint16() failed.\n\n"); 4450 "FAILED: testcase check_str_from_uint16() failed.\n\n");
4606 failures += str_from_uint16; 4451 failures += str_from_uint16;
@@ -4612,12 +4457,6 @@ run_str_from_X_tests (void)
4612 str_from_uint64 = check_str_from_uint64 (); 4457 str_from_uint64 = check_str_from_uint64 ();
4613 if (str_from_uint64 != 0) 4458 if (str_from_uint64 != 0)
4614 { 4459 {
4615 if (str_from_uint64 < 0)
4616 {
4617 fprintf (stderr,
4618 "ERROR: test internal error in check_str_from_uint16().\n");
4619 return 99;
4620 }
4621 fprintf (stderr, 4460 fprintf (stderr,
4622 "FAILED: testcase check_str_from_uint16() failed.\n\n"); 4461 "FAILED: testcase check_str_from_uint16() failed.\n\n");
4623 failures += str_from_uint64; 4462 failures += str_from_uint64;
@@ -4628,12 +4467,6 @@ run_str_from_X_tests (void)
4628 strx_from_uint32 = check_strx_from_uint32 (); 4467 strx_from_uint32 = check_strx_from_uint32 ();
4629 if (strx_from_uint32 != 0) 4468 if (strx_from_uint32 != 0)
4630 { 4469 {
4631 if (strx_from_uint32 < 0)
4632 {
4633 fprintf (stderr,
4634 "ERROR: test internal error in check_strx_from_uint32().\n");
4635 return 99;
4636 }
4637 fprintf (stderr, 4470 fprintf (stderr,
4638 "FAILED: testcase check_strx_from_uint32() failed.\n\n"); 4471 "FAILED: testcase check_strx_from_uint32() failed.\n\n");
4639 failures += strx_from_uint32; 4472 failures += strx_from_uint32;
@@ -4645,12 +4478,6 @@ run_str_from_X_tests (void)
4645 str_from_uint8_pad = check_str_from_uint8_pad (); 4478 str_from_uint8_pad = check_str_from_uint8_pad ();
4646 if (str_from_uint8_pad != 0) 4479 if (str_from_uint8_pad != 0)
4647 { 4480 {
4648 if (str_from_uint8_pad < 0)
4649 {
4650 fprintf (stderr,
4651 "ERROR: test internal error in check_str_from_uint8_pad().\n");
4652 return 99;
4653 }
4654 fprintf (stderr, 4481 fprintf (stderr,
4655 "FAILED: testcase check_str_from_uint8_pad() failed.\n\n"); 4482 "FAILED: testcase check_str_from_uint8_pad() failed.\n\n");
4656 failures += str_from_uint8_pad; 4483 failures += str_from_uint8_pad;