diff options
Diffstat (limited to 'src/microhttpd/test_str.c')
-rw-r--r-- | src/microhttpd/test_str.c | 4627 |
1 files changed, 2531 insertions, 2096 deletions
diff --git a/src/microhttpd/test_str.c b/src/microhttpd/test_str.c index 12e12a85..8739a23a 100644 --- a/src/microhttpd/test_str.c +++ b/src/microhttpd/test_str.c | |||
@@ -46,235 +46,237 @@ static int verbose = 0; /* verbose level (0-3)*/ | |||
46 | * Functions must not depend of current current locale, | 46 | * Functions must not depend of current current locale, |
47 | * so result must be the same in any locale. | 47 | * so result must be the same in any locale. |
48 | */ | 48 | */ |
49 | static const char * const locale_names[] = { | 49 | static const char *const locale_names[] = { |
50 | "C", | 50 | "C", |
51 | "", /* System default locale */ | 51 | "", /* System default locale */ |
52 | #if defined(_WIN32) && !defined(__CYGWIN__) | 52 | #if defined(_WIN32) && ! defined(__CYGWIN__) |
53 | ".OCP", /* W32 system default OEM code page */ | 53 | ".OCP", /* W32 system default OEM code page */ |
54 | ".ACP", /* W32 system default ANSI code page */ | 54 | ".ACP", /* W32 system default ANSI code page */ |
55 | ".65001", /* UTF-8 */ | 55 | ".65001", /* UTF-8 */ |
56 | ".437", | 56 | ".437", |
57 | ".850", | 57 | ".850", |
58 | ".857", | 58 | ".857", |
59 | ".866", | 59 | ".866", |
60 | ".1250", | 60 | ".1250", |
61 | ".1251", | 61 | ".1251", |
62 | ".1252", | 62 | ".1252", |
63 | ".1254", | 63 | ".1254", |
64 | ".20866", /* number for KOI8-R */ | 64 | ".20866", /* number for KOI8-R */ |
65 | ".28591", /* number for ISO-8859-1 */ | 65 | ".28591", /* number for ISO-8859-1 */ |
66 | ".28595", /* number for ISO-8859-5 */ | 66 | ".28595", /* number for ISO-8859-5 */ |
67 | ".28599", /* number for ISO-8859-9 */ | 67 | ".28599", /* number for ISO-8859-9 */ |
68 | ".28605", /* number for ISO-8859-15 */ | 68 | ".28605", /* number for ISO-8859-15 */ |
69 | "en", | 69 | "en", |
70 | "english", | 70 | "english", |
71 | "en-US", | 71 | "en-US", |
72 | "English-US", | 72 | "English-US", |
73 | "en-US.437", | 73 | "en-US.437", |
74 | "English_United States.437", | 74 | "English_United States.437", |
75 | "en-US.1252", | 75 | "en-US.1252", |
76 | "English_United States.1252", | 76 | "English_United States.1252", |
77 | "English_United States.28591", | 77 | "English_United States.28591", |
78 | "English_United States.65001", | 78 | "English_United States.65001", |
79 | "fra", | 79 | "fra", |
80 | "french", | 80 | "french", |
81 | "fr-FR", | 81 | "fr-FR", |
82 | "French_France", | 82 | "French_France", |
83 | "fr-FR.850", | 83 | "fr-FR.850", |
84 | "french_france.850", | 84 | "french_france.850", |
85 | "fr-FR.1252", | 85 | "fr-FR.1252", |
86 | "French_france.1252", | 86 | "French_france.1252", |
87 | "French_france.28605", | 87 | "French_france.28605", |
88 | "French_France.65001", | 88 | "French_France.65001", |
89 | "de", | 89 | "de", |
90 | "de-DE", | 90 | "de-DE", |
91 | "de-DE.850", | 91 | "de-DE.850", |
92 | "German_Germany.850", | 92 | "German_Germany.850", |
93 | "German_Germany.1250", | 93 | "German_Germany.1250", |
94 | "de-DE.1252", | 94 | "de-DE.1252", |
95 | "German_Germany.1252", | 95 | "German_Germany.1252", |
96 | "German_Germany.28605", | 96 | "German_Germany.28605", |
97 | "German_Germany.65001", | 97 | "German_Germany.65001", |
98 | "tr", | 98 | "tr", |
99 | "trk", | 99 | "trk", |
100 | "turkish", | 100 | "turkish", |
101 | "tr-TR", | 101 | "tr-TR", |
102 | "tr-TR.1254", | 102 | "tr-TR.1254", |
103 | "Turkish_Turkey.1254", | 103 | "Turkish_Turkey.1254", |
104 | "tr-TR.857", | 104 | "tr-TR.857", |
105 | "Turkish_Turkey.857", | 105 | "Turkish_Turkey.857", |
106 | "Turkish_Turkey.28599", | 106 | "Turkish_Turkey.28599", |
107 | "Turkish_Turkey.65001", | 107 | "Turkish_Turkey.65001", |
108 | "ru", | 108 | "ru", |
109 | "ru-RU", | 109 | "ru-RU", |
110 | "Russian", | 110 | "Russian", |
111 | "ru-RU.866", | 111 | "ru-RU.866", |
112 | "Russian_Russia.866", | 112 | "Russian_Russia.866", |
113 | "ru-RU.1251", | 113 | "ru-RU.1251", |
114 | "Russian_Russia.1251", | 114 | "Russian_Russia.1251", |
115 | "Russian_Russia.20866", | 115 | "Russian_Russia.20866", |
116 | "Russian_Russia.28595", | 116 | "Russian_Russia.28595", |
117 | "Russian_Russia.65001", | 117 | "Russian_Russia.65001", |
118 | "zh-Hans", | 118 | "zh-Hans", |
119 | "zh-Hans.936", | 119 | "zh-Hans.936", |
120 | "chinese-simplified" | 120 | "chinese-simplified" |
121 | #else /* ! _WIN32 || __CYGWIN__ */ | 121 | #else /* ! _WIN32 || __CYGWIN__ */ |
122 | "C.UTF-8", | 122 | "C.UTF-8", |
123 | "POSIX", | 123 | "POSIX", |
124 | "en", | 124 | "en", |
125 | "en_US", | 125 | "en_US", |
126 | "en_US.ISO-8859-1", | 126 | "en_US.ISO-8859-1", |
127 | "en_US.ISO_8859-1", | 127 | "en_US.ISO_8859-1", |
128 | "en_US.ISO8859-1", | 128 | "en_US.ISO8859-1", |
129 | "en_US.iso88591", | 129 | "en_US.iso88591", |
130 | "en_US.ISO-8859-15", | 130 | "en_US.ISO-8859-15", |
131 | "en_US.DIS_8859-15", | 131 | "en_US.DIS_8859-15", |
132 | "en_US.ISO8859-15", | 132 | "en_US.ISO8859-15", |
133 | "en_US.iso885915", | 133 | "en_US.iso885915", |
134 | "en_US.1252", | 134 | "en_US.1252", |
135 | "en_US.CP1252", | 135 | "en_US.CP1252", |
136 | "en_US.UTF-8", | 136 | "en_US.UTF-8", |
137 | "en_US.utf8", | 137 | "en_US.utf8", |
138 | "fr", | 138 | "fr", |
139 | "fr_FR", | 139 | "fr_FR", |
140 | "fr_FR.850", | 140 | "fr_FR.850", |
141 | "fr_FR.IBM850", | 141 | "fr_FR.IBM850", |
142 | "fr_FR.1252", | 142 | "fr_FR.1252", |
143 | "fr_FR.CP1252", | 143 | "fr_FR.CP1252", |
144 | "fr_FR.ISO-8859-1", | 144 | "fr_FR.ISO-8859-1", |
145 | "fr_FR.ISO_8859-1", | 145 | "fr_FR.ISO_8859-1", |
146 | "fr_FR.ISO8859-1", | 146 | "fr_FR.ISO8859-1", |
147 | "fr_FR.iso88591", | 147 | "fr_FR.iso88591", |
148 | "fr_FR.ISO-8859-15", | 148 | "fr_FR.ISO-8859-15", |
149 | "fr_FR.DIS_8859-15", | 149 | "fr_FR.DIS_8859-15", |
150 | "fr_FR.ISO8859-15", | 150 | "fr_FR.ISO8859-15", |
151 | "fr_FR.iso8859-15", | 151 | "fr_FR.iso8859-15", |
152 | "fr_FR.UTF-8", | 152 | "fr_FR.UTF-8", |
153 | "fr_FR.utf8", | 153 | "fr_FR.utf8", |
154 | "de", | 154 | "de", |
155 | "de_DE", | 155 | "de_DE", |
156 | "de_DE.850", | 156 | "de_DE.850", |
157 | "de_DE.IBM850", | 157 | "de_DE.IBM850", |
158 | "de_DE.1250", | 158 | "de_DE.1250", |
159 | "de_DE.CP1250", | 159 | "de_DE.CP1250", |
160 | "de_DE.1252", | 160 | "de_DE.1252", |
161 | "de_DE.CP1252", | 161 | "de_DE.CP1252", |
162 | "de_DE.ISO-8859-1", | 162 | "de_DE.ISO-8859-1", |
163 | "de_DE.ISO_8859-1", | 163 | "de_DE.ISO_8859-1", |
164 | "de_DE.ISO8859-1", | 164 | "de_DE.ISO8859-1", |
165 | "de_DE.iso88591", | 165 | "de_DE.iso88591", |
166 | "de_DE.ISO-8859-15", | 166 | "de_DE.ISO-8859-15", |
167 | "de_DE.DIS_8859-15", | 167 | "de_DE.DIS_8859-15", |
168 | "de_DE.ISO8859-15", | 168 | "de_DE.ISO8859-15", |
169 | "de_DE.iso885915", | 169 | "de_DE.iso885915", |
170 | "de_DE.UTF-8", | 170 | "de_DE.UTF-8", |
171 | "de_DE.utf8", | 171 | "de_DE.utf8", |
172 | "tr", | 172 | "tr", |
173 | "tr_TR", | 173 | "tr_TR", |
174 | "tr_TR.1254", | 174 | "tr_TR.1254", |
175 | "tr_TR.CP1254", | 175 | "tr_TR.CP1254", |
176 | "tr_TR.857", | 176 | "tr_TR.857", |
177 | "tr_TR.IBM857", | 177 | "tr_TR.IBM857", |
178 | "tr_TR.ISO-8859-9", | 178 | "tr_TR.ISO-8859-9", |
179 | "tr_TR.ISO8859-9", | 179 | "tr_TR.ISO8859-9", |
180 | "tr_TR.iso88599", | 180 | "tr_TR.iso88599", |
181 | "tr_TR.UTF-8", | 181 | "tr_TR.UTF-8", |
182 | "tr_TR.utf8", | 182 | "tr_TR.utf8", |
183 | "ru", | 183 | "ru", |
184 | "ru_RU", | 184 | "ru_RU", |
185 | "ru_RU.1251", | 185 | "ru_RU.1251", |
186 | "ru_RU.CP1251", | 186 | "ru_RU.CP1251", |
187 | "ru_RU.866", | 187 | "ru_RU.866", |
188 | "ru_RU.IBM866", | 188 | "ru_RU.IBM866", |
189 | "ru_RU.KOI8-R", | 189 | "ru_RU.KOI8-R", |
190 | "ru_RU.koi8-r", | 190 | "ru_RU.koi8-r", |
191 | "ru_RU.KOI8-RU", | 191 | "ru_RU.KOI8-RU", |
192 | "ru_RU.ISO-8859-5", | 192 | "ru_RU.ISO-8859-5", |
193 | "ru_RU.ISO_8859-5", | 193 | "ru_RU.ISO_8859-5", |
194 | "ru_RU.ISO8859-5", | 194 | "ru_RU.ISO8859-5", |
195 | "ru_RU.iso88595", | 195 | "ru_RU.iso88595", |
196 | "ru_RU.UTF-8", | 196 | "ru_RU.UTF-8", |
197 | "zh_CN", | 197 | "zh_CN", |
198 | "zh_CN.GB2312", | 198 | "zh_CN.GB2312", |
199 | "zh_CN.UTF-8", | 199 | "zh_CN.UTF-8", |
200 | #endif /* ! _WIN32 || __CYGWIN__ */ | 200 | #endif /* ! _WIN32 || __CYGWIN__ */ |
201 | }; | 201 | }; |
202 | 202 | ||
203 | static const unsigned int locale_name_count = sizeof(locale_names) / sizeof(locale_names[0]); | 203 | static const unsigned int locale_name_count = sizeof(locale_names) |
204 | / sizeof(locale_names[0]); | ||
204 | 205 | ||
205 | 206 | ||
206 | /* | 207 | /* |
207 | * Helper functions | 208 | * Helper functions |
208 | */ | 209 | */ |
209 | 210 | ||
210 | int set_test_locale(unsigned int num) | 211 | int set_test_locale (unsigned int num) |
211 | { | 212 | { |
212 | if (num >= locale_name_count) | 213 | if (num >= locale_name_count) |
213 | return -1; | 214 | return -1; |
214 | if (verbose > 2) | 215 | if (verbose > 2) |
215 | printf("Setting locale \"%s\":", locale_names[num]); | 216 | printf ("Setting locale \"%s\":", locale_names[num]); |
216 | if (setlocale(LC_ALL, locale_names[num])) | 217 | if (setlocale (LC_ALL, locale_names[num])) |
217 | { | 218 | { |
218 | if (verbose > 2) | 219 | if (verbose > 2) |
219 | printf(" succeed.\n"); | 220 | printf (" succeed.\n"); |
220 | return 1; | 221 | return 1; |
221 | } | 222 | } |
222 | if (verbose > 2) | 223 | if (verbose > 2) |
223 | printf(" failed.\n"); | 224 | printf (" failed.\n"); |
224 | return 0; | 225 | return 0; |
225 | } | 226 | } |
226 | 227 | ||
227 | const char * get_current_locale_str(void) | 228 | const char *get_current_locale_str (void) |
228 | { | 229 | { |
229 | char const * loc_str = setlocale(LC_ALL, NULL); | 230 | char const *loc_str = setlocale (LC_ALL, NULL); |
230 | return loc_str ? loc_str : "unknown"; | 231 | return loc_str ? loc_str : "unknown"; |
231 | } | 232 | } |
232 | 233 | ||
233 | static char tmp_bufs[4][4*1024]; /* should be enough for testing */ | 234 | static char tmp_bufs[4][4 * 1024]; /* should be enough for testing */ |
234 | static size_t buf_idx = 0; | 235 | static size_t buf_idx = 0; |
235 | 236 | ||
236 | /* print non-printable chars as char codes */ | 237 | /* print non-printable chars as char codes */ |
237 | char * n_prnt(const char * str) | 238 | char *n_prnt (const char *str) |
238 | { | 239 | { |
239 | static char * buf; /* should be enough for testing */ | 240 | static char *buf; /* should be enough for testing */ |
240 | static const size_t buf_size = sizeof(tmp_bufs[0]); | 241 | static const size_t buf_size = sizeof(tmp_bufs[0]); |
241 | const unsigned char * p = (const unsigned char*)str; | 242 | const unsigned char *p = (const unsigned char*) str; |
242 | size_t w_pos = 0; | 243 | size_t w_pos = 0; |
243 | if (++buf_idx > 3) | 244 | if (++buf_idx > 3) |
244 | buf_idx = 0; | 245 | buf_idx = 0; |
245 | buf = tmp_bufs[buf_idx]; | 246 | buf = tmp_bufs[buf_idx]; |
246 | 247 | ||
247 | while(*p && w_pos + 1 < buf_size) | 248 | while (*p && w_pos + 1 < buf_size) |
249 | { | ||
250 | const unsigned char c = *p; | ||
251 | if ((c == '\\') ||(c == '"') ) | ||
248 | { | 252 | { |
249 | const unsigned char c = *p; | 253 | if (w_pos + 2 >= buf_size) |
250 | if (c == '\\' || c == '"') | 254 | break; |
251 | { | 255 | buf[w_pos++] = '\\'; |
252 | if (w_pos + 2 >= buf_size) | 256 | buf[w_pos++] = c; |
253 | break; | ||
254 | buf[w_pos++] = '\\'; | ||
255 | buf[w_pos++] = c; | ||
256 | } | ||
257 | else if (c >= 0x20 && c <= 0x7E) | ||
258 | buf[w_pos++] = c; | ||
259 | else | ||
260 | { | ||
261 | if (w_pos + 4 >= buf_size) | ||
262 | break; | ||
263 | if (snprintf(buf + w_pos, buf_size - w_pos, "\\x%02hX", (short unsigned int)c) != 4) | ||
264 | break; | ||
265 | w_pos += 4; | ||
266 | } | ||
267 | p++; | ||
268 | } | 257 | } |
258 | else if ((c >= 0x20) &&(c <= 0x7E) ) | ||
259 | buf[w_pos++] = c; | ||
260 | else | ||
261 | { | ||
262 | if (w_pos + 4 >= buf_size) | ||
263 | break; | ||
264 | if (snprintf (buf + w_pos, buf_size - w_pos, "\\x%02hX", (short unsigned | ||
265 | int) c) != 4) | ||
266 | break; | ||
267 | w_pos += 4; | ||
268 | } | ||
269 | p++; | ||
270 | } | ||
269 | if (*p) | 271 | if (*p) |
270 | { /* not full string is printed */ | 272 | { /* not full string is printed */ |
271 | /* enough space for "..." ? */ | 273 | /* enough space for "..." ? */ |
272 | if (w_pos + 3 > buf_size) | 274 | if (w_pos + 3 > buf_size) |
273 | w_pos = buf_size - 4; | 275 | w_pos = buf_size - 4; |
274 | buf[w_pos++] = '.'; | 276 | buf[w_pos++] = '.'; |
275 | buf[w_pos++] = '.'; | 277 | buf[w_pos++] = '.'; |
276 | buf[w_pos++] = '.'; | 278 | buf[w_pos++] = '.'; |
277 | } | 279 | } |
278 | buf[w_pos] = 0; | 280 | buf[w_pos] = 0; |
279 | return buf; | 281 | return buf; |
280 | } | 282 | } |
@@ -282,7 +284,7 @@ char * n_prnt(const char * str) | |||
282 | 284 | ||
283 | struct str_with_len | 285 | struct str_with_len |
284 | { | 286 | { |
285 | const char * const str; | 287 | const char *const str; |
286 | const size_t len; | 288 | const size_t len; |
287 | }; | 289 | }; |
288 | 290 | ||
@@ -299,118 +301,129 @@ struct two_eq_strs | |||
299 | }; | 301 | }; |
300 | 302 | ||
301 | static const struct two_eq_strs eq_strings[] = { | 303 | static const struct two_eq_strs eq_strings[] = { |
302 | {D_STR_W_LEN("1234567890!@~%&$@#{}[]\\/!?`."), D_STR_W_LEN("1234567890!@~%&$@#{}[]\\/!?`.")}, | 304 | {D_STR_W_LEN ("1234567890!@~%&$@#{}[]\\/!?`."), D_STR_W_LEN ( |
303 | {D_STR_W_LEN("Simple string."), D_STR_W_LEN("Simple string.")}, | 305 | "1234567890!@~%&$@#{}[]\\/!?`.")}, |
304 | {D_STR_W_LEN("SIMPLE STRING."), D_STR_W_LEN("SIMPLE STRING.")}, | 306 | {D_STR_W_LEN ("Simple string."), D_STR_W_LEN ("Simple string.")}, |
305 | {D_STR_W_LEN("simple string."), D_STR_W_LEN("simple string.")}, | 307 | {D_STR_W_LEN ("SIMPLE STRING."), D_STR_W_LEN ("SIMPLE STRING.")}, |
306 | {D_STR_W_LEN("simple string."), D_STR_W_LEN("Simple String.")}, | 308 | {D_STR_W_LEN ("simple string."), D_STR_W_LEN ("simple string.")}, |
307 | {D_STR_W_LEN("sImPlE StRiNg."), D_STR_W_LEN("SiMpLe sTrInG.")}, | 309 | {D_STR_W_LEN ("simple string."), D_STR_W_LEN ("Simple String.")}, |
308 | {D_STR_W_LEN("SIMPLE STRING."), D_STR_W_LEN("simple string.")}, | 310 | {D_STR_W_LEN ("sImPlE StRiNg."), D_STR_W_LEN ("SiMpLe sTrInG.")}, |
309 | {D_STR_W_LEN("abcdefghijklmnopqrstuvwxyz"), D_STR_W_LEN("abcdefghijklmnopqrstuvwxyz")}, | 311 | {D_STR_W_LEN ("SIMPLE STRING."), D_STR_W_LEN ("simple string.")}, |
310 | {D_STR_W_LEN("ABCDEFGHIJKLMNOPQRSTUVWXYZ"), D_STR_W_LEN("ABCDEFGHIJKLMNOPQRSTUVWXYZ")}, | 312 | {D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyz"), D_STR_W_LEN ( |
311 | {D_STR_W_LEN("abcdefghijklmnopqrstuvwxyz"), D_STR_W_LEN("ABCDEFGHIJKLMNOPQRSTUVWXYZ")}, | 313 | "abcdefghijklmnopqrstuvwxyz")}, |
312 | {D_STR_W_LEN("zyxwvutsrqponMLKJIHGFEDCBA"), D_STR_W_LEN("ZYXWVUTSRQPONmlkjihgfedcba")}, | 314 | {D_STR_W_LEN ("ABCDEFGHIJKLMNOPQRSTUVWXYZ"), D_STR_W_LEN ( |
313 | 315 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ")}, | |
314 | {D_STR_W_LEN("Cha\x8cne pour le test."), | 316 | {D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyz"), D_STR_W_LEN ( |
315 | D_STR_W_LEN("Cha\x8cne pour le test.")}, /* "Chaîne pour le test." in CP850 */ | 317 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ")}, |
316 | {D_STR_W_LEN("cha\x8cne pOur Le TEst."), | 318 | {D_STR_W_LEN ("zyxwvutsrqponMLKJIHGFEDCBA"), D_STR_W_LEN ( |
317 | D_STR_W_LEN("Cha\x8cne poUr Le teST.")}, | 319 | "ZYXWVUTSRQPONmlkjihgfedcba")}, |
318 | {D_STR_W_LEN("Cha\xeene pour le test."), | 320 | |
319 | D_STR_W_LEN("Cha\xeene pour le test.")}, /* "Chaîne pour le test." in CP1252/ISO-8859-1/ISO-8859-15 */ | 321 | {D_STR_W_LEN ("Cha\x8cne pour le test."), |
320 | {D_STR_W_LEN("CHa\xeene POUR le test."), | 322 | D_STR_W_LEN ("Cha\x8cne pour le test.")}, /* "Chaîne pour le test." in CP850 */ |
321 | D_STR_W_LEN("Cha\xeeNe pour lE TEST.")}, | 323 | {D_STR_W_LEN ("cha\x8cne pOur Le TEst."), |
322 | {D_STR_W_LEN("Cha\xc3\xaene pour le Test."), | 324 | D_STR_W_LEN ("Cha\x8cne poUr Le teST.")}, |
323 | D_STR_W_LEN("Cha\xc3\xaene pour le Test.")}, /* "Chaîne pour le test." in UTF-8 */ | 325 | {D_STR_W_LEN ("Cha\xeene pour le test."), |
324 | {D_STR_W_LEN("ChA\xc3\xaene pouR lE TesT."), | 326 | D_STR_W_LEN ("Cha\xeene pour le test.")}, /* "Chaîne pour le test." in CP1252/ISO-8859-1/ISO-8859-15 */ |
325 | D_STR_W_LEN("Cha\xc3\xaeNe Pour le teSt.")}, | 327 | {D_STR_W_LEN ("CHa\xeene POUR le test."), |
326 | 328 | D_STR_W_LEN ("Cha\xeeNe pour lE TEST.")}, | |
327 | {D_STR_W_LEN(".Beispiel Zeichenfolge"), | 329 | {D_STR_W_LEN ("Cha\xc3\xaene pour le Test."), |
328 | D_STR_W_LEN(".Beispiel Zeichenfolge")}, | 330 | D_STR_W_LEN ("Cha\xc3\xaene pour le Test.")}, /* "Chaîne pour le test." in UTF-8 */ |
329 | {D_STR_W_LEN(".bEisPiel ZEIchenfoLgE"), | 331 | {D_STR_W_LEN ("ChA\xc3\xaene pouR lE TesT."), |
330 | D_STR_W_LEN(".BEiSpiEl zeIcheNfolge")}, | 332 | D_STR_W_LEN ("Cha\xc3\xaeNe Pour le teSt.")}, |
331 | 333 | ||
332 | {D_STR_W_LEN("Do\xa7rulama \x87izgi!"), | 334 | {D_STR_W_LEN (".Beispiel Zeichenfolge"), |
333 | D_STR_W_LEN("Do\xa7rulama \x87izgi!")}, /* "Doğrulama çizgi!" in CP857 */ | 335 | D_STR_W_LEN (".Beispiel Zeichenfolge")}, |
334 | {D_STR_W_LEN("Do\xa7rulama \x87IzgI!"), /* Spelling intentionally incorrect here */ | 336 | {D_STR_W_LEN (".bEisPiel ZEIchenfoLgE"), |
335 | D_STR_W_LEN("Do\xa7rulama \x87izgi!")}, /* Note: 'i' is not caseless equal to 'I' in Turkish */ | 337 | D_STR_W_LEN (".BEiSpiEl zeIcheNfolge")}, |
336 | {D_STR_W_LEN("Do\xf0rulama \xe7izgi!"), | 338 | |
337 | D_STR_W_LEN("Do\xf0rulama \xe7izgi!")}, /* "Doğrulama çizgi!" in CP1254/ISO-8859-9 */ | 339 | {D_STR_W_LEN ("Do\xa7rulama \x87izgi!"), |
338 | {D_STR_W_LEN("Do\xf0rulamA \xe7Izgi!"), | 340 | D_STR_W_LEN ("Do\xa7rulama \x87izgi!")}, /* "Doğrulama çizgi!" in CP857 */ |
339 | D_STR_W_LEN("do\xf0rulama \xe7izgi!")}, | 341 | {D_STR_W_LEN ("Do\xa7rulama \x87IzgI!"), /* Spelling intentionally incorrect here */ |
340 | {D_STR_W_LEN("Do\xc4\x9frulama \xc3\xa7izgi!"), | 342 | D_STR_W_LEN ("Do\xa7rulama \x87izgi!")}, /* Note: 'i' is not caseless equal to 'I' in Turkish */ |
341 | D_STR_W_LEN("Do\xc4\x9frulama \xc3\xa7izgi!")}, /* "Doğrulama çizgi!" in UTF-8 */ | 343 | {D_STR_W_LEN ("Do\xf0rulama \xe7izgi!"), |
342 | {D_STR_W_LEN("do\xc4\x9fruLAMA \xc3\xa7Izgi!"), /* Spelling intentionally incorrect here */ | 344 | D_STR_W_LEN ("Do\xf0rulama \xe7izgi!")}, /* "Doğrulama çizgi!" in CP1254/ISO-8859-9 */ |
343 | D_STR_W_LEN("DO\xc4\x9frulama \xc3\xa7izgI!")}, /* Spelling intentionally incorrect here */ | 345 | {D_STR_W_LEN ("Do\xf0rulamA \xe7Izgi!"), |
344 | 346 | D_STR_W_LEN ("do\xf0rulama \xe7izgi!")}, | |
345 | {D_STR_W_LEN("\x92\xa5\xe1\xe2\xae\xa2\xa0\xef \x91\xe2\xe0\xae\xaa\xa0."), | 347 | {D_STR_W_LEN ("Do\xc4\x9frulama \xc3\xa7izgi!"), |
346 | D_STR_W_LEN("\x92\xa5\xe1\xe2\xae\xa2\xa0\xef \x91\xe2\xe0\xae\xaa\xa0.")}, /* "Тестовая Строка." in CP866 */ | 348 | D_STR_W_LEN ("Do\xc4\x9frulama \xc3\xa7izgi!")}, /* "Doğrulama çizgi!" in UTF-8 */ |
347 | {D_STR_W_LEN("\xd2\xe5\xf1\xf2\xee\xe2\xe0\xff \xd1\xf2\xf0\xee\xea\xe0."), | 349 | {D_STR_W_LEN ("do\xc4\x9fruLAMA \xc3\xa7Izgi!"), /* Spelling intentionally incorrect here */ |
348 | D_STR_W_LEN("\xd2\xe5\xf1\xf2\xee\xe2\xe0\xff \xd1\xf2\xf0\xee\xea\xe0.")}, /* "Тестовая Строка." in CP1251 */ | 350 | D_STR_W_LEN ("DO\xc4\x9frulama \xc3\xa7izgI!")}, /* Spelling intentionally incorrect here */ |
349 | {D_STR_W_LEN("\xf4\xc5\xd3\xd4\xcf\xd7\xc1\xd1 \xf3\xd4\xd2\xcf\xcb\xc1."), | 351 | |
350 | D_STR_W_LEN("\xf4\xc5\xd3\xd4\xcf\xd7\xc1\xd1 \xf3\xd4\xd2\xcf\xcb\xc1.")}, /* "Тестовая Строка." in KOI8-R */ | 352 | {D_STR_W_LEN ("\x92\xa5\xe1\xe2\xae\xa2\xa0\xef \x91\xe2\xe0\xae\xaa\xa0."), |
351 | {D_STR_W_LEN("\xc2\xd5\xe1\xe2\xde\xd2\xd0\xef \xc1\xe2\xe0\xde\xda\xd0."), | 353 | D_STR_W_LEN ("\x92\xa5\xe1\xe2\xae\xa2\xa0\xef \x91\xe2\xe0\xae\xaa\xa0.")}, /* "Тестовая Строка." in CP866 */ |
352 | D_STR_W_LEN("\xc2\xd5\xe1\xe2\xde\xd2\xd0\xef \xc1\xe2\xe0\xde\xda\xd0.")}, /* "Тестовая Строка." in ISO-8859-5 */ | 354 | {D_STR_W_LEN ("\xd2\xe5\xf1\xf2\xee\xe2\xe0\xff \xd1\xf2\xf0\xee\xea\xe0."), |
353 | {D_STR_W_LEN("\xd0\xa2\xd0\xb5\xd1\x81\xd1\x82\xd0\xbe\xd0\xb2\xd0\xb0\xd1" | 355 | D_STR_W_LEN ("\xd2\xe5\xf1\xf2\xee\xe2\xe0\xff \xd1\xf2\xf0\xee\xea\xe0.")}, /* "Тестовая Строка." in CP1251 */ |
354 | "\x8f \xd0\xa1\xd1\x82\xd1\x80\xd0\xbe\xd0\xba\xd0\xb0."), | 356 | {D_STR_W_LEN ("\xf4\xc5\xd3\xd4\xcf\xd7\xc1\xd1 \xf3\xd4\xd2\xcf\xcb\xc1."), |
355 | D_STR_W_LEN("\xd0\xa2\xd0\xb5\xd1\x81\xd1\x82\xd0\xbe\xd0\xb2\xd0\xb0\xd1" | 357 | D_STR_W_LEN ("\xf4\xc5\xd3\xd4\xcf\xd7\xc1\xd1 \xf3\xd4\xd2\xcf\xcb\xc1.")}, /* "Тестовая Строка." in KOI8-R */ |
356 | "\x8f \xd0\xa1\xd1\x82\xd1\x80\xd0\xbe\xd0\xba\xd0\xb0.")}, /* "Тестовая Строка." in UTF-8 */ | 358 | {D_STR_W_LEN ("\xc2\xd5\xe1\xe2\xde\xd2\xd0\xef \xc1\xe2\xe0\xde\xda\xd0."), |
357 | 359 | D_STR_W_LEN ("\xc2\xd5\xe1\xe2\xde\xd2\xd0\xef \xc1\xe2\xe0\xde\xda\xd0.")}, /* "Тестовая Строка." in ISO-8859-5 */ | |
358 | {D_STR_W_LEN("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" | 360 | {D_STR_W_LEN ("\xd0\xa2\xd0\xb5\xd1\x81\xd1\x82\xd0\xbe\xd0\xb2\xd0\xb0\xd1" |
359 | "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@[\\]" | 361 | "\x8f \xd0\xa1\xd1\x82\xd1\x80\xd0\xbe\xd0\xba\xd0\xb0."), |
360 | "^_`{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90" | 362 | D_STR_W_LEN ("\xd0\xa2\xd0\xb5\xd1\x81\xd1\x82\xd0\xbe\xd0\xb2\xd0\xb0\xd1" |
361 | "\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4" | 363 | "\x8f \xd0\xa1\xd1\x82\xd1\x80\xd0\xbe\xd0\xba\xd0\xb0.")}, /* "Тестовая Строка." in UTF-8 */ |
362 | "\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8" | 364 | |
363 | "\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc" | 365 | {D_STR_W_LEN ( |
364 | "\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0" | 366 | "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" |
365 | "\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4" | 367 | "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@[\\]" |
366 | "\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"), | 368 | "^_`{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90" |
367 | D_STR_W_LEN("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" | 369 | "\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4" |
368 | "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@[\\]" | 370 | "\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8" |
369 | "^_`{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90" | 371 | "\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc" |
370 | "\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4" | 372 | "\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0" |
371 | "\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8" | 373 | "\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4" |
372 | "\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc" | 374 | "\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"), |
373 | "\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0" | 375 | D_STR_W_LEN ( |
374 | "\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4" | 376 | "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" |
375 | "\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff")}, /* Full sequence without a-z */ | 377 | "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@[\\]" |
376 | {D_STR_W_LEN("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" | 378 | "^_`{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90" |
377 | "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@AB" | 379 | "\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4" |
378 | "CDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83" | 380 | "\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8" |
379 | "\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97" | 381 | "\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc" |
380 | "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab" | 382 | "\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0" |
381 | "\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" | 383 | "\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4" |
382 | "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3" | 384 | "\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff")}, /* Full sequence without a-z */ |
383 | "\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7" | 385 | {D_STR_W_LEN ( |
384 | "\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb" | 386 | "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" |
385 | "\xfc\xfd\xfe\xff"), | 387 | "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@AB" |
386 | D_STR_W_LEN("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" | 388 | "CDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83" |
387 | "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@AB" | 389 | "\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97" |
388 | "CDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83" | 390 | "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab" |
389 | "\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97" | 391 | "\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" |
390 | "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab" | 392 | "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3" |
391 | "\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" | 393 | "\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7" |
392 | "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3" | 394 | "\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb" |
393 | "\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7" | 395 | "\xfc\xfd\xfe\xff"), |
394 | "\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb" | 396 | D_STR_W_LEN ( |
395 | "\xfc\xfd\xfe\xff")}, /* Full sequence */ | 397 | "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" |
396 | {D_STR_W_LEN("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" | 398 | "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@AB" |
397 | "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@AB" | 399 | "CDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83" |
398 | "CDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89" | 400 | "\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97" |
399 | "\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d" | 401 | "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab" |
400 | "\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1" | 402 | "\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" |
401 | "\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5" | 403 | "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3" |
402 | "\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9" | 404 | "\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7" |
403 | "\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed" | 405 | "\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb" |
404 | "\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"), | 406 | "\xfc\xfd\xfe\xff")}, /* Full sequence */ |
405 | D_STR_W_LEN("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" | 407 | {D_STR_W_LEN ( |
406 | "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ab" | 408 | "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" |
407 | "cdefghijklmnopqrstuvwxyz[\\]^_`{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89" | 409 | "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@AB" |
408 | "\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d" | 410 | "CDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89" |
409 | "\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1" | 411 | "\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d" |
410 | "\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5" | 412 | "\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1" |
411 | "\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9" | 413 | "\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5" |
412 | "\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed" | 414 | "\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9" |
413 | "\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff")} /* Full with A/a match */ | 415 | "\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed" |
416 | "\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"), | ||
417 | D_STR_W_LEN ( | ||
418 | "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14" | ||
419 | "\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ab" | ||
420 | "cdefghijklmnopqrstuvwxyz[\\]^_`{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89" | ||
421 | "\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d" | ||
422 | "\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1" | ||
423 | "\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5" | ||
424 | "\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9" | ||
425 | "\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed" | ||
426 | "\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff")} /* Full with A/a match */ | ||
414 | }; | 427 | }; |
415 | 428 | ||
416 | struct two_neq_strs | 429 | struct two_neq_strs |
@@ -421,367 +434,419 @@ struct two_neq_strs | |||
421 | }; | 434 | }; |
422 | 435 | ||
423 | static const struct two_neq_strs neq_strings[] = { | 436 | static const struct two_neq_strs neq_strings[] = { |
424 | {D_STR_W_LEN("1234567890!@~%&$@#{}[]\\/!?`."), D_STR_W_LEN("1234567890!@~%&$@#{}[]\\/!?`"), 27}, | 437 | {D_STR_W_LEN ("1234567890!@~%&$@#{}[]\\/!?`."), D_STR_W_LEN ( |
425 | {D_STR_W_LEN(".1234567890!@~%&$@#{}[]\\/!?`."), D_STR_W_LEN("1234567890!@~%&$@#{}[]\\/!?`"), 0}, | 438 | "1234567890!@~%&$@#{}[]\\/!?`"), 27}, |
426 | {D_STR_W_LEN("Simple string."), D_STR_W_LEN("Simple ctring."), 7}, | 439 | {D_STR_W_LEN (".1234567890!@~%&$@#{}[]\\/!?`."), D_STR_W_LEN ( |
427 | {D_STR_W_LEN("simple string."), D_STR_W_LEN("simple string"), 13}, | 440 | "1234567890!@~%&$@#{}[]\\/!?`"), 0}, |
428 | {D_STR_W_LEN("simple strings"), D_STR_W_LEN("Simple String."), 13}, | 441 | {D_STR_W_LEN ("Simple string."), D_STR_W_LEN ("Simple ctring."), 7}, |
429 | {D_STR_W_LEN("sImPlE StRiNg."), D_STR_W_LEN("SYMpLe sTrInG."), 1}, | 442 | {D_STR_W_LEN ("simple string."), D_STR_W_LEN ("simple string"), 13}, |
430 | {D_STR_W_LEN("SIMPLE STRING."), D_STR_W_LEN("simple string.2"), 14}, | 443 | {D_STR_W_LEN ("simple strings"), D_STR_W_LEN ("Simple String."), 13}, |
431 | {D_STR_W_LEN("abcdefghijklmnopqrstuvwxyz,"), D_STR_W_LEN("abcdefghijklmnopqrstuvwxyz."), 26}, | 444 | {D_STR_W_LEN ("sImPlE StRiNg."), D_STR_W_LEN ("SYMpLe sTrInG."), 1}, |
432 | {D_STR_W_LEN("abcdefghijklmnopqrstuvwxyz!"), D_STR_W_LEN("ABCDEFGHIJKLMNOPQRSTUVWXYZ?"), 26}, | 445 | {D_STR_W_LEN ("SIMPLE STRING."), D_STR_W_LEN ("simple string.2"), 14}, |
433 | {D_STR_W_LEN("zyxwvutsrqponwMLKJIHGFEDCBA"), D_STR_W_LEN("ZYXWVUTSRQPON%mlkjihgfedcba"), 13}, | 446 | {D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyz,"), D_STR_W_LEN ( |
434 | 447 | "abcdefghijklmnopqrstuvwxyz."), 26}, | |
435 | {D_STR_W_LEN("S\xbdur veulent plus d'\xbdufs."), /* "Sœur veulent plus d'œufs." in ISO-8859-15 */ | 448 | {D_STR_W_LEN ("abcdefghijklmnopqrstuvwxyz!"), D_STR_W_LEN ( |
436 | D_STR_W_LEN("S\xbcUR VEULENT PLUS D'\xbcUFS."), 1},/* "SŒUR VEULENT PLUS D'ŒUFS." in ISO-8859-15 */ | 449 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ?"), 26}, |
437 | {D_STR_W_LEN("S\x9cur veulent plus d'\x9cufs."), /* "Sœur veulent plus d'œufs." in CP1252 */ | 450 | {D_STR_W_LEN ("zyxwvutsrqponwMLKJIHGFEDCBA"), D_STR_W_LEN ( |
438 | D_STR_W_LEN("S\x8cUR VEULENT PLUS D'\x8cUFS."), 1},/* "SŒUR VEULENT PLUS D'ŒUFS." in CP1252 */ | 451 | "ZYXWVUTSRQPON%mlkjihgfedcba"), 13}, |
439 | {D_STR_W_LEN("S\xc5\x93ur veulent plus d'\xc5\x93ufs."), /* "Sœur veulent plus d'œufs." in UTF-8 */ | 452 | |
440 | D_STR_W_LEN("S\xc5\x92UR VEULENT PLUS D'\xc5\x92UFS."), 2},/* "SŒUR VEULENT PLUS D'ŒUFS." in UTF-8 */ | 453 | {D_STR_W_LEN ("S\xbdur veulent plus d'\xbdufs."), /* "Sœur veulent plus d'œufs." in ISO-8859-15 */ |
441 | 454 | D_STR_W_LEN ("S\xbcUR VEULENT PLUS D'\xbcUFS."), 1}, /* "SŒUR VEULENT PLUS D'ŒUFS." in ISO-8859-15 */ | |
442 | {D_STR_W_LEN("Um ein sch\x94nes M\x84" "dchen zu k\x81ssen."), /* "Um ein schönes Mädchen zu küssen." in CP850 */ | 455 | {D_STR_W_LEN ("S\x9cur veulent plus d'\x9cufs."), /* "Sœur veulent plus d'œufs." in CP1252 */ |
443 | D_STR_W_LEN("UM EIN SCH\x99NES M\x8e" "DCHEN ZU K\x9aSSEN."), 10},/* "UM EIN SCHÖNES MÄDCHEN ZU KÜSSEN." in CP850 */ | 456 | D_STR_W_LEN ("S\x8cUR VEULENT PLUS D'\x8cUFS."), 1}, /* "SŒUR VEULENT PLUS D'ŒUFS." in CP1252 */ |
444 | {D_STR_W_LEN("Um ein sch\xf6nes M\xe4" "dchen zu k\xfcssen."), /* "Um ein schönes Mädchen zu küssen." in ISO-8859-1/ISO-8859-15/CP1250/CP1252 */ | 457 | {D_STR_W_LEN ("S\xc5\x93ur veulent plus d'\xc5\x93ufs."), /* "Sœur veulent plus d'œufs." in UTF-8 */ |
445 | D_STR_W_LEN("UM EIN SCH\xd6NES M\xc4" "DCHEN ZU K\xdcSSEN."), 10},/* "UM EIN SCHÖNES MÄDCHEN ZU KÜSSEN." in ISO-8859-1/ISO-8859-15/CP1250/CP1252 */ | 458 | D_STR_W_LEN ("S\xc5\x92UR VEULENT PLUS D'\xc5\x92UFS."), 2}, /* "SŒUR VEULENT PLUS D'ŒUFS." in UTF-8 */ |
446 | {D_STR_W_LEN("Um ein sch\xc3\xb6nes M\xc3\xa4" "dchen zu k\xc3\xbcssen."), /* "Um ein schönes Mädchen zu küssen." in UTF-8 */ | 459 | |
447 | D_STR_W_LEN("UM EIN SCH\xc3\x96NES M\xc3\x84" "DCHEN ZU K\xc3\x9cSSEN."), 11},/* "UM EIN SCHÖNES MÄDCHEN ZU KÜSSEN." in UTF-8 */ | 460 | {D_STR_W_LEN ("Um ein sch\x94nes M\x84" "dchen zu k\x81ssen."), /* "Um ein schönes Mädchen zu küssen." in CP850 */ |
448 | 461 | D_STR_W_LEN ("UM EIN SCH\x99NES M\x8e" "DCHEN ZU K\x9aSSEN."), 10}, /* "UM EIN SCHÖNES MÄDCHEN ZU KÜSSEN." in CP850 */ | |
449 | {D_STR_W_LEN("\x98stanbul"), /* "İstanbul" in CP857 */ | 462 | {D_STR_W_LEN ("Um ein sch\xf6nes M\xe4" "dchen zu k\xfcssen."), /* "Um ein schönes Mädchen zu küssen." in ISO-8859-1/ISO-8859-15/CP1250/CP1252 */ |
450 | D_STR_W_LEN("istanbul"), 0}, /* "istanbul" in CP857 */ | 463 | D_STR_W_LEN ("UM EIN SCH\xd6NES M\xc4" "DCHEN ZU K\xdcSSEN."), 10}, /* "UM EIN SCHÖNES MÄDCHEN ZU KÜSSEN." in ISO-8859-1/ISO-8859-15/CP1250/CP1252 */ |
451 | {D_STR_W_LEN("\xddstanbul"), /* "İstanbul" in ISO-8859-9/CP1254 */ | 464 | {D_STR_W_LEN ("Um ein sch\xc3\xb6nes M\xc3\xa4" "dchen zu k\xc3\xbcssen."), /* "Um ein schönes Mädchen zu küssen." in UTF-8 */ |
452 | D_STR_W_LEN("istanbul"), 0}, /* "istanbul" in ISO-8859-9/CP1254 */ | 465 | D_STR_W_LEN ("UM EIN SCH\xc3\x96NES M\xc3\x84" "DCHEN ZU K\xc3\x9cSSEN."), |
453 | {D_STR_W_LEN("\xc4\xb0stanbul"), /* "İstanbul" in UTF-8 */ | 466 | 11}, /* "UM EIN SCHÖNES MÄDCHEN ZU KÜSSEN." in UTF-8 */ |
454 | D_STR_W_LEN("istanbul"), 0}, /* "istanbul" in UTF-8 */ | 467 | |
455 | {D_STR_W_LEN("Diyarbak\x8dr"), /* "Diyarbakır" in CP857 */ | 468 | {D_STR_W_LEN ("\x98stanbul"), /* "İstanbul" in CP857 */ |
456 | D_STR_W_LEN("DiyarbakIR"), 8}, /* "DiyarbakIR" in CP857 */ | 469 | D_STR_W_LEN ("istanbul"), 0}, /* "istanbul" in CP857 */ |
457 | {D_STR_W_LEN("Diyarbak\xfdr"), /* "Diyarbakır" in ISO-8859-9/CP1254 */ | 470 | {D_STR_W_LEN ("\xddstanbul"), /* "İstanbul" in ISO-8859-9/CP1254 */ |
458 | D_STR_W_LEN("DiyarbakIR"), 8}, /* "DiyarbakIR" in ISO-8859-9/CP1254 */ | 471 | D_STR_W_LEN ("istanbul"), 0}, /* "istanbul" in ISO-8859-9/CP1254 */ |
459 | {D_STR_W_LEN("Diyarbak\xc4\xb1r"), /* "Diyarbakır" in UTF-8 */ | 472 | {D_STR_W_LEN ("\xc4\xb0stanbul"), /* "İstanbul" in UTF-8 */ |
460 | D_STR_W_LEN("DiyarbakIR"), 8}, /* "DiyarbakIR" in UTF-8 */ | 473 | D_STR_W_LEN ("istanbul"), 0}, /* "istanbul" in UTF-8 */ |
461 | 474 | {D_STR_W_LEN ("Diyarbak\x8dr"), /* "Diyarbakır" in CP857 */ | |
462 | {D_STR_W_LEN("\x92\xa5\xe1\xe2\xae\xa2\xa0\xef \x91\xe2\xe0\xae\xaa\xa0."), /* "Тестовая Строка." in CP866 */ | 475 | D_STR_W_LEN ("DiyarbakIR"), 8}, /* "DiyarbakIR" in CP857 */ |
463 | D_STR_W_LEN("\x92\x85\x91\x92\x8e\x82\x80\x9f \x91\x92\x90\x8e\x8a\x80."), 1}, /* "ТЕСТОВАЯ СТРОКА." in CP866 */ | 476 | {D_STR_W_LEN ("Diyarbak\xfdr"), /* "Diyarbakır" in ISO-8859-9/CP1254 */ |
464 | {D_STR_W_LEN("\xd2\xe5\xf1\xf2\xee\xe2\xe0\xff \xd1\xf2\xf0\xee\xea\xe0."), /* "Тестовая Строка." in CP1251 */ | 477 | D_STR_W_LEN ("DiyarbakIR"), 8}, /* "DiyarbakIR" in ISO-8859-9/CP1254 */ |
465 | D_STR_W_LEN("\xd2\xc5\xd1\xd2\xce\xc2\xc0\xdf \xd1\xd2\xd0\xce\xca\xc0."), 1}, /* "ТЕСТОВАЯ СТРОКА." in CP1251 */ | 478 | {D_STR_W_LEN ("Diyarbak\xc4\xb1r"), /* "Diyarbakır" in UTF-8 */ |
466 | {D_STR_W_LEN("\xf4\xc5\xd3\xd4\xcf\xd7\xc1\xd1 \xf3\xd4\xd2\xcf\xcb\xc1."), /* "Тестовая Строка." in KOI8-R */ | 479 | D_STR_W_LEN ("DiyarbakIR"), 8}, /* "DiyarbakIR" in UTF-8 */ |
467 | D_STR_W_LEN("\xf4\xe5\xf3\xf4\xef\xf7\xe1\xf1 \xf3\xf4\xf2\xef\xeb\xe1."), 1}, /* "ТЕСТОВАЯ СТРОКА." in KOI8-R */ | 480 | |
468 | {D_STR_W_LEN("\xc2\xd5\xe1\xe2\xde\xd2\xd0\xef \xc1\xe2\xe0\xde\xda\xd0."), /* "Тестовая Строка." in ISO-8859-5 */ | 481 | {D_STR_W_LEN ("\x92\xa5\xe1\xe2\xae\xa2\xa0\xef \x91\xe2\xe0\xae\xaa\xa0."), /* "Тестовая Строка." in CP866 */ |
469 | D_STR_W_LEN("\xc2\xb5\xc1\xc2\xbe\xb2\xb0\xcf \xc1\xc2\xc0\xbe\xba\xb0."), 1}, /* "ТЕСТОВАЯ СТРОКА." in ISO-8859-5 */ | 482 | D_STR_W_LEN ("\x92\x85\x91\x92\x8e\x82\x80\x9f \x91\x92\x90\x8e\x8a\x80."), |
470 | {D_STR_W_LEN("\xd0\xa2\xd0\xb5\xd1\x81\xd1\x82\xd0\xbe\xd0\xb2\xd0\xb0\xd1" | 483 | 1}, /* "ТЕСТОВАЯ СТРОКА." in CP866 */ |
471 | "\x8f \xd0\xa1\xd1\x82\xd1\x80\xd0\xbe\xd0\xba\xd0\xb0."), /* "Тестовая Строка." in UTF-8 */ | 484 | {D_STR_W_LEN ("\xd2\xe5\xf1\xf2\xee\xe2\xe0\xff \xd1\xf2\xf0\xee\xea\xe0."), /* "Тестовая Строка." in CP1251 */ |
472 | D_STR_W_LEN("\xd0\xa2\xd0\x95\xd0\xa1\xd0\xa2\xd0\x9e\xd0\x92\xd0\x90\xd0" | 485 | D_STR_W_LEN ("\xd2\xc5\xd1\xd2\xce\xc2\xc0\xdf \xd1\xd2\xd0\xce\xca\xc0."), |
473 | "\xaf \xd0\xa1\xd0\xa2\xd0\xa0\xd0\x9e\xd0\x9a\xd0\x90."), 3} /* "ТЕСТОВАЯ СТРОКА." in UTF-8 */ | 486 | 1}, /* "ТЕСТОВАЯ СТРОКА." in CP1251 */ |
487 | {D_STR_W_LEN ("\xf4\xc5\xd3\xd4\xcf\xd7\xc1\xd1 \xf3\xd4\xd2\xcf\xcb\xc1."), /* "Тестовая Строка." in KOI8-R */ | ||
488 | D_STR_W_LEN ("\xf4\xe5\xf3\xf4\xef\xf7\xe1\xf1 \xf3\xf4\xf2\xef\xeb\xe1."), | ||
489 | 1}, /* "ТЕСТОВАЯ СТРОКА." in KOI8-R */ | ||
490 | {D_STR_W_LEN ("\xc2\xd5\xe1\xe2\xde\xd2\xd0\xef \xc1\xe2\xe0\xde\xda\xd0."), /* "Тестовая Строка." in ISO-8859-5 */ | ||
491 | D_STR_W_LEN ("\xc2\xb5\xc1\xc2\xbe\xb2\xb0\xcf \xc1\xc2\xc0\xbe\xba\xb0."), | ||
492 | 1}, /* "ТЕСТОВАЯ СТРОКА." in ISO-8859-5 */ | ||
493 | {D_STR_W_LEN ("\xd0\xa2\xd0\xb5\xd1\x81\xd1\x82\xd0\xbe\xd0\xb2\xd0\xb0\xd1" | ||
494 | "\x8f \xd0\xa1\xd1\x82\xd1\x80\xd0\xbe\xd0\xba\xd0\xb0."), /* "Тестовая Строка." in UTF-8 */ | ||
495 | D_STR_W_LEN ("\xd0\xa2\xd0\x95\xd0\xa1\xd0\xa2\xd0\x9e\xd0\x92\xd0\x90\xd0" | ||
496 | "\xaf \xd0\xa1\xd0\xa2\xd0\xa0\xd0\x9e\xd0\x9a\xd0\x90."), 3} /* "ТЕСТОВАЯ СТРОКА." in UTF-8 */ | ||
474 | }; | 497 | }; |
475 | 498 | ||
476 | 499 | ||
477 | int check_eq_strings(void) | 500 | int check_eq_strings (void) |
478 | { | 501 | { |
479 | size_t t_failed = 0; | 502 | size_t t_failed = 0; |
480 | size_t i, j; | 503 | size_t i, j; |
481 | static const size_t n_checks = sizeof(eq_strings) / sizeof(eq_strings[0]); | 504 | static const size_t n_checks = sizeof(eq_strings) / sizeof(eq_strings[0]); |
482 | int c_failed[n_checks]; | 505 | int c_failed[n_checks]; |
483 | 506 | ||
484 | memset(c_failed, 0, sizeof(c_failed)); | 507 | memset (c_failed, 0, sizeof(c_failed)); |
485 | 508 | ||
486 | for(j = 0; j < locale_name_count; j++) | 509 | for (j = 0; j < locale_name_count; j++) |
510 | { | ||
511 | set_test_locale (j); /* setlocale() can be slow! */ | ||
512 | for (i = 0; i < n_checks; i++) | ||
487 | { | 513 | { |
488 | set_test_locale(j); /* setlocale() can be slow! */ | 514 | const struct two_eq_strs *const t = eq_strings + i; |
489 | for(i = 0; i < n_checks; i++) | 515 | if (c_failed[i]) |
490 | { | 516 | continue; /* skip already failed checks */ |
491 | const struct two_eq_strs * const t = eq_strings + i; | 517 | if (! MHD_str_equal_caseless_ (t->s1.str, t->s2.str)) |
492 | if (c_failed[i]) | 518 | { |
493 | continue; /* skip already failed checks */ | 519 | t_failed++; |
494 | if (!MHD_str_equal_caseless_(t->s1.str, t->s2.str)) | 520 | c_failed[i] = ! 0; |
495 | { | 521 | fprintf (stderr, |
496 | t_failed++; | 522 | "FAILED: MHD_str_equal_caseless_(\"%s\", \"%s\") returned zero, while expected non-zero." |
497 | c_failed[i] = !0; | 523 | " Locale: %s\n", n_prnt (t->s1.str), n_prnt (t->s2.str), |
498 | fprintf(stderr, "FAILED: MHD_str_equal_caseless_(\"%s\", \"%s\") returned zero, while expected non-zero." | 524 | get_current_locale_str ()); |
499 | " Locale: %s\n", n_prnt(t->s1.str), n_prnt(t->s2.str), get_current_locale_str()); | 525 | } |
500 | } | 526 | else if (! MHD_str_equal_caseless_ (t->s2.str, t->s1.str)) |
501 | else if (!MHD_str_equal_caseless_(t->s2.str, t->s1.str)) | 527 | { |
502 | { | 528 | t_failed++; |
503 | t_failed++; | 529 | c_failed[i] = ! 0; |
504 | c_failed[i] = !0; | 530 | fprintf (stderr, |
505 | fprintf(stderr, "FAILED: MHD_str_equal_caseless_(\"%s\", \"%s\") returned zero, while expected non-zero." | 531 | "FAILED: MHD_str_equal_caseless_(\"%s\", \"%s\") returned zero, while expected non-zero." |
506 | " Locale: %s\n", n_prnt(t->s2.str), n_prnt(t->s1.str), get_current_locale_str()); | 532 | " Locale: %s\n", n_prnt (t->s2.str), n_prnt (t->s1.str), |
507 | } | 533 | get_current_locale_str ()); |
508 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i]) | 534 | } |
509 | printf("PASSED: MHD_str_equal_caseless_(\"%s\", \"%s\") != 0 && \\\n" | 535 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) |
510 | " MHD_str_equal_caseless_(\"%s\", \"%s\") != 0\n", n_prnt(t->s1.str), n_prnt(t->s2.str), | 536 | printf ("PASSED: MHD_str_equal_caseless_(\"%s\", \"%s\") != 0 && \\\n" |
511 | n_prnt(t->s2.str), n_prnt(t->s1.str)); | 537 | " MHD_str_equal_caseless_(\"%s\", \"%s\") != 0\n", |
512 | } | 538 | n_prnt (t->s1.str), n_prnt (t->s2.str), |
539 | n_prnt (t->s2.str), n_prnt (t->s1.str)); | ||
513 | } | 540 | } |
541 | } | ||
514 | return t_failed; | 542 | return t_failed; |
515 | } | 543 | } |
516 | 544 | ||
517 | int check_neq_strings(void) | 545 | int check_neq_strings (void) |
518 | { | 546 | { |
519 | size_t t_failed = 0; | 547 | size_t t_failed = 0; |
520 | size_t i, j; | 548 | size_t i, j; |
521 | static const size_t n_checks = sizeof(neq_strings) / sizeof(neq_strings[0]); | 549 | static const size_t n_checks = sizeof(neq_strings) / sizeof(neq_strings[0]); |
522 | int c_failed[n_checks]; | 550 | int c_failed[n_checks]; |
523 | 551 | ||
524 | memset(c_failed, 0, sizeof(c_failed)); | 552 | memset (c_failed, 0, sizeof(c_failed)); |
525 | 553 | ||
526 | for(j = 0; j < locale_name_count; j++) | 554 | for (j = 0; j < locale_name_count; j++) |
555 | { | ||
556 | set_test_locale (j); /* setlocale() can be slow! */ | ||
557 | for (i = 0; i < n_checks; i++) | ||
527 | { | 558 | { |
528 | set_test_locale(j); /* setlocale() can be slow! */ | 559 | const struct two_neq_strs *const t = neq_strings + i; |
529 | for(i = 0; i < n_checks; i++) | 560 | if (c_failed[i]) |
530 | { | 561 | continue; /* skip already failed checks */ |
531 | const struct two_neq_strs * const t = neq_strings + i; | 562 | if (MHD_str_equal_caseless_ (t->s1.str, t->s2.str)) |
532 | if (c_failed[i]) | 563 | { |
533 | continue; /* skip already failed checks */ | 564 | t_failed++; |
534 | if (MHD_str_equal_caseless_(t->s1.str, t->s2.str)) | 565 | c_failed[i] = ! 0; |
535 | { | 566 | fprintf (stderr, |
536 | t_failed++; | 567 | "FAILED: MHD_str_equal_caseless_(\"%s\", \"%s\") returned non-zero, while expected zero." |
537 | c_failed[i] = !0; | 568 | " Locale: %s\n", n_prnt (t->s1.str), n_prnt (t->s2.str), |
538 | fprintf(stderr, "FAILED: MHD_str_equal_caseless_(\"%s\", \"%s\") returned non-zero, while expected zero." | 569 | get_current_locale_str ()); |
539 | " Locale: %s\n", n_prnt(t->s1.str), n_prnt(t->s2.str), get_current_locale_str()); | 570 | } |
540 | } | 571 | else if (MHD_str_equal_caseless_ (t->s2.str, t->s1.str)) |
541 | else if (MHD_str_equal_caseless_(t->s2.str, t->s1.str)) | 572 | { |
542 | { | 573 | t_failed++; |
543 | t_failed++; | 574 | c_failed[i] = ! 0; |
544 | c_failed[i] = !0; | 575 | fprintf (stderr, |
545 | fprintf(stderr, "FAILED: MHD_str_equal_caseless_(\"%s\", \"%s\") returned non-zero, while expected zero." | 576 | "FAILED: MHD_str_equal_caseless_(\"%s\", \"%s\") returned non-zero, while expected zero." |
546 | " Locale: %s\n", n_prnt(t->s2.str), n_prnt(t->s1.str), get_current_locale_str()); | 577 | " Locale: %s\n", n_prnt (t->s2.str), n_prnt (t->s1.str), |
547 | } | 578 | get_current_locale_str ()); |
548 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i]) | 579 | } |
549 | printf("PASSED: MHD_str_equal_caseless_(\"%s\", \"%s\") == 0 && \\\n" | 580 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) |
550 | " MHD_str_equal_caseless_(\"%s\", \"%s\") == 0\n", n_prnt(t->s1.str), n_prnt(t->s2.str), | 581 | printf ("PASSED: MHD_str_equal_caseless_(\"%s\", \"%s\") == 0 && \\\n" |
551 | n_prnt(t->s2.str), n_prnt(t->s1.str)); | 582 | " MHD_str_equal_caseless_(\"%s\", \"%s\") == 0\n", |
552 | } | 583 | n_prnt (t->s1.str), n_prnt (t->s2.str), |
584 | n_prnt (t->s2.str), n_prnt (t->s1.str)); | ||
553 | } | 585 | } |
586 | } | ||
554 | return t_failed; | 587 | return t_failed; |
555 | } | 588 | } |
556 | 589 | ||
557 | int check_eq_strings_n(void) | 590 | int check_eq_strings_n (void) |
558 | { | 591 | { |
559 | size_t t_failed = 0; | 592 | size_t t_failed = 0; |
560 | size_t i, j, k; | 593 | size_t i, j, k; |
561 | static const size_t n_checks = sizeof(eq_strings) / sizeof(eq_strings[0]); | 594 | static const size_t n_checks = sizeof(eq_strings) / sizeof(eq_strings[0]); |
562 | int c_failed[n_checks]; | 595 | int c_failed[n_checks]; |
563 | 596 | ||
564 | memset(c_failed, 0, sizeof(c_failed)); | 597 | memset (c_failed, 0, sizeof(c_failed)); |
565 | 598 | ||
566 | for(j = 0; j < locale_name_count; j++) | 599 | for (j = 0; j < locale_name_count; j++) |
600 | { | ||
601 | set_test_locale (j); /* setlocale() can be slow! */ | ||
602 | for (i = 0; i < n_checks; i++) | ||
567 | { | 603 | { |
568 | set_test_locale(j); /* setlocale() can be slow! */ | 604 | size_t m_len; |
569 | for(i = 0; i < n_checks; i++) | 605 | const struct two_eq_strs *const t = eq_strings + i; |
606 | m_len = (t->s1.len > t->s2.len) ? t->s1.len : t->s2.len; | ||
607 | for (k = 0; k <= m_len + 1 && ! c_failed[i]; k++) | ||
608 | { | ||
609 | if (! MHD_str_equal_caseless_n_ (t->s1.str, t->s2.str, k)) | ||
570 | { | 610 | { |
571 | size_t m_len; | 611 | t_failed++; |
572 | const struct two_eq_strs * const t = eq_strings + i; | 612 | c_failed[i] = ! 0; |
573 | m_len = (t->s1.len > t->s2.len) ? t->s1.len : t->s2.len; | 613 | fprintf (stderr, |
574 | for(k = 0; k <= m_len + 1 && !c_failed[i]; k++) | 614 | "FAILED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", %u) returned zero," |
575 | { | 615 | " while expected non-zero. Locale: %s\n", |
576 | if (!MHD_str_equal_caseless_n_(t->s1.str, t->s2.str, k)) | 616 | n_prnt (t->s1.str), n_prnt (t->s2.str), (unsigned int) k, |
577 | { | 617 | get_current_locale_str ()); |
578 | t_failed++; | ||
579 | c_failed[i] = !0; | ||
580 | fprintf(stderr, "FAILED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", %u) returned zero," | ||
581 | " while expected non-zero. Locale: %s\n", | ||
582 | n_prnt(t->s1.str), n_prnt(t->s2.str), (unsigned int) k, get_current_locale_str()); | ||
583 | } | ||
584 | else if (!MHD_str_equal_caseless_n_(t->s2.str, t->s1.str, k)) | ||
585 | { | ||
586 | t_failed++; | ||
587 | c_failed[i] = !0; | ||
588 | fprintf(stderr, "FAILED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", %u) returned zero," | ||
589 | " while expected non-zero. Locale: %s\n", | ||
590 | n_prnt(t->s2.str), n_prnt(t->s1.str), (unsigned int) k, get_current_locale_str()); | ||
591 | } | ||
592 | } | ||
593 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i]) | ||
594 | printf("PASSED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", N) != 0 && \\\n" | ||
595 | " MHD_str_equal_caseless_n_(\"%s\", \"%s\", N) != 0, where N is 0..%u\n", | ||
596 | n_prnt(t->s1.str), n_prnt(t->s2.str), n_prnt(t->s2.str), n_prnt(t->s1.str), (unsigned int) m_len + 1); | ||
597 | } | 618 | } |
619 | else if (! MHD_str_equal_caseless_n_ (t->s2.str, t->s1.str, k)) | ||
620 | { | ||
621 | t_failed++; | ||
622 | c_failed[i] = ! 0; | ||
623 | fprintf (stderr, | ||
624 | "FAILED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", %u) returned zero," | ||
625 | " while expected non-zero. Locale: %s\n", | ||
626 | n_prnt (t->s2.str), n_prnt (t->s1.str), (unsigned int) k, | ||
627 | get_current_locale_str ()); | ||
628 | } | ||
629 | } | ||
630 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) | ||
631 | printf ( | ||
632 | "PASSED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", N) != 0 && \\\n" | ||
633 | " MHD_str_equal_caseless_n_(\"%s\", \"%s\", N) != 0, where N is 0..%u\n", | ||
634 | n_prnt (t->s1.str), n_prnt (t->s2.str), n_prnt (t->s2.str), | ||
635 | n_prnt (t->s1.str), (unsigned int) m_len + 1); | ||
598 | } | 636 | } |
637 | } | ||
599 | return t_failed; | 638 | return t_failed; |
600 | } | 639 | } |
601 | 640 | ||
602 | int check_neq_strings_n(void) | 641 | int check_neq_strings_n (void) |
603 | { | 642 | { |
604 | size_t t_failed = 0; | 643 | size_t t_failed = 0; |
605 | size_t i, j, k; | 644 | size_t i, j, k; |
606 | static const size_t n_checks = sizeof(neq_strings) / sizeof(neq_strings[0]); | 645 | static const size_t n_checks = sizeof(neq_strings) / sizeof(neq_strings[0]); |
607 | int c_failed[n_checks]; | 646 | int c_failed[n_checks]; |
608 | 647 | ||
609 | memset(c_failed, 0, sizeof(c_failed)); | 648 | memset (c_failed, 0, sizeof(c_failed)); |
610 | 649 | ||
611 | for(j = 0; j < locale_name_count; j++) | 650 | for (j = 0; j < locale_name_count; j++) |
651 | { | ||
652 | set_test_locale (j); /* setlocale() can be slow! */ | ||
653 | for (i = 0; i < n_checks; i++) | ||
612 | { | 654 | { |
613 | set_test_locale(j); /* setlocale() can be slow! */ | 655 | size_t m_len; |
614 | for(i = 0; i < n_checks; i++) | 656 | const struct two_neq_strs *const t = neq_strings + i; |
657 | m_len = t->s1.len > t->s2.len ? t->s1.len : t->s2.len; | ||
658 | if (t->dif_pos >= m_len) | ||
659 | { | ||
660 | fprintf (stderr, | ||
661 | "ERROR: neq_strings[%u] has wrong dif_pos (%u): dif_pos is expected to be less than " | ||
662 | "s1.len (%u) or s2.len (%u).\n", (unsigned int) i, (unsigned | ||
663 | int) t-> | ||
664 | dif_pos, | ||
665 | (unsigned int) t->s1.len, (unsigned int) t->s2.len); | ||
666 | return -1; | ||
667 | } | ||
668 | if (t->dif_pos > t->s1.len) | ||
669 | { | ||
670 | fprintf (stderr, | ||
671 | "ERROR: neq_strings[%u] has wrong dif_pos (%u): dif_pos is expected to be less or " | ||
672 | "equal to s1.len (%u).\n", (unsigned int) i, (unsigned | ||
673 | int) t->dif_pos, | ||
674 | (unsigned int) t->s1.len); | ||
675 | return -1; | ||
676 | } | ||
677 | if (t->dif_pos > t->s2.len) | ||
678 | { | ||
679 | fprintf (stderr, | ||
680 | "ERROR: neq_strings[%u] has wrong dif_pos (%u): dif_pos is expected to be less or " | ||
681 | "equal to s2.len (%u).\n", (unsigned int) i, (unsigned | ||
682 | int) t->dif_pos, | ||
683 | (unsigned int) t->s2.len); | ||
684 | return -1; | ||
685 | } | ||
686 | for (k = 0; k <= m_len + 1 && ! c_failed[i]; k++) | ||
687 | { | ||
688 | if (k <= t->dif_pos) | ||
689 | { | ||
690 | if (! MHD_str_equal_caseless_n_ (t->s1.str, t->s2.str, k)) | ||
691 | { | ||
692 | t_failed++; | ||
693 | c_failed[i] = ! 0; | ||
694 | fprintf (stderr, | ||
695 | "FAILED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", %u) returned zero," | ||
696 | " while expected non-zero. Locale: %s\n", | ||
697 | n_prnt (t->s1.str), n_prnt (t->s2.str), (unsigned int) k, | ||
698 | get_current_locale_str ()); | ||
699 | } | ||
700 | else if (! MHD_str_equal_caseless_n_ (t->s2.str, t->s1.str, k)) | ||
701 | { | ||
702 | t_failed++; | ||
703 | c_failed[i] = ! 0; | ||
704 | fprintf (stderr, | ||
705 | "FAILED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", %u) returned zero," | ||
706 | " while expected non-zero. Locale: %s\n", | ||
707 | n_prnt (t->s2.str), n_prnt (t->s1.str), (unsigned int) k, | ||
708 | get_current_locale_str ()); | ||
709 | } | ||
710 | } | ||
711 | else | ||
615 | { | 712 | { |
616 | size_t m_len; | 713 | if (MHD_str_equal_caseless_n_ (t->s1.str, t->s2.str, k)) |
617 | const struct two_neq_strs * const t = neq_strings + i; | 714 | { |
618 | m_len = t->s1.len > t->s2.len ? t->s1.len : t->s2.len; | 715 | t_failed++; |
619 | if (t->dif_pos >= m_len) | 716 | c_failed[i] = ! 0; |
620 | { | 717 | fprintf (stderr, |
621 | fprintf(stderr, "ERROR: neq_strings[%u] has wrong dif_pos (%u): dif_pos is expected to be less than " | 718 | "FAILED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", %u) returned non-zero," |
622 | "s1.len (%u) or s2.len (%u).\n", (unsigned int) i, (unsigned int) t->dif_pos, | 719 | " while expected zero. Locale: %s\n", |
623 | (unsigned int) t->s1.len, (unsigned int) t->s2.len); | 720 | n_prnt (t->s1.str), n_prnt (t->s2.str), (unsigned int) k, |
624 | return -1; | 721 | get_current_locale_str ()); |
625 | } | 722 | } |
626 | if (t->dif_pos > t->s1.len) | 723 | else if (MHD_str_equal_caseless_n_ (t->s2.str, t->s1.str, k)) |
627 | { | 724 | { |
628 | fprintf(stderr, "ERROR: neq_strings[%u] has wrong dif_pos (%u): dif_pos is expected to be less or " | 725 | t_failed++; |
629 | "equal to s1.len (%u).\n", (unsigned int) i, (unsigned int) t->dif_pos, | 726 | c_failed[i] = ! 0; |
630 | (unsigned int) t->s1.len); | 727 | fprintf (stderr, |
631 | return -1; | 728 | "FAILED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", %u) returned non-zero," |
632 | } | 729 | " while expected zero. Locale: %s\n", |
633 | if (t->dif_pos > t->s2.len) | 730 | n_prnt (t->s2.str), n_prnt (t->s1.str), (unsigned int) k, |
634 | { | 731 | get_current_locale_str ()); |
635 | fprintf(stderr, "ERROR: neq_strings[%u] has wrong dif_pos (%u): dif_pos is expected to be less or " | 732 | } |
636 | "equal to s2.len (%u).\n", (unsigned int) i, (unsigned int) t->dif_pos, | ||
637 | (unsigned int) t->s2.len); | ||
638 | return -1; | ||
639 | } | ||
640 | for(k = 0; k <= m_len + 1 && !c_failed[i]; k++) | ||
641 | { | ||
642 | if (k <= t->dif_pos) | ||
643 | { | ||
644 | if (!MHD_str_equal_caseless_n_(t->s1.str, t->s2.str, k)) | ||
645 | { | ||
646 | t_failed++; | ||
647 | c_failed[i] = !0; | ||
648 | fprintf(stderr, "FAILED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", %u) returned zero," | ||
649 | " while expected non-zero. Locale: %s\n", | ||
650 | n_prnt(t->s1.str), n_prnt(t->s2.str), (unsigned int) k, get_current_locale_str()); | ||
651 | } | ||
652 | else if (!MHD_str_equal_caseless_n_(t->s2.str, t->s1.str, k)) | ||
653 | { | ||
654 | t_failed++; | ||
655 | c_failed[i] = !0; | ||
656 | fprintf(stderr, "FAILED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", %u) returned zero," | ||
657 | " while expected non-zero. Locale: %s\n", | ||
658 | n_prnt(t->s2.str), n_prnt(t->s1.str), (unsigned int) k, get_current_locale_str()); | ||
659 | } | ||
660 | } | ||
661 | else | ||
662 | { | ||
663 | if (MHD_str_equal_caseless_n_(t->s1.str, t->s2.str, k)) | ||
664 | { | ||
665 | t_failed++; | ||
666 | c_failed[i] = !0; | ||
667 | fprintf(stderr, "FAILED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", %u) returned non-zero," | ||
668 | " while expected zero. Locale: %s\n", | ||
669 | n_prnt(t->s1.str), n_prnt(t->s2.str), (unsigned int) k, get_current_locale_str()); | ||
670 | } | ||
671 | else if (MHD_str_equal_caseless_n_(t->s2.str, t->s1.str, k)) | ||
672 | { | ||
673 | t_failed++; | ||
674 | c_failed[i] = !0; | ||
675 | fprintf(stderr, "FAILED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", %u) returned non-zero," | ||
676 | " while expected zero. Locale: %s\n", | ||
677 | n_prnt(t->s2.str), n_prnt(t->s1.str), (unsigned int) k, get_current_locale_str()); | ||
678 | } | ||
679 | } | ||
680 | } | ||
681 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i]) | ||
682 | { | ||
683 | printf("PASSED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", N) != 0 && \\\n" | ||
684 | " MHD_str_equal_caseless_n_(\"%s\", \"%s\", N) != 0, where N is 0..%u\n", | ||
685 | n_prnt(t->s1.str), n_prnt(t->s2.str), n_prnt(t->s2.str), n_prnt(t->s1.str), | ||
686 | (unsigned int) t->dif_pos); | ||
687 | |||
688 | printf("PASSED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", N) == 0 && \\\n" | ||
689 | " MHD_str_equal_caseless_n_(\"%s\", \"%s\", N) == 0, where N is %u..%u\n", | ||
690 | n_prnt(t->s1.str), n_prnt(t->s2.str), n_prnt(t->s2.str), n_prnt(t->s1.str), | ||
691 | (unsigned int) t->dif_pos + 1, (unsigned int) m_len + 1); | ||
692 | } | ||
693 | } | 733 | } |
734 | } | ||
735 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) | ||
736 | { | ||
737 | printf ( | ||
738 | "PASSED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", N) != 0 && \\\n" | ||
739 | " MHD_str_equal_caseless_n_(\"%s\", \"%s\", N) != 0, where N is 0..%u\n", | ||
740 | n_prnt (t->s1.str), n_prnt (t->s2.str), n_prnt (t->s2.str), | ||
741 | n_prnt (t->s1.str), | ||
742 | (unsigned int) t->dif_pos); | ||
743 | |||
744 | printf ( | ||
745 | "PASSED: MHD_str_equal_caseless_n_(\"%s\", \"%s\", N) == 0 && \\\n" | ||
746 | " MHD_str_equal_caseless_n_(\"%s\", \"%s\", N) == 0, where N is %u..%u\n", | ||
747 | n_prnt (t->s1.str), n_prnt (t->s2.str), n_prnt (t->s2.str), | ||
748 | n_prnt (t->s1.str), | ||
749 | (unsigned int) t->dif_pos + 1, (unsigned int) m_len + 1); | ||
750 | } | ||
694 | } | 751 | } |
752 | } | ||
695 | return t_failed; | 753 | return t_failed; |
696 | } | 754 | } |
697 | 755 | ||
698 | /* | 756 | /* |
699 | * Run eq/neq strings tests | 757 | * Run eq/neq strings tests |
700 | */ | 758 | */ |
701 | int run_eq_neq_str_tests(void) | 759 | int run_eq_neq_str_tests (void) |
702 | { | 760 | { |
703 | int str_equal_caseless_fails = 0; | 761 | int str_equal_caseless_fails = 0; |
704 | int str_equal_caseless_n_fails = 0; | 762 | int str_equal_caseless_n_fails = 0; |
705 | int res; | 763 | int res; |
706 | 764 | ||
707 | res = check_eq_strings(); | 765 | res = check_eq_strings (); |
708 | if (res != 0) | 766 | if (res != 0) |
767 | { | ||
768 | if (res < 0) | ||
709 | { | 769 | { |
710 | if (res < 0) | 770 | fprintf (stderr, "ERROR: test internal error in check_eq_strings().\n"); |
711 | { | 771 | return 99; |
712 | fprintf(stderr, "ERROR: test internal error in check_eq_strings().\n"); | ||
713 | return 99; | ||
714 | } | ||
715 | str_equal_caseless_fails += res; | ||
716 | fprintf(stderr, "FAILED: testcase check_eq_strings() failed.\n\n"); | ||
717 | } | 772 | } |
773 | str_equal_caseless_fails += res; | ||
774 | fprintf (stderr, "FAILED: testcase check_eq_strings() failed.\n\n"); | ||
775 | } | ||
718 | else if (verbose > 1) | 776 | else if (verbose > 1) |
719 | printf("PASSED: testcase check_eq_strings() successfully passed.\n\n"); | 777 | printf ("PASSED: testcase check_eq_strings() successfully passed.\n\n"); |
720 | 778 | ||
721 | res = check_neq_strings(); | 779 | res = check_neq_strings (); |
722 | if (res != 0) | 780 | if (res != 0) |
781 | { | ||
782 | if (res < 0) | ||
723 | { | 783 | { |
724 | if (res < 0) | 784 | fprintf (stderr, "ERROR: test internal error in check_neq_strings().\n"); |
725 | { | 785 | return 99; |
726 | fprintf(stderr, "ERROR: test internal error in check_neq_strings().\n"); | ||
727 | return 99; | ||
728 | } | ||
729 | str_equal_caseless_fails += res; | ||
730 | fprintf(stderr, "FAILED: testcase check_neq_strings() failed.\n\n"); | ||
731 | } | 786 | } |
787 | str_equal_caseless_fails += res; | ||
788 | fprintf (stderr, "FAILED: testcase check_neq_strings() failed.\n\n"); | ||
789 | } | ||
732 | else if (verbose > 1) | 790 | else if (verbose > 1) |
733 | printf("PASSED: testcase check_neq_strings() successfully passed.\n\n"); | 791 | printf ("PASSED: testcase check_neq_strings() successfully passed.\n\n"); |
734 | 792 | ||
735 | if (str_equal_caseless_fails) | 793 | if (str_equal_caseless_fails) |
736 | fprintf(stderr, "FAILED: function MHD_str_equal_caseless_() failed %d time%s.\n\n", | 794 | fprintf (stderr, |
737 | str_equal_caseless_fails, str_equal_caseless_fails == 1 ? "" : "s"); | 795 | "FAILED: function MHD_str_equal_caseless_() failed %d time%s.\n\n", |
796 | str_equal_caseless_fails, str_equal_caseless_fails == 1 ? "" : | ||
797 | "s"); | ||
738 | else if (verbose > 0) | 798 | else if (verbose > 0) |
739 | printf("PASSED: function MHD_str_equal_caseless_() successfully passed all checks.\n\n"); | 799 | printf ( |
800 | "PASSED: function MHD_str_equal_caseless_() successfully passed all checks.\n\n"); | ||
740 | 801 | ||
741 | res = check_eq_strings_n(); | 802 | res = check_eq_strings_n (); |
742 | if (res != 0) | 803 | if (res != 0) |
804 | { | ||
805 | if (res < 0) | ||
743 | { | 806 | { |
744 | if (res < 0) | 807 | fprintf (stderr, "ERROR: test internal error in check_eq_strings_n().\n"); |
745 | { | 808 | return 99; |
746 | fprintf(stderr, "ERROR: test internal error in check_eq_strings_n().\n"); | ||
747 | return 99; | ||
748 | } | ||
749 | str_equal_caseless_n_fails += res; | ||
750 | fprintf(stderr, "FAILED: testcase check_eq_strings_n() failed.\n\n"); | ||
751 | } | 809 | } |
810 | str_equal_caseless_n_fails += res; | ||
811 | fprintf (stderr, "FAILED: testcase check_eq_strings_n() failed.\n\n"); | ||
812 | } | ||
752 | else if (verbose > 1) | 813 | else if (verbose > 1) |
753 | printf("PASSED: testcase check_eq_strings_n() successfully passed.\n\n"); | 814 | printf ("PASSED: testcase check_eq_strings_n() successfully passed.\n\n"); |
754 | 815 | ||
755 | res = check_neq_strings_n(); | 816 | res = check_neq_strings_n (); |
756 | if (res != 0) | 817 | if (res != 0) |
818 | { | ||
819 | if (res < 0) | ||
757 | { | 820 | { |
758 | if (res < 0) | 821 | fprintf (stderr, |
759 | { | 822 | "ERROR: test internal error in check_neq_strings_n().\n"); |
760 | fprintf(stderr, "ERROR: test internal error in check_neq_strings_n().\n"); | 823 | return 99; |
761 | return 99; | ||
762 | } | ||
763 | str_equal_caseless_n_fails += res; | ||
764 | fprintf(stderr, "FAILED: testcase check_neq_strings_n() failed.\n\n"); | ||
765 | } | 824 | } |
825 | str_equal_caseless_n_fails += res; | ||
826 | fprintf (stderr, "FAILED: testcase check_neq_strings_n() failed.\n\n"); | ||
827 | } | ||
766 | else if (verbose > 1) | 828 | else if (verbose > 1) |
767 | printf("PASSED: testcase check_neq_strings_n() successfully passed.\n\n"); | 829 | printf ("PASSED: testcase check_neq_strings_n() successfully passed.\n\n"); |
768 | 830 | ||
769 | if (str_equal_caseless_n_fails) | 831 | if (str_equal_caseless_n_fails) |
770 | fprintf(stderr, "FAILED: function MHD_str_equal_caseless_n_() failed %d time%s.\n\n", | 832 | fprintf (stderr, |
771 | str_equal_caseless_n_fails, str_equal_caseless_n_fails == 1 ? "" : "s"); | 833 | "FAILED: function MHD_str_equal_caseless_n_() failed %d time%s.\n\n", |
834 | str_equal_caseless_n_fails, str_equal_caseless_n_fails == 1 ? "" : | ||
835 | "s"); | ||
772 | else if (verbose > 0) | 836 | else if (verbose > 0) |
773 | printf("PASSED: function MHD_str_equal_caseless_n_() successfully passed all checks.\n\n"); | 837 | printf ( |
838 | "PASSED: function MHD_str_equal_caseless_n_() successfully passed all checks.\n\n"); | ||
774 | 839 | ||
775 | if (str_equal_caseless_fails || str_equal_caseless_n_fails) | 840 | if (str_equal_caseless_fails || str_equal_caseless_n_fails) |
776 | { | 841 | { |
777 | if (verbose > 0) | 842 | if (verbose > 0) |
778 | printf("At least one test failed.\n"); | 843 | printf ("At least one test failed.\n"); |
779 | 844 | ||
780 | return 1; | 845 | return 1; |
781 | } | 846 | } |
782 | 847 | ||
783 | if (verbose > 0) | 848 | if (verbose > 0) |
784 | printf("All tests passed successfully.\n"); | 849 | printf ("All tests passed successfully.\n"); |
785 | 850 | ||
786 | return 0; | 851 | return 0; |
787 | } | 852 | } |
@@ -790,7 +855,8 @@ int run_eq_neq_str_tests(void) | |||
790 | * Digits in string -> value tests | 855 | * Digits in string -> value tests |
791 | */ | 856 | */ |
792 | 857 | ||
793 | struct str_with_value { | 858 | struct str_with_value |
859 | { | ||
794 | const struct str_with_len str; | 860 | const struct str_with_len str; |
795 | const size_t num_of_digt; | 861 | const size_t num_of_digt; |
796 | const uint64_t val; | 862 | const uint64_t val; |
@@ -798,1646 +864,1930 @@ struct str_with_value { | |||
798 | 864 | ||
799 | /* valid string for conversion to unsigned integer value */ | 865 | /* valid string for conversion to unsigned integer value */ |
800 | static const struct str_with_value dstrs_w_values[] = { | 866 | static const struct str_with_value dstrs_w_values[] = { |
801 | /* simplest strings */ | 867 | /* simplest strings */ |
802 | {D_STR_W_LEN("1"), 1, 1}, | 868 | {D_STR_W_LEN ("1"), 1, 1}, |
803 | {D_STR_W_LEN("0"), 1, 0}, | 869 | {D_STR_W_LEN ("0"), 1, 0}, |
804 | {D_STR_W_LEN("10000"), 5, 10000}, | 870 | {D_STR_W_LEN ("10000"), 5, 10000}, |
805 | 871 | ||
806 | /* all digits */ | 872 | /* all digits */ |
807 | {D_STR_W_LEN("1234"), 4, 1234}, | 873 | {D_STR_W_LEN ("1234"), 4, 1234}, |
808 | {D_STR_W_LEN("4567"), 4, 4567}, | 874 | {D_STR_W_LEN ("4567"), 4, 4567}, |
809 | {D_STR_W_LEN("7890"), 4, 7890}, | 875 | {D_STR_W_LEN ("7890"), 4, 7890}, |
810 | {D_STR_W_LEN("8021"), 4, 8021}, | 876 | {D_STR_W_LEN ("8021"), 4, 8021}, |
811 | {D_STR_W_LEN("9754"), 4, 9754}, | 877 | {D_STR_W_LEN ("9754"), 4, 9754}, |
812 | {D_STR_W_LEN("6392"), 4, 6392}, | 878 | {D_STR_W_LEN ("6392"), 4, 6392}, |
813 | 879 | ||
814 | /* various prefixes */ | 880 | /* various prefixes */ |
815 | {D_STR_W_LEN("00000000"), 8, 0}, | 881 | {D_STR_W_LEN ("00000000"), 8, 0}, |
816 | {D_STR_W_LEN("0755"), 4, 755}, /* not to be interpreted as octal value! */ | 882 | {D_STR_W_LEN ("0755"), 4, 755}, /* not to be interpreted as octal value! */ |
817 | {D_STR_W_LEN("002"), 3, 2}, | 883 | {D_STR_W_LEN ("002"), 3, 2}, |
818 | {D_STR_W_LEN("0001"), 4, 1}, | 884 | {D_STR_W_LEN ("0001"), 4, 1}, |
819 | {D_STR_W_LEN("00000000000000000000000031295483"), 32, 31295483}, | 885 | {D_STR_W_LEN ("00000000000000000000000031295483"), 32, 31295483}, |
820 | 886 | ||
821 | /* numbers below and above limits */ | 887 | /* numbers below and above limits */ |
822 | {D_STR_W_LEN("127"), 3, 127}, /* 0x7F, SCHAR_MAX */ | 888 | {D_STR_W_LEN ("127"), 3, 127}, /* 0x7F, SCHAR_MAX */ |
823 | {D_STR_W_LEN("128"), 3, 128}, /* 0x80, SCHAR_MAX+1 */ | 889 | {D_STR_W_LEN ("128"), 3, 128}, /* 0x80, SCHAR_MAX+1 */ |
824 | {D_STR_W_LEN("255"), 3, 255}, /* 0xFF, UCHAR_MAX */ | 890 | {D_STR_W_LEN ("255"), 3, 255}, /* 0xFF, UCHAR_MAX */ |
825 | {D_STR_W_LEN("256"), 3, 256}, /* 0x100, UCHAR_MAX+1 */ | 891 | {D_STR_W_LEN ("256"), 3, 256}, /* 0x100, UCHAR_MAX+1 */ |
826 | {D_STR_W_LEN("32767"), 5, 32767}, /* 0x7FFF, INT16_MAX */ | 892 | {D_STR_W_LEN ("32767"), 5, 32767}, /* 0x7FFF, INT16_MAX */ |
827 | {D_STR_W_LEN("32768"), 5, 32768}, /* 0x8000, INT16_MAX+1 */ | 893 | {D_STR_W_LEN ("32768"), 5, 32768}, /* 0x8000, INT16_MAX+1 */ |
828 | {D_STR_W_LEN("65535"), 5, 65535}, /* 0xFFFF, UINT16_MAX */ | 894 | {D_STR_W_LEN ("65535"), 5, 65535}, /* 0xFFFF, UINT16_MAX */ |
829 | {D_STR_W_LEN("65536"), 5, 65536}, /* 0x10000, UINT16_MAX+1 */ | 895 | {D_STR_W_LEN ("65536"), 5, 65536}, /* 0x10000, UINT16_MAX+1 */ |
830 | {D_STR_W_LEN("2147483647"), 10, 2147483647}, /* 0x7FFFFFFF, INT32_MAX */ | 896 | {D_STR_W_LEN ("2147483647"), 10, 2147483647}, /* 0x7FFFFFFF, INT32_MAX */ |
831 | {D_STR_W_LEN("2147483648"), 10, UINT64_C(2147483648)}, /* 0x80000000, INT32_MAX+1 */ | 897 | {D_STR_W_LEN ("2147483648"), 10, UINT64_C (2147483648)}, /* 0x80000000, INT32_MAX+1 */ |
832 | {D_STR_W_LEN("4294967295"), 10, UINT64_C(4294967295)}, /* 0xFFFFFFFF, UINT32_MAX */ | 898 | {D_STR_W_LEN ("4294967295"), 10, UINT64_C (4294967295)}, /* 0xFFFFFFFF, UINT32_MAX */ |
833 | {D_STR_W_LEN("4294967296"), 10, UINT64_C(4294967296)}, /* 0x100000000, UINT32_MAX+1 */ | 899 | {D_STR_W_LEN ("4294967296"), 10, UINT64_C (4294967296)}, /* 0x100000000, UINT32_MAX+1 */ |
834 | {D_STR_W_LEN("9223372036854775807"), 19, UINT64_C(9223372036854775807)}, /* 0x7FFFFFFFFFFFFFFF, INT64_MAX */ | 900 | {D_STR_W_LEN ("9223372036854775807"), 19, UINT64_C (9223372036854775807)}, /* 0x7FFFFFFFFFFFFFFF, INT64_MAX */ |
835 | {D_STR_W_LEN("9223372036854775808"), 19, UINT64_C(9223372036854775808)}, /* 0x8000000000000000, INT64_MAX+1 */ | 901 | {D_STR_W_LEN ("9223372036854775808"), 19, UINT64_C (9223372036854775808)}, /* 0x8000000000000000, INT64_MAX+1 */ |
836 | {D_STR_W_LEN("18446744073709551615"), 20, UINT64_C(18446744073709551615)}, /* 0xFFFFFFFFFFFFFFFF, UINT64_MAX */ | 902 | {D_STR_W_LEN ("18446744073709551615"), 20, UINT64_C (18446744073709551615)}, /* 0xFFFFFFFFFFFFFFFF, UINT64_MAX */ |
837 | 903 | ||
838 | /* random numbers */ | 904 | /* random numbers */ |
839 | {D_STR_W_LEN("10186753"), 8, 10186753}, | 905 | {D_STR_W_LEN ("10186753"), 8, 10186753}, |
840 | {D_STR_W_LEN("144402566"), 9, 144402566}, | 906 | {D_STR_W_LEN ("144402566"), 9, 144402566}, |
841 | {D_STR_W_LEN("151903144"), 9, 151903144}, | 907 | {D_STR_W_LEN ("151903144"), 9, 151903144}, |
842 | {D_STR_W_LEN("139264621"), 9, 139264621}, | 908 | {D_STR_W_LEN ("139264621"), 9, 139264621}, |
843 | {D_STR_W_LEN("730348"), 6, 730348}, | 909 | {D_STR_W_LEN ("730348"), 6, 730348}, |
844 | {D_STR_W_LEN("21584377"), 8, 21584377}, | 910 | {D_STR_W_LEN ("21584377"), 8, 21584377}, |
845 | {D_STR_W_LEN("709"), 3, 709}, | 911 | {D_STR_W_LEN ("709"), 3, 709}, |
846 | {D_STR_W_LEN("54"), 2, 54}, | 912 | {D_STR_W_LEN ("54"), 2, 54}, |
847 | {D_STR_W_LEN("8452"), 4, 8452}, | 913 | {D_STR_W_LEN ("8452"), 4, 8452}, |
848 | {D_STR_W_LEN("17745098750013624977"), 20, UINT64_C(17745098750013624977)}, | 914 | {D_STR_W_LEN ("17745098750013624977"), 20, UINT64_C (17745098750013624977)}, |
849 | {D_STR_W_LEN("06786878769931678000"), 20, UINT64_C(6786878769931678000)}, | 915 | {D_STR_W_LEN ("06786878769931678000"), 20, UINT64_C (6786878769931678000)}, |
850 | 916 | ||
851 | /* non-digit suffixes */ | 917 | /* non-digit suffixes */ |
852 | {D_STR_W_LEN("1234oa"), 4, 1234}, | 918 | {D_STR_W_LEN ("1234oa"), 4, 1234}, |
853 | {D_STR_W_LEN("20h"), 2, 20}, /* not to be interpreted as hex value! */ | 919 | {D_STR_W_LEN ("20h"), 2, 20}, /* not to be interpreted as hex value! */ |
854 | {D_STR_W_LEN("0x1F"), 1, 0}, /* not to be interpreted as hex value! */ | 920 | {D_STR_W_LEN ("0x1F"), 1, 0}, /* not to be interpreted as hex value! */ |
855 | {D_STR_W_LEN("0564`~}"), 4, 564}, | 921 | {D_STR_W_LEN ("0564`~}"), 4, 564}, |
856 | {D_STR_W_LEN("7240146.724"), 7, 7240146}, | 922 | {D_STR_W_LEN ("7240146.724"), 7, 7240146}, |
857 | {D_STR_W_LEN("2,9"), 1, 2}, | 923 | {D_STR_W_LEN ("2,9"), 1, 2}, |
858 | {D_STR_W_LEN("200+1"), 3, 200}, | 924 | {D_STR_W_LEN ("200+1"), 3, 200}, |
859 | {D_STR_W_LEN("1a"), 1, 1}, | 925 | {D_STR_W_LEN ("1a"), 1, 1}, |
860 | {D_STR_W_LEN("2E"), 1, 2}, | 926 | {D_STR_W_LEN ("2E"), 1, 2}, |
861 | {D_STR_W_LEN("6c"), 1, 6}, | 927 | {D_STR_W_LEN ("6c"), 1, 6}, |
862 | {D_STR_W_LEN("8F"), 1, 8}, | 928 | {D_STR_W_LEN ("8F"), 1, 8}, |
863 | {D_STR_W_LEN("287416997! And the not too long string."), 9, 287416997} | 929 | {D_STR_W_LEN ("287416997! And the not too long string."), 9, 287416997} |
864 | }; | 930 | }; |
865 | 931 | ||
866 | /* strings that should overflow uint64_t */ | 932 | /* strings that should overflow uint64_t */ |
867 | const struct str_with_len str_ovflw[] = { | 933 | const struct str_with_len str_ovflw[] = { |
868 | D_STR_W_LEN("18446744073709551616"), /* 0x10000000000000000, UINT64_MAX+1 */ | 934 | D_STR_W_LEN ("18446744073709551616"), /* 0x10000000000000000, UINT64_MAX+1 */ |
869 | D_STR_W_LEN("18446744073709551620"), | 935 | D_STR_W_LEN ("18446744073709551620"), |
870 | D_STR_W_LEN("18446744083709551615"), | 936 | D_STR_W_LEN ("18446744083709551615"), |
871 | D_STR_W_LEN("19234761020556472143"), | 937 | D_STR_W_LEN ("19234761020556472143"), |
872 | D_STR_W_LEN("184467440737095516150"), | 938 | D_STR_W_LEN ("184467440737095516150"), |
873 | D_STR_W_LEN("1844674407370955161500"), | 939 | D_STR_W_LEN ("1844674407370955161500"), |
874 | D_STR_W_LEN("000018446744073709551616"), /* 0x10000000000000000, UINT64_MAX+1 */ | 940 | D_STR_W_LEN ("000018446744073709551616"), /* 0x10000000000000000, UINT64_MAX+1 */ |
875 | D_STR_W_LEN("20000000000000000000"), | 941 | D_STR_W_LEN ("20000000000000000000"), |
876 | D_STR_W_LEN("020000000000000000000"), | 942 | D_STR_W_LEN ("020000000000000000000"), |
877 | D_STR_W_LEN("0020000000000000000000"), | 943 | D_STR_W_LEN ("0020000000000000000000"), |
878 | D_STR_W_LEN("100000000000000000000"), | 944 | D_STR_W_LEN ("100000000000000000000"), |
879 | D_STR_W_LEN("434532891232591226417"), | 945 | D_STR_W_LEN ("434532891232591226417"), |
880 | D_STR_W_LEN("99999999999999999999"), | 946 | D_STR_W_LEN ("99999999999999999999"), |
881 | D_STR_W_LEN("18446744073709551616abcd"), /* 0x10000000000000000, UINT64_MAX+1 */ | 947 | D_STR_W_LEN ("18446744073709551616abcd"), /* 0x10000000000000000, UINT64_MAX+1 */ |
882 | D_STR_W_LEN("20000000000000000000 suffix"), | 948 | D_STR_W_LEN ("20000000000000000000 suffix"), |
883 | D_STR_W_LEN("020000000000000000000x") | 949 | D_STR_W_LEN ("020000000000000000000x") |
884 | }; | 950 | }; |
885 | 951 | ||
886 | /* strings that should not be convertible to numeric value */ | 952 | /* strings that should not be convertible to numeric value */ |
887 | const struct str_with_len str_no_num[] = { | 953 | const struct str_with_len str_no_num[] = { |
888 | D_STR_W_LEN("zero"), | 954 | D_STR_W_LEN ("zero"), |
889 | D_STR_W_LEN("one"), | 955 | D_STR_W_LEN ("one"), |
890 | D_STR_W_LEN("\xb9\xb2\xb3"), /* superscript "123" in ISO-8859-1/CP1252 */ | 956 | D_STR_W_LEN ("\xb9\xb2\xb3"), /* superscript "123" in ISO-8859-1/CP1252 */ |
891 | D_STR_W_LEN("\xc2\xb9\xc2\xb2\xc2\xb3"), /* superscript "123" in UTF-8 */ | 957 | D_STR_W_LEN ("\xc2\xb9\xc2\xb2\xc2\xb3"), /* superscript "123" in UTF-8 */ |
892 | D_STR_W_LEN("\xd9\xa1\xd9\xa2\xd9\xa3"), /* Arabic-Indic "١٢٣" in UTF-8 */ | 958 | D_STR_W_LEN ("\xd9\xa1\xd9\xa2\xd9\xa3"), /* Arabic-Indic "١٢٣" in UTF-8 */ |
893 | D_STR_W_LEN("\xdb\xb1\xdb\xb2\xdb\xb3"), /* Ext Arabic-Indic "۱۲۳" in UTF-8 */ | 959 | D_STR_W_LEN ("\xdb\xb1\xdb\xb2\xdb\xb3"), /* Ext Arabic-Indic "۱۲۳" in UTF-8 */ |
894 | D_STR_W_LEN("\xe0\xa5\xa7\xe0\xa5\xa8\xe0\xa5\xa9"), /* Devanagari "१२३" in UTF-8 */ | 960 | D_STR_W_LEN ("\xe0\xa5\xa7\xe0\xa5\xa8\xe0\xa5\xa9"), /* Devanagari "१२३" in UTF-8 */ |
895 | D_STR_W_LEN("\xe4\xb8\x80\xe4\xba\x8c\xe4\xb8\x89"), /* Chinese "一二三" in UTF-8 */ | 961 | D_STR_W_LEN ("\xe4\xb8\x80\xe4\xba\x8c\xe4\xb8\x89"), /* Chinese "一二三" in UTF-8 */ |
896 | D_STR_W_LEN("\xd2\xbb\xb6\xfe\xc8\xfd"), /* Chinese "一二三" in GB2312/CP936 */ | 962 | D_STR_W_LEN ("\xd2\xbb\xb6\xfe\xc8\xfd"), /* Chinese "一二三" in GB2312/CP936 */ |
897 | D_STR_W_LEN("\x1B\x24\x29\x41\x0E\x52\x3B\x36\x7E\x48\x7D\x0F") /* Chinese "一二三" in ISO-2022-CN */ | 963 | D_STR_W_LEN ("\x1B\x24\x29\x41\x0E\x52\x3B\x36\x7E\x48\x7D\x0F") /* Chinese "一二三" in ISO-2022-CN */ |
898 | }; | 964 | }; |
899 | 965 | ||
900 | /* valid hex string for conversion to unsigned integer value */ | 966 | /* valid hex string for conversion to unsigned integer value */ |
901 | static const struct str_with_value xdstrs_w_values[] = { | 967 | static const struct str_with_value xdstrs_w_values[] = { |
902 | /* simplest strings */ | 968 | /* simplest strings */ |
903 | {D_STR_W_LEN("1"), 1, 0x1}, | 969 | {D_STR_W_LEN ("1"), 1, 0x1}, |
904 | {D_STR_W_LEN("0"), 1, 0x0}, | 970 | {D_STR_W_LEN ("0"), 1, 0x0}, |
905 | {D_STR_W_LEN("10000"), 5, 0x10000}, | 971 | {D_STR_W_LEN ("10000"), 5, 0x10000}, |
906 | 972 | ||
907 | /* all digits */ | 973 | /* all digits */ |
908 | {D_STR_W_LEN("1234"), 4, 0x1234}, | 974 | {D_STR_W_LEN ("1234"), 4, 0x1234}, |
909 | {D_STR_W_LEN("4567"), 4, 0x4567}, | 975 | {D_STR_W_LEN ("4567"), 4, 0x4567}, |
910 | {D_STR_W_LEN("7890"), 4, 0x7890}, | 976 | {D_STR_W_LEN ("7890"), 4, 0x7890}, |
911 | {D_STR_W_LEN("8021"), 4, 0x8021}, | 977 | {D_STR_W_LEN ("8021"), 4, 0x8021}, |
912 | {D_STR_W_LEN("9754"), 4, 0x9754}, | 978 | {D_STR_W_LEN ("9754"), 4, 0x9754}, |
913 | {D_STR_W_LEN("6392"), 4, 0x6392}, | 979 | {D_STR_W_LEN ("6392"), 4, 0x6392}, |
914 | {D_STR_W_LEN("abcd"), 4, 0xABCD}, | 980 | {D_STR_W_LEN ("abcd"), 4, 0xABCD}, |
915 | {D_STR_W_LEN("cdef"), 4, 0xCDEF}, | 981 | {D_STR_W_LEN ("cdef"), 4, 0xCDEF}, |
916 | {D_STR_W_LEN("FEAB"), 4, 0xFEAB}, | 982 | {D_STR_W_LEN ("FEAB"), 4, 0xFEAB}, |
917 | {D_STR_W_LEN("BCED"), 4, 0xBCED}, | 983 | {D_STR_W_LEN ("BCED"), 4, 0xBCED}, |
918 | {D_STR_W_LEN("bCeD"), 4, 0xBCED}, | 984 | {D_STR_W_LEN ("bCeD"), 4, 0xBCED}, |
919 | {D_STR_W_LEN("1A5F"), 4, 0x1A5F}, | 985 | {D_STR_W_LEN ("1A5F"), 4, 0x1A5F}, |
920 | {D_STR_W_LEN("12AB"), 4, 0x12AB}, | 986 | {D_STR_W_LEN ("12AB"), 4, 0x12AB}, |
921 | {D_STR_W_LEN("CD34"), 4, 0xCD34}, | 987 | {D_STR_W_LEN ("CD34"), 4, 0xCD34}, |
922 | {D_STR_W_LEN("56EF"), 4, 0x56EF}, | 988 | {D_STR_W_LEN ("56EF"), 4, 0x56EF}, |
923 | {D_STR_W_LEN("7a9f"), 4, 0x7A9F}, | 989 | {D_STR_W_LEN ("7a9f"), 4, 0x7A9F}, |
924 | 990 | ||
925 | /* various prefixes */ | 991 | /* various prefixes */ |
926 | {D_STR_W_LEN("00000000"), 8, 0x0}, | 992 | {D_STR_W_LEN ("00000000"), 8, 0x0}, |
927 | {D_STR_W_LEN("0755"), 4, 0x755}, /* not to be interpreted as octal value! */ | 993 | {D_STR_W_LEN ("0755"), 4, 0x755}, /* not to be interpreted as octal value! */ |
928 | {D_STR_W_LEN("002"), 3, 0x2}, | 994 | {D_STR_W_LEN ("002"), 3, 0x2}, |
929 | {D_STR_W_LEN("0001"), 4, 0x1}, | 995 | {D_STR_W_LEN ("0001"), 4, 0x1}, |
930 | {D_STR_W_LEN("00a"), 3, 0xA}, | 996 | {D_STR_W_LEN ("00a"), 3, 0xA}, |
931 | {D_STR_W_LEN("0F"), 2, 0xF}, | 997 | {D_STR_W_LEN ("0F"), 2, 0xF}, |
932 | {D_STR_W_LEN("0000000000000000000000003A29e4C3"), 32, 0x3A29E4C3}, | 998 | {D_STR_W_LEN ("0000000000000000000000003A29e4C3"), 32, 0x3A29E4C3}, |
933 | 999 | ||
934 | /* numbers below and above limits */ | 1000 | /* numbers below and above limits */ |
935 | {D_STR_W_LEN("7F"), 2, 127}, /* 0x7F, SCHAR_MAX */ | 1001 | {D_STR_W_LEN ("7F"), 2, 127}, /* 0x7F, SCHAR_MAX */ |
936 | {D_STR_W_LEN("7f"), 2, 127}, /* 0x7F, SCHAR_MAX */ | 1002 | {D_STR_W_LEN ("7f"), 2, 127}, /* 0x7F, SCHAR_MAX */ |
937 | {D_STR_W_LEN("80"), 2, 128}, /* 0x80, SCHAR_MAX+1 */ | 1003 | {D_STR_W_LEN ("80"), 2, 128}, /* 0x80, SCHAR_MAX+1 */ |
938 | {D_STR_W_LEN("fF"), 2, 255}, /* 0xFF, UCHAR_MAX */ | 1004 | {D_STR_W_LEN ("fF"), 2, 255}, /* 0xFF, UCHAR_MAX */ |
939 | {D_STR_W_LEN("Ff"), 2, 255}, /* 0xFF, UCHAR_MAX */ | 1005 | {D_STR_W_LEN ("Ff"), 2, 255}, /* 0xFF, UCHAR_MAX */ |
940 | {D_STR_W_LEN("FF"), 2, 255}, /* 0xFF, UCHAR_MAX */ | 1006 | {D_STR_W_LEN ("FF"), 2, 255}, /* 0xFF, UCHAR_MAX */ |
941 | {D_STR_W_LEN("ff"), 2, 255}, /* 0xFF, UCHAR_MAX */ | 1007 | {D_STR_W_LEN ("ff"), 2, 255}, /* 0xFF, UCHAR_MAX */ |
942 | {D_STR_W_LEN("100"), 3, 256}, /* 0x100, UCHAR_MAX+1 */ | 1008 | {D_STR_W_LEN ("100"), 3, 256}, /* 0x100, UCHAR_MAX+1 */ |
943 | {D_STR_W_LEN("7fff"), 4, 32767}, /* 0x7FFF, INT16_MAX */ | 1009 | {D_STR_W_LEN ("7fff"), 4, 32767}, /* 0x7FFF, INT16_MAX */ |
944 | {D_STR_W_LEN("7FFF"), 4, 32767}, /* 0x7FFF, INT16_MAX */ | 1010 | {D_STR_W_LEN ("7FFF"), 4, 32767}, /* 0x7FFF, INT16_MAX */ |
945 | {D_STR_W_LEN("7Fff"), 4, 32767}, /* 0x7FFF, INT16_MAX */ | 1011 | {D_STR_W_LEN ("7Fff"), 4, 32767}, /* 0x7FFF, INT16_MAX */ |
946 | {D_STR_W_LEN("8000"), 4, 32768}, /* 0x8000, INT16_MAX+1 */ | 1012 | {D_STR_W_LEN ("8000"), 4, 32768}, /* 0x8000, INT16_MAX+1 */ |
947 | {D_STR_W_LEN("ffff"), 4, 65535}, /* 0xFFFF, UINT16_MAX */ | 1013 | {D_STR_W_LEN ("ffff"), 4, 65535}, /* 0xFFFF, UINT16_MAX */ |
948 | {D_STR_W_LEN("FFFF"), 4, 65535}, /* 0xFFFF, UINT16_MAX */ | 1014 | {D_STR_W_LEN ("FFFF"), 4, 65535}, /* 0xFFFF, UINT16_MAX */ |
949 | {D_STR_W_LEN("FffF"), 4, 65535}, /* 0xFFFF, UINT16_MAX */ | 1015 | {D_STR_W_LEN ("FffF"), 4, 65535}, /* 0xFFFF, UINT16_MAX */ |
950 | {D_STR_W_LEN("10000"), 5, 65536}, /* 0x10000, UINT16_MAX+1 */ | 1016 | {D_STR_W_LEN ("10000"), 5, 65536}, /* 0x10000, UINT16_MAX+1 */ |
951 | {D_STR_W_LEN("7FFFFFFF"), 8, 2147483647}, /* 0x7FFFFFFF, INT32_MAX */ | 1017 | {D_STR_W_LEN ("7FFFFFFF"), 8, 2147483647}, /* 0x7FFFFFFF, INT32_MAX */ |
952 | {D_STR_W_LEN("7fffffff"), 8, 2147483647}, /* 0x7FFFFFFF, INT32_MAX */ | 1018 | {D_STR_W_LEN ("7fffffff"), 8, 2147483647}, /* 0x7FFFFFFF, INT32_MAX */ |
953 | {D_STR_W_LEN("7FFffFff"), 8, 2147483647}, /* 0x7FFFFFFF, INT32_MAX */ | 1019 | {D_STR_W_LEN ("7FFffFff"), 8, 2147483647}, /* 0x7FFFFFFF, INT32_MAX */ |
954 | {D_STR_W_LEN("80000000"), 8, UINT64_C(2147483648)}, /* 0x80000000, INT32_MAX+1 */ | 1020 | {D_STR_W_LEN ("80000000"), 8, UINT64_C (2147483648)}, /* 0x80000000, INT32_MAX+1 */ |
955 | {D_STR_W_LEN("FFFFFFFF"), 8, UINT64_C(4294967295)}, /* 0xFFFFFFFF, UINT32_MAX */ | 1021 | {D_STR_W_LEN ("FFFFFFFF"), 8, UINT64_C (4294967295)}, /* 0xFFFFFFFF, UINT32_MAX */ |
956 | {D_STR_W_LEN("ffffffff"), 8, UINT64_C(4294967295)}, /* 0xFFFFFFFF, UINT32_MAX */ | 1022 | {D_STR_W_LEN ("ffffffff"), 8, UINT64_C (4294967295)}, /* 0xFFFFFFFF, UINT32_MAX */ |
957 | {D_STR_W_LEN("FfFfFfFf"), 8, UINT64_C(4294967295)}, /* 0xFFFFFFFF, UINT32_MAX */ | 1023 | {D_STR_W_LEN ("FfFfFfFf"), 8, UINT64_C (4294967295)}, /* 0xFFFFFFFF, UINT32_MAX */ |
958 | {D_STR_W_LEN("100000000"), 9, UINT64_C(4294967296)}, /* 0x100000000, UINT32_MAX+1 */ | 1024 | {D_STR_W_LEN ("100000000"), 9, UINT64_C (4294967296)}, /* 0x100000000, UINT32_MAX+1 */ |
959 | {D_STR_W_LEN("7fffffffffffffff"), 16, UINT64_C(9223372036854775807)}, /* 0x7FFFFFFFFFFFFFFF, INT64_MAX */ | 1025 | {D_STR_W_LEN ("7fffffffffffffff"), 16, UINT64_C (9223372036854775807)}, /* 0x7FFFFFFFFFFFFFFF, INT64_MAX */ |
960 | {D_STR_W_LEN("7FFFFFFFFFFFFFFF"), 16, UINT64_C(9223372036854775807)}, /* 0x7FFFFFFFFFFFFFFF, INT64_MAX */ | 1026 | {D_STR_W_LEN ("7FFFFFFFFFFFFFFF"), 16, UINT64_C (9223372036854775807)}, /* 0x7FFFFFFFFFFFFFFF, INT64_MAX */ |
961 | {D_STR_W_LEN("7FfffFFFFffFFffF"), 16, UINT64_C(9223372036854775807)}, /* 0x7FFFFFFFFFFFFFFF, INT64_MAX */ | 1027 | {D_STR_W_LEN ("7FfffFFFFffFFffF"), 16, UINT64_C (9223372036854775807)}, /* 0x7FFFFFFFFFFFFFFF, INT64_MAX */ |
962 | {D_STR_W_LEN("8000000000000000"), 16, UINT64_C(9223372036854775808)}, /* 0x8000000000000000, INT64_MAX+1 */ | 1028 | {D_STR_W_LEN ("8000000000000000"), 16, UINT64_C (9223372036854775808)}, /* 0x8000000000000000, INT64_MAX+1 */ |
963 | {D_STR_W_LEN("ffffffffffffffff"), 16, UINT64_C(18446744073709551615)}, /* 0xFFFFFFFFFFFFFFFF, UINT64_MAX */ | 1029 | {D_STR_W_LEN ("ffffffffffffffff"), 16, UINT64_C (18446744073709551615)}, /* 0xFFFFFFFFFFFFFFFF, UINT64_MAX */ |
964 | {D_STR_W_LEN("FFFFFFFFFFFFFFFF"), 16, UINT64_C(18446744073709551615)}, /* 0xFFFFFFFFFFFFFFFF, UINT64_MAX */ | 1030 | {D_STR_W_LEN ("FFFFFFFFFFFFFFFF"), 16, UINT64_C (18446744073709551615)}, /* 0xFFFFFFFFFFFFFFFF, UINT64_MAX */ |
965 | {D_STR_W_LEN("FffFffFFffFFfFFF"), 16, UINT64_C(18446744073709551615)}, /* 0xFFFFFFFFFFFFFFFF, UINT64_MAX */ | 1031 | {D_STR_W_LEN ("FffFffFFffFFfFFF"), 16, UINT64_C (18446744073709551615)}, /* 0xFFFFFFFFFFFFFFFF, UINT64_MAX */ |
966 | 1032 | ||
967 | /* random numbers */ | 1033 | /* random numbers */ |
968 | {D_STR_W_LEN("10186753"), 8, 0x10186753}, | 1034 | {D_STR_W_LEN ("10186753"), 8, 0x10186753}, |
969 | {D_STR_W_LEN("144402566"), 9, 0x144402566}, | 1035 | {D_STR_W_LEN ("144402566"), 9, 0x144402566}, |
970 | {D_STR_W_LEN("151903144"), 9, 0x151903144}, | 1036 | {D_STR_W_LEN ("151903144"), 9, 0x151903144}, |
971 | {D_STR_W_LEN("139264621"), 9, 0x139264621}, | 1037 | {D_STR_W_LEN ("139264621"), 9, 0x139264621}, |
972 | {D_STR_W_LEN("730348"), 6, 0x730348}, | 1038 | {D_STR_W_LEN ("730348"), 6, 0x730348}, |
973 | {D_STR_W_LEN("21584377"), 8, 0x21584377}, | 1039 | {D_STR_W_LEN ("21584377"), 8, 0x21584377}, |
974 | {D_STR_W_LEN("709"), 3, 0x709}, | 1040 | {D_STR_W_LEN ("709"), 3, 0x709}, |
975 | {D_STR_W_LEN("54"), 2, 0x54}, | 1041 | {D_STR_W_LEN ("54"), 2, 0x54}, |
976 | {D_STR_W_LEN("8452"), 4, 0x8452}, | 1042 | {D_STR_W_LEN ("8452"), 4, 0x8452}, |
977 | {D_STR_W_LEN("22353EC6"), 8, 0x22353EC6}, | 1043 | {D_STR_W_LEN ("22353EC6"), 8, 0x22353EC6}, |
978 | {D_STR_W_LEN("307F1655"), 8, 0x307F1655}, | 1044 | {D_STR_W_LEN ("307F1655"), 8, 0x307F1655}, |
979 | {D_STR_W_LEN("1FCB7226"), 8, 0x1FCB7226}, | 1045 | {D_STR_W_LEN ("1FCB7226"), 8, 0x1FCB7226}, |
980 | {D_STR_W_LEN("82480560"), 8, 0x82480560}, | 1046 | {D_STR_W_LEN ("82480560"), 8, 0x82480560}, |
981 | {D_STR_W_LEN("7386D95"), 7, 0x7386D95}, | 1047 | {D_STR_W_LEN ("7386D95"), 7, 0x7386D95}, |
982 | {D_STR_W_LEN("EC3AB"), 5, 0xEC3AB}, | 1048 | {D_STR_W_LEN ("EC3AB"), 5, 0xEC3AB}, |
983 | {D_STR_W_LEN("6DD05"), 5, 0x6DD05}, | 1049 | {D_STR_W_LEN ("6DD05"), 5, 0x6DD05}, |
984 | {D_STR_W_LEN("C5DF"), 4, 0xC5DF}, | 1050 | {D_STR_W_LEN ("C5DF"), 4, 0xC5DF}, |
985 | {D_STR_W_LEN("6CE"), 3, 0x6CE}, | 1051 | {D_STR_W_LEN ("6CE"), 3, 0x6CE}, |
986 | {D_STR_W_LEN("CE6"), 3, 0xCE6}, | 1052 | {D_STR_W_LEN ("CE6"), 3, 0xCE6}, |
987 | {D_STR_W_LEN("ce6"), 3, 0xCE6}, | 1053 | {D_STR_W_LEN ("ce6"), 3, 0xCE6}, |
988 | {D_STR_W_LEN("F27"), 3, 0xF27}, | 1054 | {D_STR_W_LEN ("F27"), 3, 0xF27}, |
989 | {D_STR_W_LEN("8497D54277D7E1"), 14, UINT64_C(37321639124785121)}, | 1055 | {D_STR_W_LEN ("8497D54277D7E1"), 14, UINT64_C (37321639124785121)}, |
990 | {D_STR_W_LEN("8497d54277d7e1"), 14, UINT64_C(37321639124785121)}, | 1056 | {D_STR_W_LEN ("8497d54277d7e1"), 14, UINT64_C (37321639124785121)}, |
991 | {D_STR_W_LEN("8497d54277d7E1"), 14, UINT64_C(37321639124785121)}, | 1057 | {D_STR_W_LEN ("8497d54277d7E1"), 14, UINT64_C (37321639124785121)}, |
992 | {D_STR_W_LEN("8C8112D0A06"), 11, UINT64_C(9655374645766)}, | 1058 | {D_STR_W_LEN ("8C8112D0A06"), 11, UINT64_C (9655374645766)}, |
993 | {D_STR_W_LEN("8c8112d0a06"), 11, UINT64_C(9655374645766)}, | 1059 | {D_STR_W_LEN ("8c8112d0a06"), 11, UINT64_C (9655374645766)}, |
994 | {D_STR_W_LEN("8c8112d0A06"), 11, UINT64_C(9655374645766)}, | 1060 | {D_STR_W_LEN ("8c8112d0A06"), 11, UINT64_C (9655374645766)}, |
995 | {D_STR_W_LEN("1774509875001362"), 16, UINT64_C(1690064375898968930)}, | 1061 | {D_STR_W_LEN ("1774509875001362"), 16, UINT64_C (1690064375898968930)}, |
996 | {D_STR_W_LEN("0678687876998000"), 16, UINT64_C(466237428027981824)}, | 1062 | {D_STR_W_LEN ("0678687876998000"), 16, UINT64_C (466237428027981824)}, |
997 | 1063 | ||
998 | /* non-digit suffixes */ | 1064 | /* non-digit suffixes */ |
999 | {D_STR_W_LEN("1234oa"), 4, 0x1234}, | 1065 | {D_STR_W_LEN ("1234oa"), 4, 0x1234}, |
1000 | {D_STR_W_LEN("20h"), 2, 0x20}, | 1066 | {D_STR_W_LEN ("20h"), 2, 0x20}, |
1001 | {D_STR_W_LEN("2CH"), 2, 0x2C}, | 1067 | {D_STR_W_LEN ("2CH"), 2, 0x2C}, |
1002 | {D_STR_W_LEN("2ch"), 2, 0x2C}, | 1068 | {D_STR_W_LEN ("2ch"), 2, 0x2C}, |
1003 | {D_STR_W_LEN("0x1F"), 1, 0x0}, /* not to be interpreted as hex prefix! */ | 1069 | {D_STR_W_LEN ("0x1F"), 1, 0x0}, /* not to be interpreted as hex prefix! */ |
1004 | {D_STR_W_LEN("0564`~}"), 4, 0x564}, | 1070 | {D_STR_W_LEN ("0564`~}"), 4, 0x564}, |
1005 | {D_STR_W_LEN("0A64`~}"), 4, 0xA64}, | 1071 | {D_STR_W_LEN ("0A64`~}"), 4, 0xA64}, |
1006 | {D_STR_W_LEN("056c`~}"), 4, 0X56C}, | 1072 | {D_STR_W_LEN ("056c`~}"), 4, 0X56C}, |
1007 | {D_STR_W_LEN("7240146.724"), 7, 0x7240146}, | 1073 | {D_STR_W_LEN ("7240146.724"), 7, 0x7240146}, |
1008 | {D_STR_W_LEN("7E4c1AB.724"), 7, 0X7E4C1AB}, | 1074 | {D_STR_W_LEN ("7E4c1AB.724"), 7, 0X7E4C1AB}, |
1009 | {D_STR_W_LEN("F24B1B6.724"), 7, 0xF24B1B6}, | 1075 | {D_STR_W_LEN ("F24B1B6.724"), 7, 0xF24B1B6}, |
1010 | {D_STR_W_LEN("2,9"), 1, 0x2}, | 1076 | {D_STR_W_LEN ("2,9"), 1, 0x2}, |
1011 | {D_STR_W_LEN("a,9"), 1, 0xA}, | 1077 | {D_STR_W_LEN ("a,9"), 1, 0xA}, |
1012 | {D_STR_W_LEN("200+1"), 3, 0x200}, | 1078 | {D_STR_W_LEN ("200+1"), 3, 0x200}, |
1013 | {D_STR_W_LEN("2cc+1"), 3, 0x2CC}, | 1079 | {D_STR_W_LEN ("2cc+1"), 3, 0x2CC}, |
1014 | {D_STR_W_LEN("2cC+1"), 3, 0x2CC}, | 1080 | {D_STR_W_LEN ("2cC+1"), 3, 0x2CC}, |
1015 | {D_STR_W_LEN("27416997! And the not too long string."), 8, 0x27416997}, | 1081 | {D_STR_W_LEN ("27416997! And the not too long string."), 8, 0x27416997}, |
1016 | {D_STR_W_LEN("27555416997! And the not too long string."), 11, 0x27555416997}, | 1082 | {D_STR_W_LEN ("27555416997! And the not too long string."), 11, |
1017 | {D_STR_W_LEN("416997And the not too long string."), 7, 0x416997A}, | 1083 | 0x27555416997}, |
1018 | {D_STR_W_LEN("0F4C3Dabstract addition to make string even longer"), 8, 0xF4C3DAB} | 1084 | {D_STR_W_LEN ("416997And the not too long string."), 7, 0x416997A}, |
1085 | {D_STR_W_LEN ("0F4C3Dabstract addition to make string even longer"), 8, | ||
1086 | 0xF4C3DAB} | ||
1019 | }; | 1087 | }; |
1020 | 1088 | ||
1021 | /* hex strings that should overflow uint64_t */ | 1089 | /* hex strings that should overflow uint64_t */ |
1022 | const struct str_with_len strx_ovflw[] = { | 1090 | const struct str_with_len strx_ovflw[] = { |
1023 | D_STR_W_LEN("10000000000000000"), /* 0x10000000000000000, UINT64_MAX+1 */ | 1091 | D_STR_W_LEN ("10000000000000000"), /* 0x10000000000000000, UINT64_MAX+1 */ |
1024 | D_STR_W_LEN("10000000000000001"), | 1092 | D_STR_W_LEN ("10000000000000001"), |
1025 | D_STR_W_LEN("10000000000000002"), | 1093 | D_STR_W_LEN ("10000000000000002"), |
1026 | D_STR_W_LEN("1000000000000000A"), | 1094 | D_STR_W_LEN ("1000000000000000A"), |
1027 | D_STR_W_LEN("11000000000000000"), | 1095 | D_STR_W_LEN ("11000000000000000"), |
1028 | D_STR_W_LEN("010000000000000000"), /* 0x10000000000000000, UINT64_MAX+1 */ | 1096 | D_STR_W_LEN ("010000000000000000"), /* 0x10000000000000000, UINT64_MAX+1 */ |
1029 | D_STR_W_LEN("000010000000000000000"), /* 0x10000000000000000, UINT64_MAX+1 */ | 1097 | D_STR_W_LEN ("000010000000000000000"), /* 0x10000000000000000, UINT64_MAX+1 */ |
1030 | D_STR_W_LEN("20000000000000000000"), | 1098 | D_STR_W_LEN ("20000000000000000000"), |
1031 | D_STR_W_LEN("020000000000000000000"), | 1099 | D_STR_W_LEN ("020000000000000000000"), |
1032 | D_STR_W_LEN("0020000000000000000000"), | 1100 | D_STR_W_LEN ("0020000000000000000000"), |
1033 | D_STR_W_LEN("20000000000000000"), | 1101 | D_STR_W_LEN ("20000000000000000"), |
1034 | D_STR_W_LEN("A0000000000000000"), | 1102 | D_STR_W_LEN ("A0000000000000000"), |
1035 | D_STR_W_LEN("F0000000000000000"), | 1103 | D_STR_W_LEN ("F0000000000000000"), |
1036 | D_STR_W_LEN("a0000000000000000"), | 1104 | D_STR_W_LEN ("a0000000000000000"), |
1037 | D_STR_W_LEN("11111111111111111"), | 1105 | D_STR_W_LEN ("11111111111111111"), |
1038 | D_STR_W_LEN("CcCcCCccCCccCCccC"), | 1106 | D_STR_W_LEN ("CcCcCCccCCccCCccC"), |
1039 | D_STR_W_LEN("f0000000000000000"), | 1107 | D_STR_W_LEN ("f0000000000000000"), |
1040 | D_STR_W_LEN("100000000000000000000"), | 1108 | D_STR_W_LEN ("100000000000000000000"), |
1041 | D_STR_W_LEN("434532891232591226417"), | 1109 | D_STR_W_LEN ("434532891232591226417"), |
1042 | D_STR_W_LEN("10000000000000000a"), | 1110 | D_STR_W_LEN ("10000000000000000a"), |
1043 | D_STR_W_LEN("10000000000000000E"), | 1111 | D_STR_W_LEN ("10000000000000000E"), |
1044 | D_STR_W_LEN("100000000000000000 and nothing"), /* 0x10000000000000000, UINT64_MAX+1 */ | 1112 | D_STR_W_LEN ("100000000000000000 and nothing"), /* 0x10000000000000000, UINT64_MAX+1 */ |
1045 | D_STR_W_LEN("100000000000000000xx"), /* 0x10000000000000000, UINT64_MAX+1 */ | 1113 | D_STR_W_LEN ("100000000000000000xx"), /* 0x10000000000000000, UINT64_MAX+1 */ |
1046 | D_STR_W_LEN("99999999999999999999"), | 1114 | D_STR_W_LEN ("99999999999999999999"), |
1047 | D_STR_W_LEN("18446744073709551616abcd"), | 1115 | D_STR_W_LEN ("18446744073709551616abcd"), |
1048 | D_STR_W_LEN("20000000000000000000 suffix"), | 1116 | D_STR_W_LEN ("20000000000000000000 suffix"), |
1049 | D_STR_W_LEN("020000000000000000000x") | 1117 | D_STR_W_LEN ("020000000000000000000x") |
1050 | }; | 1118 | }; |
1051 | 1119 | ||
1052 | 1120 | ||
1053 | int check_str_to_uint64_valid(void) | 1121 | int check_str_to_uint64_valid (void) |
1054 | { | 1122 | { |
1055 | size_t t_failed = 0; | 1123 | size_t t_failed = 0; |
1056 | size_t i, j; | 1124 | size_t i, j; |
1057 | static const size_t n_checks = sizeof(dstrs_w_values) / sizeof(dstrs_w_values[0]); | 1125 | static const size_t n_checks = sizeof(dstrs_w_values) |
1126 | / sizeof(dstrs_w_values[0]); | ||
1058 | int c_failed[n_checks]; | 1127 | int c_failed[n_checks]; |
1059 | 1128 | ||
1060 | memset(c_failed, 0, sizeof(c_failed)); | 1129 | memset (c_failed, 0, sizeof(c_failed)); |
1061 | 1130 | ||
1062 | for(j = 0; j < locale_name_count; j++) | 1131 | for (j = 0; j < locale_name_count; j++) |
1132 | { | ||
1133 | set_test_locale (j); /* setlocale() can be slow! */ | ||
1134 | for (i = 0; i < n_checks; i++) | ||
1063 | { | 1135 | { |
1064 | set_test_locale(j); /* setlocale() can be slow! */ | 1136 | uint64_t rv; |
1065 | for(i = 0; i < n_checks; i++) | 1137 | size_t rs; |
1066 | { | 1138 | const struct str_with_value *const t = dstrs_w_values + i; |
1067 | uint64_t rv; | 1139 | |
1068 | size_t rs; | 1140 | if (c_failed[i]) |
1069 | const struct str_with_value * const t = dstrs_w_values + i; | 1141 | continue; /* skip already failed checks */ |
1070 | 1142 | ||
1071 | if (c_failed[i]) | 1143 | if (t->str.len < t->num_of_digt) |
1072 | continue; /* skip already failed checks */ | 1144 | { |
1073 | 1145 | fprintf (stderr, | |
1074 | if (t->str.len < t->num_of_digt) | 1146 | "ERROR: dstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" |
1075 | { | 1147 | " to be less or equal to str.len (%u).\n", |
1076 | fprintf(stderr, "ERROR: dstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" | 1148 | (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned |
1077 | " to be less or equal to str.len (%u).\n", | 1149 | int) t->str. |
1078 | (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned int) t->str.len); | 1150 | len); |
1079 | return -1; | 1151 | return -1; |
1080 | } | 1152 | } |
1081 | rv = 9435223; /* some random value */ | 1153 | rv = 9435223; /* some random value */ |
1082 | rs = MHD_str_to_uint64_(t->str.str, &rv); | 1154 | rs = MHD_str_to_uint64_ (t->str.str, &rv); |
1083 | if (rs != t->num_of_digt) | 1155 | if (rs != t->num_of_digt) |
1084 | { | 1156 | { |
1085 | t_failed++; | 1157 | t_failed++; |
1086 | c_failed[i] = !0; | 1158 | c_failed[i] = ! 0; |
1087 | fprintf(stderr, "FAILED: MHD_str_to_uint64_(\"%s\", ->%" PRIu64 ") returned %" PRIuPTR ", while expecting %d." | 1159 | fprintf (stderr, |
1088 | " Locale: %s\n", n_prnt(t->str.str), rv, (intptr_t)rs, (int)t->num_of_digt, get_current_locale_str()); | 1160 | "FAILED: MHD_str_to_uint64_(\"%s\", ->%" PRIu64 ") returned %" |
1089 | } | 1161 | PRIuPTR |
1090 | if (rv != t->val) | 1162 | ", while expecting %d." |
1091 | { | 1163 | " Locale: %s\n", n_prnt (t->str.str), rv, (intptr_t) rs, |
1092 | t_failed++; | 1164 | (int) t->num_of_digt, get_current_locale_str ()); |
1093 | c_failed[i] = !0; | 1165 | } |
1094 | fprintf(stderr, "FAILED: MHD_str_to_uint64_(\"%s\", ->%" PRIu64 ") converted string to value %" PRIu64 "," | 1166 | if (rv != t->val) |
1095 | " while expecting result %" PRIu64 ". Locale: %s\n", n_prnt(t->str.str), rv, rv, | 1167 | { |
1096 | t->val, get_current_locale_str()); | 1168 | t_failed++; |
1097 | } | 1169 | c_failed[i] = ! 0; |
1098 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i]) | 1170 | fprintf (stderr, |
1099 | printf("PASSED: MHD_str_to_uint64_(\"%s\", ->%" PRIu64 ") == %" PRIuPTR "\n", | 1171 | "FAILED: MHD_str_to_uint64_(\"%s\", ->%" PRIu64 |
1100 | n_prnt(t->str.str), rv, rs); | 1172 | ") converted string to value %" |
1101 | } | 1173 | PRIu64 "," |
1174 | " while expecting result %" PRIu64 ". Locale: %s\n", n_prnt ( | ||
1175 | t->str.str), rv, rv, | ||
1176 | t->val, get_current_locale_str ()); | ||
1177 | } | ||
1178 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) | ||
1179 | printf ( | ||
1180 | "PASSED: MHD_str_to_uint64_(\"%s\", ->%" PRIu64 ") == %" PRIuPTR "\n", | ||
1181 | n_prnt (t->str.str), rv, rs); | ||
1102 | } | 1182 | } |
1183 | } | ||
1103 | return t_failed; | 1184 | return t_failed; |
1104 | } | 1185 | } |
1105 | 1186 | ||
1106 | 1187 | ||
1107 | int check_str_to_uint64_all_chars(void) | 1188 | int check_str_to_uint64_all_chars (void) |
1108 | { | 1189 | { |
1109 | static const size_t n_checks = 256; /* from 0 to 255 */ | 1190 | static const size_t n_checks = 256; /* from 0 to 255 */ |
1110 | int c_failed[n_checks]; | 1191 | int c_failed[n_checks]; |
1111 | size_t t_failed = 0; | 1192 | size_t t_failed = 0; |
1112 | size_t j; | 1193 | size_t j; |
1113 | 1194 | ||
1114 | memset(c_failed, 0, sizeof(c_failed)); | 1195 | memset (c_failed, 0, sizeof(c_failed)); |
1115 | 1196 | ||
1116 | for(j = 0; j < locale_name_count; j++) | 1197 | for (j = 0; j < locale_name_count; j++) |
1117 | { | 1198 | { |
1118 | unsigned int c; | 1199 | unsigned int c; |
1119 | uint64_t test_val; | 1200 | uint64_t test_val; |
1120 | 1201 | ||
1121 | set_test_locale(j); /* setlocale() can be slow! */ | 1202 | set_test_locale (j); /* setlocale() can be slow! */ |
1122 | for(c = 0; c < n_checks; c++) | 1203 | for (c = 0; c < n_checks; c++) |
1204 | { | ||
1205 | static const uint64_t rnd_val = 24941852; | ||
1206 | size_t rs; | ||
1207 | if ((c >= '0') &&(c <= '9') ) | ||
1208 | continue; /* skip digits */ | ||
1209 | for (test_val = 0; test_val <= rnd_val&& ! c_failed[c]; test_val += | ||
1210 | rnd_val) | ||
1211 | { | ||
1212 | char test_str[] = "0123"; | ||
1213 | uint64_t rv = test_val; | ||
1214 | |||
1215 | test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ | ||
1216 | rs = MHD_str_to_uint64_ (test_str, &rv); | ||
1217 | if (rs != 0) | ||
1218 | { | ||
1219 | t_failed++; | ||
1220 | c_failed[c] = ! 0; | ||
1221 | fprintf (stderr, | ||
1222 | "FAILED: MHD_str_to_uint64_(\"%s\", ->%" PRIu64 | ||
1223 | ") returned %" PRIuPTR | ||
1224 | ", while expecting zero." | ||
1225 | " Locale: %s\n", n_prnt (test_str), rv, (uintptr_t) rs, | ||
1226 | get_current_locale_str ()); | ||
1227 | } | ||
1228 | else if (rv != test_val) | ||
1123 | { | 1229 | { |
1124 | static const uint64_t rnd_val = 24941852; | 1230 | t_failed++; |
1125 | size_t rs; | 1231 | c_failed[c] = ! 0; |
1126 | if (c >= '0' && c <= '9') | 1232 | fprintf (stderr, |
1127 | continue; /* skip digits */ | 1233 | "FAILED: MHD_str_to_uint64_(\"%s\", &ret_val) modified value of ret_val" |
1128 | for(test_val = 0; test_val <= rnd_val&& !c_failed[c]; test_val += rnd_val) | 1234 | " (before call: %" PRIu64 ", after call %" PRIu64 |
1129 | { | 1235 | "). Locale: %s\n", |
1130 | char test_str[] = "0123"; | 1236 | n_prnt (test_str), test_val, rv, get_current_locale_str ()); |
1131 | uint64_t rv = test_val; | ||
1132 | |||
1133 | test_str[0] = (char) (unsigned char)c; /* replace first char with non-digit char */ | ||
1134 | rs = MHD_str_to_uint64_(test_str, &rv); | ||
1135 | if (rs != 0) | ||
1136 | { | ||
1137 | t_failed++; | ||
1138 | c_failed[c] = !0; | ||
1139 | fprintf(stderr, "FAILED: MHD_str_to_uint64_(\"%s\", ->%" PRIu64 ") returned %" PRIuPTR ", while expecting zero." | ||
1140 | " Locale: %s\n", n_prnt(test_str), rv, (uintptr_t)rs, get_current_locale_str()); | ||
1141 | } | ||
1142 | else if (rv != test_val) | ||
1143 | { | ||
1144 | t_failed++; | ||
1145 | c_failed[c] = !0; | ||
1146 | fprintf(stderr, "FAILED: MHD_str_to_uint64_(\"%s\", &ret_val) modified value of ret_val" | ||
1147 | " (before call: %" PRIu64 ", after call %" PRIu64 "). Locale: %s\n", | ||
1148 | n_prnt(test_str), test_val, rv, get_current_locale_str()); | ||
1149 | } | ||
1150 | } | ||
1151 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[c]) | ||
1152 | { | ||
1153 | char test_str[] = "0123"; | ||
1154 | test_str[0] = (char) (unsigned char)c; /* replace first char with non-digit char */ | ||
1155 | |||
1156 | printf("PASSED: MHD_str_to_uint64_(\"%s\", &ret_val) == 0, value of ret_val is unmodified\n", | ||
1157 | n_prnt(test_str)); | ||
1158 | } | ||
1159 | } | 1237 | } |
1238 | } | ||
1239 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[c]) | ||
1240 | { | ||
1241 | char test_str[] = "0123"; | ||
1242 | test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ | ||
1243 | |||
1244 | printf ( | ||
1245 | "PASSED: MHD_str_to_uint64_(\"%s\", &ret_val) == 0, value of ret_val is unmodified\n", | ||
1246 | n_prnt (test_str)); | ||
1247 | } | ||
1160 | } | 1248 | } |
1249 | } | ||
1161 | return t_failed; | 1250 | return t_failed; |
1162 | } | 1251 | } |
1163 | 1252 | ||
1164 | 1253 | ||
1165 | int check_str_to_uint64_overflow(void) | 1254 | int check_str_to_uint64_overflow (void) |
1166 | { | 1255 | { |
1167 | size_t t_failed = 0; | 1256 | size_t t_failed = 0; |
1168 | size_t i, j; | 1257 | size_t i, j; |
1169 | static const size_t n_checks = sizeof(str_ovflw) / sizeof(str_ovflw[0]); | 1258 | static const size_t n_checks = sizeof(str_ovflw) / sizeof(str_ovflw[0]); |
1170 | int c_failed[n_checks]; | 1259 | int c_failed[n_checks]; |
1171 | 1260 | ||
1172 | memset(c_failed, 0, sizeof(c_failed)); | 1261 | memset (c_failed, 0, sizeof(c_failed)); |
1173 | 1262 | ||
1174 | for(j = 0; j < locale_name_count; j++) | 1263 | for (j = 0; j < locale_name_count; j++) |
1264 | { | ||
1265 | set_test_locale (j); /* setlocale() can be slow! */ | ||
1266 | for (i = 0; i < n_checks; i++) | ||
1175 | { | 1267 | { |
1176 | set_test_locale(j); /* setlocale() can be slow! */ | 1268 | size_t rs; |
1177 | for(i = 0; i < n_checks; i++) | 1269 | const struct str_with_len *const t = str_ovflw + i; |
1270 | static const uint64_t rnd_val = 2; | ||
1271 | uint64_t test_val; | ||
1272 | |||
1273 | for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += | ||
1274 | rnd_val) | ||
1275 | { | ||
1276 | uint64_t rv = test_val; | ||
1277 | |||
1278 | rs = MHD_str_to_uint64_ (t->str, &rv); | ||
1279 | if (rs != 0) | ||
1178 | { | 1280 | { |
1179 | size_t rs; | 1281 | t_failed++; |
1180 | const struct str_with_len * const t = str_ovflw + i; | 1282 | c_failed[i] = ! 0; |
1181 | static const uint64_t rnd_val = 2; | 1283 | fprintf (stderr, |
1182 | uint64_t test_val; | 1284 | "FAILED: MHD_str_to_uint64_(\"%s\", ->%" PRIu64 |
1183 | 1285 | ") returned %" PRIuPTR | |
1184 | for(test_val = 0; test_val <= rnd_val && !c_failed[i]; test_val += rnd_val) | 1286 | ", while expecting zero." |
1185 | { | 1287 | " Locale: %s\n", n_prnt (t->str), rv, (uintptr_t) rs, |
1186 | uint64_t rv = test_val; | 1288 | get_current_locale_str ()); |
1187 | |||
1188 | rs = MHD_str_to_uint64_(t->str, &rv); | ||
1189 | if (rs != 0) | ||
1190 | { | ||
1191 | t_failed++; | ||
1192 | c_failed[i] = !0; | ||
1193 | fprintf(stderr, "FAILED: MHD_str_to_uint64_(\"%s\", ->%" PRIu64 ") returned %" PRIuPTR ", while expecting zero." | ||
1194 | " Locale: %s\n", n_prnt(t->str), rv, (uintptr_t)rs, get_current_locale_str()); | ||
1195 | } | ||
1196 | else if (rv != test_val) | ||
1197 | { | ||
1198 | t_failed++; | ||
1199 | c_failed[i] = !0; | ||
1200 | fprintf(stderr, "FAILED: MHD_str_to_uint64_(\"%s\", &ret_val) modified value of ret_val" | ||
1201 | " (before call: %" PRIu64 ", after call %" PRIu64 "). Locale: %s\n", | ||
1202 | n_prnt(t->str), test_val, rv, get_current_locale_str()); | ||
1203 | } | ||
1204 | } | ||
1205 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i]) | ||
1206 | printf("PASSED: MHD_str_to_uint64_(\"%s\", &ret_val) == 0, value of ret_val is unmodified\n", | ||
1207 | n_prnt(t->str)); | ||
1208 | } | 1289 | } |
1290 | else if (rv != test_val) | ||
1291 | { | ||
1292 | t_failed++; | ||
1293 | c_failed[i] = ! 0; | ||
1294 | fprintf (stderr, | ||
1295 | "FAILED: MHD_str_to_uint64_(\"%s\", &ret_val) modified value of ret_val" | ||
1296 | " (before call: %" PRIu64 ", after call %" PRIu64 | ||
1297 | "). Locale: %s\n", | ||
1298 | n_prnt (t->str), test_val, rv, get_current_locale_str ()); | ||
1299 | } | ||
1300 | } | ||
1301 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) | ||
1302 | printf ( | ||
1303 | "PASSED: MHD_str_to_uint64_(\"%s\", &ret_val) == 0, value of ret_val is unmodified\n", | ||
1304 | n_prnt (t->str)); | ||
1209 | } | 1305 | } |
1306 | } | ||
1210 | return t_failed; | 1307 | return t_failed; |
1211 | } | 1308 | } |
1212 | 1309 | ||
1213 | 1310 | ||
1214 | int check_str_to_uint64_no_val(void) | 1311 | int check_str_to_uint64_no_val (void) |
1215 | { | 1312 | { |
1216 | size_t t_failed = 0; | 1313 | size_t t_failed = 0; |
1217 | size_t i, j; | 1314 | size_t i, j; |
1218 | static const size_t n_checks = sizeof(str_no_num) / sizeof(str_no_num[0]); | 1315 | static const size_t n_checks = sizeof(str_no_num) / sizeof(str_no_num[0]); |
1219 | int c_failed[n_checks]; | 1316 | int c_failed[n_checks]; |
1220 | 1317 | ||
1221 | memset(c_failed, 0, sizeof(c_failed)); | 1318 | memset (c_failed, 0, sizeof(c_failed)); |
1222 | 1319 | ||
1223 | for(j = 0; j < locale_name_count; j++) | 1320 | for (j = 0; j < locale_name_count; j++) |
1321 | { | ||
1322 | set_test_locale (j); /* setlocale() can be slow! */ | ||
1323 | for (i = 0; i < n_checks; i++) | ||
1224 | { | 1324 | { |
1225 | set_test_locale(j); /* setlocale() can be slow! */ | 1325 | size_t rs; |
1226 | for(i = 0; i < n_checks; i++) | 1326 | const struct str_with_len *const t = str_no_num + i; |
1327 | static const uint64_t rnd_val = 74218431; | ||
1328 | uint64_t test_val; | ||
1329 | |||
1330 | for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += | ||
1331 | rnd_val) | ||
1332 | { | ||
1333 | uint64_t rv = test_val; | ||
1334 | |||
1335 | rs = MHD_str_to_uint64_ (t->str, &rv); | ||
1336 | if (rs != 0) | ||
1227 | { | 1337 | { |
1228 | size_t rs; | 1338 | t_failed++; |
1229 | const struct str_with_len * const t = str_no_num + i; | 1339 | c_failed[i] = ! 0; |
1230 | static const uint64_t rnd_val = 74218431; | 1340 | fprintf (stderr, |
1231 | uint64_t test_val; | 1341 | "FAILED: MHD_str_to_uint64_(\"%s\", ->%" PRIu64 |
1232 | 1342 | ") returned %" PRIuPTR | |
1233 | for(test_val = 0; test_val <= rnd_val && !c_failed[i]; test_val += rnd_val) | 1343 | ", while expecting zero." |
1234 | { | 1344 | " Locale: %s\n", n_prnt (t->str), rv, (uintptr_t) rs, |
1235 | uint64_t rv = test_val; | 1345 | get_current_locale_str ()); |
1236 | |||
1237 | rs = MHD_str_to_uint64_(t->str, &rv); | ||
1238 | if (rs != 0) | ||
1239 | { | ||
1240 | t_failed++; | ||
1241 | c_failed[i] = !0; | ||
1242 | fprintf(stderr, "FAILED: MHD_str_to_uint64_(\"%s\", ->%" PRIu64 ") returned %" PRIuPTR ", while expecting zero." | ||
1243 | " Locale: %s\n", n_prnt(t->str), rv, (uintptr_t)rs, get_current_locale_str()); | ||
1244 | } | ||
1245 | else if (rv != test_val) | ||
1246 | { | ||
1247 | t_failed++; | ||
1248 | c_failed[i] = !0; | ||
1249 | fprintf(stderr, "FAILED: MHD_str_to_uint64_(\"%s\", &ret_val) modified value of ret_val" | ||
1250 | " (before call: %" PRIu64 ", after call %" PRIu64 "). Locale: %s\n", | ||
1251 | n_prnt(t->str), test_val, rv, get_current_locale_str()); | ||
1252 | } | ||
1253 | } | ||
1254 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i]) | ||
1255 | printf("PASSED: MHD_str_to_uint64_(\"%s\", &ret_val) == 0, value of ret_val is unmodified\n", | ||
1256 | n_prnt(t->str)); | ||
1257 | } | 1346 | } |
1347 | else if (rv != test_val) | ||
1348 | { | ||
1349 | t_failed++; | ||
1350 | c_failed[i] = ! 0; | ||
1351 | fprintf (stderr, | ||
1352 | "FAILED: MHD_str_to_uint64_(\"%s\", &ret_val) modified value of ret_val" | ||
1353 | " (before call: %" PRIu64 ", after call %" PRIu64 | ||
1354 | "). Locale: %s\n", | ||
1355 | n_prnt (t->str), test_val, rv, get_current_locale_str ()); | ||
1356 | } | ||
1357 | } | ||
1358 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) | ||
1359 | printf ( | ||
1360 | "PASSED: MHD_str_to_uint64_(\"%s\", &ret_val) == 0, value of ret_val is unmodified\n", | ||
1361 | n_prnt (t->str)); | ||
1258 | } | 1362 | } |
1363 | } | ||
1259 | return t_failed; | 1364 | return t_failed; |
1260 | } | 1365 | } |
1261 | 1366 | ||
1262 | 1367 | ||
1263 | int check_str_to_uint64_n_valid(void) | 1368 | int check_str_to_uint64_n_valid (void) |
1264 | { | 1369 | { |
1265 | size_t t_failed = 0; | 1370 | size_t t_failed = 0; |
1266 | size_t i, j; | 1371 | size_t i, j; |
1267 | static const size_t n_checks = sizeof(dstrs_w_values) / sizeof(dstrs_w_values[0]); | 1372 | static const size_t n_checks = sizeof(dstrs_w_values) |
1373 | / sizeof(dstrs_w_values[0]); | ||
1268 | int c_failed[n_checks]; | 1374 | int c_failed[n_checks]; |
1269 | 1375 | ||
1270 | memset(c_failed, 0, sizeof(c_failed)); | 1376 | memset (c_failed, 0, sizeof(c_failed)); |
1271 | 1377 | ||
1272 | for(j = 0; j < locale_name_count; j++) | 1378 | for (j = 0; j < locale_name_count; j++) |
1379 | { | ||
1380 | set_test_locale (j); /* setlocale() can be slow! */ | ||
1381 | for (i = 0; i < n_checks; i++) | ||
1273 | { | 1382 | { |
1274 | set_test_locale(j); /* setlocale() can be slow! */ | 1383 | uint64_t rv = 1235572; /* some random value */ |
1275 | for(i = 0; i < n_checks; i++) | 1384 | size_t rs = 0; |
1385 | size_t len; | ||
1386 | const struct str_with_value *const t = dstrs_w_values + i; | ||
1387 | |||
1388 | if (t->str.len < t->num_of_digt) | ||
1389 | { | ||
1390 | fprintf (stderr, | ||
1391 | "ERROR: dstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" | ||
1392 | " to be less or equal to str.len (%u).\n", | ||
1393 | (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned | ||
1394 | int) t->str. | ||
1395 | len); | ||
1396 | return -1; | ||
1397 | } | ||
1398 | for (len = t->num_of_digt; len <= t->str.len + 1 && ! c_failed[i]; len++) | ||
1399 | { | ||
1400 | rs = MHD_str_to_uint64_n_ (t->str.str, len, &rv); | ||
1401 | if (rs != t->num_of_digt) | ||
1276 | { | 1402 | { |
1277 | uint64_t rv = 1235572; /* some random value */ | 1403 | t_failed++; |
1278 | size_t rs = 0; | 1404 | c_failed[i] = ! 0; |
1279 | size_t len; | 1405 | fprintf (stderr, |
1280 | const struct str_with_value * const t = dstrs_w_values + i; | 1406 | "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR ", ->%" |
1281 | 1407 | PRIu64 ")" | |
1282 | if (t->str.len < t->num_of_digt) | 1408 | " returned %" PRIuPTR ", while expecting %d. Locale: %s\n", |
1283 | { | 1409 | n_prnt (t->str.str), (intptr_t) len, rv, (intptr_t) rs, |
1284 | fprintf(stderr, "ERROR: dstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" | 1410 | (int) t->num_of_digt, get_current_locale_str ()); |
1285 | " to be less or equal to str.len (%u).\n", | ||
1286 | (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned int) t->str.len); | ||
1287 | return -1; | ||
1288 | } | ||
1289 | for (len = t->num_of_digt; len <= t->str.len + 1 && !c_failed[i]; len++) | ||
1290 | { | ||
1291 | rs = MHD_str_to_uint64_n_(t->str.str, len, &rv); | ||
1292 | if (rs != t->num_of_digt) | ||
1293 | { | ||
1294 | t_failed++; | ||
1295 | c_failed[i] = !0; | ||
1296 | fprintf(stderr, "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR ", ->%" PRIu64 ")" | ||
1297 | " returned %" PRIuPTR ", while expecting %d. Locale: %s\n", | ||
1298 | n_prnt(t->str.str), (intptr_t)len, rv, (intptr_t)rs, | ||
1299 | (int)t->num_of_digt, get_current_locale_str()); | ||
1300 | } | ||
1301 | if (rv != t->val) | ||
1302 | { | ||
1303 | t_failed++; | ||
1304 | c_failed[i] = !0; | ||
1305 | fprintf(stderr, "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR ", ->%" PRIu64 ")" | ||
1306 | " converted string to value %" PRIu64 ", while expecting result %" PRIu64 | ||
1307 | ". Locale: %s\n", n_prnt(t->str.str), (intptr_t)len, rv, rv, | ||
1308 | t->val, get_current_locale_str()); | ||
1309 | } | ||
1310 | } | ||
1311 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i]) | ||
1312 | printf("PASSED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR "..%" PRIuPTR ", ->%" PRIu64 ")" | ||
1313 | " == %" PRIuPTR "\n", n_prnt(t->str.str), (intptr_t)t->num_of_digt, | ||
1314 | (intptr_t)t->str.len + 1, rv, rs); | ||
1315 | } | 1411 | } |
1412 | if (rv != t->val) | ||
1413 | { | ||
1414 | t_failed++; | ||
1415 | c_failed[i] = ! 0; | ||
1416 | fprintf (stderr, | ||
1417 | "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR ", ->%" | ||
1418 | PRIu64 ")" | ||
1419 | " converted string to value %" PRIu64 | ||
1420 | ", while expecting result %" PRIu64 | ||
1421 | ". Locale: %s\n", n_prnt (t->str.str), (intptr_t) len, rv, | ||
1422 | rv, | ||
1423 | t->val, get_current_locale_str ()); | ||
1424 | } | ||
1425 | } | ||
1426 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) | ||
1427 | printf ( | ||
1428 | "PASSED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR "..%" PRIuPTR ", ->%" | ||
1429 | PRIu64 ")" | ||
1430 | " == %" PRIuPTR "\n", n_prnt (t->str.str), | ||
1431 | (intptr_t) t->num_of_digt, | ||
1432 | (intptr_t) t->str.len + 1, rv, rs); | ||
1316 | } | 1433 | } |
1434 | } | ||
1317 | return t_failed; | 1435 | return t_failed; |
1318 | } | 1436 | } |
1319 | 1437 | ||
1320 | 1438 | ||
1321 | int check_str_to_uint64_n_all_chars(void) | 1439 | int check_str_to_uint64_n_all_chars (void) |
1322 | { | 1440 | { |
1323 | static const size_t n_checks = 256; /* from 0 to 255 */ | 1441 | static const size_t n_checks = 256; /* from 0 to 255 */ |
1324 | int c_failed[n_checks]; | 1442 | int c_failed[n_checks]; |
1325 | size_t t_failed = 0; | 1443 | size_t t_failed = 0; |
1326 | size_t j; | 1444 | size_t j; |
1327 | 1445 | ||
1328 | memset(c_failed, 0, sizeof(c_failed)); | 1446 | memset (c_failed, 0, sizeof(c_failed)); |
1447 | |||
1448 | for (j = 0; j < locale_name_count; j++) | ||
1449 | { | ||
1450 | unsigned int c; | ||
1451 | uint64_t test_val; | ||
1329 | 1452 | ||
1330 | for(j = 0; j < locale_name_count; j++) | 1453 | set_test_locale (j); /* setlocale() can be slow! */ |
1454 | for (c = 0; c < n_checks; c++) | ||
1331 | { | 1455 | { |
1332 | unsigned int c; | 1456 | static const uint64_t rnd_val = 98372558; |
1333 | uint64_t test_val; | 1457 | size_t rs; |
1458 | size_t len; | ||
1334 | 1459 | ||
1335 | set_test_locale(j); /* setlocale() can be slow! */ | 1460 | if ((c >= '0') &&(c <= '9') ) |
1336 | for(c = 0; c < n_checks; c++) | 1461 | continue; /* skip digits */ |
1462 | |||
1463 | for (len = 0; len <= 5; len++) | ||
1464 | { | ||
1465 | for (test_val = 0; test_val <= rnd_val&& ! c_failed[c]; test_val += | ||
1466 | rnd_val) | ||
1337 | { | 1467 | { |
1338 | static const uint64_t rnd_val = 98372558; | 1468 | char test_str[] = "0123"; |
1339 | size_t rs; | 1469 | uint64_t rv = test_val; |
1340 | size_t len; | 1470 | |
1341 | 1471 | test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ | |
1342 | if (c >= '0' && c <= '9') | 1472 | rs = MHD_str_to_uint64_n_ (test_str, len, &rv); |
1343 | continue; /* skip digits */ | 1473 | if (rs != 0) |
1344 | 1474 | { | |
1345 | for (len = 0; len <= 5; len++) | 1475 | t_failed++; |
1346 | { | 1476 | c_failed[c] = ! 0; |
1347 | for(test_val = 0; test_val <= rnd_val&& !c_failed[c]; test_val += rnd_val) | 1477 | fprintf (stderr, |
1348 | { | 1478 | "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR ", ->%" |
1349 | char test_str[] = "0123"; | 1479 | PRIu64 ")" |
1350 | uint64_t rv = test_val; | 1480 | " returned %" PRIuPTR |
1351 | 1481 | ", while expecting zero. Locale: %s\n", | |
1352 | test_str[0] = (char) (unsigned char)c; /* replace first char with non-digit char */ | 1482 | n_prnt (test_str), (uintptr_t) len, rv, (uintptr_t) rs, |
1353 | rs = MHD_str_to_uint64_n_(test_str, len, &rv); | 1483 | get_current_locale_str ()); |
1354 | if (rs != 0) | 1484 | } |
1355 | { | 1485 | else if (rv != test_val) |
1356 | t_failed++; | 1486 | { |
1357 | c_failed[c] = !0; | 1487 | t_failed++; |
1358 | fprintf(stderr, "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR ", ->%" PRIu64 ")" | 1488 | c_failed[c] = ! 0; |
1359 | " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", | 1489 | fprintf (stderr, |
1360 | n_prnt(test_str), (uintptr_t)len, rv, (uintptr_t)rs, get_current_locale_str()); | 1490 | "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR |
1361 | } | 1491 | ", &ret_val)" |
1362 | else if (rv != test_val) | 1492 | " modified value of ret_val (before call: %" PRIu64 |
1363 | { | 1493 | ", after call %" PRIu64 ")." |
1364 | t_failed++; | 1494 | " Locale: %s\n", |
1365 | c_failed[c] = !0; | 1495 | n_prnt (test_str), (uintptr_t) len, test_val, rv, |
1366 | fprintf(stderr, "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR ", &ret_val)" | 1496 | get_current_locale_str ()); |
1367 | " modified value of ret_val (before call: %" PRIu64 ", after call %" PRIu64 ")." | 1497 | } |
1368 | " Locale: %s\n", | ||
1369 | n_prnt(test_str), (uintptr_t)len, test_val, rv, get_current_locale_str()); | ||
1370 | } | ||
1371 | } | ||
1372 | } | ||
1373 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[c]) | ||
1374 | { | ||
1375 | char test_str[] = "0123"; | ||
1376 | test_str[0] = (char) (unsigned char)c; /* replace first char with non-digit char */ | ||
1377 | |||
1378 | printf("PASSED: MHD_str_to_uint64_n_(\"%s\", 0..5, &ret_val) == 0, value of ret_val is unmodified\n", | ||
1379 | n_prnt(test_str)); | ||
1380 | } | ||
1381 | } | 1498 | } |
1499 | } | ||
1500 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[c]) | ||
1501 | { | ||
1502 | char test_str[] = "0123"; | ||
1503 | test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ | ||
1504 | |||
1505 | printf ( | ||
1506 | "PASSED: MHD_str_to_uint64_n_(\"%s\", 0..5, &ret_val) == 0, value of ret_val is unmodified\n", | ||
1507 | n_prnt (test_str)); | ||
1508 | } | ||
1382 | } | 1509 | } |
1510 | } | ||
1383 | return t_failed; | 1511 | return t_failed; |
1384 | } | 1512 | } |
1385 | 1513 | ||
1386 | 1514 | ||
1387 | int check_str_to_uint64_n_overflow(void) | 1515 | int check_str_to_uint64_n_overflow (void) |
1388 | { | 1516 | { |
1389 | size_t t_failed = 0; | 1517 | size_t t_failed = 0; |
1390 | size_t i, j; | 1518 | size_t i, j; |
1391 | static const size_t n_checks = sizeof(str_ovflw) / sizeof(str_ovflw[0]); | 1519 | static const size_t n_checks = sizeof(str_ovflw) / sizeof(str_ovflw[0]); |
1392 | int c_failed[n_checks]; | 1520 | int c_failed[n_checks]; |
1393 | 1521 | ||
1394 | memset(c_failed, 0, sizeof(c_failed)); | 1522 | memset (c_failed, 0, sizeof(c_failed)); |
1395 | 1523 | ||
1396 | for(j = 0; j < locale_name_count; j++) | 1524 | for (j = 0; j < locale_name_count; j++) |
1525 | { | ||
1526 | set_test_locale (j); /* setlocale() can be slow! */ | ||
1527 | for (i = 0; i < n_checks; i++) | ||
1397 | { | 1528 | { |
1398 | set_test_locale(j); /* setlocale() can be slow! */ | 1529 | size_t rs; |
1399 | for(i = 0; i < n_checks; i++) | 1530 | const struct str_with_len *const t = str_ovflw + i; |
1531 | static const uint64_t rnd_val = 3; | ||
1532 | size_t len; | ||
1533 | |||
1534 | for (len = t->len; len <= t->len + 1; len++) | ||
1535 | { | ||
1536 | uint64_t test_val; | ||
1537 | for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += | ||
1538 | rnd_val) | ||
1400 | { | 1539 | { |
1401 | size_t rs; | 1540 | uint64_t rv = test_val; |
1402 | const struct str_with_len * const t = str_ovflw + i; | 1541 | |
1403 | static const uint64_t rnd_val = 3; | 1542 | rs = MHD_str_to_uint64_n_ (t->str, len, &rv); |
1404 | size_t len; | 1543 | if (rs != 0) |
1405 | 1544 | { | |
1406 | for (len = t->len; len <= t->len + 1; len++) | 1545 | t_failed++; |
1407 | { | 1546 | c_failed[i] = ! 0; |
1408 | uint64_t test_val; | 1547 | fprintf (stderr, |
1409 | for(test_val = 0; test_val <= rnd_val && !c_failed[i]; test_val += rnd_val) | 1548 | "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR ", ->%" |
1410 | { | 1549 | PRIu64 ")" |
1411 | uint64_t rv = test_val; | 1550 | " returned %" PRIuPTR |
1412 | 1551 | ", while expecting zero. Locale: %s\n", | |
1413 | rs = MHD_str_to_uint64_n_(t->str, len, &rv); | 1552 | n_prnt (t->str), (uintptr_t) len, rv, (uintptr_t) rs, |
1414 | if (rs != 0) | 1553 | get_current_locale_str ()); |
1415 | { | 1554 | } |
1416 | t_failed++; | 1555 | else if (rv != test_val) |
1417 | c_failed[i] = !0; | 1556 | { |
1418 | fprintf(stderr, "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR ", ->%" PRIu64 ")" | 1557 | t_failed++; |
1419 | " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", | 1558 | c_failed[i] = ! 0; |
1420 | n_prnt(t->str), (uintptr_t)len, rv, (uintptr_t)rs, get_current_locale_str()); | 1559 | fprintf (stderr, |
1421 | } | 1560 | "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR |
1422 | else if (rv != test_val) | 1561 | ", &ret_val)" |
1423 | { | 1562 | " modified value of ret_val (before call: %" PRIu64 |
1424 | t_failed++; | 1563 | ", after call %" PRIu64 ")." |
1425 | c_failed[i] = !0; | 1564 | " Locale: %s\n", n_prnt (t->str), (uintptr_t) len, |
1426 | fprintf(stderr, "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR ", &ret_val)" | 1565 | test_val, rv, |
1427 | " modified value of ret_val (before call: %" PRIu64 ", after call %" PRIu64 ")." | 1566 | get_current_locale_str ()); |
1428 | " Locale: %s\n", n_prnt(t->str), (uintptr_t)len, test_val, rv, | 1567 | } |
1429 | get_current_locale_str()); | ||
1430 | } | ||
1431 | } | ||
1432 | } | ||
1433 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i]) | ||
1434 | printf("PASSED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR "..%" PRIuPTR ", &ret_val) == 0," | ||
1435 | " value of ret_val is unmodified\n", n_prnt(t->str), (uintptr_t)t->len, | ||
1436 | (uintptr_t)t->len + 1); | ||
1437 | } | 1568 | } |
1569 | } | ||
1570 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) | ||
1571 | printf ( | ||
1572 | "PASSED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR "..%" PRIuPTR | ||
1573 | ", &ret_val) == 0," | ||
1574 | " value of ret_val is unmodified\n", n_prnt (t->str), | ||
1575 | (uintptr_t) t->len, | ||
1576 | (uintptr_t) t->len + 1); | ||
1438 | } | 1577 | } |
1578 | } | ||
1439 | return t_failed; | 1579 | return t_failed; |
1440 | } | 1580 | } |
1441 | 1581 | ||
1442 | 1582 | ||
1443 | int check_str_to_uint64_n_no_val(void) | 1583 | int check_str_to_uint64_n_no_val (void) |
1444 | { | 1584 | { |
1445 | size_t t_failed = 0; | 1585 | size_t t_failed = 0; |
1446 | size_t i, j; | 1586 | size_t i, j; |
1447 | static const size_t n_checks = sizeof(str_no_num) / sizeof(str_no_num[0]); | 1587 | static const size_t n_checks = sizeof(str_no_num) / sizeof(str_no_num[0]); |
1448 | int c_failed[n_checks]; | 1588 | int c_failed[n_checks]; |
1449 | 1589 | ||
1450 | memset(c_failed, 0, sizeof(c_failed)); | 1590 | memset (c_failed, 0, sizeof(c_failed)); |
1451 | 1591 | ||
1452 | for(j = 0; j < locale_name_count; j++) | 1592 | for (j = 0; j < locale_name_count; j++) |
1593 | { | ||
1594 | set_test_locale (j); /* setlocale() can be slow! */ | ||
1595 | for (i = 0; i < n_checks; i++) | ||
1453 | { | 1596 | { |
1454 | set_test_locale(j); /* setlocale() can be slow! */ | 1597 | size_t rs; |
1455 | for(i = 0; i < n_checks; i++) | 1598 | const struct str_with_len *const t = str_no_num + i; |
1599 | static const uint64_t rnd_val = 43255654342; | ||
1600 | size_t len; | ||
1601 | |||
1602 | for (len = 0; len <= t->len + 1; len++) | ||
1603 | { | ||
1604 | uint64_t test_val; | ||
1605 | for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += | ||
1606 | rnd_val) | ||
1456 | { | 1607 | { |
1457 | size_t rs; | 1608 | uint64_t rv = test_val; |
1458 | const struct str_with_len * const t = str_no_num + i; | 1609 | |
1459 | static const uint64_t rnd_val = 43255654342; | 1610 | rs = MHD_str_to_uint64_n_ (t->str, len, &rv); |
1460 | size_t len; | 1611 | if (rs != 0) |
1461 | 1612 | { | |
1462 | for (len = 0; len <= t->len + 1; len++) | 1613 | t_failed++; |
1463 | { | 1614 | c_failed[i] = ! 0; |
1464 | uint64_t test_val; | 1615 | fprintf (stderr, |
1465 | for(test_val = 0; test_val <= rnd_val && !c_failed[i]; test_val += rnd_val) | 1616 | "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR ", ->%" |
1466 | { | 1617 | PRIu64 ")" |
1467 | uint64_t rv = test_val; | 1618 | " returned %" PRIuPTR |
1468 | 1619 | ", while expecting zero. Locale: %s\n", | |
1469 | rs = MHD_str_to_uint64_n_(t->str, len, &rv); | 1620 | n_prnt (t->str), (uintptr_t) len, rv, (uintptr_t) rs, |
1470 | if (rs != 0) | 1621 | get_current_locale_str ()); |
1471 | { | 1622 | } |
1472 | t_failed++; | 1623 | else if (rv != test_val) |
1473 | c_failed[i] = !0; | 1624 | { |
1474 | fprintf(stderr, "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR ", ->%" PRIu64 ")" | 1625 | t_failed++; |
1475 | " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", | 1626 | c_failed[i] = ! 0; |
1476 | n_prnt(t->str), (uintptr_t)len, rv, (uintptr_t)rs, get_current_locale_str()); | 1627 | fprintf (stderr, |
1477 | } | 1628 | "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR |
1478 | else if (rv != test_val) | 1629 | ", &ret_val)" |
1479 | { | 1630 | " modified value of ret_val (before call: %" PRIu64 |
1480 | t_failed++; | 1631 | ", after call %" PRIu64 ")." |
1481 | c_failed[i] = !0; | 1632 | " Locale: %s\n", n_prnt (t->str), (uintptr_t) len, |
1482 | fprintf(stderr, "FAILED: MHD_str_to_uint64_n_(\"%s\", %" PRIuPTR ", &ret_val)" | 1633 | test_val, rv, |
1483 | " modified value of ret_val (before call: %" PRIu64 ", after call %" PRIu64 ")." | 1634 | get_current_locale_str ()); |
1484 | " Locale: %s\n", n_prnt(t->str), (uintptr_t)len, test_val, rv, | 1635 | } |
1485 | get_current_locale_str()); | ||
1486 | } | ||
1487 | } | ||
1488 | } | ||
1489 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i]) | ||
1490 | printf("PASSED: MHD_str_to_uint64_n_(\"%s\", 0..%" PRIuPTR ", &ret_val) == 0," | ||
1491 | " value of ret_val is unmodified\n", n_prnt(t->str), | ||
1492 | (uintptr_t)t->len + 1); | ||
1493 | } | 1636 | } |
1637 | } | ||
1638 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) | ||
1639 | printf ( | ||
1640 | "PASSED: MHD_str_to_uint64_n_(\"%s\", 0..%" PRIuPTR | ||
1641 | ", &ret_val) == 0," | ||
1642 | " value of ret_val is unmodified\n", n_prnt (t->str), | ||
1643 | (uintptr_t) t->len + 1); | ||
1494 | } | 1644 | } |
1645 | } | ||
1495 | return t_failed; | 1646 | return t_failed; |
1496 | } | 1647 | } |
1497 | 1648 | ||
1498 | 1649 | ||
1499 | int check_strx_to_uint32_valid(void) | 1650 | int check_strx_to_uint32_valid (void) |
1500 | { | 1651 | { |
1501 | size_t t_failed = 0; | 1652 | size_t t_failed = 0; |
1502 | size_t i, j; | 1653 | size_t i, j; |
1503 | static const size_t n_checks = sizeof(xdstrs_w_values) / sizeof(xdstrs_w_values[0]); | 1654 | static const size_t n_checks = sizeof(xdstrs_w_values) |
1655 | / sizeof(xdstrs_w_values[0]); | ||
1504 | int c_failed[n_checks]; | 1656 | int c_failed[n_checks]; |
1505 | 1657 | ||
1506 | memset(c_failed, 0, sizeof(c_failed)); | 1658 | memset (c_failed, 0, sizeof(c_failed)); |
1507 | 1659 | ||
1508 | for(j = 0; j < locale_name_count; j++) | 1660 | for (j = 0; j < locale_name_count; j++) |
1661 | { | ||
1662 | set_test_locale (j); /* setlocale() can be slow! */ | ||
1663 | for (i = 0; i < n_checks; i++) | ||
1509 | { | 1664 | { |
1510 | set_test_locale(j); /* setlocale() can be slow! */ | 1665 | uint32_t rv; |
1511 | for(i = 0; i < n_checks; i++) | 1666 | size_t rs; |
1512 | { | 1667 | const struct str_with_value *const t = xdstrs_w_values + i; |
1513 | uint32_t rv; | 1668 | |
1514 | size_t rs; | 1669 | if (t->val > UINT32_MAX) |
1515 | const struct str_with_value * const t = xdstrs_w_values + i; | 1670 | continue; /* number is too high for this function */ |
1516 | 1671 | ||
1517 | if (t->val > UINT32_MAX) | 1672 | if (c_failed[i]) |
1518 | continue; /* number is too high for this function */ | 1673 | continue; /* skip already failed checks */ |
1519 | 1674 | ||
1520 | if (c_failed[i]) | 1675 | if (t->str.len < t->num_of_digt) |
1521 | continue; /* skip already failed checks */ | 1676 | { |
1522 | 1677 | fprintf (stderr, | |
1523 | if (t->str.len < t->num_of_digt) | 1678 | "ERROR: xdstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" |
1524 | { | 1679 | " to be less or equal to str.len (%u).\n", |
1525 | fprintf(stderr, "ERROR: xdstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" | 1680 | (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned |
1526 | " to be less or equal to str.len (%u).\n", | 1681 | int) t->str. |
1527 | (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned int) t->str.len); | 1682 | len); |
1528 | return -1; | 1683 | return -1; |
1529 | } | 1684 | } |
1530 | rv = 1458532; /* some random value */ | 1685 | rv = 1458532; /* some random value */ |
1531 | rs = MHD_strx_to_uint32_(t->str.str, &rv); | 1686 | rs = MHD_strx_to_uint32_ (t->str.str, &rv); |
1532 | if (rs != t->num_of_digt) | 1687 | if (rs != t->num_of_digt) |
1533 | { | 1688 | { |
1534 | t_failed++; | 1689 | t_failed++; |
1535 | c_failed[i] = !0; | 1690 | c_failed[i] = ! 0; |
1536 | fprintf(stderr, "FAILED: MHD_strx_to_uint32_(\"%s\", ->0x%" PRIX64 ") returned %" PRIuPTR ", while expecting %d." | 1691 | fprintf (stderr, |
1537 | " Locale: %s\n", n_prnt(t->str.str), (uint64_t)rv, (intptr_t)rs, (int)t->num_of_digt, get_current_locale_str()); | 1692 | "FAILED: MHD_strx_to_uint32_(\"%s\", ->0x%" PRIX64 |
1538 | } | 1693 | ") returned %" |
1539 | if (rv != t->val) | 1694 | PRIuPTR ", while expecting %d." |
1540 | { | 1695 | " Locale: %s\n", n_prnt (t->str.str), (uint64_t) rv, |
1541 | t_failed++; | 1696 | (intptr_t) rs, (int) t->num_of_digt, |
1542 | c_failed[i] = !0; | 1697 | get_current_locale_str ()); |
1543 | fprintf(stderr, "FAILED: MHD_strx_to_uint32_(\"%s\", ->0x%" PRIX64 ") converted string to value 0x%" PRIX64 "," | 1698 | } |
1544 | " while expecting result 0x%" PRIX64 ". Locale: %s\n", n_prnt(t->str.str), (uint64_t)rv, (uint64_t)rv, | 1699 | if (rv != t->val) |
1545 | t->val, get_current_locale_str()); | 1700 | { |
1546 | } | 1701 | t_failed++; |
1547 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i]) | 1702 | c_failed[i] = ! 0; |
1548 | printf("PASSED: MHD_strx_to_uint32_(\"%s\", ->0x%" PRIX64 ") == %" PRIuPTR "\n", | 1703 | fprintf (stderr, |
1549 | n_prnt(t->str.str), (uint64_t)rv, rs); | 1704 | "FAILED: MHD_strx_to_uint32_(\"%s\", ->0x%" PRIX64 |
1550 | } | 1705 | ") converted string to value 0x%" |
1706 | PRIX64 "," | ||
1707 | " while expecting result 0x%" PRIX64 ". Locale: %s\n", n_prnt ( | ||
1708 | t->str.str), (uint64_t) rv, (uint64_t) rv, | ||
1709 | t->val, get_current_locale_str ()); | ||
1710 | } | ||
1711 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) | ||
1712 | printf ( | ||
1713 | "PASSED: MHD_strx_to_uint32_(\"%s\", ->0x%" PRIX64 ") == %" PRIuPTR | ||
1714 | "\n", | ||
1715 | n_prnt (t->str.str), (uint64_t) rv, rs); | ||
1551 | } | 1716 | } |
1717 | } | ||
1552 | return t_failed; | 1718 | return t_failed; |
1553 | } | 1719 | } |
1554 | 1720 | ||
1555 | 1721 | ||
1556 | int check_strx_to_uint32_all_chars(void) | 1722 | int check_strx_to_uint32_all_chars (void) |
1557 | { | 1723 | { |
1558 | static const size_t n_checks = 256; /* from 0 to 255 */ | 1724 | static const size_t n_checks = 256; /* from 0 to 255 */ |
1559 | int c_failed[n_checks]; | 1725 | int c_failed[n_checks]; |
1560 | size_t t_failed = 0; | 1726 | size_t t_failed = 0; |
1561 | size_t j; | 1727 | size_t j; |
1562 | 1728 | ||
1563 | memset(c_failed, 0, sizeof(c_failed)); | 1729 | memset (c_failed, 0, sizeof(c_failed)); |
1564 | 1730 | ||
1565 | for(j = 0; j < locale_name_count; j++) | 1731 | for (j = 0; j < locale_name_count; j++) |
1566 | { | 1732 | { |
1567 | unsigned int c; | 1733 | unsigned int c; |
1568 | uint32_t test_val; | 1734 | uint32_t test_val; |
1569 | 1735 | ||
1570 | set_test_locale(j); /* setlocale() can be slow! */ | 1736 | set_test_locale (j); /* setlocale() can be slow! */ |
1571 | for(c = 0; c < n_checks; c++) | 1737 | for (c = 0; c < n_checks; c++) |
1738 | { | ||
1739 | static const uint32_t rnd_val = 234234; | ||
1740 | size_t rs; | ||
1741 | if (((c >= '0') &&(c <= '9') ) || ((c >= 'A') &&(c <= 'F') ) ||((c >= | ||
1742 | 'a') && | ||
1743 | (c <= | ||
1744 | 'f') )) | ||
1745 | continue; /* skip xdigits */ | ||
1746 | for (test_val = 0; test_val <= rnd_val&& ! c_failed[c]; test_val += | ||
1747 | rnd_val) | ||
1748 | { | ||
1749 | char test_str[] = "0123"; | ||
1750 | uint32_t rv = test_val; | ||
1751 | |||
1752 | test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ | ||
1753 | rs = MHD_strx_to_uint32_ (test_str, &rv); | ||
1754 | if (rs != 0) | ||
1572 | { | 1755 | { |
1573 | static const uint32_t rnd_val = 234234; | 1756 | t_failed++; |
1574 | size_t rs; | 1757 | c_failed[c] = ! 0; |
1575 | if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') ||(c >= 'a' && c <= 'f')) | 1758 | fprintf (stderr, |
1576 | continue; /* skip xdigits */ | 1759 | "FAILED: MHD_strx_to_uint32_(\"%s\", ->0x%" PRIX64 |
1577 | for(test_val = 0; test_val <= rnd_val&& !c_failed[c]; test_val += rnd_val) | 1760 | ") returned %" |
1578 | { | 1761 | PRIuPTR ", while expecting zero." |
1579 | char test_str[] = "0123"; | 1762 | " Locale: %s\n", n_prnt (test_str), (uint64_t) rv, |
1580 | uint32_t rv = test_val; | 1763 | (uintptr_t) rs, get_current_locale_str ()); |
1581 | |||
1582 | test_str[0] = (char) (unsigned char)c; /* replace first char with non-digit char */ | ||
1583 | rs = MHD_strx_to_uint32_(test_str, &rv); | ||
1584 | if (rs != 0) | ||
1585 | { | ||
1586 | t_failed++; | ||
1587 | c_failed[c] = !0; | ||
1588 | fprintf(stderr, "FAILED: MHD_strx_to_uint32_(\"%s\", ->0x%" PRIX64 ") returned %" PRIuPTR ", while expecting zero." | ||
1589 | " Locale: %s\n", n_prnt(test_str), (uint64_t)rv, (uintptr_t)rs, get_current_locale_str()); | ||
1590 | } | ||
1591 | else if (rv != test_val) | ||
1592 | { | ||
1593 | t_failed++; | ||
1594 | c_failed[c] = !0; | ||
1595 | fprintf(stderr, "FAILED: MHD_strx_to_uint32_(\"%s\", &ret_val) modified value of ret_val" | ||
1596 | " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 "). Locale: %s\n", | ||
1597 | n_prnt(test_str), (uint64_t)test_val, (uint64_t)rv, get_current_locale_str()); | ||
1598 | } | ||
1599 | } | ||
1600 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[c]) | ||
1601 | { | ||
1602 | char test_str[] = "0123"; | ||
1603 | test_str[0] = (char) (unsigned char)c; /* replace first char with non-digit char */ | ||
1604 | |||
1605 | printf("PASSED: MHD_strx_to_uint32_(\"%s\", &ret_val) == 0, value of ret_val is unmodified\n", | ||
1606 | n_prnt(test_str)); | ||
1607 | } | ||
1608 | } | 1764 | } |
1765 | else if (rv != test_val) | ||
1766 | { | ||
1767 | t_failed++; | ||
1768 | c_failed[c] = ! 0; | ||
1769 | fprintf (stderr, | ||
1770 | "FAILED: MHD_strx_to_uint32_(\"%s\", &ret_val) modified value of ret_val" | ||
1771 | " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 | ||
1772 | "). Locale: %s\n", | ||
1773 | n_prnt (test_str), (uint64_t) test_val, (uint64_t) rv, | ||
1774 | get_current_locale_str ()); | ||
1775 | } | ||
1776 | } | ||
1777 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[c]) | ||
1778 | { | ||
1779 | char test_str[] = "0123"; | ||
1780 | test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ | ||
1781 | |||
1782 | printf ( | ||
1783 | "PASSED: MHD_strx_to_uint32_(\"%s\", &ret_val) == 0, value of ret_val is unmodified\n", | ||
1784 | n_prnt (test_str)); | ||
1785 | } | ||
1609 | } | 1786 | } |
1787 | } | ||
1610 | return t_failed; | 1788 | return t_failed; |
1611 | } | 1789 | } |
1612 | 1790 | ||
1613 | 1791 | ||
1614 | int check_strx_to_uint32_overflow(void) | 1792 | int check_strx_to_uint32_overflow (void) |
1615 | { | 1793 | { |
1616 | size_t t_failed = 0; | 1794 | size_t t_failed = 0; |
1617 | size_t i, j; | 1795 | size_t i, j; |
1618 | static const size_t n_checks1 = sizeof(strx_ovflw) / sizeof(strx_ovflw[0]); | 1796 | static const size_t n_checks1 = sizeof(strx_ovflw) / sizeof(strx_ovflw[0]); |
1619 | static const size_t n_checks = sizeof(strx_ovflw) / sizeof(strx_ovflw[0]) + | 1797 | static const size_t n_checks = sizeof(strx_ovflw) / sizeof(strx_ovflw[0]) |
1620 | sizeof(xdstrs_w_values) / sizeof(xdstrs_w_values[0]); | 1798 | + sizeof(xdstrs_w_values) |
1799 | / sizeof(xdstrs_w_values[0]); | ||
1621 | int c_failed[n_checks]; | 1800 | int c_failed[n_checks]; |
1622 | 1801 | ||
1623 | memset(c_failed, 0, sizeof(c_failed)); | 1802 | memset (c_failed, 0, sizeof(c_failed)); |
1624 | 1803 | ||
1625 | for(j = 0; j < locale_name_count; j++) | 1804 | for (j = 0; j < locale_name_count; j++) |
1805 | { | ||
1806 | set_test_locale (j); /* setlocale() can be slow! */ | ||
1807 | for (i = 0; i < n_checks; i++) | ||
1626 | { | 1808 | { |
1627 | set_test_locale(j); /* setlocale() can be slow! */ | 1809 | size_t rs; |
1628 | for(i = 0; i < n_checks; i++) | 1810 | static const uint32_t rnd_val = 74218431; |
1811 | uint32_t test_val; | ||
1812 | const char *str; | ||
1813 | if (i < n_checks1) | ||
1814 | { | ||
1815 | const struct str_with_len *const t = strx_ovflw + i; | ||
1816 | str = t->str; | ||
1817 | } | ||
1818 | else | ||
1819 | { | ||
1820 | const struct str_with_value *const t = xdstrs_w_values + (i | ||
1821 | - n_checks1); | ||
1822 | if (t->val <= UINT32_MAX) | ||
1823 | continue; /* check only strings that should overflow uint32_t */ | ||
1824 | str = t->str.str; | ||
1825 | } | ||
1826 | |||
1827 | |||
1828 | for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += | ||
1829 | rnd_val) | ||
1830 | { | ||
1831 | uint32_t rv = test_val; | ||
1832 | |||
1833 | rs = MHD_strx_to_uint32_ (str, &rv); | ||
1834 | if (rs != 0) | ||
1629 | { | 1835 | { |
1630 | size_t rs; | 1836 | t_failed++; |
1631 | static const uint32_t rnd_val = 74218431; | 1837 | c_failed[i] = ! 0; |
1632 | uint32_t test_val; | 1838 | fprintf (stderr, |
1633 | const char * str; | 1839 | "FAILED: MHD_strx_to_uint32_(\"%s\", ->0x%" PRIX64 |
1634 | if (i < n_checks1) | 1840 | ") returned %" |
1635 | { | 1841 | PRIuPTR ", while expecting zero." |
1636 | const struct str_with_len * const t = strx_ovflw + i; | 1842 | " Locale: %s\n", n_prnt (str), (uint64_t) rv, (uintptr_t) rs, |
1637 | str = t->str; | 1843 | get_current_locale_str ()); |
1638 | } | ||
1639 | else | ||
1640 | { | ||
1641 | const struct str_with_value * const t = xdstrs_w_values + (i - n_checks1); | ||
1642 | if (t->val <= UINT32_MAX) | ||
1643 | continue; /* check only strings that should overflow uint32_t */ | ||
1644 | str = t->str.str; | ||
1645 | } | ||
1646 | |||
1647 | |||
1648 | for(test_val = 0; test_val <= rnd_val && !c_failed[i]; test_val += rnd_val) | ||
1649 | { | ||
1650 | uint32_t rv = test_val; | ||
1651 | |||
1652 | rs = MHD_strx_to_uint32_(str, &rv); | ||
1653 | if (rs != 0) | ||
1654 | { | ||
1655 | t_failed++; | ||
1656 | c_failed[i] = !0; | ||
1657 | fprintf(stderr, "FAILED: MHD_strx_to_uint32_(\"%s\", ->0x%" PRIX64 ") returned %" PRIuPTR ", while expecting zero." | ||
1658 | " Locale: %s\n", n_prnt(str), (uint64_t)rv, (uintptr_t)rs, get_current_locale_str()); | ||
1659 | } | ||
1660 | else if (rv != test_val) | ||
1661 | { | ||
1662 | t_failed++; | ||
1663 | c_failed[i] = !0; | ||
1664 | fprintf(stderr, "FAILED: MHD_strx_to_uint32_(\"%s\", &ret_val) modified value of ret_val" | ||
1665 | " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 "). Locale: %s\n", | ||
1666 | n_prnt(str), (uint64_t)test_val, (uint64_t)rv, get_current_locale_str()); | ||
1667 | } | ||
1668 | } | ||
1669 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i]) | ||
1670 | printf("PASSED: MHD_strx_to_uint32_(\"%s\", &ret_val) == 0, value of ret_val is unmodified\n", | ||
1671 | n_prnt(str)); | ||
1672 | } | 1844 | } |
1845 | else if (rv != test_val) | ||
1846 | { | ||
1847 | t_failed++; | ||
1848 | c_failed[i] = ! 0; | ||
1849 | fprintf (stderr, | ||
1850 | "FAILED: MHD_strx_to_uint32_(\"%s\", &ret_val) modified value of ret_val" | ||
1851 | " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 | ||
1852 | "). Locale: %s\n", | ||
1853 | n_prnt (str), (uint64_t) test_val, (uint64_t) rv, | ||
1854 | get_current_locale_str ()); | ||
1855 | } | ||
1856 | } | ||
1857 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) | ||
1858 | printf ( | ||
1859 | "PASSED: MHD_strx_to_uint32_(\"%s\", &ret_val) == 0, value of ret_val is unmodified\n", | ||
1860 | n_prnt (str)); | ||
1673 | } | 1861 | } |
1862 | } | ||
1674 | return t_failed; | 1863 | return t_failed; |
1675 | } | 1864 | } |
1676 | 1865 | ||
1677 | 1866 | ||
1678 | int check_strx_to_uint32_no_val(void) | 1867 | int check_strx_to_uint32_no_val (void) |
1679 | { | 1868 | { |
1680 | size_t t_failed = 0; | 1869 | size_t t_failed = 0; |
1681 | size_t i, j; | 1870 | size_t i, j; |
1682 | static const size_t n_checks = sizeof(str_no_num) / sizeof(str_no_num[0]); | 1871 | static const size_t n_checks = sizeof(str_no_num) / sizeof(str_no_num[0]); |
1683 | int c_failed[n_checks]; | 1872 | int c_failed[n_checks]; |
1684 | 1873 | ||
1685 | memset(c_failed, 0, sizeof(c_failed)); | 1874 | memset (c_failed, 0, sizeof(c_failed)); |
1686 | 1875 | ||
1687 | for(j = 0; j < locale_name_count; j++) | 1876 | for (j = 0; j < locale_name_count; j++) |
1877 | { | ||
1878 | set_test_locale (j); /* setlocale() can be slow! */ | ||
1879 | for (i = 0; i < n_checks; i++) | ||
1688 | { | 1880 | { |
1689 | set_test_locale(j); /* setlocale() can be slow! */ | 1881 | size_t rs; |
1690 | for(i = 0; i < n_checks; i++) | 1882 | const struct str_with_len *const t = str_no_num + i; |
1883 | static const uint32_t rnd_val = 74218431; | ||
1884 | uint32_t test_val; | ||
1885 | |||
1886 | for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += | ||
1887 | rnd_val) | ||
1888 | { | ||
1889 | uint32_t rv = test_val; | ||
1890 | |||
1891 | rs = MHD_strx_to_uint32_ (t->str, &rv); | ||
1892 | if (rs != 0) | ||
1691 | { | 1893 | { |
1692 | size_t rs; | 1894 | t_failed++; |
1693 | const struct str_with_len * const t = str_no_num + i; | 1895 | c_failed[i] = ! 0; |
1694 | static const uint32_t rnd_val = 74218431; | 1896 | fprintf (stderr, |
1695 | uint32_t test_val; | 1897 | "FAILED: MHD_strx_to_uint32_(\"%s\", ->0x%" PRIX64 |
1696 | 1898 | ") returned %" | |
1697 | for(test_val = 0; test_val <= rnd_val && !c_failed[i]; test_val += rnd_val) | 1899 | PRIuPTR ", while expecting zero." |
1698 | { | 1900 | " Locale: %s\n", n_prnt (t->str), (uint64_t) rv, |
1699 | uint32_t rv = test_val; | 1901 | (uintptr_t) rs, get_current_locale_str ()); |
1700 | |||
1701 | rs = MHD_strx_to_uint32_(t->str, &rv); | ||
1702 | if (rs != 0) | ||
1703 | { | ||
1704 | t_failed++; | ||
1705 | c_failed[i] = !0; | ||
1706 | fprintf(stderr, "FAILED: MHD_strx_to_uint32_(\"%s\", ->0x%" PRIX64 ") returned %" PRIuPTR ", while expecting zero." | ||
1707 | " Locale: %s\n", n_prnt(t->str), (uint64_t)rv, (uintptr_t)rs, get_current_locale_str()); | ||
1708 | } | ||
1709 | else if (rv != test_val) | ||
1710 | { | ||
1711 | t_failed++; | ||
1712 | c_failed[i] = !0; | ||
1713 | fprintf(stderr, "FAILED: MHD_strx_to_uint32_(\"%s\", &ret_val) modified value of ret_val" | ||
1714 | " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 "). Locale: %s\n", | ||
1715 | n_prnt(t->str), (uint64_t)test_val, (uint64_t)rv, get_current_locale_str()); | ||
1716 | } | ||
1717 | } | ||
1718 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i]) | ||
1719 | printf("PASSED: MHD_strx_to_uint32_(\"%s\", &ret_val) == 0, value of ret_val is unmodified\n", | ||
1720 | n_prnt(t->str)); | ||
1721 | } | 1902 | } |
1903 | else if (rv != test_val) | ||
1904 | { | ||
1905 | t_failed++; | ||
1906 | c_failed[i] = ! 0; | ||
1907 | fprintf (stderr, | ||
1908 | "FAILED: MHD_strx_to_uint32_(\"%s\", &ret_val) modified value of ret_val" | ||
1909 | " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 | ||
1910 | "). Locale: %s\n", | ||
1911 | n_prnt (t->str), (uint64_t) test_val, (uint64_t) rv, | ||
1912 | get_current_locale_str ()); | ||
1913 | } | ||
1914 | } | ||
1915 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) | ||
1916 | printf ( | ||
1917 | "PASSED: MHD_strx_to_uint32_(\"%s\", &ret_val) == 0, value of ret_val is unmodified\n", | ||
1918 | n_prnt (t->str)); | ||
1722 | } | 1919 | } |
1920 | } | ||
1723 | return t_failed; | 1921 | return t_failed; |
1724 | } | 1922 | } |
1725 | 1923 | ||
1726 | 1924 | ||
1727 | int check_strx_to_uint32_n_valid(void) | 1925 | int check_strx_to_uint32_n_valid (void) |
1728 | { | 1926 | { |
1729 | size_t t_failed = 0; | 1927 | size_t t_failed = 0; |
1730 | size_t i, j; | 1928 | size_t i, j; |
1731 | static const size_t n_checks = sizeof(xdstrs_w_values) / sizeof(xdstrs_w_values[0]); | 1929 | static const size_t n_checks = sizeof(xdstrs_w_values) |
1930 | / sizeof(xdstrs_w_values[0]); | ||
1732 | int c_failed[n_checks]; | 1931 | int c_failed[n_checks]; |
1733 | 1932 | ||
1734 | memset(c_failed, 0, sizeof(c_failed)); | 1933 | memset (c_failed, 0, sizeof(c_failed)); |
1735 | 1934 | ||
1736 | for(j = 0; j < locale_name_count; j++) | 1935 | for (j = 0; j < locale_name_count; j++) |
1936 | { | ||
1937 | set_test_locale (j); /* setlocale() can be slow! */ | ||
1938 | for (i = 0; i < n_checks; i++) | ||
1737 | { | 1939 | { |
1738 | set_test_locale(j); /* setlocale() can be slow! */ | 1940 | uint32_t rv = 2352932; /* some random value */ |
1739 | for(i = 0; i < n_checks; i++) | 1941 | size_t rs = 0; |
1942 | size_t len; | ||
1943 | const struct str_with_value *const t = xdstrs_w_values + i; | ||
1944 | |||
1945 | if (t->val > UINT32_MAX) | ||
1946 | continue; /* number is too high for this function */ | ||
1947 | |||
1948 | if (t->str.len < t->num_of_digt) | ||
1949 | { | ||
1950 | fprintf (stderr, | ||
1951 | "ERROR: xdstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" | ||
1952 | " to be less or equal to str.len (%u).\n", | ||
1953 | (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned | ||
1954 | int) t->str. | ||
1955 | len); | ||
1956 | return -1; | ||
1957 | } | ||
1958 | for (len = t->num_of_digt; len <= t->str.len + 1 && ! c_failed[i]; len++) | ||
1959 | { | ||
1960 | rs = MHD_strx_to_uint32_n_ (t->str.str, len, &rv); | ||
1961 | if (rs != t->num_of_digt) | ||
1740 | { | 1962 | { |
1741 | uint32_t rv = 2352932; /* some random value */ | 1963 | t_failed++; |
1742 | size_t rs = 0; | 1964 | c_failed[i] = ! 0; |
1743 | size_t len; | 1965 | fprintf (stderr, |
1744 | const struct str_with_value * const t = xdstrs_w_values + i; | 1966 | "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR ", ->0x%" |
1745 | 1967 | PRIX64 ")" | |
1746 | if (t->val > UINT32_MAX) | 1968 | " returned %" PRIuPTR ", while expecting %d. Locale: %s\n", |
1747 | continue; /* number is too high for this function */ | 1969 | n_prnt (t->str.str), (intptr_t) len, (uint64_t) rv, |
1748 | 1970 | (intptr_t) rs, | |
1749 | if (t->str.len < t->num_of_digt) | 1971 | (int) t->num_of_digt, get_current_locale_str ()); |
1750 | { | ||
1751 | fprintf(stderr, "ERROR: xdstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" | ||
1752 | " to be less or equal to str.len (%u).\n", | ||
1753 | (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned int) t->str.len); | ||
1754 | return -1; | ||
1755 | } | ||
1756 | for (len = t->num_of_digt; len <= t->str.len + 1 && !c_failed[i]; len++) | ||
1757 | { | ||
1758 | rs = MHD_strx_to_uint32_n_(t->str.str, len, &rv); | ||
1759 | if (rs != t->num_of_digt) | ||
1760 | { | ||
1761 | t_failed++; | ||
1762 | c_failed[i] = !0; | ||
1763 | fprintf(stderr, "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR ", ->0x%" PRIX64 ")" | ||
1764 | " returned %" PRIuPTR ", while expecting %d. Locale: %s\n", | ||
1765 | n_prnt(t->str.str), (intptr_t)len, (uint64_t)rv, (intptr_t)rs, | ||
1766 | (int)t->num_of_digt, get_current_locale_str()); | ||
1767 | } | ||
1768 | if (rv != t->val) | ||
1769 | { | ||
1770 | t_failed++; | ||
1771 | c_failed[i] = !0; | ||
1772 | fprintf(stderr, "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR ", ->0x%" PRIX64 ")" | ||
1773 | " converted string to value 0x%" PRIX64 ", while expecting result 0x%" PRIX64 | ||
1774 | ". Locale: %s\n", n_prnt(t->str.str), (intptr_t)len, (uint64_t)rv, (uint64_t)rv, | ||
1775 | t->val, get_current_locale_str()); | ||
1776 | } | ||
1777 | } | ||
1778 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i]) | ||
1779 | printf("PASSED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR "..%" PRIuPTR ", ->0x%" PRIX64 ")" | ||
1780 | " == %" PRIuPTR "\n", n_prnt(t->str.str), (intptr_t)t->num_of_digt, | ||
1781 | (intptr_t)t->str.len + 1, (uint64_t)rv, rs); | ||
1782 | } | 1972 | } |
1973 | if (rv != t->val) | ||
1974 | { | ||
1975 | t_failed++; | ||
1976 | c_failed[i] = ! 0; | ||
1977 | fprintf (stderr, | ||
1978 | "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR ", ->0x%" | ||
1979 | PRIX64 ")" | ||
1980 | " converted string to value 0x%" PRIX64 | ||
1981 | ", while expecting result 0x%" PRIX64 | ||
1982 | ". Locale: %s\n", n_prnt (t->str.str), (intptr_t) len, | ||
1983 | (uint64_t) rv, (uint64_t) rv, | ||
1984 | t->val, get_current_locale_str ()); | ||
1985 | } | ||
1986 | } | ||
1987 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) | ||
1988 | printf ( | ||
1989 | "PASSED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR "..%" PRIuPTR | ||
1990 | ", ->0x%" | ||
1991 | PRIX64 ")" | ||
1992 | " == %" PRIuPTR "\n", n_prnt (t->str.str), | ||
1993 | (intptr_t) t->num_of_digt, | ||
1994 | (intptr_t) t->str.len + 1, (uint64_t) rv, rs); | ||
1783 | } | 1995 | } |
1996 | } | ||
1784 | return t_failed; | 1997 | return t_failed; |
1785 | } | 1998 | } |
1786 | 1999 | ||
1787 | 2000 | ||
1788 | int check_strx_to_uint32_n_all_chars(void) | 2001 | int check_strx_to_uint32_n_all_chars (void) |
1789 | { | 2002 | { |
1790 | static const size_t n_checks = 256; /* from 0 to 255 */ | 2003 | static const size_t n_checks = 256; /* from 0 to 255 */ |
1791 | int c_failed[n_checks]; | 2004 | int c_failed[n_checks]; |
1792 | size_t t_failed = 0; | 2005 | size_t t_failed = 0; |
1793 | size_t j; | 2006 | size_t j; |
1794 | 2007 | ||
1795 | memset(c_failed, 0, sizeof(c_failed)); | 2008 | memset (c_failed, 0, sizeof(c_failed)); |
1796 | 2009 | ||
1797 | for(j = 0; j < locale_name_count; j++) | 2010 | for (j = 0; j < locale_name_count; j++) |
1798 | { | 2011 | { |
1799 | unsigned int c; | 2012 | unsigned int c; |
1800 | uint32_t test_val; | 2013 | uint32_t test_val; |
1801 | 2014 | ||
1802 | set_test_locale(j); /* setlocale() can be slow! */ | 2015 | set_test_locale (j); /* setlocale() can be slow! */ |
1803 | for(c = 0; c < n_checks; c++) | 2016 | for (c = 0; c < n_checks; c++) |
2017 | { | ||
2018 | static const uint32_t rnd_val = 98372558; | ||
2019 | size_t rs; | ||
2020 | size_t len; | ||
2021 | |||
2022 | if (((c >= '0') &&(c <= '9') ) || ((c >= 'A') &&(c <= 'F') ) || ((c >= | ||
2023 | 'a') && | ||
2024 | (c <= | ||
2025 | 'f') )) | ||
2026 | continue; /* skip xdigits */ | ||
2027 | |||
2028 | for (len = 0; len <= 5; len++) | ||
2029 | { | ||
2030 | for (test_val = 0; test_val <= rnd_val&& ! c_failed[c]; test_val += | ||
2031 | rnd_val) | ||
1804 | { | 2032 | { |
1805 | static const uint32_t rnd_val = 98372558; | 2033 | char test_str[] = "0123"; |
1806 | size_t rs; | 2034 | uint32_t rv = test_val; |
1807 | size_t len; | 2035 | |
1808 | 2036 | test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ | |
1809 | if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f')) | 2037 | rs = MHD_strx_to_uint32_n_ (test_str, len, &rv); |
1810 | continue; /* skip xdigits */ | 2038 | if (rs != 0) |
1811 | 2039 | { | |
1812 | for (len = 0; len <= 5; len++) | 2040 | t_failed++; |
1813 | { | 2041 | c_failed[c] = ! 0; |
1814 | for(test_val = 0; test_val <= rnd_val&& !c_failed[c]; test_val += rnd_val) | 2042 | fprintf (stderr, |
1815 | { | 2043 | "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR ", ->0x%" |
1816 | char test_str[] = "0123"; | 2044 | PRIX64 |
1817 | uint32_t rv = test_val; | 2045 | ")" |
1818 | 2046 | " returned %" PRIuPTR | |
1819 | test_str[0] = (char) (unsigned char)c; /* replace first char with non-digit char */ | 2047 | ", while expecting zero. Locale: %s\n", |
1820 | rs = MHD_strx_to_uint32_n_(test_str, len, &rv); | 2048 | n_prnt (test_str), (uintptr_t) len, (uint64_t) rv, |
1821 | if (rs != 0) | 2049 | (uintptr_t) rs, get_current_locale_str ()); |
1822 | { | 2050 | } |
1823 | t_failed++; | 2051 | else if (rv != test_val) |
1824 | c_failed[c] = !0; | 2052 | { |
1825 | fprintf(stderr, "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR ", ->0x%" PRIX64 ")" | 2053 | t_failed++; |
1826 | " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", | 2054 | c_failed[c] = ! 0; |
1827 | n_prnt(test_str), (uintptr_t)len, (uint64_t)rv, (uintptr_t)rs, get_current_locale_str()); | 2055 | fprintf (stderr, |
1828 | } | 2056 | "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR |
1829 | else if (rv != test_val) | 2057 | ", &ret_val)" |
1830 | { | 2058 | " modified value of ret_val (before call: 0x%" PRIX64 |
1831 | t_failed++; | 2059 | ", after call 0x%" PRIX64 ")." |
1832 | c_failed[c] = !0; | 2060 | " Locale: %s\n", |
1833 | fprintf(stderr, "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR ", &ret_val)" | 2061 | n_prnt (test_str), (uintptr_t) len, (uint64_t) test_val, |
1834 | " modified value of ret_val (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 ")." | 2062 | (uint64_t) rv, get_current_locale_str ()); |
1835 | " Locale: %s\n", | 2063 | } |
1836 | n_prnt(test_str), (uintptr_t)len, (uint64_t)test_val, (uint64_t)rv, get_current_locale_str()); | ||
1837 | } | ||
1838 | } | ||
1839 | } | ||
1840 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[c]) | ||
1841 | { | ||
1842 | char test_str[] = "0123"; | ||
1843 | test_str[0] = (char) (unsigned char)c; /* replace first char with non-digit char */ | ||
1844 | |||
1845 | printf("PASSED: MHD_strx_to_uint32_n_(\"%s\", 0..5, &ret_val) == 0, value of ret_val is unmodified\n", | ||
1846 | n_prnt(test_str)); | ||
1847 | } | ||
1848 | } | 2064 | } |
2065 | } | ||
2066 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[c]) | ||
2067 | { | ||
2068 | char test_str[] = "0123"; | ||
2069 | test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ | ||
2070 | |||
2071 | printf ( | ||
2072 | "PASSED: MHD_strx_to_uint32_n_(\"%s\", 0..5, &ret_val) == 0, value of ret_val is unmodified\n", | ||
2073 | n_prnt (test_str)); | ||
2074 | } | ||
1849 | } | 2075 | } |
2076 | } | ||
1850 | return t_failed; | 2077 | return t_failed; |
1851 | } | 2078 | } |
1852 | 2079 | ||
1853 | 2080 | ||
1854 | int check_strx_to_uint32_n_overflow(void) | 2081 | int check_strx_to_uint32_n_overflow (void) |
1855 | { | 2082 | { |
1856 | size_t t_failed = 0; | 2083 | size_t t_failed = 0; |
1857 | size_t i, j; | 2084 | size_t i, j; |
1858 | static const size_t n_checks1 = sizeof(strx_ovflw) / sizeof(strx_ovflw[0]); | 2085 | static const size_t n_checks1 = sizeof(strx_ovflw) / sizeof(strx_ovflw[0]); |
1859 | static const size_t n_checks = sizeof(strx_ovflw) / sizeof(strx_ovflw[0]) + | 2086 | static const size_t n_checks = sizeof(strx_ovflw) / sizeof(strx_ovflw[0]) |
1860 | sizeof(xdstrs_w_values) / sizeof(xdstrs_w_values[0]); | 2087 | + sizeof(xdstrs_w_values) |
2088 | / sizeof(xdstrs_w_values[0]); | ||
1861 | int c_failed[n_checks]; | 2089 | int c_failed[n_checks]; |
1862 | 2090 | ||
1863 | memset(c_failed, 0, sizeof(c_failed)); | 2091 | memset (c_failed, 0, sizeof(c_failed)); |
1864 | 2092 | ||
1865 | for(j = 0; j < locale_name_count; j++) | 2093 | for (j = 0; j < locale_name_count; j++) |
2094 | { | ||
2095 | set_test_locale (j); /* setlocale() can be slow! */ | ||
2096 | for (i = 0; i < n_checks; i++) | ||
1866 | { | 2097 | { |
1867 | set_test_locale(j); /* setlocale() can be slow! */ | 2098 | size_t rs; |
1868 | for(i = 0; i < n_checks; i++) | 2099 | static const uint32_t rnd_val = 4; |
2100 | size_t len; | ||
2101 | const char *str; | ||
2102 | size_t min_len, max_len; | ||
2103 | if (i < n_checks1) | ||
2104 | { | ||
2105 | const struct str_with_len *const t = strx_ovflw + i; | ||
2106 | str = t->str; | ||
2107 | min_len = t->len; | ||
2108 | max_len = t->len + 1; | ||
2109 | } | ||
2110 | else | ||
2111 | { | ||
2112 | const struct str_with_value *const t = xdstrs_w_values + (i | ||
2113 | - n_checks1); | ||
2114 | if (t->val <= UINT32_MAX) | ||
2115 | continue; /* check only strings that should overflow uint32_t */ | ||
2116 | |||
2117 | if (t->str.len < t->num_of_digt) | ||
1869 | { | 2118 | { |
1870 | size_t rs; | 2119 | fprintf (stderr, |
1871 | static const uint32_t rnd_val = 4; | 2120 | "ERROR: xdstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" |
1872 | size_t len; | 2121 | " to be less or equal to str.len (%u).\n", |
1873 | const char * str; | 2122 | (unsigned int) (i - n_checks1), (unsigned |
1874 | size_t min_len, max_len; | 2123 | int) t->num_of_digt, |
1875 | if (i < n_checks1) | 2124 | (unsigned int) t->str.len); |
1876 | { | 2125 | return -1; |
1877 | const struct str_with_len * const t = strx_ovflw + i; | ||
1878 | str = t->str; | ||
1879 | min_len = t->len; | ||
1880 | max_len = t->len + 1; | ||
1881 | } | ||
1882 | else | ||
1883 | { | ||
1884 | const struct str_with_value * const t = xdstrs_w_values + (i - n_checks1); | ||
1885 | if (t->val <= UINT32_MAX) | ||
1886 | continue; /* check only strings that should overflow uint32_t */ | ||
1887 | |||
1888 | if (t->str.len < t->num_of_digt) | ||
1889 | { | ||
1890 | fprintf(stderr, "ERROR: xdstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" | ||
1891 | " to be less or equal to str.len (%u).\n", | ||
1892 | (unsigned int) (i - n_checks1), (unsigned int) t->num_of_digt, | ||
1893 | (unsigned int) t->str.len); | ||
1894 | return -1; | ||
1895 | } | ||
1896 | str = t->str.str; | ||
1897 | min_len = t->num_of_digt; | ||
1898 | max_len = t->str.len + 1; | ||
1899 | } | ||
1900 | |||
1901 | for (len = min_len; len <= max_len; len++) | ||
1902 | { | ||
1903 | uint32_t test_val; | ||
1904 | for(test_val = 0; test_val <= rnd_val && !c_failed[i]; test_val += rnd_val) | ||
1905 | { | ||
1906 | uint32_t rv = test_val; | ||
1907 | |||
1908 | rs = MHD_strx_to_uint32_n_(str, len, &rv); | ||
1909 | if (rs != 0) | ||
1910 | { | ||
1911 | t_failed++; | ||
1912 | c_failed[i] = !0; | ||
1913 | fprintf(stderr, "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR ", ->0x%" PRIX64 ")" | ||
1914 | " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", | ||
1915 | n_prnt(str), (uintptr_t)len, (uint64_t)rv, (uintptr_t)rs, get_current_locale_str()); | ||
1916 | } | ||
1917 | else if (rv != test_val) | ||
1918 | { | ||
1919 | t_failed++; | ||
1920 | c_failed[i] = !0; | ||
1921 | fprintf(stderr, "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR ", &ret_val)" | ||
1922 | " modified value of ret_val (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 ")." | ||
1923 | " Locale: %s\n", n_prnt(str), (uintptr_t)len, (uint64_t)test_val, (uint64_t)rv, | ||
1924 | get_current_locale_str()); | ||
1925 | } | ||
1926 | } | ||
1927 | } | ||
1928 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i]) | ||
1929 | printf("PASSED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR "..%" PRIuPTR ", &ret_val) == 0," | ||
1930 | " value of ret_val is unmodified\n", n_prnt(str), (uintptr_t)min_len, | ||
1931 | (uintptr_t)max_len); | ||
1932 | } | 2126 | } |
2127 | str = t->str.str; | ||
2128 | min_len = t->num_of_digt; | ||
2129 | max_len = t->str.len + 1; | ||
2130 | } | ||
2131 | |||
2132 | for (len = min_len; len <= max_len; len++) | ||
2133 | { | ||
2134 | uint32_t test_val; | ||
2135 | for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += | ||
2136 | rnd_val) | ||
2137 | { | ||
2138 | uint32_t rv = test_val; | ||
2139 | |||
2140 | rs = MHD_strx_to_uint32_n_ (str, len, &rv); | ||
2141 | if (rs != 0) | ||
2142 | { | ||
2143 | t_failed++; | ||
2144 | c_failed[i] = ! 0; | ||
2145 | fprintf (stderr, | ||
2146 | "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR ", ->0x%" | ||
2147 | PRIX64 | ||
2148 | ")" | ||
2149 | " returned %" PRIuPTR | ||
2150 | ", while expecting zero. Locale: %s\n", | ||
2151 | n_prnt (str), (uintptr_t) len, (uint64_t) rv, | ||
2152 | (uintptr_t) rs, get_current_locale_str ()); | ||
2153 | } | ||
2154 | else if (rv != test_val) | ||
2155 | { | ||
2156 | t_failed++; | ||
2157 | c_failed[i] = ! 0; | ||
2158 | fprintf (stderr, | ||
2159 | "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR | ||
2160 | ", &ret_val)" | ||
2161 | " modified value of ret_val (before call: 0x%" PRIX64 | ||
2162 | ", after call 0x%" PRIX64 ")." | ||
2163 | " Locale: %s\n", n_prnt (str), (uintptr_t) len, | ||
2164 | (uint64_t) test_val, (uint64_t) rv, | ||
2165 | get_current_locale_str ()); | ||
2166 | } | ||
2167 | } | ||
2168 | } | ||
2169 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) | ||
2170 | printf ( | ||
2171 | "PASSED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR "..%" PRIuPTR | ||
2172 | ", &ret_val) == 0," | ||
2173 | " value of ret_val is unmodified\n", n_prnt (str), | ||
2174 | (uintptr_t) min_len, | ||
2175 | (uintptr_t) max_len); | ||
1933 | } | 2176 | } |
2177 | } | ||
1934 | return t_failed; | 2178 | return t_failed; |
1935 | } | 2179 | } |
1936 | 2180 | ||
1937 | 2181 | ||
1938 | int check_strx_to_uint32_n_no_val(void) | 2182 | int check_strx_to_uint32_n_no_val (void) |
1939 | { | 2183 | { |
1940 | size_t t_failed = 0; | 2184 | size_t t_failed = 0; |
1941 | size_t i, j; | 2185 | size_t i, j; |
1942 | static const size_t n_checks = sizeof(str_no_num) / sizeof(str_no_num[0]); | 2186 | static const size_t n_checks = sizeof(str_no_num) / sizeof(str_no_num[0]); |
1943 | int c_failed[n_checks]; | 2187 | int c_failed[n_checks]; |
1944 | 2188 | ||
1945 | memset(c_failed, 0, sizeof(c_failed)); | 2189 | memset (c_failed, 0, sizeof(c_failed)); |
1946 | 2190 | ||
1947 | for(j = 0; j < locale_name_count; j++) | 2191 | for (j = 0; j < locale_name_count; j++) |
2192 | { | ||
2193 | set_test_locale (j); /* setlocale() can be slow! */ | ||
2194 | for (i = 0; i < n_checks; i++) | ||
1948 | { | 2195 | { |
1949 | set_test_locale(j); /* setlocale() can be slow! */ | 2196 | size_t rs; |
1950 | for(i = 0; i < n_checks; i++) | 2197 | const struct str_with_len *const t = str_no_num + i; |
2198 | static const uint32_t rnd_val = 3214314212UL; | ||
2199 | size_t len; | ||
2200 | |||
2201 | for (len = 0; len <= t->len + 1; len++) | ||
2202 | { | ||
2203 | uint32_t test_val; | ||
2204 | for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += | ||
2205 | rnd_val) | ||
1951 | { | 2206 | { |
1952 | size_t rs; | 2207 | uint32_t rv = test_val; |
1953 | const struct str_with_len * const t = str_no_num + i; | 2208 | |
1954 | static const uint32_t rnd_val = 3214314212UL; | 2209 | rs = MHD_strx_to_uint32_n_ (t->str, len, &rv); |
1955 | size_t len; | 2210 | if (rs != 0) |
1956 | 2211 | { | |
1957 | for (len = 0; len <= t->len + 1; len++) | 2212 | t_failed++; |
1958 | { | 2213 | c_failed[i] = ! 0; |
1959 | uint32_t test_val; | 2214 | fprintf (stderr, |
1960 | for(test_val = 0; test_val <= rnd_val && !c_failed[i]; test_val += rnd_val) | 2215 | "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR ", ->0x%" |
1961 | { | 2216 | PRIX64 |
1962 | uint32_t rv = test_val; | 2217 | ")" |
1963 | 2218 | " returned %" PRIuPTR | |
1964 | rs = MHD_strx_to_uint32_n_(t->str, len, &rv); | 2219 | ", while expecting zero. Locale: %s\n", |
1965 | if (rs != 0) | 2220 | n_prnt (t->str), (uintptr_t) len, (uint64_t) rv, |
1966 | { | 2221 | (uintptr_t) rs, get_current_locale_str ()); |
1967 | t_failed++; | 2222 | } |
1968 | c_failed[i] = !0; | 2223 | else if (rv != test_val) |
1969 | fprintf(stderr, "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR ", ->0x%" PRIX64 ")" | 2224 | { |
1970 | " returned %" PRIuPTR ", while expecting zero. Locale: %s\n", | 2225 | t_failed++; |
1971 | n_prnt(t->str), (uintptr_t)len, (uint64_t)rv, (uintptr_t)rs, get_current_locale_str()); | 2226 | c_failed[i] = ! 0; |
1972 | } | 2227 | fprintf (stderr, |
1973 | else if (rv != test_val) | 2228 | "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR |
1974 | { | 2229 | ", &ret_val)" |
1975 | t_failed++; | 2230 | " modified value of ret_val (before call: 0x%" PRIX64 |
1976 | c_failed[i] = !0; | 2231 | ", after call 0x%" PRIX64 ")." |
1977 | fprintf(stderr, "FAILED: MHD_strx_to_uint32_n_(\"%s\", %" PRIuPTR ", &ret_val)" | 2232 | " Locale: %s\n", n_prnt (t->str), (uintptr_t) len, |
1978 | " modified value of ret_val (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 ")." | 2233 | (uint64_t) test_val, (uint64_t) rv, |
1979 | " Locale: %s\n", n_prnt(t->str), (uintptr_t)len, (uint64_t)test_val, (uint64_t)rv, | 2234 | get_current_locale_str ()); |
1980 | get_current_locale_str()); | 2235 | } |
1981 | } | ||
1982 | } | ||
1983 | } | ||
1984 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i]) | ||
1985 | printf("PASSED: MHD_strx_to_uint32_n_(\"%s\", 0..%" PRIuPTR ", &ret_val) == 0," | ||
1986 | " value of ret_val is unmodified\n", n_prnt(t->str), | ||
1987 | (uintptr_t)t->len + 1); | ||
1988 | } | 2236 | } |
2237 | } | ||
2238 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) | ||
2239 | printf ( | ||
2240 | "PASSED: MHD_strx_to_uint32_n_(\"%s\", 0..%" PRIuPTR | ||
2241 | ", &ret_val) == 0," | ||
2242 | " value of ret_val is unmodified\n", n_prnt (t->str), | ||
2243 | (uintptr_t) t->len + 1); | ||
1989 | } | 2244 | } |
2245 | } | ||
1990 | return t_failed; | 2246 | return t_failed; |
1991 | } | 2247 | } |
1992 | 2248 | ||
1993 | 2249 | ||
1994 | int check_strx_to_uint64_valid(void) | 2250 | int check_strx_to_uint64_valid (void) |
1995 | { | 2251 | { |
1996 | size_t t_failed = 0; | 2252 | size_t t_failed = 0; |
1997 | size_t i, j; | 2253 | size_t i, j; |
1998 | static const size_t n_checks = sizeof(xdstrs_w_values) / sizeof(xdstrs_w_values[0]); | 2254 | static const size_t n_checks = sizeof(xdstrs_w_values) |
2255 | / sizeof(xdstrs_w_values[0]); | ||
1999 | int c_failed[n_checks]; | 2256 | int c_failed[n_checks]; |
2000 | 2257 | ||
2001 | memset(c_failed, 0, sizeof(c_failed)); | 2258 | memset (c_failed, 0, sizeof(c_failed)); |
2002 | 2259 | ||
2003 | for(j = 0; j < locale_name_count; j++) | 2260 | for (j = 0; j < locale_name_count; j++) |
2261 | { | ||
2262 | set_test_locale (j); /* setlocale() can be slow! */ | ||
2263 | for (i = 0; i < n_checks; i++) | ||
2004 | { | 2264 | { |
2005 | set_test_locale(j); /* setlocale() can be slow! */ | 2265 | uint64_t rv; |
2006 | for(i = 0; i < n_checks; i++) | 2266 | size_t rs; |
2007 | { | 2267 | const struct str_with_value *const t = xdstrs_w_values + i; |
2008 | uint64_t rv; | 2268 | |
2009 | size_t rs; | 2269 | if (c_failed[i]) |
2010 | const struct str_with_value * const t = xdstrs_w_values + i; | 2270 | continue; /* skip already failed checks */ |
2011 | 2271 | ||
2012 | if (c_failed[i]) | 2272 | if (t->str.len < t->num_of_digt) |
2013 | continue; /* skip already failed checks */ | 2273 | { |
2014 | 2274 | fprintf (stderr, | |
2015 | if (t->str.len < t->num_of_digt) | 2275 | "ERROR: xdstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" |
2016 | { | 2276 | " to be less or equal to str.len (%u).\n", |
2017 | fprintf(stderr, "ERROR: xdstrs_w_values[%u] has wrong num_of_digt (%u): num_of_digt is expected" | 2277 | (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned |
2018 | " to be less or equal to str.len (%u).\n", | 2278 | int) t->str. |
2019 | (unsigned int) i, (unsigned int) t->num_of_digt, (unsigned int) t->str.len); | 2279 | len); |
2020 | return -1; | 2280 | return -1; |
2021 | } | 2281 | } |
2022 | rv = 1458532; /* some random value */ | 2282 | rv = 1458532; /* some random value */ |
2023 | rs = MHD_strx_to_uint64_(t->str.str, &rv); | 2283 | rs = MHD_strx_to_uint64_ (t->str.str, &rv); |
2024 | if (rs != t->num_of_digt) | 2284 | if (rs != t->num_of_digt) |
2025 | { | 2285 | { |
2026 | t_failed++; | 2286 | t_failed++; |
2027 | c_failed[i] = !0; | 2287 | c_failed[i] = ! 0; |
2028 | fprintf(stderr, "FAILED: MHD_strx_to_uint64_(\"%s\", ->0x%" PRIX64 ") returned %" PRIuPTR ", while expecting %d." | 2288 | fprintf (stderr, |
2029 | " Locale: %s\n", n_prnt(t->str.str), rv, (intptr_t)rs, (int)t->num_of_digt, get_current_locale_str()); | 2289 | "FAILED: MHD_strx_to_uint64_(\"%s\", ->0x%" PRIX64 |
2030 | } | 2290 | ") returned %" |
2031 | if (rv != t->val) | 2291 | PRIuPTR ", while expecting %d." |
2032 | { | 2292 | " Locale: %s\n", n_prnt (t->str.str), rv, (intptr_t) rs, |
2033 | t_failed++; | 2293 | (int) t->num_of_digt, get_current_locale_str ()); |
2034 | c_failed[i] = !0; | 2294 | } |
2035 | fprintf(stderr, "FAILED: MHD_strx_to_uint64_(\"%s\", ->0x%" PRIX64 ") converted string to value 0x%" PRIX64 "," | 2295 | if (rv != t->val) |
2036 | " while expecting result 0x%" PRIX64 ". Locale: %s\n", n_prnt(t->str.str), rv, rv, | 2296 | { |
2037 | t->val, get_current_locale_str()); | 2297 | t_failed++; |
2038 | } | 2298 | c_failed[i] = ! 0; |
2039 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i]) | 2299 | fprintf (stderr, |
2040 | printf("PASSED: MHD_strx_to_uint64_(\"%s\", ->0x%" PRIX64 ") == %" PRIuPTR "\n", | 2300 | "FAILED: MHD_strx_to_uint64_(\"%s\", ->0x%" PRIX64 |
2041 | n_prnt(t->str.str), rv, rs); | 2301 | ") converted string to value 0x%" |
2042 | } | 2302 | PRIX64 "," |
2303 | " while expecting result 0x%" PRIX64 ". Locale: %s\n", n_prnt ( | ||
2304 | t->str.str), rv, rv, | ||
2305 | t->val, get_current_locale_str ()); | ||
2306 | } | ||
2307 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) | ||
2308 | printf ( | ||
2309 | "PASSED: MHD_strx_to_uint64_(\"%s\", ->0x%" PRIX64 ") == %" PRIuPTR | ||
2310 | "\n", | ||
2311 | n_prnt (t->str.str), rv, rs); | ||
2043 | } | 2312 | } |
2313 | } | ||
2044 | return t_failed; | 2314 | return t_failed; |
2045 | } | 2315 | } |
2046 | 2316 | ||
2047 | 2317 | ||
2048 | int check_strx_to_uint64_all_chars(void) | 2318 | int check_strx_to_uint64_all_chars (void) |
2049 | { | 2319 | { |
2050 | static const size_t n_checks = 256; /* from 0 to 255 */ | 2320 | static const size_t n_checks = 256; /* from 0 to 255 */ |
2051 | int c_failed[n_checks]; | 2321 | int c_failed[n_checks]; |
2052 | size_t t_failed = 0; | 2322 | size_t t_failed = 0; |
2053 | size_t j; | 2323 | size_t j; |
2054 | 2324 | ||
2055 | memset(c_failed, 0, sizeof(c_failed)); | 2325 | memset (c_failed, 0, sizeof(c_failed)); |
2056 | 2326 | ||
2057 | for(j = 0; j < locale_name_count; j++) | 2327 | for (j = 0; j < locale_name_count; j++) |
2058 | { | 2328 | { |
2059 | unsigned int c; | 2329 | unsigned int c; |
2060 | uint64_t test_val; | 2330 | uint64_t test_val; |
2061 | 2331 | ||
2062 | set_test_locale(j); /* setlocale() can be slow! */ | 2332 | set_test_locale (j); /* setlocale() can be slow! */ |
2063 | for(c = 0; c < n_checks; c++) | 2333 | for (c = 0; c < n_checks; c++) |
2334 | { | ||
2335 | static const uint64_t rnd_val = 234234; | ||
2336 | size_t rs; | ||
2337 | if (((c >= '0') &&(c <= '9') ) || ((c >= 'A') &&(c <= 'F') ) || ((c >= | ||
2338 | 'a') && | ||
2339 | (c <= | ||
2340 | 'f') )) | ||
2341 | continue; /* skip xdigits */ | ||
2342 | for (test_val = 0; test_val <= rnd_val&& ! c_failed[c]; test_val += | ||
2343 | rnd_val) | ||
2344 | { | ||
2345 | char test_str[] = "0123"; | ||
2346 | uint64_t rv = test_val; | ||
2347 | |||
2348 | test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ | ||
2349 | rs = MHD_strx_to_uint64_ (test_str, &rv); | ||
2350 | if (rs != 0) | ||
2064 | { | 2351 | { |
2065 | static const uint64_t rnd_val = 234234; | 2352 | t_failed++; |
2066 | size_t rs; | 2353 | c_failed[c] = ! 0; |
2067 | if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f')) | 2354 | fprintf (stderr, |
2068 | continue; /* skip xdigits */ | 2355 | "FAILED: MHD_strx_to_uint64_(\"%s\", ->0x%" PRIX64 |
2069 | for(test_val = 0; test_val <= rnd_val&& !c_failed[c]; test_val += rnd_val) | 2356 | ") returned %" |
2070 | { | 2357 | PRIuPTR ", while expecting zero." |
2071 | char test_str[] = "0123"; | 2358 | " Locale: %s\n", n_prnt (test_str), rv, (uintptr_t) rs, |
2072 | uint64_t rv = test_val; | 2359 | get_current_locale_str ()); |
2073 | |||
2074 | test_str[0] = (char) (unsigned char)c; /* replace first char with non-digit char */ | ||
2075 | rs = MHD_strx_to_uint64_(test_str, &rv); | ||
2076 | if (rs != 0) | ||
2077 | { | ||
2078 | t_failed++; | ||
2079 | c_failed[c] = !0; | ||
2080 | fprintf(stderr, "FAILED: MHD_strx_to_uint64_(\"%s\", ->0x%" PRIX64 ") returned %" PRIuPTR ", while expecting zero." | ||
2081 | " Locale: %s\n", n_prnt(test_str), rv, (uintptr_t)rs, get_current_locale_str()); | ||
2082 | } | ||
2083 | else if (rv != test_val) | ||
2084 | { | ||
2085 | t_failed++; | ||
2086 | c_failed[c] = !0; | ||
2087 | fprintf(stderr, "FAILED: MHD_strx_to_uint64_(\"%s\", &ret_val) modified value of ret_val" | ||
2088 | " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 "). Locale: %s\n", | ||
2089 | n_prnt(test_str), test_val, rv, get_current_locale_str()); | ||
2090 | } | ||
2091 | } | ||
2092 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[c]) | ||
2093 | { | ||
2094 | char test_str[] = "0123"; | ||
2095 | test_str[0] = (char) (unsigned char)c; /* replace first char with non-digit char */ | ||
2096 | |||
2097 | printf("PASSED: MHD_strx_to_uint64_(\"%s\", &ret_val) == 0, value of ret_val is unmodified\n", | ||
2098 | n_prnt(test_str)); | ||
2099 | } | ||
2100 | } | 2360 | } |
2361 | else if (rv != test_val) | ||
2362 | { | ||
2363 | t_failed++; | ||
2364 | c_failed[c] = ! 0; | ||
2365 | fprintf (stderr, | ||
2366 | "FAILED: MHD_strx_to_uint64_(\"%s\", &ret_val) modified value of ret_val" | ||
2367 | " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 | ||
2368 | "). Locale: %s\n", | ||
2369 | n_prnt (test_str), test_val, rv, get_current_locale_str ()); | ||
2370 | } | ||
2371 | } | ||
2372 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[c]) | ||
2373 | { | ||
2374 | char test_str[] = "0123"; | ||
2375 | test_str[0] = (char) (unsigned char) c; /* replace first char with non-digit char */ | ||
2376 | |||
2377 | printf ( | ||
2378 | "PASSED: MHD_strx_to_uint64_(\"%s\", &ret_val) == 0, value of ret_val is unmodified\n", | ||
2379 | n_prnt (test_str)); | ||
2380 | } | ||
2101 | } | 2381 | } |
2382 | } | ||
2102 | return t_failed; | 2383 | return t_failed; |
2103 | } | 2384 | } |
2104 | 2385 | ||
2105 | 2386 | ||
2106 | int check_strx_to_uint64_overflow(void) | 2387 | int check_strx_to_uint64_overflow (void) |
2107 | { | 2388 | { |
2108 | size_t t_failed = 0; | 2389 | size_t t_failed = 0; |
2109 | size_t i, j; | 2390 | size_t i, j; |
2110 | static const size_t n_checks = sizeof(strx_ovflw) / sizeof(strx_ovflw[0]); | 2391 | static const size_t n_checks = sizeof(strx_ovflw) / sizeof(strx_ovflw[0]); |
2111 | int c_failed[n_checks]; | 2392 | int c_failed[n_checks]; |
2112 | 2393 | ||
2113 | memset(c_failed, 0, sizeof(c_failed)); | 2394 | memset (c_failed, 0, sizeof(c_failed)); |
2114 | 2395 | ||
2115 | for(j = 0; j < locale_name_count; j++) | 2396 | for (j = 0; j < locale_name_count; j++) |
2397 | { | ||
2398 | set_test_locale (j); /* setlocale() can be slow! */ | ||
2399 | for (i = 0; i < n_checks; i++) | ||
2116 | { | 2400 | { |
2117 | set_test_locale(j); /* setlocale() can be slow! */ | 2401 | size_t rs; |
2118 | for(i = 0; i < n_checks; i++) | 2402 | const struct str_with_len *const t = strx_ovflw + i; |
2403 | static const uint64_t rnd_val = 74218431; | ||
2404 | uint64_t test_val; | ||
2405 | |||
2406 | for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += | ||
2407 | rnd_val) | ||
2408 | { | ||
2409 | uint64_t rv = test_val; | ||
2410 | |||
2411 | rs = MHD_strx_to_uint64_ (t->str, &rv); | ||
2412 | if (rs != 0) | ||
2119 | { | 2413 | { |
2120 | size_t rs; | 2414 | t_failed++; |
2121 | const struct str_with_len * const t = strx_ovflw + i; | 2415 | c_failed[i] = ! 0; |
2122 | static const uint64_t rnd_val = 74218431; | 2416 | fprintf (stderr, |
2123 | uint64_t test_val; | 2417 | "FAILED: MHD_strx_to_uint64_(\"%s\", ->0x%" PRIX64 |
2124 | 2418 | ") returned %" | |
2125 | for(test_val = 0; test_val <= rnd_val && !c_failed[i]; test_val += rnd_val) | 2419 | PRIuPTR ", while expecting zero." |
2126 | { | 2420 | " Locale: %s\n", n_prnt (t->str), rv, (uintptr_t) rs, |
2127 | uint64_t rv = test_val; | 2421 | get_current_locale_str ()); |
2128 | |||
2129 | rs = MHD_strx_to_uint64_(t->str, &rv); | ||
2130 | if (rs != 0) | ||
2131 | { | ||
2132 | t_failed++; | ||
2133 | c_failed[i] = !0; | ||
2134 | fprintf(stderr, "FAILED: MHD_strx_to_uint64_(\"%s\", ->0x%" PRIX64 ") returned %" PRIuPTR ", while expecting zero." | ||
2135 | " Locale: %s\n", n_prnt(t->str), rv, (uintptr_t)rs, get_current_locale_str()); | ||
2136 | } | ||
2137 | else if (rv != test_val) | ||
2138 | { | ||
2139 | t_failed++; | ||
2140 | c_failed[i] = !0; | ||
2141 | fprintf(stderr, "FAILED: MHD_strx_to_uint64_(\"%s\", &ret_val) modified value of ret_val" | ||
2142 | " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 "). Locale: %s\n", | ||
2143 | n_prnt(t->str), test_val, rv, get_current_locale_str()); | ||
2144 | } | ||
2145 | } | ||
2146 | if (verbose > 1 && j == locale_name_count - 1 && !c_failed[i]) | ||
2147 | printf("PASSED: MHD_strx_to_uint64_(\"%s\", &ret_val) == 0, value of ret_val is unmodified\n", | ||
2148 | n_prnt(t->str)); | ||
2149 | } | 2422 | } |
2423 | else if (rv != test_val) | ||
2424 | { | ||
2425 | t_failed++; | ||
2426 | c_failed[i] = ! 0; | ||
2427 | fprintf (stderr, | ||
2428 | "FAILED: MHD_strx_to_uint64_(\"%s\", &ret_val) modified value of ret_val" | ||
2429 | " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 | ||
2430 | "). Locale: %s\n", | ||
2431 | n_prnt (t->str), test_val, rv, get_current_locale_str ()); | ||
2432 | } | ||
2433 | } | ||
2434 | if ((verbose > 1) &&(j == locale_name_count - 1) && ! c_failed[i]) | ||
2435 | printf ( | ||
2436 | "PASSED: MHD_strx_to_uint64_(\"%s\", &ret_val) == 0, value of ret_val is unmodified\n", | ||
2437 | n_prnt (t->str)); | ||
2150 | } | 2438 | } |
2439 | } | ||
2151 | return t_failed; | 2440 | return t_failed; |
2152 | } | 2441 | } |
2153 | 2442 | ||
2154 | 2443 | ||
2155 | int check_strx_to_uint64_no_val(void) | 2444 | int check_strx_to_uint64_no_val (void) |
2156 | { | 2445 | { |
2157 | size_t t_failed = 0; | 2446 | size_t t_failed = 0; |
2158 | size_t i, j; | 2447 | size_t i, j; |
2159 | static const size_t n_checks = sizeof(str_no_num) / sizeof(str_no_num[0]); | 2448 | static const size_t n_checks = sizeof(str_no_num) / sizeof(str_no_num[0]); |
2160 | int c_failed[n_checks]; | 2449 | int c_failed[n_checks]; |
2161 | 2450 | ||
2162 | memset(c_failed, 0, sizeof(c_failed)); | 2451 | memset (c_failed, 0, sizeof(c_failed)); |
2163 | 2452 | ||
2164 | for(j = 0; j < locale_name_count; j++) | 2453 | for (j = 0; j < locale_name_count; j++) |
2454 | { | ||
2455 | set_test_locale (j); /* setlocale() can be slow! */ | ||
2456 | for (i = 0; i < n_checks; i++) | ||
2165 | { | 2457 | { |
2166 | set_test_locale(j); /* setlocale() can be slow! */ | 2458 | size_t rs; |
2167 | for(i = 0; i < n_checks; i++) | 2459 | const struct str_with_len *const t = str_no_num + i; |
2460 | static const uint64_t rnd_val = 74218431; | ||
2461 | uint64_t test_val; | ||
2462 | |||
2463 | for (test_val = 0; test_val <= rnd_val && ! c_failed[i]; test_val += | ||
2464 | rnd_val) | ||
2465 | { | ||
2466 | uint64_t rv = test_val; | ||
2467 | |||
2468 | rs = MHD_strx_to_uint64_ (t->str, &rv); | ||
2469 | if (rs != 0) | ||
2470 | { | ||
2471 | t_failed++; | ||
2472 | c_failed[i] = ! 0; | ||
2473 | fprintf (stderr, | ||
2474 | "FAILED: MHD_strx_to_uint64_(\"%s\", ->0x%" PRIX64 | ||
2475 | ") returned %" | ||
2476 | PRIuPTR ", while expecting zero." | ||
2477 | " Locale: %s\n", n_prnt (t->str), rv, (uintptr_t) rs, | ||
2478 | get_current_locale_str ()); | ||
2479 | } | ||
2480 | else if (rv != test_val) | ||
2168 | { | 2481 | { |
2169 | size_t rs; | 2482 | t_failed++; |
2170 | const struct str_with_len * const t = str_no_num + i; | 2483 | c_failed[i] = ! 0; |
2171 | static const uint64_t rnd_val = 74218431; | 2484 | fprintf (stderr, |
2172 | uint64_t test_val; | 2485 | "FAILED: MHD_strx_to_uint64_(\"%s\", &ret_val) modified value of ret_val" |
2173 | 2486 | " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 | |
2174 | for(test_val = 0; test_val <= rnd_val && !c_failed[i]; test_val += rnd_val) | 2487 | "). Locale: %s\n", |
2175 | { | 2488 | n_prnt (t->str), test_val, rv, get_current_locale_str ()); |
2176 | uint64_t rv = test_val; | ||
2177 | |||
2178 | rs = MHD_strx_to_uint64_(t->str, &rv); | ||
2179 | if (rs != 0) | ||
2180 | { | ||
2181 | t_failed++; | ||
2182 | c_failed[i] = !0; | ||
2183 | fprintf(stderr, "FAILED: MHD_strx_to_uint64_(\"%s\", ->0x%" PRIX64 ") returned %" PRIuPTR ", while expecting zero." | ||
2184 | " Locale: %s\n", n_prnt(t->str), rv, (uintptr_t)rs, get_current_locale_str()); | ||
2185 | } | ||
2186 | else if (rv != test_val) | ||
2187 | { | ||
2188 | t_failed++; | ||
2189 | c_failed[i] = !0; | ||
2190 | fprintf(stderr, "FAILED: MHD_strx_to_uint64_(\"%s\", &ret_val) modified value of ret_val" | ||
2191 | " (before call: 0x%" PRIX64 ", after call 0x%" PRIX64 "). Locale: %s\n", | ||