2 sitest -- exercise features of C99 <stdint.h> and <inttypes.h>
4 This source code has been placed into the PUBLIC DOMAIN by its author.
6 last edit: 1999/11/05 gwyn@arl.mil
8 Tries to accommodate pre-C99 versions of <inttypes.h>.
10 Takes advantage of __Q8_* symbols defined by a particular
11 implementation of <stdint.h>, but doesn't require them.
13 NOTE: This is not a thorough validation test of the facilities.
17 #include <limits.h> /* for CHAR_BIT */
19 #include <stddef.h> /* for ptrdiff_t */
23 #include <inttypes.h> /* embeds <stdint.h> */
24 #include <signal.h> /* for sig_atomic_t */
25 #if defined(INTMAX_MAX) /* <inttypes.h> has C99 features */
29 #include <inttypes.h> /* test idempotency */
31 #if 1 /* __STDC_VERSION__ >= 199901 */
33 #define __Q8_QT long long
40 #define __Q8_MT intmax_t
45 #define __Q8_MT int_least64_t
47 #define PRIdMAX PRIdLEAST64
58 #define U__Q8_MT uintmax_t
61 #define U__Q8_MT uint_least64_t
62 #define PRIuMAX PRIuLEAST64
64 #define U__Q8_MT unsigned long
70 #define STRINGIZE(s) STR_SUB(s) /* extra level to expand argument */
72 #if defined(SCNo32) || defined(PRIo32)
75 static int_least16_t intl16;
76 static uint_least16_t uintl16;
77 static uint_fast16_t uintf16;
78 static intmax_t intmax;
79 static uintmax_t uintmax;
83 int status = 0; /* exit status to be returned */
85 /* <stdint.h> features: */
87 printf("CHAR_BIT=%u\n", (unsigned)CHAR_BIT );
88 printf("sizeof(char)=%u\n", (unsigned)sizeof(char)); /* s.b. 1 */
89 printf("sizeof(short)=%u\n", (unsigned)sizeof(short));
90 printf("sizeof(int)=%u\n", (unsigned)sizeof(int));
91 printf("sizeof(long)=%u\n", (unsigned)sizeof(long));
93 printf("sizeof(long long)=%u\n", (unsigned)sizeof(__Q8_QT));
95 printf("sizeof(intmax_t)=%u\n", (unsigned)sizeof(intmax_t));
96 printf("sizeof(ptrdiff_t)=%u\n", (unsigned)sizeof(ptrdiff_t));
97 printf("sizeof(size_t)=%u\n", (unsigned)sizeof(size_t));
98 printf("sizeof(sig_atomic_t)=%u\n", (unsigned)sizeof(sig_atomic_t));
99 printf("sizeof(wchar_t)=%u\n", (unsigned)sizeof(wchar_t));
100 #if defined(WINT_MAX) || __STDC_VERSION__ >= 199901
101 printf("sizeof(wint_t)=%u\n", (unsigned)sizeof(wint_t));
103 printf("*** wint_t isn't defined ***\n");
104 status = EXIT_FAILURE;
107 printf("sizeof(int8_t)=%u\n", (unsigned)sizeof(int8_t));
108 printf("sizeof(uint8_t)=%u\n", (unsigned)sizeof(uint8_t));
111 printf("sizeof(int9_t)=%u\n", (unsigned)sizeof(int9_t));
112 printf("sizeof(uint9_t)=%u\n", (unsigned)sizeof(uint9_t));
115 printf("sizeof(int12_t)=%u\n", (unsigned)sizeof(int12_t));
116 printf("sizeof(uint12_t)=%u\n", (unsigned)sizeof(uint12_t));
119 printf("sizeof(int16_t)=%u\n", (unsigned)sizeof(int16_t));
120 printf("sizeof(uint16_t)=%u\n", (unsigned)sizeof(uint16_t));
123 printf("sizeof(int18_t)=%u\n", (unsigned)sizeof(int18_t));
124 printf("sizeof(uint18_t)=%u\n", (unsigned)sizeof(uint18_t));
127 printf("sizeof(int24_t)=%u\n", (unsigned)sizeof(int24_t));
128 printf("sizeof(uint24_t)=%u\n", (unsigned)sizeof(uint24_t));
131 printf("sizeof(int32_t)=%u\n", (unsigned)sizeof(int32_t));
132 printf("sizeof(uint32_t)=%u\n", (unsigned)sizeof(uint32_t));
135 printf("sizeof(int36_t)=%u\n", (unsigned)sizeof(int36_t));
136 printf("sizeof(uint36_t)=%u\n", (unsigned)sizeof(uint36_t));
139 printf("sizeof(int40_t)=%u\n", (unsigned)sizeof(int40_t));
140 printf("sizeof(uint40_t)=%u\n", (unsigned)sizeof(uint40_t));
143 printf("sizeof(int48_t)=%u\n", (unsigned)sizeof(int48_t));
144 printf("sizeof(uint48_t)=%u\n", (unsigned)sizeof(uint48_t));
147 printf("sizeof(int60_t)=%u\n", (unsigned)sizeof(int60_t));
148 printf("sizeof(uint60_t)=%u\n", (unsigned)sizeof(uint60_t));
151 printf("sizeof(int64_t)=%u\n", (unsigned)sizeof(int64_t));
152 printf("sizeof(uint64_t)=%u\n", (unsigned)sizeof(uint64_t));
155 printf("sizeof(int72_t)=%u\n", (unsigned)sizeof(int72_t));
156 printf("sizeof(uint72_t)=%u\n", (unsigned)sizeof(uint72_t));
159 printf("sizeof(int128_t)=%u\n", (unsigned)sizeof(int128_t));
160 printf("sizeof(uint128_t)=%u\n", (unsigned)sizeof(uint128_t));
162 printf("sizeof(int_least8_t)=%u\n", (unsigned)sizeof(int_least8_t));
163 printf("sizeof(uint_least8_t)=%u\n", (unsigned)sizeof(uint_least8_t));
164 printf("sizeof(int_least16_t)=%u\n", (unsigned)sizeof(int_least16_t));
165 printf("sizeof(uint_least16_t)=%u\n", (unsigned)sizeof(uint_least16_t));
166 printf("sizeof(int_least32_t)=%u\n", (unsigned)sizeof(int_least32_t));
167 printf("sizeof(uint_least32_t)=%u\n", (unsigned)sizeof(uint_least32_t));
168 #ifdef INT_LEAST64_MAX
169 printf("sizeof(int_least64_t)=%u\n", (unsigned)sizeof(int_least64_t));
170 printf("sizeof(uint_least64_t)=%u\n", (unsigned)sizeof(uint_least64_t));
172 printf("*** uint_least64_t isn't defined ***\n");
173 status = EXIT_FAILURE;
175 #ifdef INT_LEAST128_MAX
176 printf("sizeof(int_least128_t)=%u\n", (unsigned)sizeof(int_least128_t));
177 printf("sizeof(uint_least128_t)=%u\n",
178 (unsigned)sizeof(uint_least128_t));
180 printf("sizeof(int_fast8_t)=%u\n", (unsigned)sizeof(int_fast8_t));
181 printf("sizeof(uint_fast8_t)=%u\n", (unsigned)sizeof(uint_fast8_t));
182 printf("sizeof(int_fast16_t)=%u\n", (unsigned)sizeof(int_fast16_t));
183 printf("sizeof(uint_fast16_t)=%u\n", (unsigned)sizeof(uint_fast16_t));
184 printf("sizeof(int_fast32_t)=%u\n", (unsigned)sizeof(int_fast32_t));
185 printf("sizeof(uint_fast32_t)=%u\n", (unsigned)sizeof(uint_fast32_t));
186 #ifdef INT_FAST64_MAX
187 printf("sizeof(int_fast64_t)=%u\n", (unsigned)sizeof(int_fast64_t));
188 printf("sizeof(uint_fast64_t)=%u\n", (unsigned)sizeof(uint_fast64_t));
190 printf("*** int_fast64_t isn't defined ***\n");
191 status = EXIT_FAILURE;
193 #ifdef INT_FAST128_MAX
194 printf("sizeof(int_fast128_t)=%u\n", (unsigned)sizeof(int_fast128_t));
195 printf("sizeof(uint_fast128_t)=%u\n", (unsigned)sizeof(uint_fast128_t));
197 #if defined(INTPTR_MAX)
198 printf("sizeof(intptr_t)=%u\n", (unsigned)sizeof(intptr_t));
199 #if defined(UINTPTR_MAX)
200 printf("sizeof(uintptr_t)=%u\n", (unsigned)sizeof(uintptr_t));
202 printf("*** intptr_t is defined but uintptr_t isn't ***\n");
203 status = EXIT_FAILURE;
205 #elif defined(UINTPTR_MAX)
206 printf("sizeof(uintptr_t)=%u\n", (unsigned)sizeof(uintptr_t));
207 printf("*** uintptr_t is defined but intptr_t isn't ***\n");
208 status = EXIT_FAILURE;
210 printf("*** neither intptr_t nor uintptr_t is defined ***\n");
211 status = EXIT_FAILURE;
214 printf("sizeof(intmax_t)=%u\n", (unsigned)sizeof(intmax_t));
215 printf("sizeof(uintmax_t)=%u\n", (unsigned)sizeof(uintmax_t));
217 printf("*** intmax_t isn't defined ***\n");
218 status = EXIT_FAILURE;
222 printf("INT8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT8_MIN);
223 printf("INT8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT8_MAX);
224 printf("UINT8_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT8_MAX);
227 printf("INT9_MIN=%"PRIdMAX"\n", (__Q8_MT)INT9_MIN);
228 printf("INT9_MAX=%"PRIdMAX"\n", (__Q8_MT)INT9_MAX);
229 printf("UINT9_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT9_MAX);
232 printf("INT12_MIN=%"PRIdMAX"\n", (__Q8_MT)INT12_MIN);
233 printf("INT12_MAX=%"PRIdMAX"\n", (__Q8_MT)INT12_MAX);
234 printf("UINT12_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT12_MAX);
237 printf("INT16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT16_MIN);
238 printf("INT16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT16_MAX);
239 printf("UINT16_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT16_MAX);
242 printf("INT18_MIN=%"PRIdMAX"\n", (__Q8_MT)INT18_MIN);
243 printf("INT18_MAX=%"PRIdMAX"\n", (__Q8_MT)INT18_MAX);
244 printf("UINT18_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT18_MAX);
247 printf("INT24_MIN=%"PRIdMAX"\n", (__Q8_MT)INT24_MIN);
248 printf("INT24_MAX=%"PRIdMAX"\n", (__Q8_MT)INT24_MAX);
249 printf("UINT24_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT24_MAX);
252 printf("INT32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT32_MIN);
253 printf("INT32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT32_MAX);
254 printf("UINT32_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT32_MAX);
257 printf("INT36_MIN=%"PRIdMAX"\n", (__Q8_MT)INT36_MIN);
258 printf("INT36_MAX=%"PRIdMAX"\n", (__Q8_MT)INT36_MAX);
259 printf("UINT36_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT36_MAX);
262 printf("INT40_MIN=%"PRIdMAX"\n", (__Q8_MT)INT40_MIN);
263 printf("INT40_MAX=%"PRIdMAX"\n", (__Q8_MT)INT40_MAX);
264 printf("UINT40_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT40_MAX);
267 printf("INT48_MIN=%"PRIdMAX"\n", (__Q8_MT)INT48_MIN);
268 printf("INT48_MAX=%"PRIdMAX"\n", (__Q8_MT)INT48_MAX);
269 printf("UINT48_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT48_MAX);
272 printf("INT60_MIN=%"PRIdMAX"\n", (__Q8_MT)INT60_MIN);
273 printf("INT60_MAX=%"PRIdMAX"\n", (__Q8_MT)INT60_MAX);
274 printf("UINT60_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT60_MAX);
277 printf("INT64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT64_MIN);
278 printf("INT64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT64_MAX);
279 printf("UINT64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT64_MAX);
282 printf("INT72_MIN=%"PRIdMAX"\n", (__Q8_MT)INT72_MIN);
283 printf("INT72_MAX=%"PRIdMAX"\n", (__Q8_MT)INT72_MAX);
284 printf("UINT72_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT72_MAX);
287 printf("INT128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT128_MIN);
288 printf("INT128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT128_MAX);
289 printf("UINT128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT128_MAX);
291 printf("INT_LEAST8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST8_MIN);
292 printf("INT_LEAST8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST8_MAX);
293 printf("UINT_LEAST8_MAX=%"PRIuMAX"\n",
294 (U__Q8_MT)UINT_LEAST8_MAX);
295 printf("INT_LEAST16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST16_MIN);
296 printf("INT_LEAST16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST16_MAX);
297 printf("UINT_LEAST16_MAX=%"PRIuMAX"\n",
298 (U__Q8_MT)UINT_LEAST16_MAX);
299 printf("INT_LEAST32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST32_MIN);
300 printf("INT_LEAST32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST32_MAX);
301 printf("UINT_LEAST32_MAX=%"PRIuMAX"\n",
302 (U__Q8_MT)UINT_LEAST32_MAX);
303 #ifdef INT_LEAST64_MAX
304 printf("INT_LEAST64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST64_MIN);
305 printf("INT_LEAST64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST64_MAX);
306 printf("UINT_LEAST64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_LEAST64_MAX);
308 #ifdef INT_LEAST128_MAX
309 printf("INT_LEAST128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST128_MIN);
310 printf("INT_LEAST128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST128_MAX);
311 printf("UINT_LEAST128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_LEAST128_MAX);
313 printf("INT_FAST8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST8_MIN);
314 printf("INT_FAST8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST8_MAX);
315 printf("UINT_FAST8_MAX=%"PRIuMAX"\n",
316 (U__Q8_MT)UINT_FAST8_MAX);
317 printf("INT_FAST16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST16_MIN);
318 printf("INT_FAST16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST16_MAX);
319 printf("UINT_FAST16_MAX=%"PRIuMAX"\n",
320 (U__Q8_MT)UINT_FAST16_MAX);
321 printf("INT_FAST32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST32_MIN);
322 printf("INT_FAST32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST32_MAX);
323 printf("UINT_FAST32_MAX=%"PRIuMAX"\n",
324 (U__Q8_MT)UINT_FAST32_MAX);
325 #ifdef INT_FAST64_MAX
326 printf("INT_FAST64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST64_MIN);
327 printf("INT_FAST64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST64_MAX);
328 printf("UINT_FAST64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_FAST64_MAX);
330 #ifdef INT_FAST128_MAX
331 printf("INT_FAST128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST128_MIN);
332 printf("INT_FAST128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST128_MAX);
333 printf("UINT_FAST128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_FAST128_MAX);
336 printf("INTPTR_MIN=%"PRIdMAX"\n", (__Q8_MT)INTPTR_MIN);
337 printf("INTPTR_MAX=%"PRIdMAX"\n", (__Q8_MT)INTPTR_MAX);
340 printf("UINTPTR_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINTPTR_MAX);
343 printf("INTMAX_MIN=%"PRIdMAX"\n", (__Q8_MT)INTMAX_MIN);
344 printf("INTMAX_MAX=%"PRIdMAX"\n", (__Q8_MT)INTMAX_MAX);
345 printf("UINTMAX_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINTMAX_MAX);
348 printf("PTRDIFF_MIN=%"PRIdMAX"\n", (__Q8_MT)PTRDIFF_MIN);
349 printf("PTRDIFF_MAX=%"PRIdMAX"\n", (__Q8_MT)PTRDIFF_MAX);
351 #ifdef SIG_ATOMIC_MAX
352 #if SIG_ATOMIC_MIN < 0
353 printf("SIG_ATOMIC_MIN=%"PRIdMAX"\n", (__Q8_MT)SIG_ATOMIC_MIN);
354 printf("SIG_ATOMIC_MAX=%"PRIdMAX"\n", (__Q8_MT)SIG_ATOMIC_MAX);
356 printf("SIG_ATOMIC_MIN=%"PRIuMAX"\n", (U__Q8_MT)SIG_ATOMIC_MIN);
357 printf("SIG_ATOMIC_MAX=%"PRIuMAX"\n", (U__Q8_MT)SIG_ATOMIC_MAX);
361 printf("SIZE_MAX=%"PRIuMAX"\n", (U__Q8_MT)SIZE_MAX);
366 printf("WCHAR_MIN=%"PRIdMAX"\n", (__Q8_MT)WCHAR_MIN);
367 printf("WCHAR_MAX=%"PRIdMAX"\n", (__Q8_MT)WCHAR_MAX);
369 printf("WCHAR_MIN=%"PRIuMAX"\n", (U__Q8_MT)WCHAR_MIN);
370 printf("WCHAR_MAX=%"PRIuMAX"\n", (U__Q8_MT)WCHAR_MAX);
375 printf("WINT_MIN=%"PRIdMAX"\n", (__Q8_MT)WINT_MIN);
376 printf("WINT_MAX=%"PRIdMAX"\n", (__Q8_MT)WINT_MAX);
378 printf("WINT_MIN=%"PRIuMAX"\n", (U__Q8_MT)WINT_MIN);
379 printf("WINT_MAX=%"PRIuMAX"\n", (U__Q8_MT)WINT_MAX);
384 7.18.4 Macros for integer constants
387 /* INTn_C for n=8 and 16 were at one point unimplementable
388 on most platforms, so they're treated as "optional": */
390 if ( INT8_C(-123) != -123 )
391 printf("*** INT8_C(-123) produced %"PRIdMAX" ***\n",
392 (__Q8_MT)INT8_C(-123)
394 if ( UINT8_C(123) != 123 )
395 printf("*** UINT8_C(123) produced %"PRIuMAX" ***\n",
396 (U__Q8_MT)UINT8_C(123)
400 if ( INT16_C(-12345) != -12345 )
401 printf("*** INT16_C(-12345) produced %"PRIdMAX" ***\n",
402 (__Q8_MT)INT16_C(-12345)
404 if ( UINT16_C(12345) != 12345 )
405 printf("*** UINT16_C(12345) produced %"PRIuMAX" ***\n",
406 (U__Q8_MT)UINT16_C(12345)
409 if ( INT32_C(-123456789) != -123456789 )
410 printf("*** INT32_C(-123456789) produced %"PRIdMAX" ***\n",
411 (__Q8_MT)INT32_C(-123456789)
413 if ( UINT32_C(123456789) != 123456789 )
414 printf("*** UINT32_C(123456789) produced %"PRIuMAX" ***\n",
415 (U__Q8_MT)UINT32_C(123456789)
417 #ifdef INT_LEAST64_MAX
418 if ( INT64_C(-1234567890123456789) != -1234567890123456789 )
419 printf("*** INT64_C(-1234567890123456789) produced %"PRIdMAX
421 (__Q8_MT)INT64_C(-1234567890123456789)
423 if ( UINT64_C(1234567890123456789) != 1234567890123456789 )
424 printf("*** UINT64_C(1234567890123456789) produced %"PRIuMAX
426 (U__Q8_MT)UINT64_C(1234567890123456789)
430 if ( INTMAX_C(-1234567890123456789) != -1234567890123456789 )
431 printf("*** INTMAX_C(-1234567890123456789) produced %"PRIdMAX
433 (__Q8_MT)INTMAX_C(-1234567890123456789)
435 if ( UINTMAX_C(1234567890123456789) != 1234567890123456789 )
436 printf("*** UINTMAX_C(1234567890123456789) produced %"PRIuMAX
438 (U__Q8_MT)UINTMAX_C(1234567890123456789)
442 /* <inttypes.h> features: */
444 #if __STDC_VERSION__ >= 199901
445 printf("sizeof(imaxdiv_t)=%u\n", (unsigned)sizeof(imaxdiv_t));
449 7.8.1 Macros for format specifiers
453 /* scanf these strings */
454 static const char in_dn[] = "Z119bZ";
455 static const char in_dmo[] = "Z-0119bZ";
456 static const char in_dspx[] = "Z \t\n +0X119bZ";
457 static const char in_dsmx[] = "Z \t\n -0x119bZ";
458 static const char in_dsn[] = "Z \t\n 119bZ";
459 static const char in_dp[] = "Z+119bZ";
460 static const char in_dpx[] = "Z+0X119bz";
462 /* sprintf into this */
463 static char buffer[1024];
465 #define SCAN(buf,fs,var,exp) if ( sscanf(buf, "Z%" fs, &var) != 1 ) \
467 printf("*** " #fs "=" STR_SUB(fs) \
470 status = EXIT_FAILURE; \
472 else if ( var != (exp) ) \
474 printf("*** " #fs "=" STR_SUB(fs) \
475 " should be: " STR_SUB(exp) \
476 ", was: %" fs " ***\n", var \
478 status = EXIT_FAILURE; \
482 #define PRINT(fs,var,exp) if ( sprintf(buffer, "%" fs, var ) <= 0 ) \
484 printf("*** " #fs "=" STR_SUB(fs) \
487 status = EXIT_FAILURE; \
489 else if ( strcmp(buffer, STR_SUB(exp)) != 0 ) \
491 printf("*** " #fs "=" STR_SUB(fs) \
492 " should be: " STR_SUB(exp) \
493 ", was: %s ***\n", buffer \
495 status = EXIT_FAILURE; \
500 SCAN(in_dn, SCNo32, int32, 9);
503 PRINT(PRIo32, int32, 11);
505 SCAN(in_dmo, SCNiLEAST16, intl16, -9);
506 SCAN(in_dspx, SCNdLEAST16, intl16, 0);
507 SCAN(in_dsmx, SCNiLEAST16, intl16, -4507);
508 PRINT(PRIdLEAST16, intl16, -4507);
509 PRINT(PRIiLEAST16, intl16, -4507);
510 SCAN(in_dsn, SCNxLEAST16, uintl16, 4507);
511 PRINT(PRIoLEAST16, uintl16, 10633);
512 PRINT(PRIuLEAST16, uintl16, 4507);
513 PRINT(PRIxLEAST16, uintl16, 119b);
514 PRINT(PRIXLEAST16, uintl16, 119B);
515 SCAN(in_dp, SCNxFAST16, uintf16, 4507);
516 PRINT(PRIxFAST16, uintf16, 119b);
518 SCAN(in_dp, SCNdMAX, intmax, 119);
521 PRINT(PRIiMAX, intmax, 119);
524 SCAN(in_dpx, SCNoMAX, uintmax, 0);
527 PRINT(PRIxMAX, uintmax, 0);
529 /* Obviously there should be a much larger battery of such tests. */
532 #if defined(INTMAX_MAX) /* <inttypes.h> has C99 features */
534 7.8.2 Functions for greatest-width integer types
545 {INT8_MAX, INT8_MAX},
546 {-INT8_MAX, INT8_MAX},
547 {UINT8_MAX, UINT8_MAX},
551 { INT16_MAX, INT16_MAX},
552 { -INT16_MAX, INT16_MAX},
553 { UINT16_MAX, UINT16_MAX},
556 { INT32_MAX, INT32_MAX},
557 { -INT32_MAX, INT32_MAX},
558 #ifdef INT_LEAST64_MAX
559 { UINT32_MAX, UINT32_MAX},
563 { INT64_MAX, INT64_MAX},
564 { -INT64_MAX, INT64_MAX},
566 { INT_LEAST8_MAX, INT_LEAST8_MAX},
567 { -INT_LEAST8_MAX, INT_LEAST8_MAX},
568 { UINT_LEAST8_MAX, UINT_LEAST8_MAX},
569 { INT_LEAST16_MAX, INT_LEAST16_MAX},
570 { -INT_LEAST16_MAX, INT_LEAST16_MAX},
571 { UINT_LEAST16_MAX, UINT_LEAST16_MAX},
572 { INT_LEAST32_MAX, INT_LEAST32_MAX},
573 { -INT_LEAST32_MAX, INT_LEAST32_MAX},
574 #ifdef INT_LEAST64_MAX
575 { UINT_LEAST32_MAX, UINT_LEAST32_MAX},
576 { INT_LEAST64_MAX, INT_LEAST64_MAX},
577 { -INT_LEAST64_MAX, INT_LEAST64_MAX},
579 { INT_FAST8_MAX, INT_FAST8_MAX},
580 { -INT_FAST8_MAX, INT_FAST8_MAX},
581 { UINT_FAST8_MAX, UINT_FAST8_MAX},
582 { INT_FAST16_MAX, INT_FAST16_MAX},
583 { -INT_FAST16_MAX, INT_FAST16_MAX},
584 { UINT_FAST16_MAX, UINT_FAST16_MAX},
585 { INT_FAST32_MAX, INT_FAST32_MAX},
586 { -INT_FAST32_MAX, INT_FAST32_MAX},
587 #ifdef INT_FAST64_MAX
588 { UINT_FAST32_MAX, UINT_FAST32_MAX},
589 { INT_FAST64_MAX, INT_FAST64_MAX},
590 { -INT_FAST64_MAX, INT_FAST64_MAX},
593 { INTPTR_MAX, INTPTR_MAX},
594 { -INTPTR_MAX, INTPTR_MAX},
597 { UINTPTR_MAX, UINTPTR_MAX},
599 { INTMAX_MAX, INTMAX_MAX},
601 { PTRDIFF_MAX, PTRDIFF_MAX},
603 #ifdef SIG_ATOMIC_MAX
604 { SIG_ATOMIC_MAX, SIG_ATOMIC_MAX},
605 #if SIG_ATOMIC_MIN < 0
606 { -SIG_ATOMIC_MAX, SIG_ATOMIC_MAX},
610 { SIZE_MAX, SIZE_MAX},
613 { WCHAR_MAX, WCHAR_MAX},
615 { -WCHAR_MAX, WCHAR_MAX},
619 { WINT_MAX, WINT_MAX},
621 { -WINT_MAX, WINT_MAX},
640 { 2147483647, 2147483647},
641 { -2147483647, 2147483647},
642 { 2147483648LL, 2147483648LL},
643 { -2147483647LL-1, 2147483648LL},
644 #ifdef INT_LEAST64_MAX
645 { 4294967295LL, 4294967295LL},
646 { -4294967296LL+1, 4294967295LL},
647 { 4294967296LL, 4294967296LL},
648 { -4294967296LL, 4294967296LL},
649 { 9223372036854775807LL, 9223372036854775807LL},
650 { -9223372036854775807LL, 9223372036854775807LL},
651 { 1234567890123456789LL, 1234567890123456789LL},
652 { -1234567890123456789LL, 1234567890123456789LL},
662 /* Other test cases can be added here. */
663 {0, 0} /* terminates the list */
667 intmax = imaxabs(adp->input);
669 if (intmax != adp->expect )
672 printf("*** imaxabs(%"PRIdMAX") failed; should be: %"
673 PRIdMAX", was: %"PRIdMAX" ***\n",
674 adp->input, adp->expect, intmax
676 status = EXIT_FAILURE;
679 while ( adp++->input != 0 );
726 { 2147483647, 1, 2147483647, 0},
727 { -2147483647LL, 1, -2147483647LL, 0},
728 { 2147483648LL, 1LL, 2147483648LL, 0LL},
729 { -2147483647-1LL, 1LL, -2147483647-1LL, 0LL},
730 { 2147483647LL, 2LL, 1073741823LL, 1LL},
731 { -2147483647LL, 2LL, -1073741823LL, -1LL},
732 { 2147483648LL, 2LL, 1073741824LL, 0LL},
733 { -2147483647-1LL, 2LL, -1073741824LL, 0LL},
734 #ifdef INT_LEAST64_MAX /* else might support only 32 bits */
735 { 4294967295LL, 1LL, 4294967295LL, 0LL},
736 { -4294967296LL+1LL, 1LL, -4294967296LL+1, 0},
737 { 4294967296LL, 1, 4294967296LL, 0},
738 { -4294967296LL, 1LL, -4294967296LL, 0LL},
739 { 4294967295LL, -1LL, -4294967296+1LL, 0LL},
740 { -4294967296+1LL, -1LL, 4294967295LL, 0LL},
741 { 4294967296LL, -1LL, -4294967296LL, 0LL},
742 { -4294967296LL, -1LL, 4294967296LL, 0LL},
743 { 4294967295LL, 2LL, 2147483647LL, 1LL},
744 { -4294967296+1LL, 2LL, -2147483647LL, -1LL},
745 { 4294967296LL, 2LL, 2147483648LL, 0LL},
746 { -4294967296LL, 2LL, -2147483647-1LL, 0LL},
747 { 4294967295LL, 2147483647LL, 2LL, 1LL},
748 { -4294967296+1LL, 2147483647LL, -2LL, -1LL},
749 { 4294967296LL, 2147483647LL, 2LL, 2LL},
750 { -4294967296LL, 2147483647LL, -2LL, -2LL},
751 { 4294967295LL, -2147483647LL, -2LL, 1LL},
752 { -4294967296+1LL, -2147483647LL, 2LL, -1LL},
753 { 4294967296LL, -2147483647LL, -2LL, 2LL},
754 { -4294967296LL, -2147483647LL, 2LL, -2LL},
755 { 4294967295LL, 2147483648LL, 1LL, 2147483647LL},
756 { -4294967296+1LL, 2147483648LL, -1LL, -2147483647LL},
757 { 4294967296LL, 2147483648LL, 2LL, 0LL},
758 { -4294967296LL, 2147483648LL, -2LL, 0LL},
759 { 4294967295LL, -2147483647-1LL, -1LL, 2147483647LL},
760 { -4294967296+1LL, -2147483647-1LL, 1LL, -2147483647LL},
761 { 4294967296LL, -2147483647-1LL, -2LL, 0LL},
762 { -4294967296LL, -2147483647-1LL, 2LL, 0LL},
763 { 9223372036854775807LL, 1LL, 9223372036854775807LL, 0LL},
764 { -9223372036854775807LL, 1LL, -9223372036854775807LL, 0LL},
765 { 9223372036854775807LL, 2LL, 4611686018427387903LL, 1LL},
766 { -9223372036854775807LL, 2LL, -4611686018427387903LL, -1LL},
768 /* There should be a much larger battery of such tests. */
769 { 0, 0, 0, 0} /* 0 denom terminates the list */
772 for ( ddp = div_data; ddp->denom != 0; ++ddp )
773 if ( (result = imaxdiv(ddp->numer, ddp->denom)).quot
774 != ddp->exp_quot || result.rem != ddp->exp_rem
776 printf("*** imaxdiv(%"PRIdMAX",%"PRIdMAX
777 ") failed; should be: (%"PRIdMAX",%"PRIdMAX
778 "), was: (%"PRIdMAX",%"PRIdMAX") ***\n",
779 ddp->numer, ddp->denom, ddp->exp_quot,
780 ddp->exp_rem, result.quot, result.rem
782 status = EXIT_FAILURE;
789 static char saved[64]; /* holds copy of input string */
790 static wchar_t wnptr[64]; /* holds wide copy of test string */
791 static int warned; /* "warned for null endptr" flag */
835 { "Inf", 36, 24171, 3},
842 { "+Inf", 36, 24171, 4},
849 { "-Inf", 36, -24171, 4},
856 { "inf", 36, 24171, 3},
863 { "+inf", 36, 24171, 4},
870 { "-inf", 36, -24171, 4},
871 { "119b8Z", 0, 119, 3},
872 { "119bZ", 0, 119, 3},
873 { "-0119bZ", 0, -9, 4},
874 { " \t\n 0X119bZ", 0, 4507, 10},
875 { " \t\n +0X119bZ", 0, 4507, 11},
876 { " \t\n -0x119bZ", 0, -4507, 11},
877 { " \t\n 119bZ", 0, 119, 7},
878 { "+119bZ", 0, 119, 4},
879 { "+0X119bz", 0, 4507, 7},
880 { "119b8Z", 2, 3, 2},
882 { "-0119bZ", 2, -3, 4},
883 { " \t\n 0X119bZ", 2, 0, 5},
884 { " \t\n +0X119bZ", 2, 0, 6},
885 { " \t\n -0x119bZ", 2, 0, 6},
886 { " \t\n 119bZ", 2, 3, 6},
887 { "+119bZ", 2, 3, 3},
888 { "+0X119bz", 2, 0, 2},
889 { "119b8Z", 8, 9, 2},
891 { "-0119bZ", 8, -9, 4},
892 { " \t\n 0X119bZ", 8, 0, 5},
893 { " \t\n +0X119bZ", 8, 0, 6},
894 { " \t\n -0x119bZ", 8, 0, 6},
895 { " \t\n 119bZ", 8, 9, 6},
896 { "+119bZ", 8, 9, 3},
897 { "+0X119bz", 8, 0, 2},
898 { "119b8Z", 9, 10, 2},
899 { "119bZ", 9, 10, 2},
900 { "-0119bZ", 9, -10, 4},
901 { " \t\n 0X119bZ", 9, 0, 5},
902 { " \t\n +0X119bZ", 9, 0, 6},
903 { " \t\n -0x119bZ", 9, 0, 6},
904 { " \t\n 119bZ", 9, 10, 6},
905 { "+119bZ", 9, 10, 3},
906 { "+0X119bz", 9, 0, 2},
907 { "119b8Z", 10, 119, 3},
908 { "119bZ", 10, 119, 3},
909 { "-0119bZ", 10, -119, 5},
910 { " \t\n 0X119bZ", 10, 0, 5},
911 { " \t\n +0X119bZ", 10, 0, 6},
912 { " \t\n -0x119bZ", 10, 0, 6},
913 { " \t\n 119bZ", 10, 119, 7},
914 { "+119bZ", 10, 119, 4},
915 { "+0X119bz", 10, 0, 2},
916 { "119b8Z", 16, 72120, 5},
917 { "119bZ", 16, 4507, 4},
918 { "-0119bZ", 16, -4507, 6},
919 { " \t\n 0X119bZ", 16, 4507, 10},
920 { " \t\n +0X119bZ", 16, 4507, 11},
921 { " \t\n -0x119bZ", 16, -4507, 11},
922 { " \t\n 119bZ", 16, 4507,8},
923 { "+119bZ", 16, 4507, 5},
924 { "+0X119bz", 16, 4507, 7},
925 { "119b8Z", 36, 62580275, 6},
926 { "119bZ", 36, 1738367, 5},
927 { "-0119bZ", 36, -1738367, 7},
928 { " \t\n 0X119bZ", 36, 1997122175, 11},
929 { " \t\n +0X119bZ", 36, 1997122175, 12},
930 { " \t\n -0x119bZ", 36, -1997122175, 12},
931 { " \t\n 119bZ", 36, 1738367, 9},
932 { "+119bZ", 36, 1738367, 6},
933 { "+0X119bz", 36, 1997122175, 8},
934 /* There should be a much larger battery of such tests. */
936 { "-127", 0, -127, 4},
938 { "-128", 0, -127-1, 4},
940 { "-255", 0, -255, 4},
942 { "-256", 0, -255-1, 4},
943 { "32767", 0, 32767, 5},
944 { "-32767", 0, -32767, 6},
945 { "32768", 0, 32768, 5},
946 { "-32768", 0, -32767-1, 6},
947 { "65535", 0, 65535, 5},
948 { "-65535", 0, -65536+1, 6},
949 { "65536", 0, 65536, 5},
950 { "-65536", 0, -65536, 6},
951 { "2147483647", 0, 2147483647, 10},
952 { "-2147483647", 0, -2147483647, 11},
953 { "2147483648", 0, 2147483648LL, 10},
954 { "-2147483648", 0, -2147483647LL-1, 11},
955 { "4294967295", 0, 4294967295LL, 10},
956 { "-4294967295", 0, -4294967296LL+1, 11},
957 { "4294967296", 0, 4294967296LL, 10},
958 { "-4294967296", 0, -4294967296L, 11},
959 { "9223372036854775807", 0, 9223372036854775807LL, 19},
960 { "-9223372036854775807", 0, -9223372036854775807LL, 20},
961 { "1234567890123456789", 0, 1234567890123456789LL, 19},
962 { "-1234567890123456789", 0, -1234567890123456789LL, 20},
971 /* Other test cases can be added here. */
972 { NULL, 0, 0, 0 } /* terminates the list */
975 for ( sdp = str_data; sdp->nptr != NULL ; ++sdp )
978 7.8.2.3 The strtoimax and strtoumax functions
981 strcpy(saved, sdp->nptr);
983 errno = 0; /* shouldn't be changed */
985 if ( (intmax = strtoimax(sdp->nptr, &endptr, sdp->base))
990 printf("*** strtoimax(%s,,%d) failed; should be: %"
991 PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr,
992 sdp->base, sdp->exp_val, intmax
994 status = EXIT_FAILURE;
997 else if ( endptr != sdp->nptr + sdp->exp_len )
1001 printf("*** strtoimax(%s,,%d) returned wrong endptr"
1002 " ***\n", sdp->nptr, sdp->base
1004 status = EXIT_FAILURE;
1010 printf("*** strtoimax modified errno ***\n");
1011 status = EXIT_FAILURE;
1014 if ( strcmp(sdp->nptr, saved) != 0 )
1016 printf("*** strtoimax modified its input ***\n");
1017 status = EXIT_FAILURE;
1018 strcpy(saved, sdp->nptr);
1021 if ( sdp->exp_val >= 0 ) /* else some sign extension */
1023 errno = 0; /* shouldn't be changed */
1025 if ( (uintmax = strtoumax(sdp->nptr, &endptr, sdp->base
1031 printf("*** strtoumax(%s,,%d) failed; "
1032 "should be: %"PRIuMAX", was: %"PRIuMAX
1033 " ***\n", sdp->nptr, sdp->base,
1034 sdp->exp_val, uintmax
1036 status = EXIT_FAILURE;
1039 else if ( endptr != sdp->nptr + sdp->exp_len )
1043 printf("*** strtoumax(%s,,%d) returned wrong "
1044 "endptr ***\n", sdp->nptr, sdp->base
1046 status = EXIT_FAILURE;
1052 printf("*** strtoumax modified errno ***\n");
1053 status = EXIT_FAILURE;
1056 if ( strcmp(sdp->nptr, saved) != 0 )
1058 printf("*** strtoumax"
1059 " modified its input ***\n"
1061 status = EXIT_FAILURE;
1062 strcpy(saved, sdp->nptr);
1066 /* tests for null endptr */
1068 #define WARN() if (!warned) warned = 1, printf("*** Using null endptr: ***\n")
1071 errno = 0; /* shouldn't be changed */
1073 if ( (intmax = strtoimax(sdp->nptr, (char **)NULL, sdp->base))
1079 printf("*** strtoimax(%s,NULL,%d) failed; "
1080 "should be: %"PRIdMAX", was: %"PRIdMAX" ***\n",
1081 sdp->nptr, sdp->base, sdp->exp_val, intmax
1083 status = EXIT_FAILURE;
1090 printf("*** strtoimax modified errno ***\n");
1091 status = EXIT_FAILURE;
1094 if ( strcmp(sdp->nptr, saved) != 0 )
1097 printf("*** strtoimax modified its input ***\n");
1098 status = EXIT_FAILURE;
1099 strcpy(saved, sdp->nptr);
1102 if ( sdp->exp_val >= 0 ) /* else some sign extension */
1104 errno = 0; /* shouldn't be changed */
1106 if ( (uintmax = strtoumax(sdp->nptr, (char **)NULL,
1114 printf("*** strtoumax(%s,NULL,%d) failed; "
1115 "should be: %"PRIuMAX", was: %"PRIuMAX
1116 " ***\n", sdp->nptr, sdp->base,
1117 sdp->exp_val, uintmax
1119 status = EXIT_FAILURE;
1126 printf("*** strtoumax modified errno ***\n");
1127 status = EXIT_FAILURE;
1130 if ( strcmp(sdp->nptr, saved) != 0 )
1133 printf("*** strtoumax"
1134 " modified its input ***\n"
1136 status = EXIT_FAILURE;
1137 strcpy(saved, sdp->nptr);
1142 7.8.2.4 The wcstoimax and wcstoumax functions
1145 for ( i = 0; i < 64; ++i )
1146 if ( (wnptr[i] = sdp->nptr[i]) == '\0' )
1149 errno = 0; /* shouldn't be changed */
1151 if ( (intmax = wcstoimax(wnptr, &wendptr, sdp->base))
1156 printf("*** wcstoimax(%s,,%d) failed; should be: %"
1157 PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr,
1158 sdp->base, sdp->exp_val, intmax
1160 status = EXIT_FAILURE;
1163 else if ( wendptr != wnptr + sdp->exp_len )
1167 printf("*** wcstoimax(%s,,%d) returned wrong endptr"
1168 " ***\n", sdp->nptr, sdp->base
1170 status = EXIT_FAILURE;
1176 printf("*** wcstoimax modified errno ***\n");
1177 status = EXIT_FAILURE;
1180 for ( i = 0; i < 64; ++i )
1181 if ( wnptr[i] != sdp->nptr[i] )
1183 printf("*** wcstoimax modified its input ***\n"
1185 status = EXIT_FAILURE;
1187 for ( ; i < 64; ++i )
1188 if ( (wnptr[i] = sdp->nptr[i]) == '\0' )
1193 else if ( wnptr[i] == '\0' )
1196 if ( sdp->exp_val >= 0 ) /* else some sign extension */
1198 errno = 0; /* shouldn't be changed */
1200 if ( (uintmax = wcstoumax(wnptr, &wendptr, sdp->base)
1205 printf("*** wcstoumax(%s,,%d) failed; "
1206 "should be: %"PRIuMAX", was: %"PRIuMAX
1207 " ***\n", sdp->nptr, sdp->base,
1208 sdp->exp_val, uintmax
1210 status = EXIT_FAILURE;
1213 else if ( wendptr != wnptr + sdp->exp_len )
1217 printf("*** wcstoumax(%s,,%d) returned wrong "
1218 "endptr ***\n", sdp->nptr, sdp->base
1220 status = EXIT_FAILURE;
1226 printf("*** wcstoumax modified errno ***\n");
1227 status = EXIT_FAILURE;
1230 for ( i = 0; i < 64; ++i )
1231 if ( wnptr[i] != sdp->nptr[i] )
1233 printf("*** wcstoumax"
1234 " modified its input ***\n"
1236 status = EXIT_FAILURE;
1238 for ( ; i < 64; ++i )
1239 if ( (wnptr[i] = sdp->nptr[i])
1246 else if ( wnptr[i] == '\0' )
1250 /* tests for null endptr */
1253 errno = 0; /* shouldn't be changed */
1255 if ( (intmax = wcstoimax(wnptr, (wchar_t **)NULL, sdp->base))
1261 printf("*** wcstoimax(%s,NULL,%d) failed; should be: %"
1262 PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr,
1263 sdp->base, sdp->exp_val, intmax
1265 status = EXIT_FAILURE;
1272 printf("*** wcstoimax modified errno ***\n");
1273 status = EXIT_FAILURE;
1276 for ( i = 0; i < 64; ++i )
1277 if ( wnptr[i] != sdp->nptr[i] )
1280 printf("*** wcstoimax modified its input ***\n"
1282 status = EXIT_FAILURE;
1284 for ( ; i < 64; ++i )
1285 if ( (wnptr[i] = sdp->nptr[i])
1292 else if ( wnptr[i] == '\0' )
1295 if ( sdp->exp_val >= 0 ) /* else some sign extension */
1297 errno = 0; /* shouldn't be changed */
1299 if ( (uintmax = wcstoumax(wnptr, (wchar_t **)NULL,
1307 printf("*** wcstoumax(%s,NULL,%d) failed; "
1308 "should be: %"PRIuMAX", was: %"PRIuMAX
1309 " ***\n", sdp->nptr, sdp->base,
1310 sdp->exp_val, uintmax
1312 status = EXIT_FAILURE;
1319 printf("*** wcstoumax modified errno ***\n");
1320 status = EXIT_FAILURE;
1323 for ( i = 0; i < 64; ++i )
1324 if ( wnptr[i] != sdp->nptr[i] )
1327 printf("*** wcstoumax"
1328 " modified its input ***\n"
1330 status = EXIT_FAILURE;
1332 for ( ; i < 64; ++i )
1333 if ( (wnptr[i] = sdp->nptr[i])
1340 else if ( wnptr[i] == '\0' )
1346 7.8.2.3 The strtoimax and strtoumax functions (continued)
1349 if ( (intmax = strtoimax("1234567890123456789012345678901234567890"
1350 "1234567890123456789012345678901234567890"
1351 "1234567890123456789012345678901234567890"
1352 "1234567890123456789012345678901234567890"
1353 "1234567890123456789012345678901234567890"
1354 "1234567890123456789012345678901234567890",
1357 ) != INTMAX_MAX || errno != ERANGE
1359 printf("*** strtoimax failed overflow test ***\n");
1360 status = EXIT_FAILURE;
1363 if ( (intmax = strtoimax("+1234567890123456789012345678901234567890"
1364 "1234567890123456789012345678901234567890"
1365 "1234567890123456789012345678901234567890"
1366 "1234567890123456789012345678901234567890"
1367 "1234567890123456789012345678901234567890"
1368 "1234567890123456789012345678901234567890",
1371 ) != INTMAX_MAX || errno != ERANGE
1373 printf("*** strtoimax failed +overflow test ***\n");
1374 status = EXIT_FAILURE;
1377 if ( (intmax = strtoimax("-1234567890123456789012345678901234567890"
1378 "1234567890123456789012345678901234567890"
1379 "1234567890123456789012345678901234567890"
1380 "1234567890123456789012345678901234567890"
1381 "1234567890123456789012345678901234567890"
1382 "1234567890123456789012345678901234567890",
1385 ) != INTMAX_MIN || errno != ERANGE
1387 printf("*** strtoimax failed -overflow test ***\n");
1388 status = EXIT_FAILURE;
1391 if ( (uintmax = strtoumax("1234567890123456789012345678901234567890"
1392 "1234567890123456789012345678901234567890"
1393 "1234567890123456789012345678901234567890"
1394 "1234567890123456789012345678901234567890"
1395 "1234567890123456789012345678901234567890"
1396 "1234567890123456789012345678901234567890",
1399 ) != UINTMAX_MAX || errno != ERANGE
1401 printf("*** strtoumax failed overflow test ***\n");
1402 status = EXIT_FAILURE;
1405 if ( (uintmax = strtoumax("+1234567890123456789012345678901234567890"
1406 "1234567890123456789012345678901234567890"
1407 "1234567890123456789012345678901234567890"
1408 "1234567890123456789012345678901234567890"
1409 "1234567890123456789012345678901234567890"
1410 "1234567890123456789012345678901234567890",
1413 ) != UINTMAX_MAX || errno != ERANGE
1415 printf("*** strtoumax failed +overflow test ***\n");
1416 status = EXIT_FAILURE;
1419 if ( (uintmax = strtoumax("-1234567890123456789012345678901234567890"
1420 "1234567890123456789012345678901234567890"
1421 "1234567890123456789012345678901234567890"
1422 "1234567890123456789012345678901234567890"
1423 "1234567890123456789012345678901234567890"
1424 "1234567890123456789012345678901234567890",
1427 ) != UINTMAX_MAX || errno != ERANGE
1429 printf("*** strtoumax failed -overflow test ***\n");
1430 status = EXIT_FAILURE;
1434 7.8.2.4 The wcstoimax and wcstoumax functions (continued)
1437 if ( (intmax = wcstoimax(L"1234567890123456789012345678901234567890"
1438 L"1234567890123456789012345678901234567890"
1439 L"1234567890123456789012345678901234567890"
1440 L"1234567890123456789012345678901234567890"
1441 L"1234567890123456789012345678901234567890"
1442 L"1234567890123456789012345678901234567890",
1445 ) != INTMAX_MAX || errno != ERANGE
1447 printf("*** wcstoimax failed overflow test ***\n");
1448 status = EXIT_FAILURE;
1451 if ( (intmax = wcstoimax(L"+1234567890123456789012345678901234567890"
1452 L"1234567890123456789012345678901234567890"
1453 L"1234567890123456789012345678901234567890"
1454 L"1234567890123456789012345678901234567890"
1455 L"1234567890123456789012345678901234567890"
1456 L"1234567890123456789012345678901234567890",
1459 ) != INTMAX_MAX || errno != ERANGE
1461 printf("*** wcstoimax failed +overflow test ***\n");
1462 status = EXIT_FAILURE;
1465 if ( (intmax = wcstoimax(L"-1234567890123456789012345678901234567890"
1466 L"1234567890123456789012345678901234567890"
1467 L"1234567890123456789012345678901234567890"
1468 L"1234567890123456789012345678901234567890"
1469 L"1234567890123456789012345678901234567890"
1470 L"1234567890123456789012345678901234567890",
1473 ) != INTMAX_MIN || errno != ERANGE
1475 printf("*** wcstoimax failed -overflow test ***\n");
1476 status = EXIT_FAILURE;
1479 if ( (uintmax = wcstoumax(L"1234567890123456789012345678901234567890"
1480 L"1234567890123456789012345678901234567890"
1481 L"1234567890123456789012345678901234567890"
1482 L"1234567890123456789012345678901234567890"
1483 L"1234567890123456789012345678901234567890"
1484 L"1234567890123456789012345678901234567890",
1487 ) != UINTMAX_MAX || errno != ERANGE
1489 printf("*** wcstoumax failed overflow test ***\n");
1490 status = EXIT_FAILURE;
1493 if ( (uintmax = wcstoumax(L"+1234567890123456789012345678901234567890"
1494 L"1234567890123456789012345678901234567890"
1495 L"1234567890123456789012345678901234567890"
1496 L"1234567890123456789012345678901234567890"
1497 L"1234567890123456789012345678901234567890"
1498 L"1234567890123456789012345678901234567890",
1501 ) != UINTMAX_MAX || errno != ERANGE
1503 printf("*** wcstoumax failed +overflow test ***\n");
1504 status = EXIT_FAILURE;
1507 if ( (uintmax = wcstoumax(L"-1234567890123456789012345678901234567890"
1508 L"1234567890123456789012345678901234567890"
1509 L"1234567890123456789012345678901234567890"
1510 L"1234567890123456789012345678901234567890"
1511 L"1234567890123456789012345678901234567890"
1512 L"1234567890123456789012345678901234567890",
1515 ) != UINTMAX_MAX || errno != ERANGE
1517 printf("*** wcstoumax failed -overflow test ***\n");
1518 status = EXIT_FAILURE;
1521 #endif /* defined(INTMAX_MAX) */
1524 fprintf(stderr, "sitest failed; see stdout for details\n");