2 !!DESCRIPTION!! C99 WCHAR test
4 !!LICENCE!! public domain
8 sitest -- exercise features of C99 <stdint.h> and <inttypes.h>
10 This source code has been placed into the PUBLIC DOMAIN by its author.
12 last edit: 1999/11/05 gwyn@arl.mil
14 Tries to accommodate pre-C99 versions of <inttypes.h>.
16 Takes advantage of __Q8_* symbols defined by a particular
17 implementation of <stdint.h>, but doesn't require them.
19 NOTE: This is not a thorough validation test of the facilities.
22 #define NO_INTERNAL_WCHAR
23 /*#define STANDALONE*/
26 #include <limits.h> /* for CHAR_BIT */
28 #include <stddef.h> /* for ptrdiff_t */
32 #if !defined(STANDARD_C99) && !defined(STANDARD_CC65)
34 #error "this test checks C99 features, which are not available in the selected standard."
40 #warn "this test checks C99 features, but NO_WCHAR is defined so the test will most definetly fails."
44 #include <inttypes.h> /* embeds <stdint.h> */
46 #include <signal.h> /* for sig_atomic_t */
48 #if defined(INTMAX_MAX) /* <inttypes.h> has C99 features */
52 #include <inttypes.h> /* test idempotency */
57 #define opentest(x) outfile=stdout;
64 #if __STDC_VERSION__ >= 199901
66 #define __Q8_QT long long
73 #define __Q8_MT intmax_t
78 #define __Q8_MT int_least64_t
80 #define PRIdMAX PRIdLEAST64
91 #define U__Q8_MT uintmax_t
94 #define U__Q8_MT uint_least64_t
95 #define PRIuMAX PRIuLEAST64
97 #define U__Q8_MT unsigned long
102 #define STR_SUB(s) # s
103 #define STRINGIZE(s) STR_SUB(s) /* extra level to expand argument */
105 #if defined(SCNo32) || defined(PRIo32)
106 static int32_t int32;
108 static int_least16_t intl16;
109 static uint_least16_t uintl16;
110 static uint_fast16_t uintf16;
111 static intmax_t intmax;
112 static uintmax_t uintmax;
116 int status = 0; /* exit status to be returned */
119 /* <stdint.h> features: */
121 printf("CHAR_BIT=%u\n", (unsigned)CHAR_BIT );
122 printf("sizeof(char)=%u\n", (unsigned)sizeof(char)); /* s.b. 1 */
123 printf("sizeof(short)=%u\n", (unsigned)sizeof(short));
124 printf("sizeof(int)=%u\n", (unsigned)sizeof(int));
125 printf("sizeof(long)=%u\n", (unsigned)sizeof(long));
127 printf("sizeof(long long)=%u\n", (unsigned)sizeof(__Q8_QT));
129 printf("*** long long isn't defined ***\n");
131 printf("sizeof(intmax_t)=%u\n", (unsigned)sizeof(intmax_t));
132 printf("sizeof(ptrdiff_t)=%u\n", (unsigned)sizeof(ptrdiff_t));
133 printf("sizeof(size_t)=%u\n", (unsigned)sizeof(size_t));
134 printf("sizeof(sig_atomic_t)=%u\n", (unsigned)sizeof(sig_atomic_t));
135 printf("sizeof(wchar_t)=%u\n", (unsigned)sizeof(wchar_t));
136 #if defined(WINT_MAX) || __STDC_VERSION__ >= 199901
137 printf("sizeof(wint_t)=%u\n", (unsigned)sizeof(wint_t));
139 printf("*** wint_t isn't defined ***\n");
140 status = EXIT_FAILURE;
143 printf("sizeof(int8_t)=%u\n", (unsigned)sizeof(int8_t));
144 printf("sizeof(uint8_t)=%u\n", (unsigned)sizeof(uint8_t));
147 printf("sizeof(int9_t)=%u\n", (unsigned)sizeof(int9_t));
148 printf("sizeof(uint9_t)=%u\n", (unsigned)sizeof(uint9_t));
151 printf("sizeof(int12_t)=%u\n", (unsigned)sizeof(int12_t));
152 printf("sizeof(uint12_t)=%u\n", (unsigned)sizeof(uint12_t));
155 printf("sizeof(int16_t)=%u\n", (unsigned)sizeof(int16_t));
156 printf("sizeof(uint16_t)=%u\n", (unsigned)sizeof(uint16_t));
159 printf("sizeof(int18_t)=%u\n", (unsigned)sizeof(int18_t));
160 printf("sizeof(uint18_t)=%u\n", (unsigned)sizeof(uint18_t));
163 printf("sizeof(int24_t)=%u\n", (unsigned)sizeof(int24_t));
164 printf("sizeof(uint24_t)=%u\n", (unsigned)sizeof(uint24_t));
167 printf("sizeof(int32_t)=%u\n", (unsigned)sizeof(int32_t));
168 printf("sizeof(uint32_t)=%u\n", (unsigned)sizeof(uint32_t));
171 printf("sizeof(int36_t)=%u\n", (unsigned)sizeof(int36_t));
172 printf("sizeof(uint36_t)=%u\n", (unsigned)sizeof(uint36_t));
175 printf("sizeof(int40_t)=%u\n", (unsigned)sizeof(int40_t));
176 printf("sizeof(uint40_t)=%u\n", (unsigned)sizeof(uint40_t));
179 printf("sizeof(int48_t)=%u\n", (unsigned)sizeof(int48_t));
180 printf("sizeof(uint48_t)=%u\n", (unsigned)sizeof(uint48_t));
183 printf("sizeof(int60_t)=%u\n", (unsigned)sizeof(int60_t));
184 printf("sizeof(uint60_t)=%u\n", (unsigned)sizeof(uint60_t));
187 printf("sizeof(int64_t)=%u\n", (unsigned)sizeof(int64_t));
188 printf("sizeof(uint64_t)=%u\n", (unsigned)sizeof(uint64_t));
191 printf("sizeof(int72_t)=%u\n", (unsigned)sizeof(int72_t));
192 printf("sizeof(uint72_t)=%u\n", (unsigned)sizeof(uint72_t));
195 printf("sizeof(int128_t)=%u\n", (unsigned)sizeof(int128_t));
196 printf("sizeof(uint128_t)=%u\n", (unsigned)sizeof(uint128_t));
198 printf("sizeof(int_least8_t)=%u\n", (unsigned)sizeof(int_least8_t));
199 printf("sizeof(uint_least8_t)=%u\n", (unsigned)sizeof(uint_least8_t));
200 printf("sizeof(int_least16_t)=%u\n", (unsigned)sizeof(int_least16_t));
201 printf("sizeof(uint_least16_t)=%u\n", (unsigned)sizeof(uint_least16_t));
202 printf("sizeof(int_least32_t)=%u\n", (unsigned)sizeof(int_least32_t));
203 printf("sizeof(uint_least32_t)=%u\n", (unsigned)sizeof(uint_least32_t));
204 #ifdef INT_LEAST64_MAX
205 printf("sizeof(int_least64_t)=%u\n", (unsigned)sizeof(int_least64_t));
206 printf("sizeof(uint_least64_t)=%u\n", (unsigned)sizeof(uint_least64_t));
208 printf("*** uint_least64_t isn't defined ***\n");
209 status = EXIT_FAILURE;
211 #ifdef INT_LEAST128_MAX
212 printf("sizeof(int_least128_t)=%u\n", (unsigned)sizeof(int_least128_t));
213 printf("sizeof(uint_least128_t)=%u\n",
214 (unsigned)sizeof(uint_least128_t));
216 printf("sizeof(int_fast8_t)=%u\n", (unsigned)sizeof(int_fast8_t));
217 printf("sizeof(uint_fast8_t)=%u\n", (unsigned)sizeof(uint_fast8_t));
218 printf("sizeof(int_fast16_t)=%u\n", (unsigned)sizeof(int_fast16_t));
219 printf("sizeof(uint_fast16_t)=%u\n", (unsigned)sizeof(uint_fast16_t));
220 printf("sizeof(int_fast32_t)=%u\n", (unsigned)sizeof(int_fast32_t));
221 printf("sizeof(uint_fast32_t)=%u\n", (unsigned)sizeof(uint_fast32_t));
222 #ifdef INT_FAST64_MAX
223 printf("sizeof(int_fast64_t)=%u\n", (unsigned)sizeof(int_fast64_t));
224 printf("sizeof(uint_fast64_t)=%u\n", (unsigned)sizeof(uint_fast64_t));
226 printf("*** int_fast64_t isn't defined ***\n");
227 status = EXIT_FAILURE;
229 #ifdef INT_FAST128_MAX
230 printf("sizeof(int_fast128_t)=%u\n", (unsigned)sizeof(int_fast128_t));
231 printf("sizeof(uint_fast128_t)=%u\n", (unsigned)sizeof(uint_fast128_t));
233 #if defined(INTPTR_MAX)
234 printf("sizeof(intptr_t)=%u\n", (unsigned)sizeof(intptr_t));
235 #if defined(UINTPTR_MAX)
236 printf("sizeof(uintptr_t)=%u\n", (unsigned)sizeof(uintptr_t));
238 printf("*** intptr_t is defined but uintptr_t isn't ***\n");
239 status = EXIT_FAILURE;
241 #elif defined(UINTPTR_MAX)
242 printf("sizeof(uintptr_t)=%u\n", (unsigned)sizeof(uintptr_t));
243 printf("*** uintptr_t is defined but intptr_t isn't ***\n");
244 status = EXIT_FAILURE;
246 printf("*** neither intptr_t nor uintptr_t is defined ***\n");
247 status = EXIT_FAILURE;
250 printf("sizeof(intmax_t)=%u\n", (unsigned)sizeof(intmax_t));
251 printf("sizeof(uintmax_t)=%u\n", (unsigned)sizeof(uintmax_t));
253 printf("*** intmax_t isn't defined ***\n");
254 status = EXIT_FAILURE;
258 printf("INT8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT8_MIN);
259 printf("INT8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT8_MAX);
260 printf("UINT8_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT8_MAX);
263 printf("INT9_MIN=%"PRIdMAX"\n", (__Q8_MT)INT9_MIN);
264 printf("INT9_MAX=%"PRIdMAX"\n", (__Q8_MT)INT9_MAX);
265 printf("UINT9_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT9_MAX);
268 printf("INT12_MIN=%"PRIdMAX"\n", (__Q8_MT)INT12_MIN);
269 printf("INT12_MAX=%"PRIdMAX"\n", (__Q8_MT)INT12_MAX);
270 printf("UINT12_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT12_MAX);
273 printf("INT16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT16_MIN);
274 printf("INT16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT16_MAX);
275 printf("UINT16_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT16_MAX);
278 printf("INT18_MIN=%"PRIdMAX"\n", (__Q8_MT)INT18_MIN);
279 printf("INT18_MAX=%"PRIdMAX"\n", (__Q8_MT)INT18_MAX);
280 printf("UINT18_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT18_MAX);
283 printf("INT24_MIN=%"PRIdMAX"\n", (__Q8_MT)INT24_MIN);
284 printf("INT24_MAX=%"PRIdMAX"\n", (__Q8_MT)INT24_MAX);
285 printf("UINT24_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT24_MAX);
288 printf("INT32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT32_MIN);
289 printf("INT32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT32_MAX);
290 printf("UINT32_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT32_MAX);
293 printf("INT36_MIN=%"PRIdMAX"\n", (__Q8_MT)INT36_MIN);
294 printf("INT36_MAX=%"PRIdMAX"\n", (__Q8_MT)INT36_MAX);
295 printf("UINT36_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT36_MAX);
298 printf("INT40_MIN=%"PRIdMAX"\n", (__Q8_MT)INT40_MIN);
299 printf("INT40_MAX=%"PRIdMAX"\n", (__Q8_MT)INT40_MAX);
300 printf("UINT40_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT40_MAX);
303 printf("INT48_MIN=%"PRIdMAX"\n", (__Q8_MT)INT48_MIN);
304 printf("INT48_MAX=%"PRIdMAX"\n", (__Q8_MT)INT48_MAX);
305 printf("UINT48_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT48_MAX);
308 printf("INT60_MIN=%"PRIdMAX"\n", (__Q8_MT)INT60_MIN);
309 printf("INT60_MAX=%"PRIdMAX"\n", (__Q8_MT)INT60_MAX);
310 printf("UINT60_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT60_MAX);
313 printf("INT64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT64_MIN);
314 printf("INT64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT64_MAX);
315 printf("UINT64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT64_MAX);
318 printf("INT72_MIN=%"PRIdMAX"\n", (__Q8_MT)INT72_MIN);
319 printf("INT72_MAX=%"PRIdMAX"\n", (__Q8_MT)INT72_MAX);
320 printf("UINT72_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT72_MAX);
323 printf("INT128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT128_MIN);
324 printf("INT128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT128_MAX);
325 printf("UINT128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT128_MAX);
327 printf("INT_LEAST8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST8_MIN);
328 printf("INT_LEAST8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST8_MAX);
329 printf("UINT_LEAST8_MAX=%"PRIuMAX"\n",
330 (U__Q8_MT)UINT_LEAST8_MAX);
331 printf("INT_LEAST16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST16_MIN);
332 printf("INT_LEAST16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST16_MAX);
333 printf("UINT_LEAST16_MAX=%"PRIuMAX"\n",
334 (U__Q8_MT)UINT_LEAST16_MAX);
335 printf("INT_LEAST32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST32_MIN);
336 printf("INT_LEAST32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST32_MAX);
337 printf("UINT_LEAST32_MAX=%"PRIuMAX"\n",
338 (U__Q8_MT)UINT_LEAST32_MAX);
339 #ifdef INT_LEAST64_MAX
340 printf("INT_LEAST64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST64_MIN);
341 printf("INT_LEAST64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST64_MAX);
342 printf("UINT_LEAST64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_LEAST64_MAX);
344 #ifdef INT_LEAST128_MAX
345 printf("INT_LEAST128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST128_MIN);
346 printf("INT_LEAST128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST128_MAX);
347 printf("UINT_LEAST128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_LEAST128_MAX);
349 printf("INT_FAST8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST8_MIN);
350 printf("INT_FAST8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST8_MAX);
351 printf("UINT_FAST8_MAX=%"PRIuMAX"\n",
352 (U__Q8_MT)UINT_FAST8_MAX);
353 printf("INT_FAST16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST16_MIN);
354 printf("INT_FAST16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST16_MAX);
355 printf("UINT_FAST16_MAX=%"PRIuMAX"\n",
356 (U__Q8_MT)UINT_FAST16_MAX);
357 printf("INT_FAST32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST32_MIN);
358 printf("INT_FAST32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST32_MAX);
359 printf("UINT_FAST32_MAX=%"PRIuMAX"\n",
360 (U__Q8_MT)UINT_FAST32_MAX);
361 #ifdef INT_FAST64_MAX
362 printf("INT_FAST64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST64_MIN);
363 printf("INT_FAST64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST64_MAX);
364 printf("UINT_FAST64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_FAST64_MAX);
366 #ifdef INT_FAST128_MAX
367 printf("INT_FAST128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST128_MIN);
368 printf("INT_FAST128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST128_MAX);
369 printf("UINT_FAST128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_FAST128_MAX);
372 printf("INTPTR_MIN=%"PRIdMAX"\n", (__Q8_MT)INTPTR_MIN);
373 printf("INTPTR_MAX=%"PRIdMAX"\n", (__Q8_MT)INTPTR_MAX);
376 printf("UINTPTR_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINTPTR_MAX);
379 printf("INTMAX_MIN=%"PRIdMAX"\n", (__Q8_MT)INTMAX_MIN);
380 printf("INTMAX_MAX=%"PRIdMAX"\n", (__Q8_MT)INTMAX_MAX);
381 printf("UINTMAX_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINTMAX_MAX);
384 printf("PTRDIFF_MIN=%"PRIdMAX"\n", (__Q8_MT)PTRDIFF_MIN);
385 printf("PTRDIFF_MAX=%"PRIdMAX"\n", (__Q8_MT)PTRDIFF_MAX);
387 #ifdef SIG_ATOMIC_MAX
388 #if SIG_ATOMIC_MIN < 0
389 printf("SIG_ATOMIC_MIN=%"PRIdMAX"\n", (__Q8_MT)SIG_ATOMIC_MIN);
390 printf("SIG_ATOMIC_MAX=%"PRIdMAX"\n", (__Q8_MT)SIG_ATOMIC_MAX);
392 printf("SIG_ATOMIC_MIN=%"PRIuMAX"\n", (U__Q8_MT)SIG_ATOMIC_MIN);
393 printf("SIG_ATOMIC_MAX=%"PRIuMAX"\n", (U__Q8_MT)SIG_ATOMIC_MAX);
397 printf("SIZE_MAX=%"PRIuMAX"\n", (U__Q8_MT)SIZE_MAX);
402 printf("WCHAR_MIN=%"PRIdMAX"\n", (__Q8_MT)WCHAR_MIN);
403 printf("WCHAR_MAX=%"PRIdMAX"\n", (__Q8_MT)WCHAR_MAX);
405 printf("WCHAR_MIN=%"PRIuMAX"\n", (U__Q8_MT)WCHAR_MIN);
406 printf("WCHAR_MAX=%"PRIuMAX"\n", (U__Q8_MT)WCHAR_MAX);
411 printf("WINT_MIN=%"PRIdMAX"\n", (__Q8_MT)WINT_MIN);
412 printf("WINT_MAX=%"PRIdMAX"\n", (__Q8_MT)WINT_MAX);
414 printf("WINT_MIN=%"PRIuMAX"\n", (U__Q8_MT)WINT_MIN);
415 printf("WINT_MAX=%"PRIuMAX"\n", (U__Q8_MT)WINT_MAX);
420 7.18.4 Macros for integer constants
423 /* INTn_C for n=8 and 16 were at one point unimplementable
424 on most platforms, so they're treated as "optional": */
426 if ( INT8_C(-123) != -123 )
427 printf("*** INT8_C(-123) produced %"PRIdMAX" ***\n",
428 (__Q8_MT)INT8_C(-123)
430 if ( UINT8_C(123) != 123 )
431 printf("*** UINT8_C(123) produced %"PRIuMAX" ***\n",
432 (U__Q8_MT)UINT8_C(123)
436 if ( INT16_C(-12345) != -12345 )
437 printf("*** INT16_C(-12345) produced %"PRIdMAX" ***\n",
438 (__Q8_MT)INT16_C(-12345)
440 if ( UINT16_C(12345) != 12345 )
441 printf("*** UINT16_C(12345) produced %"PRIuMAX" ***\n",
442 (U__Q8_MT)UINT16_C(12345)
445 if ( INT32_C(-123456789) != -123456789 )
446 printf("*** INT32_C(-123456789) produced %"PRIdMAX" ***\n",
447 (__Q8_MT)INT32_C(-123456789)
449 if ( UINT32_C(123456789) != 123456789 )
450 printf("*** UINT32_C(123456789) produced %"PRIuMAX" ***\n",
451 (U__Q8_MT)UINT32_C(123456789)
453 #ifdef INT_LEAST64_MAX
454 if ( INT64_C(-1234567890123456789) != -1234567890123456789 )
455 printf("*** INT64_C(-1234567890123456789) produced %"PRIdMAX
457 (__Q8_MT)INT64_C(-1234567890123456789)
459 if ( UINT64_C(1234567890123456789) != 1234567890123456789 )
460 printf("*** UINT64_C(1234567890123456789) produced %"PRIuMAX
462 (U__Q8_MT)UINT64_C(1234567890123456789)
466 if ( INTMAX_C(-1234567890123456789) != -1234567890123456789 )
467 printf("*** INTMAX_C(-1234567890123456789) produced %"PRIdMAX
469 (__Q8_MT)INTMAX_C(-1234567890123456789)
471 if ( UINTMAX_C(1234567890123456789) != 1234567890123456789 )
472 printf("*** UINTMAX_C(1234567890123456789) produced %"PRIuMAX
474 (U__Q8_MT)UINTMAX_C(1234567890123456789)
478 /* <inttypes.h> features: */
480 #if __STDC_VERSION__ >= 199901
481 printf("sizeof(imaxdiv_t)=%u\n", (unsigned)sizeof(imaxdiv_t));
485 7.8.1 Macros for format specifiers
489 /* scanf these strings */
490 static const char in_dn[] = "Z119bZ";
491 static const char in_dmo[] = "Z-0119bZ";
492 static const char in_dspx[] = "Z \t\n +0X119bZ";
493 static const char in_dsmx[] = "Z \t\n -0x119bZ";
494 static const char in_dsn[] = "Z \t\n 119bZ";
495 static const char in_dp[] = "Z+119bZ";
496 static const char in_dpx[] = "Z+0X119bz";
498 /* sprintf into this */
499 static char buffer[1024];
503 #define SCAN(buf,fs,var,exp) if ( sscanf(buf, "Z%" fs, &var) != 1 ) \
505 printf("***%s=",fs, STR_SUB(fs) \
508 status = EXIT_FAILURE; \
510 else if ( var != (exp) ) \
512 printf("***%s=",fs, STR_SUB(fs) \
513 " should be: " STR_SUB(exp) \
514 ", was: %" fs " ***\n", var \
516 status = EXIT_FAILURE; \
518 else /* for trailing semicolon */
520 #define PRINT(fs,var,exp) if ( sprintf(buffer, "%" fs, var ) <= 0 ) \
522 printf("***%s=",fs, STR_SUB(fs) \
525 status = EXIT_FAILURE; \
527 else if ( strcmp(buffer, STR_SUB(exp)) != 0 ) \
529 printf("***%s=",fs, STR_SUB(fs) \
530 " should be: " STR_SUB(exp) \
531 ", was: %s ***\n", buffer \
533 status = EXIT_FAILURE; \
535 else /* for trailing semicolon */
539 #define SCAN(buf,fs,var,exp)
540 #define PRINT(fs,var,exp)
546 SCAN(in_dn, SCNo32, int32, 9);
550 PRINT(PRIo32, int32, 11);
552 SCAN(in_dmo, SCNiLEAST16, intl16, -9);
553 SCAN(in_dspx, SCNdLEAST16, intl16, 0);
554 SCAN(in_dsmx, SCNiLEAST16, intl16, -4507);
555 PRINT(PRIdLEAST16, intl16, -4507);
556 PRINT(PRIiLEAST16, intl16, -4507);
557 SCAN(in_dsn, SCNxLEAST16, uintl16, 4507);
558 PRINT(PRIoLEAST16, uintl16, 10633);
559 PRINT(PRIuLEAST16, uintl16, 4507);
560 PRINT(PRIxLEAST16, uintl16, 119b);
561 PRINT(PRIXLEAST16, uintl16, 119B);
562 SCAN(in_dp, SCNxFAST16, uintf16, 4507);
563 PRINT(PRIxFAST16, uintf16, 119b);
565 SCAN(in_dp, SCNdMAX, intmax, 119);
568 PRINT(PRIiMAX, intmax, 119);
571 SCAN(in_dpx, SCNoMAX, uintmax, 0);
574 PRINT(PRIxMAX, uintmax, 0);
576 /* Obviously there should be a much larger battery of such tests. */
579 #if defined(INTMAX_MAX) /* <inttypes.h> has C99 features */
581 7.8.2 Functions for greatest-width integer types
592 { INT8_MAX, INT8_MAX, },
593 { -INT8_MAX, INT8_MAX, },
594 { UINT8_MAX, UINT8_MAX, },
600 { INT16_MAX, INT16_MAX, },
601 { -INT16_MAX, INT16_MAX, },
602 { UINT16_MAX, UINT16_MAX, },
605 { INT32_MAX, INT32_MAX, },
606 { -INT32_MAX, INT32_MAX, },
607 #ifdef INT_LEAST64_MAX /* else might support only 32 bits */
608 { UINT32_MAX, UINT32_MAX, },
612 { INT64_MAX, INT64_MAX, },
613 { -INT64_MAX, INT64_MAX, },
615 { INT_LEAST8_MAX, INT_LEAST8_MAX, },
616 { -INT_LEAST8_MAX, INT_LEAST8_MAX, },
617 { UINT_LEAST8_MAX, UINT_LEAST8_MAX, },
618 { INT_LEAST16_MAX, INT_LEAST16_MAX, },
619 { -INT_LEAST16_MAX, INT_LEAST16_MAX, },
620 { UINT_LEAST16_MAX, UINT_LEAST16_MAX, },
621 { INT_LEAST32_MAX, INT_LEAST32_MAX, },
622 { -INT_LEAST32_MAX, INT_LEAST32_MAX, },
623 #ifdef INT_LEAST64_MAX
624 { UINT_LEAST32_MAX, UINT_LEAST32_MAX, },
625 { INT_LEAST64_MAX, INT_LEAST64_MAX, },
626 { -INT_LEAST64_MAX, INT_LEAST64_MAX, },
628 { INT_FAST8_MAX, INT_FAST8_MAX, },
629 { -INT_FAST8_MAX, INT_FAST8_MAX, },
630 { UINT_FAST8_MAX, UINT_FAST8_MAX, },
631 { INT_FAST16_MAX, INT_FAST16_MAX, },
632 { -INT_FAST16_MAX, INT_FAST16_MAX, },
633 { UINT_FAST16_MAX, UINT_FAST16_MAX, },
634 { INT_FAST32_MAX, INT_FAST32_MAX, },
635 { -INT_FAST32_MAX, INT_FAST32_MAX, },
636 #ifdef INT_FAST64_MAX
637 { UINT_FAST32_MAX, UINT_FAST32_MAX, },
638 { INT_FAST64_MAX, INT_FAST64_MAX, },
639 { -INT_FAST64_MAX, INT_FAST64_MAX, },
642 { INTPTR_MAX, INTPTR_MAX, },
643 { -INTPTR_MAX, INTPTR_MAX, },
646 { UINTPTR_MAX, UINTPTR_MAX, },
648 { INTMAX_MAX, INTMAX_MAX, },
650 { PTRDIFF_MAX, PTRDIFF_MAX, },
652 #ifdef SIG_ATOMIC_MAX
653 { SIG_ATOMIC_MAX, SIG_ATOMIC_MAX, },
654 #if SIG_ATOMIC_MIN < 0
655 { -SIG_ATOMIC_MAX, SIG_ATOMIC_MAX, },
659 { SIZE_MAX, SIZE_MAX, },
662 { WCHAR_MAX, WCHAR_MAX, },
664 { -WCHAR_MAX, WCHAR_MAX, },
668 { WINT_MAX, WINT_MAX, },
670 { -WINT_MAX, WINT_MAX, },
684 { -32767-1, 32768, },
686 { -65536+1, 65535, },
689 { 2147483647, 2147483647, },
690 { -2147483647, 2147483647, },
691 { 2147483648, 2147483648, },
692 { -2147483647-1, 2147483648, },
693 #ifdef INT_LEAST64_MAX /* else might support only 32 bits */
694 { 4294967295, 4294967295, },
695 { -4294967296+1, 4294967295, },
696 { 4294967296, 4294967296, },
697 { -4294967296, 4294967296, },
698 { 9223372036854775807, 9223372036854775807, },
699 { -9223372036854775807, 9223372036854775807, },
700 { 1234567890123456789, 1234567890123456789, },
701 { -1234567890123456789, 1234567890123456789, },
712 /* Other test cases can be added here. */
713 { 0, 0 /* terminates the list */ },
717 if ( (intmax = imaxabs(adp->input)) != adp->expect )
719 printf("*** imaxabs(%"PRIdMAX") failed; should be: %"
720 PRIdMAX", was: %"PRIdMAX" ***\n",
721 adp->input, adp->expect, intmax
723 status = EXIT_FAILURE;
725 // } while ( adp++->input != 0 );
726 } while ( (adp++)->input != 0 );
774 { 2147483647, 1, 2147483647, 0, },
775 { -2147483647, 1, -2147483647, 0, },
776 { 2147483648, 1, 2147483648, 0, },
777 { -2147483647-1, 1, -2147483647-1, 0, },
778 { 2147483647, 2, 1073741823, 1, },
779 { -2147483647, 2, -1073741823, -1, },
780 { 2147483648, 2, 1073741824, 0, },
781 { -2147483647-1, 2, -1073741824, 0, },
782 #ifdef INT_LEAST64_MAX /* else might support only 32 bits */
783 { 4294967295, 1, 4294967295, 0, },
784 { -4294967296+1, 1, -4294967296+1, 0, },
785 { 4294967296, 1, 4294967296, 0, },
786 { -4294967296, 1, -4294967296, 0, },
787 { 4294967295, -1, -4294967296+1, 0, },
788 { -4294967296+1, -1, 4294967295, 0, },
789 { 4294967296, -1, -4294967296, 0, },
790 { -4294967296, -1, 4294967296, 0, },
791 { 4294967295, 2, 2147483647, 1, },
792 { -4294967296+1, 2, -2147483647, -1, },
793 { 4294967296, 2, 2147483648, 0, },
794 { -4294967296, 2, -2147483647-1, 0, },
795 { 4294967295, 2147483647, 2, 1, },
796 { -4294967296+1, 2147483647, -2, -1, },
797 { 4294967296, 2147483647, 2, 2, },
798 { -4294967296, 2147483647, -2, -2, },
799 { 4294967295, -2147483647, -2, 1, },
800 { -4294967296+1, -2147483647, 2, -1, },
801 { 4294967296, -2147483647, -2, 2, },
802 { -4294967296, -2147483647, 2, -2, },
803 { 4294967295, 2147483648, 1, 2147483647, },
804 { -4294967296+1, 2147483648, -1, -2147483647, },
805 { 4294967296, 2147483648, 2, 0, },
806 { -4294967296, 2147483648, -2, 0, },
807 { 4294967295, -2147483647-1, -1, 2147483647, },
808 { -4294967296+1, -2147483647-1, 1, -2147483647,},
809 { 4294967296, -2147483647-1, -2, 0, },
810 { -4294967296, -2147483647-1, 2, 0, },
811 { 9223372036854775807, 1, 9223372036854775807, 0, },
812 { -9223372036854775807, 1, -9223372036854775807, 0, },
813 { 9223372036854775807, 2, 4611686018427387903, 1, },
814 { -9223372036854775807, 2, -4611686018427387903, -1, },
817 /* There should be a much larger battery of such tests. */
818 { 0, 0, 0, 0 }, /* 0 denom terminates the list */
822 for ( ddp = div_data; ddp->denom != 0; ++ddp )
823 if ( (result = imaxdiv(ddp->numer, ddp->denom)).quot
824 != ddp->exp_quot || result.rem != ddp->exp_rem
826 // printf("*** imaxdiv(%"PRIdMAX",%"PRIdMAX
827 // ") failed; should be: (%"PRIdMAX",%"PRIdMAX
828 // "), was: (%"PRIdMAX",%"PRIdMAX") ***\n",
829 // ddp->numer, ddp->denom, ddp->exp_quot,
830 // ddp->exp_rem, result.quot, result.rem
832 printf("err:imaxdiv(%"PRIdMAX",%"PRIdMAX
833 ") = (%"PRIdMAX",%"PRIdMAX
834 "), is: (%"PRIdMAX",%"PRIdMAX")\n",
835 ddp->numer, ddp->denom, ddp->exp_quot,
836 ddp->exp_rem, result.quot, result.rem
838 status = EXIT_FAILURE;
846 static char saved[64]; /* holds copy of input string */
847 static wchar_t wnptr[64]; /* holds wide copy of test string */
848 static int warned; /* "warned for null endptr" flag */
890 { "Inf", 10, 0, 0, },
891 { "Inf", 16, 0, 0, },
892 { "Inf", 36, 24171, 3, },
893 { "+Inf", 0, 0, 0, },
894 { "+Inf", 2, 0, 0, },
895 { "+Inf", 8, 0, 0, },
896 { "+Inf", 9, 0, 0, },
897 { "+Inf", 10, 0, 0, },
898 { "+Inf", 16, 0, 0, },
899 { "+Inf", 36, 24171, 4, },
900 { "-Inf", 0, 0, 0, },
901 { "-Inf", 2, 0, 0, },
902 { "-Inf", 8, 0, 0, },
903 { "-Inf", 9, 0, 0, },
904 { "-Inf", 10, 0, 0, },
905 { "-Inf", 16, 0, 0, },
906 { "-Inf", 36, -24171, 4, },
911 { "inf", 10, 0, 0, },
912 { "inf", 16, 0, 0, },
913 { "inf", 36, 24171, 3, },
914 { "+inf", 0, 0, 0, },
915 { "+inf", 2, 0, 0, },
916 { "+inf", 8, 0, 0, },
917 { "+inf", 9, 0, 0, },
918 { "+inf", 10, 0, 0, },
919 { "+inf", 16, 0, 0, },
920 { "+inf", 36, 24171, 4, },
921 { "-inf", 0, 0, 0, },
922 { "-inf", 2, 0, 0, },
923 { "-inf", 8, 0, 0, },
924 { "-inf", 9, 0, 0, },
925 { "-inf", 10, 0, 0, },
926 { "-inf", 16, 0, 0, },
927 { "-inf", 36, -24171, 4, },
928 { "119b8Z", 0, 119, 3, },
929 { "119bZ", 0, 119, 3, },
930 { "-0119bZ", 0, -9, 4, },
931 { " \t\n 0X119bZ", 0, 4507, 10, },
932 { " \t\n +0X119bZ", 0, 4507, 11, },
933 { " \t\n -0x119bZ", 0, -4507, 11, },
934 { " \t\n 119bZ", 0, 119, 7, },
935 { "+119bZ", 0, 119, 4, },
936 { "+0X119bz", 0, 4507, 7, },
937 { "119b8Z", 2, 3, 2, },
938 { "119bZ", 2, 3, 2, },
939 { "-0119bZ", 2, -3, 4, },
940 { " \t\n 0X119bZ", 2, 0, 5, },
941 { " \t\n +0X119bZ", 2, 0, 6, },
942 { " \t\n -0x119bZ", 2, 0, 6, },
943 { " \t\n 119bZ", 2, 3, 6, },
944 { "+119bZ", 2, 3, 3, },
945 { "+0X119bz", 2, 0, 2, },
946 { "119b8Z", 8, 9, 2, },
947 { "119bZ", 8, 9, 2, },
948 { "-0119bZ", 8, -9, 4, },
949 { " \t\n 0X119bZ", 8, 0, 5, },
950 { " \t\n +0X119bZ", 8, 0, 6, },
951 { " \t\n -0x119bZ", 8, 0, 6, },
952 { " \t\n 119bZ", 8, 9, 6, },
953 { "+119bZ", 8, 9, 3, },
954 { "+0X119bz", 8, 0, 2, },
955 { "119b8Z", 9, 10, 2, },
956 { "119bZ", 9, 10, 2, },
957 { "-0119bZ", 9, -10, 4, },
958 { " \t\n 0X119bZ", 9, 0, 5, },
959 { " \t\n +0X119bZ", 9, 0, 6, },
960 { " \t\n -0x119bZ", 9, 0, 6, },
961 { " \t\n 119bZ", 9, 10, 6, },
962 { "+119bZ", 9, 10, 3, },
963 { "+0X119bz", 9, 0, 2, },
964 { "119b8Z", 10, 119, 3, },
965 { "119bZ", 10, 119, 3, },
966 { "-0119bZ", 10, -119, 5, },
967 { " \t\n 0X119bZ", 10, 0, 5, },
968 { " \t\n +0X119bZ", 10, 0, 6, },
969 { " \t\n -0x119bZ", 10, 0, 6, },
970 { " \t\n 119bZ", 10, 119, 7, },
971 { "+119bZ", 10, 119, 4, },
972 { "+0X119bz", 10, 0, 2, },
973 { "119b8Z", 16, 72120, 5, },
974 { "119bZ", 16, 4507, 4, },
975 { "-0119bZ", 16, -4507, 6, },
976 { " \t\n 0X119bZ", 16, 4507, 10, },
977 { " \t\n +0X119bZ", 16, 4507, 11, },
978 { " \t\n -0x119bZ", 16, -4507, 11, },
979 { " \t\n 119bZ", 16, 4507,8, },
980 { "+119bZ", 16, 4507, 5, },
981 { "+0X119bz", 16, 4507, 7, },
982 { "119b8Z", 36, 62580275, 6, },
983 { "119bZ", 36, 1738367, 5, },
984 { "-0119bZ", 36, -1738367, 7, },
985 { " \t\n 0X119bZ", 36, 1997122175, 11, },
986 { " \t\n +0X119bZ", 36, 1997122175, 12, },
987 { " \t\n -0x119bZ", 36, -1997122175, 12, },
988 { " \t\n 119bZ", 36, 1738367, 9, },
989 { "+119bZ", 36, 1738367, 6, },
990 { "+0X119bz", 36, 1997122175, 8, },
991 /* There should be a much larger battery of such tests. */
992 { "127", 0, 127, 3, },
993 { "-127", 0, -127, 4, },
994 { "128", 0, 128, 3, },
995 { "-128", 0, -127-1, 4, },
996 { "255", 0, 255, 3, },
997 { "-255", 0, -255, 4, },
998 { "256", 0, 256, 3, },
999 { "-256", 0, -255-1, 4, },
1000 { "32767", 0, 32767, 5, },
1001 { "-32767", 0, -32767, 6, },
1002 { "32768", 0, 32768, 5, },
1003 { "-32768", 0, -32767-1, 6, },
1004 { "65535", 0, 65535, 5, },
1005 { "-65535", 0, -65536+1, 6, },
1006 { "65536", 0, 65536, 5, },
1007 { "-65536", 0, -65536, 6, },
1008 { "2147483647", 0, 2147483647, 10, },
1009 { "-2147483647", 0, -2147483647, 11, },
1010 { "2147483648", 0, 2147483648, 10, },
1011 { "-2147483648", 0, -2147483647-1, 11, },
1012 { "4294967295", 0, 4294967295, 10, },
1013 { "-4294967295", 0, -4294967296+1, 11, },
1014 { "4294967296", 0, 4294967296, 10, },
1015 { "-4294967296", 0, -4294967296, 11, },
1016 { "9223372036854775807", 0, 9223372036854775807, 19, },
1017 { "-9223372036854775807", 0, -9223372036854775807, 20, },
1018 { "1234567890123456789", 0, 1234567890123456789, 19, },
1019 { "-1234567890123456789", 0, -1234567890123456789, 20, },
1021 { "-1", 0, -1, 2, },
1023 { "-2", 0, -2, 2, },
1024 { "10", 0, 10, 2, },
1025 { "-10", 0, -10, 3, },
1026 { "16", 0, 16, 2, },
1027 { "-16", 0, -16, 3, },
1028 /* Other test cases can be added here. */
1029 { NULL, 0, 0, 0 }, /* terminates the list */
1032 for ( sdp = str_data; sdp->nptr != NULL ; ++sdp )
1035 7.8.2.3 The strtoimax and strtoumax functions
1038 strcpy(saved, sdp->nptr);
1040 errno = 0; /* shouldn't be changed */
1042 if ( (intmax = strtoimax(sdp->nptr, &endptr, sdp->base))
1047 printf("*** strtoimax(%s,,%d) failed; should be: %"
1048 PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr,
1049 sdp->base, sdp->exp_val, intmax
1051 status = EXIT_FAILURE;
1054 else if ( endptr != sdp->nptr + sdp->exp_len )
1058 printf("*** strtoimax(%s,,%d) returned wrong endptr"
1059 " ***\n", sdp->nptr, sdp->base
1061 status = EXIT_FAILURE;
1067 printf("*** strtoimax modified errno ***\n");
1068 status = EXIT_FAILURE;
1071 if ( strcmp(sdp->nptr, saved) != 0 )
1073 printf("*** strtoimax modified its input ***\n");
1074 status = EXIT_FAILURE;
1075 strcpy(saved, sdp->nptr);
1078 if ( sdp->exp_val >= 0 ) /* else some sign extension */
1080 errno = 0; /* shouldn't be changed */
1082 if ( (uintmax = strtoumax(sdp->nptr, &endptr, sdp->base
1088 printf("*** strtoumax(%s,,%d) failed; "
1089 "should be: %"PRIuMAX", was: %"PRIuMAX
1090 " ***\n", sdp->nptr, sdp->base,
1091 sdp->exp_val, uintmax
1093 status = EXIT_FAILURE;
1096 else if ( endptr != sdp->nptr + sdp->exp_len )
1100 printf("*** strtoumax(%s,,%d) returned wrong "
1101 "endptr ***\n", sdp->nptr, sdp->base
1103 status = EXIT_FAILURE;
1109 printf("*** strtoumax modified errno ***\n");
1110 status = EXIT_FAILURE;
1113 if ( strcmp(sdp->nptr, saved) != 0 )
1115 printf("*** strtoumax"
1116 " modified its input ***\n"
1118 status = EXIT_FAILURE;
1119 strcpy(saved, sdp->nptr);
1123 /* tests for null endptr */
1125 #define WARN() if (!warned) warned = 1, printf("*** Using null endptr: ***\n")
1128 errno = 0; /* shouldn't be changed */
1130 if ( (intmax = strtoimax(sdp->nptr, (char **)NULL, sdp->base))
1136 printf("*** strtoimax(%s,NULL,%d) failed; "
1137 "should be: %"PRIdMAX", was: %"PRIdMAX" ***\n",
1138 sdp->nptr, sdp->base, sdp->exp_val, intmax
1140 status = EXIT_FAILURE;
1147 printf("*** strtoimax modified errno ***\n");
1148 status = EXIT_FAILURE;
1151 if ( strcmp(sdp->nptr, saved) != 0 )
1154 printf("*** strtoimax modified its input ***\n");
1155 status = EXIT_FAILURE;
1156 strcpy(saved, sdp->nptr);
1159 if ( sdp->exp_val >= 0 ) /* else some sign extension */
1161 errno = 0; /* shouldn't be changed */
1163 if ( (uintmax = strtoumax(sdp->nptr, (char **)NULL,
1171 printf("*** strtoumax(%s,NULL,%d) failed; "
1172 "should be: %"PRIuMAX", was: %"PRIuMAX
1173 " ***\n", sdp->nptr, sdp->base,
1174 sdp->exp_val, uintmax
1176 status = EXIT_FAILURE;
1183 printf("*** strtoumax modified errno ***\n");
1184 status = EXIT_FAILURE;
1187 if ( strcmp(sdp->nptr, saved) != 0 )
1190 printf("*** strtoumax"
1191 " modified its input ***\n"
1193 status = EXIT_FAILURE;
1194 strcpy(saved, sdp->nptr);
1199 7.8.2.4 The wcstoimax and wcstoumax functions
1202 for ( i = 0; i < 64; ++i )
1203 if ( (wnptr[i] = sdp->nptr[i]) == '\0' )
1206 errno = 0; /* shouldn't be changed */
1208 if ( (intmax = wcstoimax(wnptr, &wendptr, sdp->base))
1213 printf("*** wcstoimax(%s,,%d) failed; should be: %"
1214 PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr,
1215 sdp->base, sdp->exp_val, intmax
1217 status = EXIT_FAILURE;
1220 else if ( wendptr != wnptr + sdp->exp_len )
1224 printf("*** wcstoimax(%s,,%d) returned wrong endptr"
1225 " ***\n", sdp->nptr, sdp->base
1227 status = EXIT_FAILURE;
1233 printf("*** wcstoimax modified errno ***\n");
1234 status = EXIT_FAILURE;
1237 for ( i = 0; i < 64; ++i )
1238 if ( wnptr[i] != sdp->nptr[i] )
1240 printf("*** wcstoimax modified its input ***\n"
1242 status = EXIT_FAILURE;
1244 for ( ; i < 64; ++i )
1245 if ( (wnptr[i] = sdp->nptr[i]) == '\0' )
1250 else if ( wnptr[i] == '\0' )
1253 if ( sdp->exp_val >= 0 ) /* else some sign extension */
1255 errno = 0; /* shouldn't be changed */
1257 if ( (uintmax = wcstoumax(wnptr, &wendptr, sdp->base)
1262 printf("*** wcstoumax(%s,,%d) failed; "
1263 "should be: %"PRIuMAX", was: %"PRIuMAX
1264 " ***\n", sdp->nptr, sdp->base,
1265 sdp->exp_val, uintmax
1267 status = EXIT_FAILURE;
1270 else if ( wendptr != wnptr + sdp->exp_len )
1274 printf("*** wcstoumax(%s,,%d) returned wrong "
1275 "endptr ***\n", sdp->nptr, sdp->base
1277 status = EXIT_FAILURE;
1283 printf("*** wcstoumax modified errno ***\n");
1284 status = EXIT_FAILURE;
1287 for ( i = 0; i < 64; ++i )
1288 if ( wnptr[i] != sdp->nptr[i] )
1290 printf("*** wcstoumax"
1291 " modified its input ***\n"
1293 status = EXIT_FAILURE;
1295 for ( ; i < 64; ++i )
1296 if ( (wnptr[i] = sdp->nptr[i])
1303 else if ( wnptr[i] == '\0' )
1307 /* tests for null endptr */
1310 errno = 0; /* shouldn't be changed */
1312 if ( (intmax = wcstoimax(wnptr, (wchar_t **)NULL, sdp->base))
1318 printf("*** wcstoimax(%s,NULL,%d) failed; should be: %"
1319 PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr,
1320 sdp->base, sdp->exp_val, intmax
1322 status = EXIT_FAILURE;
1329 printf("*** wcstoimax modified errno ***\n");
1330 status = EXIT_FAILURE;
1333 for ( i = 0; i < 64; ++i )
1334 if ( wnptr[i] != sdp->nptr[i] )
1337 printf("*** wcstoimax modified its input ***\n"
1339 status = EXIT_FAILURE;
1341 for ( ; i < 64; ++i )
1342 if ( (wnptr[i] = sdp->nptr[i])
1349 else if ( wnptr[i] == '\0' )
1352 if ( sdp->exp_val >= 0 ) /* else some sign extension */
1354 errno = 0; /* shouldn't be changed */
1356 if ( (uintmax = wcstoumax(wnptr, (wchar_t **)NULL,
1364 printf("*** wcstoumax(%s,NULL,%d) failed; "
1365 "should be: %"PRIuMAX", was: %"PRIuMAX
1366 " ***\n", sdp->nptr, sdp->base,
1367 sdp->exp_val, uintmax
1369 status = EXIT_FAILURE;
1376 printf("*** wcstoumax modified errno ***\n");
1377 status = EXIT_FAILURE;
1380 for ( i = 0; i < 64; ++i )
1381 if ( wnptr[i] != sdp->nptr[i] )
1384 printf("*** wcstoumax"
1385 " modified its input ***\n"
1387 status = EXIT_FAILURE;
1389 for ( ; i < 64; ++i )
1390 if ( (wnptr[i] = sdp->nptr[i])
1397 else if ( wnptr[i] == '\0' )
1403 7.8.2.3 The strtoimax and strtoumax functions (continued)
1406 if ( (intmax = strtoimax("1234567890123456789012345678901234567890"
1407 "1234567890123456789012345678901234567890"
1408 "1234567890123456789012345678901234567890"
1409 "1234567890123456789012345678901234567890"
1410 "1234567890123456789012345678901234567890"
1411 "1234567890123456789012345678901234567890",
1414 ) != INTMAX_MAX || errno != ERANGE
1416 printf("*** strtoimax failed overflow test ***\n");
1417 status = EXIT_FAILURE;
1420 if ( (intmax = strtoimax("+1234567890123456789012345678901234567890"
1421 "1234567890123456789012345678901234567890"
1422 "1234567890123456789012345678901234567890"
1423 "1234567890123456789012345678901234567890"
1424 "1234567890123456789012345678901234567890"
1425 "1234567890123456789012345678901234567890",
1428 ) != INTMAX_MAX || errno != ERANGE
1430 printf("*** strtoimax failed +overflow test ***\n");
1431 status = EXIT_FAILURE;
1434 if ( (intmax = strtoimax("-1234567890123456789012345678901234567890"
1435 "1234567890123456789012345678901234567890"
1436 "1234567890123456789012345678901234567890"
1437 "1234567890123456789012345678901234567890"
1438 "1234567890123456789012345678901234567890"
1439 "1234567890123456789012345678901234567890",
1442 ) != INTMAX_MIN || errno != ERANGE
1444 printf("*** strtoimax failed -overflow test ***\n");
1445 status = EXIT_FAILURE;
1448 if ( (uintmax = strtoumax("1234567890123456789012345678901234567890"
1449 "1234567890123456789012345678901234567890"
1450 "1234567890123456789012345678901234567890"
1451 "1234567890123456789012345678901234567890"
1452 "1234567890123456789012345678901234567890"
1453 "1234567890123456789012345678901234567890",
1456 ) != UINTMAX_MAX || errno != ERANGE
1458 printf("*** strtoumax failed overflow test ***\n");
1459 status = EXIT_FAILURE;
1462 if ( (uintmax = strtoumax("+1234567890123456789012345678901234567890"
1463 "1234567890123456789012345678901234567890"
1464 "1234567890123456789012345678901234567890"
1465 "1234567890123456789012345678901234567890"
1466 "1234567890123456789012345678901234567890"
1467 "1234567890123456789012345678901234567890",
1470 ) != UINTMAX_MAX || errno != ERANGE
1472 printf("*** strtoumax failed +overflow test ***\n");
1473 status = EXIT_FAILURE;
1476 if ( (uintmax = strtoumax("-1234567890123456789012345678901234567890"
1477 "1234567890123456789012345678901234567890"
1478 "1234567890123456789012345678901234567890"
1479 "1234567890123456789012345678901234567890"
1480 "1234567890123456789012345678901234567890"
1481 "1234567890123456789012345678901234567890",
1484 ) != UINTMAX_MAX || errno != ERANGE
1486 printf("*** strtoumax failed -overflow test ***\n");
1487 status = EXIT_FAILURE;
1491 7.8.2.4 The wcstoimax and wcstoumax functions (continued)
1494 #ifdef NO_INTERNAL_WCHAR
1495 printf("NO_INTERNAL_WCHAR\n");
1498 if ( (intmax = wcstoimax(L"1234567890123456789012345678901234567890"
1499 L"1234567890123456789012345678901234567890"
1500 L"1234567890123456789012345678901234567890"
1501 L"1234567890123456789012345678901234567890"
1502 L"1234567890123456789012345678901234567890"
1503 L"1234567890123456789012345678901234567890",
1506 ) != INTMAX_MAX || errno != ERANGE
1508 printf("*** wcstoimax failed overflow test ***\n");
1509 status = EXIT_FAILURE;
1512 if ( (intmax = wcstoimax(L"+1234567890123456789012345678901234567890"
1513 L"1234567890123456789012345678901234567890"
1514 L"1234567890123456789012345678901234567890"
1515 L"1234567890123456789012345678901234567890"
1516 L"1234567890123456789012345678901234567890"
1517 L"1234567890123456789012345678901234567890",
1520 ) != INTMAX_MAX || errno != ERANGE
1522 printf("*** wcstoimax failed +overflow test ***\n");
1523 status = EXIT_FAILURE;
1526 if ( (intmax = wcstoimax(L"-1234567890123456789012345678901234567890"
1527 L"1234567890123456789012345678901234567890"
1528 L"1234567890123456789012345678901234567890"
1529 L"1234567890123456789012345678901234567890"
1530 L"1234567890123456789012345678901234567890"
1531 L"1234567890123456789012345678901234567890",
1534 ) != INTMAX_MIN || errno != ERANGE
1536 printf("*** wcstoimax failed -overflow test ***\n");
1537 status = EXIT_FAILURE;
1540 if ( (uintmax = wcstoumax(L"1234567890123456789012345678901234567890"
1541 L"1234567890123456789012345678901234567890"
1542 L"1234567890123456789012345678901234567890"
1543 L"1234567890123456789012345678901234567890"
1544 L"1234567890123456789012345678901234567890"
1545 L"1234567890123456789012345678901234567890",
1548 ) != UINTMAX_MAX || errno != ERANGE
1550 printf("*** wcstoumax failed overflow test ***\n");
1551 status = EXIT_FAILURE;
1554 if ( (uintmax = wcstoumax(L"+1234567890123456789012345678901234567890"
1555 L"1234567890123456789012345678901234567890"
1556 L"1234567890123456789012345678901234567890"
1557 L"1234567890123456789012345678901234567890"
1558 L"1234567890123456789012345678901234567890"
1559 L"1234567890123456789012345678901234567890",
1562 ) != UINTMAX_MAX || errno != ERANGE
1564 printf("*** wcstoumax failed +overflow test ***\n");
1565 status = EXIT_FAILURE;
1568 if ( (uintmax = wcstoumax(L"-1234567890123456789012345678901234567890"
1569 L"1234567890123456789012345678901234567890"
1570 L"1234567890123456789012345678901234567890"
1571 L"1234567890123456789012345678901234567890"
1572 L"1234567890123456789012345678901234567890"
1573 L"1234567890123456789012345678901234567890",
1576 ) != UINTMAX_MAX || errno != ERANGE
1578 printf("*** wcstoumax failed -overflow test ***\n");
1579 status = EXIT_FAILURE;
1581 #endif // NO_INTERNAL_WCHAR
1583 #endif /* defined(INTMAX_MAX) */
1586 printf("sitest failed.\n");