Backed out changeset 8f976ed899d7 (bug 1847231) for causing bc failures on browser_se...
[gecko.git] / mozglue / tests / TestIntegerPrintfMacros.cpp
blob71fb26fc47635eb64c061a21241e72c6c299eb75
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/Assertions.h"
8 #include "mozilla/Sprintf.h"
10 #include <string.h>
11 #include <inttypes.h>
13 /* Output array and poisoning method shared by all tests. */
14 static char gOutput[32];
16 static void PoisonOutput() { memset(gOutput, 0xDA, sizeof(gOutput)); }
19 * The fprintf macros for signed integers are:
21 * PRIdN PRIdLEASTN PRIdFASTN PRIdMAX PRIdPTR
22 * PRIiN PRIiLEASTN PRIiFASTN PRIiMAX PRIiPTR
24 * In these names N is the width of the type as described in C99 7.18.1.
27 static void TestPrintSigned8() {
28 PoisonOutput();
29 SprintfLiteral(gOutput, "%" PRId8, int8_t(-17));
30 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-17"));
32 PoisonOutput();
33 SprintfLiteral(gOutput, "%" PRIi8, int8_t(42));
34 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "42"));
37 static void TestPrintSigned16() {
38 PoisonOutput();
39 SprintfLiteral(gOutput, "%" PRId16, int16_t(-289));
40 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-289"));
42 PoisonOutput();
43 SprintfLiteral(gOutput, "%" PRIi16, int16_t(728));
44 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "728"));
47 static void TestPrintSigned32() {
48 PoisonOutput();
49 SprintfLiteral(gOutput, "%" PRId32, int32_t(-342178));
50 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-342178"));
52 PoisonOutput();
53 SprintfLiteral(gOutput, "%" PRIi32, int32_t(5719283));
54 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "5719283"));
57 static void TestPrintSigned64() {
58 PoisonOutput();
59 SprintfLiteral(gOutput, "%" PRId64, int64_t(-INT64_C(432157943248732)));
60 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-432157943248732"));
62 PoisonOutput();
63 SprintfLiteral(gOutput, "%" PRIi64, int64_t(INT64_C(325719232983)));
64 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "325719232983"));
67 static void TestPrintSignedN() {
68 TestPrintSigned8();
69 TestPrintSigned16();
70 TestPrintSigned32();
71 TestPrintSigned64();
74 static void TestPrintSignedLeast8() {
75 PoisonOutput();
76 SprintfLiteral(gOutput, "%" PRIdLEAST8, int_least8_t(-17));
77 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-17"));
79 PoisonOutput();
80 SprintfLiteral(gOutput, "%" PRIiLEAST8, int_least8_t(42));
81 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "42"));
84 static void TestPrintSignedLeast16() {
85 PoisonOutput();
86 SprintfLiteral(gOutput, "%" PRIdLEAST16, int_least16_t(-289));
87 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-289"));
89 PoisonOutput();
90 SprintfLiteral(gOutput, "%" PRIiLEAST16, int_least16_t(728));
91 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "728"));
94 static void TestPrintSignedLeast32() {
95 PoisonOutput();
96 SprintfLiteral(gOutput, "%" PRIdLEAST32, int_least32_t(-342178));
97 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-342178"));
99 PoisonOutput();
100 SprintfLiteral(gOutput, "%" PRIiLEAST32, int_least32_t(5719283));
101 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "5719283"));
104 static void TestPrintSignedLeast64() {
105 PoisonOutput();
106 SprintfLiteral(gOutput, "%" PRIdLEAST64,
107 int_least64_t(-INT64_C(432157943248732)));
108 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-432157943248732"));
110 PoisonOutput();
111 SprintfLiteral(gOutput, "%" PRIiLEAST64,
112 int_least64_t(INT64_C(325719232983)));
113 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "325719232983"));
116 static void TestPrintSignedLeastN() {
117 TestPrintSignedLeast8();
118 TestPrintSignedLeast16();
119 TestPrintSignedLeast32();
120 TestPrintSignedLeast64();
123 static void TestPrintSignedFast8() {
124 PoisonOutput();
125 SprintfLiteral(gOutput, "%" PRIdFAST8, int_fast8_t(-17));
126 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-17"));
128 PoisonOutput();
129 SprintfLiteral(gOutput, "%" PRIiFAST8, int_fast8_t(42));
130 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "42"));
133 static void TestPrintSignedFast16() {
134 PoisonOutput();
135 SprintfLiteral(gOutput, "%" PRIdFAST16, int_fast16_t(-289));
136 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-289"));
138 PoisonOutput();
139 SprintfLiteral(gOutput, "%" PRIiFAST16, int_fast16_t(728));
140 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "728"));
143 static void TestPrintSignedFast32() {
144 PoisonOutput();
145 SprintfLiteral(gOutput, "%" PRIdFAST32, int_fast32_t(-342178));
146 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-342178"));
148 PoisonOutput();
149 SprintfLiteral(gOutput, "%" PRIiFAST32, int_fast32_t(5719283));
150 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "5719283"));
153 static void TestPrintSignedFast64() {
154 PoisonOutput();
155 SprintfLiteral(gOutput, "%" PRIdFAST64,
156 int_fast64_t(-INT64_C(432157943248732)));
157 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-432157943248732"));
159 PoisonOutput();
160 SprintfLiteral(gOutput, "%" PRIiFAST64, int_fast64_t(INT64_C(325719232983)));
161 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "325719232983"));
164 static void TestPrintSignedFastN() {
165 TestPrintSignedFast8();
166 TestPrintSignedFast16();
167 TestPrintSignedFast32();
168 TestPrintSignedFast64();
171 static void TestPrintSignedMax() {
172 PoisonOutput();
173 SprintfLiteral(gOutput, "%" PRIdMAX, intmax_t(-INTMAX_C(432157943248732)));
174 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "-432157943248732"));
176 PoisonOutput();
177 SprintfLiteral(gOutput, "%" PRIiMAX, intmax_t(INTMAX_C(325719232983)));
178 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "325719232983"));
181 static void TestPrintSignedPtr() {
182 PoisonOutput();
183 SprintfLiteral(gOutput, "%" PRIdPTR,
184 intptr_t(reinterpret_cast<void*>(12345678)));
185 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "12345678"));
187 PoisonOutput();
188 SprintfLiteral(gOutput, "%" PRIiPTR,
189 intptr_t(reinterpret_cast<void*>(87654321)));
190 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "87654321"));
193 static void TestPrintSigned() {
194 TestPrintSignedN();
195 TestPrintSignedLeastN();
196 TestPrintSignedFastN();
197 TestPrintSignedMax();
198 TestPrintSignedPtr();
202 * The fprintf macros for unsigned integers are:
204 * PRIoN PRIoLEASTN PRIoFASTN PRIoMAX PRIoPTR
205 * PRIuN PRIuLEASTN PRIuFASTN PRIuMAX PRIuPTR
206 * PRIxN PRIxLEASTN PRIxFASTN PRIxMAX PRIxPTR
207 * PRIXN PRIXLEASTN PRIXFASTN PRIXMAX PRIXPTR
209 * In these names N is the width of the type as described in C99 7.18.1.
212 static void TestPrintUnsigned8() {
213 PoisonOutput();
214 SprintfLiteral(gOutput, "%" PRIo8, uint8_t(042));
215 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "42"));
217 PoisonOutput();
218 SprintfLiteral(gOutput, "%" PRIu8, uint8_t(17));
219 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "17"));
221 PoisonOutput();
222 SprintfLiteral(gOutput, "%" PRIx8, uint8_t(0x2a));
223 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a"));
225 PoisonOutput();
226 SprintfLiteral(gOutput, "%" PRIX8, uint8_t(0xCD));
227 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CD"));
230 static void TestPrintUnsigned16() {
231 PoisonOutput();
232 SprintfLiteral(gOutput, "%" PRIo16, uint16_t(04242));
233 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "4242"));
235 PoisonOutput();
236 SprintfLiteral(gOutput, "%" PRIu16, uint16_t(1717));
237 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "1717"));
239 PoisonOutput();
240 SprintfLiteral(gOutput, "%" PRIx16, uint16_t(0x2a2a));
241 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a2a"));
243 PoisonOutput();
244 SprintfLiteral(gOutput, "%" PRIX16, uint16_t(0xCDCD));
245 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CDCD"));
248 static void TestPrintUnsigned32() {
249 PoisonOutput();
250 SprintfLiteral(gOutput, "%" PRIo32, uint32_t(0424242));
251 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "424242"));
253 PoisonOutput();
254 SprintfLiteral(gOutput, "%" PRIu32, uint32_t(171717));
255 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "171717"));
257 PoisonOutput();
258 SprintfLiteral(gOutput, "%" PRIx32, uint32_t(0x2a2a2a));
259 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a2a2a"));
261 PoisonOutput();
262 SprintfLiteral(gOutput, "%" PRIX32, uint32_t(0xCDCDCD));
263 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CDCDCD"));
266 static void TestPrintUnsigned64() {
267 PoisonOutput();
268 SprintfLiteral(gOutput, "%" PRIo64, uint64_t(UINT64_C(0424242424242)));
269 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "424242424242"));
271 PoisonOutput();
272 SprintfLiteral(gOutput, "%" PRIu64, uint64_t(UINT64_C(17171717171717171717)));
273 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "17171717171717171717"));
275 PoisonOutput();
276 SprintfLiteral(gOutput, "%" PRIx64, uint64_t(UINT64_C(0x2a2a2a2a2a2a2a)));
277 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a2a2a2a2a2a2a"));
279 PoisonOutput();
280 SprintfLiteral(gOutput, "%" PRIX64, uint64_t(UINT64_C(0xCDCDCDCDCDCD)));
281 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CDCDCDCDCDCD"));
284 static void TestPrintUnsignedN() {
285 TestPrintUnsigned8();
286 TestPrintUnsigned16();
287 TestPrintUnsigned32();
288 TestPrintUnsigned64();
291 static void TestPrintUnsignedLeast8() {
292 PoisonOutput();
293 SprintfLiteral(gOutput, "%" PRIoLEAST8, uint_least8_t(042));
294 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "42"));
296 PoisonOutput();
297 SprintfLiteral(gOutput, "%" PRIuLEAST8, uint_least8_t(17));
298 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "17"));
300 PoisonOutput();
301 SprintfLiteral(gOutput, "%" PRIxLEAST8, uint_least8_t(0x2a));
302 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a"));
304 PoisonOutput();
305 SprintfLiteral(gOutput, "%" PRIXLEAST8, uint_least8_t(0xCD));
306 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CD"));
309 static void TestPrintUnsignedLeast16() {
310 PoisonOutput();
311 SprintfLiteral(gOutput, "%" PRIoLEAST16, uint_least16_t(04242));
312 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "4242"));
314 PoisonOutput();
315 SprintfLiteral(gOutput, "%" PRIuLEAST16, uint_least16_t(1717));
316 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "1717"));
318 PoisonOutput();
319 SprintfLiteral(gOutput, "%" PRIxLEAST16, uint_least16_t(0x2a2a));
320 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a2a"));
322 PoisonOutput();
323 SprintfLiteral(gOutput, "%" PRIXLEAST16, uint_least16_t(0xCDCD));
324 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CDCD"));
327 static void TestPrintUnsignedLeast32() {
328 PoisonOutput();
329 SprintfLiteral(gOutput, "%" PRIoLEAST32, uint_least32_t(0424242));
330 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "424242"));
332 PoisonOutput();
333 SprintfLiteral(gOutput, "%" PRIuLEAST32, uint_least32_t(171717));
334 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "171717"));
336 PoisonOutput();
337 SprintfLiteral(gOutput, "%" PRIxLEAST32, uint_least32_t(0x2a2a2a));
338 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a2a2a"));
340 PoisonOutput();
341 SprintfLiteral(gOutput, "%" PRIXLEAST32, uint_least32_t(0xCDCDCD));
342 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CDCDCD"));
345 static void TestPrintUnsignedLeast64() {
346 PoisonOutput();
347 SprintfLiteral(gOutput, "%" PRIoLEAST64,
348 uint_least64_t(UINT64_C(0424242424242)));
349 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "424242424242"));
351 PoisonOutput();
352 SprintfLiteral(gOutput, "%" PRIuLEAST64,
353 uint_least64_t(UINT64_C(17171717171717171717)));
354 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "17171717171717171717"));
356 PoisonOutput();
357 SprintfLiteral(gOutput, "%" PRIxLEAST64,
358 uint_least64_t(UINT64_C(0x2a2a2a2a2a2a2a)));
359 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a2a2a2a2a2a2a"));
361 PoisonOutput();
362 SprintfLiteral(gOutput, "%" PRIXLEAST64,
363 uint_least64_t(UINT64_C(0xCDCDCDCDCDCD)));
364 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CDCDCDCDCDCD"));
367 static void TestPrintUnsignedLeastN() {
368 TestPrintUnsignedLeast8();
369 TestPrintUnsignedLeast16();
370 TestPrintUnsignedLeast32();
371 TestPrintUnsignedLeast64();
374 static void TestPrintUnsignedFast8() {
375 PoisonOutput();
376 SprintfLiteral(gOutput, "%" PRIoFAST8, uint_fast8_t(042));
377 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "42"));
379 PoisonOutput();
380 SprintfLiteral(gOutput, "%" PRIuFAST8, uint_fast8_t(17));
381 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "17"));
383 PoisonOutput();
384 SprintfLiteral(gOutput, "%" PRIxFAST8, uint_fast8_t(0x2a));
385 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a"));
387 PoisonOutput();
388 SprintfLiteral(gOutput, "%" PRIXFAST8, uint_fast8_t(0xCD));
389 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CD"));
392 static void TestPrintUnsignedFast16() {
393 PoisonOutput();
394 SprintfLiteral(gOutput, "%" PRIoFAST16, uint_fast16_t(04242));
395 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "4242"));
397 PoisonOutput();
398 SprintfLiteral(gOutput, "%" PRIuFAST16, uint_fast16_t(1717));
399 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "1717"));
401 PoisonOutput();
402 SprintfLiteral(gOutput, "%" PRIxFAST16, uint_fast16_t(0x2a2a));
403 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a2a"));
405 PoisonOutput();
406 SprintfLiteral(gOutput, "%" PRIXFAST16, uint_fast16_t(0xCDCD));
407 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CDCD"));
410 static void TestPrintUnsignedFast32() {
411 PoisonOutput();
412 SprintfLiteral(gOutput, "%" PRIoFAST32, uint_fast32_t(0424242));
413 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "424242"));
415 PoisonOutput();
416 SprintfLiteral(gOutput, "%" PRIuFAST32, uint_fast32_t(171717));
417 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "171717"));
419 PoisonOutput();
420 SprintfLiteral(gOutput, "%" PRIxFAST32, uint_fast32_t(0x2a2a2a));
421 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a2a2a"));
423 PoisonOutput();
424 SprintfLiteral(gOutput, "%" PRIXFAST32, uint_fast32_t(0xCDCDCD));
425 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CDCDCD"));
428 static void TestPrintUnsignedFast64() {
429 PoisonOutput();
430 SprintfLiteral(gOutput, "%" PRIoFAST64,
431 uint_fast64_t(UINT64_C(0424242424242)));
432 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "424242424242"));
434 PoisonOutput();
435 SprintfLiteral(gOutput, "%" PRIuFAST64,
436 uint_fast64_t(UINT64_C(17171717171717171717)));
437 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "17171717171717171717"));
439 PoisonOutput();
440 SprintfLiteral(gOutput, "%" PRIxFAST64,
441 uint_fast64_t(UINT64_C(0x2a2a2a2a2a2a2a)));
442 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "2a2a2a2a2a2a2a"));
444 PoisonOutput();
445 SprintfLiteral(gOutput, "%" PRIXFAST64,
446 uint_fast64_t(UINT64_C(0xCDCDCDCDCDCD)));
447 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "CDCDCDCDCDCD"));
450 static void TestPrintUnsignedFastN() {
451 TestPrintUnsignedFast8();
452 TestPrintUnsignedFast16();
453 TestPrintUnsignedFast32();
454 TestPrintUnsignedFast64();
457 static void TestPrintUnsignedMax() {
458 PoisonOutput();
459 SprintfLiteral(gOutput, "%" PRIoMAX, uintmax_t(UINTMAX_C(432157943248732)));
460 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "14220563454333534"));
462 PoisonOutput();
463 SprintfLiteral(gOutput, "%" PRIuMAX, uintmax_t(UINTMAX_C(325719232983)));
464 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "325719232983"));
466 PoisonOutput();
467 SprintfLiteral(gOutput, "%" PRIxMAX, uintmax_t(UINTMAX_C(327281321873)));
468 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "4c337ca791"));
470 PoisonOutput();
471 SprintfLiteral(gOutput, "%" PRIXMAX, uintmax_t(UINTMAX_C(912389523743523)));
472 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "33DD03D75A323"));
475 static void TestPrintUnsignedPtr() {
476 PoisonOutput();
477 SprintfLiteral(gOutput, "%" PRIoPTR,
478 uintptr_t(reinterpret_cast<void*>(12345678)));
479 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "57060516"));
481 PoisonOutput();
482 SprintfLiteral(gOutput, "%" PRIuPTR,
483 uintptr_t(reinterpret_cast<void*>(87654321)));
484 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "87654321"));
486 PoisonOutput();
487 SprintfLiteral(gOutput, "%" PRIxPTR,
488 uintptr_t(reinterpret_cast<void*>(0x4c3a791)));
489 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "4c3a791"));
491 PoisonOutput();
492 SprintfLiteral(gOutput, "%" PRIXPTR,
493 uintptr_t(reinterpret_cast<void*>(0xF328DB)));
494 MOZ_RELEASE_ASSERT(!strcmp(gOutput, "F328DB"));
497 static void TestPrintUnsigned() {
498 TestPrintUnsignedN();
499 TestPrintUnsignedLeastN();
500 TestPrintUnsignedFastN();
501 TestPrintUnsignedMax();
502 TestPrintUnsignedPtr();
505 static void TestPrint() {
506 TestPrintSigned();
507 TestPrintUnsigned();
511 * The fscanf macros for signed integers are:
513 * SCNdN SCNdLEASTN SCNdFASTN SCNdMAX SCNdPTR
514 * SCNiN SCNiLEASTN SCNiFASTN SCNiMAX SCNiPTR
516 * In these names N is the width of the type as described in C99 7.18.1.
520 * MSVC's scanf is insufficiently powerful to implement all the SCN* macros.
521 * Rather than support some subset of them, we instead support none of them.
522 * See the comment at the top of IntegerPrintfMacros.h. But in case we ever do
523 * support them, the following tests should adequately test implementation
524 * correctness. (Indeed, these tests *revealed* MSVC's limitations.)
526 * That said, even if MSVC ever picks up complete support, we still probably
527 * don't want to support these, because of the undefined-behavior issue noted
528 * further down in the comment atop IntegerPrintfMacros.h.
530 #define SHOULD_TEST_SCANF_MACROS 0
532 #if SHOULD_TEST_SCANF_MACROS
535 * glibc header definitions for SCN{d,i,o,u,x}{,LEAST,FAST}8 use the "hh" length
536 * modifier, which is new in C99 (and C++11, by reference). We compile this
537 * file as C++11, so if "hh" is used in these macros, it's standard. But some
538 * versions of gcc wrongly think it isn't and warn about a "non-standard"
539 * modifier. And since these tests mostly exist to verify format-macro/type
540 * consistency (particularly through compiler warnings about incorrect formats),
541 * these warnings are unacceptable. So for now, compile tests for those macros
542 * only if we aren't compiling with gcc.
544 # define SHOULD_TEST_8BIT_FORMAT_MACROS (!(MOZ_IS_GCC))
546 template <typename T>
547 union Input {
548 T mI;
549 unsigned char mPun[16];
552 template <typename T>
553 static void PoisonInput(Input<T>& aInput) {
554 memset(aInput.mPun, 0xDA, sizeof(aInput.mPun));
557 template <typename T>
558 static bool ExtraBitsUntouched(const Input<T>& aInput) {
559 for (size_t i = sizeof(aInput.mI); i < sizeof(aInput); i++) {
560 if (aInput.mPun[i] != 0xDA) {
561 return false;
565 return true;
568 static void TestScanSigned8() {
569 # if SHOULD_TEST_8BIT_FORMAT_MACROS
570 Input<int8_t> u;
572 PoisonInput(u);
573 sscanf("-17", "%" SCNd8, &u.mI);
574 MOZ_RELEASE_ASSERT(u.mI == -17);
575 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
577 PoisonInput(u);
578 sscanf("042", "%" SCNi8, &u.mI);
579 MOZ_RELEASE_ASSERT(u.mI == 042);
580 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
581 # endif
584 static void TestScanSigned16() {
585 Input<int16_t> u;
587 PoisonInput(u);
588 sscanf("-1742", "%" SCNd16, &u.mI);
589 MOZ_RELEASE_ASSERT(u.mI == -1742);
590 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
592 PoisonInput(u);
593 sscanf("04217", "%" SCNi16, &u.mI);
594 MOZ_RELEASE_ASSERT(u.mI == 04217);
595 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
598 static void TestScanSigned32() {
599 Input<int32_t> u;
601 PoisonInput(u);
602 sscanf("-174257", "%" SCNd32, &u.mI);
603 MOZ_RELEASE_ASSERT(u.mI == -174257);
604 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
606 PoisonInput(u);
607 sscanf("0423571", "%" SCNi32, &u.mI);
608 MOZ_RELEASE_ASSERT(u.mI == 0423571);
609 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
612 static void TestScanSigned64() {
613 Input<int64_t> u;
615 PoisonInput(u);
616 sscanf("-17425238927232", "%" SCNd64, &u.mI);
617 MOZ_RELEASE_ASSERT(u.mI == -INT64_C(17425238927232));
618 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
620 PoisonInput(u);
621 sscanf("042333576571", "%" SCNi64, &u.mI);
622 MOZ_RELEASE_ASSERT(u.mI == INT64_C(042333576571));
623 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
626 static void TestScanSignedN() {
627 TestScanSigned8();
628 TestScanSigned16();
629 TestScanSigned32();
630 TestScanSigned64();
633 static void TestScanSignedLeast8() {
634 # if SHOULD_TEST_8BIT_FORMAT_MACROS
635 Input<int_least8_t> u;
637 PoisonInput(u);
638 sscanf("-17", "%" SCNdLEAST8, &u.mI);
639 MOZ_RELEASE_ASSERT(u.mI == -17);
640 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
642 PoisonInput(u);
643 sscanf("042", "%" SCNiLEAST8, &u.mI);
644 MOZ_RELEASE_ASSERT(u.mI == 042);
645 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
646 # endif
649 static void TestScanSignedLeast16() {
650 Input<int_least16_t> u;
652 PoisonInput(u);
653 sscanf("-1742", "%" SCNdLEAST16, &u.mI);
654 MOZ_RELEASE_ASSERT(u.mI == -1742);
655 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
657 PoisonInput(u);
658 sscanf("04217", "%" SCNiLEAST16, &u.mI);
659 MOZ_RELEASE_ASSERT(u.mI == 04217);
660 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
663 static void TestScanSignedLeast32() {
664 Input<int_least32_t> u;
666 PoisonInput(u);
667 sscanf("-174257", "%" SCNdLEAST32, &u.mI);
668 MOZ_RELEASE_ASSERT(u.mI == -174257);
669 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
671 PoisonInput(u);
672 sscanf("0423571", "%" SCNiLEAST32, &u.mI);
673 MOZ_RELEASE_ASSERT(u.mI == 0423571);
674 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
677 static void TestScanSignedLeast64() {
678 Input<int_least64_t> u;
680 PoisonInput(u);
681 sscanf("-17425238927232", "%" SCNdLEAST64, &u.mI);
682 MOZ_RELEASE_ASSERT(u.mI == -INT64_C(17425238927232));
683 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
685 PoisonInput(u);
686 sscanf("042333576571", "%" SCNiLEAST64, &u.mI);
687 MOZ_RELEASE_ASSERT(u.mI == INT64_C(042333576571));
688 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
691 static void TestScanSignedLeastN() {
692 TestScanSignedLeast8();
693 TestScanSignedLeast16();
694 TestScanSignedLeast32();
695 TestScanSignedLeast64();
698 static void TestScanSignedFast8() {
699 # if SHOULD_TEST_8BIT_FORMAT_MACROS
700 Input<int_fast8_t> u;
702 PoisonInput(u);
703 sscanf("-17", "%" SCNdFAST8, &u.mI);
704 MOZ_RELEASE_ASSERT(u.mI == -17);
705 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
707 PoisonInput(u);
708 sscanf("042", "%" SCNiFAST8, &u.mI);
709 MOZ_RELEASE_ASSERT(u.mI == 042);
710 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
711 # endif
714 static void TestScanSignedFast16() {
715 Input<int_fast16_t> u;
717 PoisonInput(u);
718 sscanf("-1742", "%" SCNdFAST16, &u.mI);
719 MOZ_RELEASE_ASSERT(u.mI == -1742);
720 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
722 PoisonInput(u);
723 sscanf("04217", "%" SCNiFAST16, &u.mI);
724 MOZ_RELEASE_ASSERT(u.mI == 04217);
725 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
728 static void TestScanSignedFast32() {
729 Input<int_fast32_t> u;
731 PoisonInput(u);
732 sscanf("-174257", "%" SCNdFAST32, &u.mI);
733 MOZ_RELEASE_ASSERT(u.mI == -174257);
734 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
736 PoisonInput(u);
737 sscanf("0423571", "%" SCNiFAST32, &u.mI);
738 MOZ_RELEASE_ASSERT(u.mI == 0423571);
739 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
742 static void TestScanSignedFast64() {
743 Input<int_fast64_t> u;
745 PoisonInput(u);
746 sscanf("-17425238927232", "%" SCNdFAST64, &u.mI);
747 MOZ_RELEASE_ASSERT(u.mI == -INT64_C(17425238927232));
748 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
750 PoisonInput(u);
751 sscanf("042333576571", "%" SCNiFAST64, &u.mI);
752 MOZ_RELEASE_ASSERT(u.mI == INT64_C(042333576571));
753 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
756 static void TestScanSignedFastN() {
757 TestScanSignedFast8();
758 TestScanSignedFast16();
759 TestScanSignedFast32();
760 TestScanSignedFast64();
763 static void TestScanSignedMax() {
764 Input<intmax_t> u;
766 PoisonInput(u);
767 sscanf("-432157943248732", "%" SCNdMAX, &u.mI);
768 MOZ_RELEASE_ASSERT(u.mI == -INTMAX_C(432157943248732));
769 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
771 PoisonInput(u);
772 sscanf("04233357236571", "%" SCNiMAX, &u.mI);
773 MOZ_RELEASE_ASSERT(u.mI == INTMAX_C(04233357236571));
774 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
777 static void TestScanSignedPtr() {
778 Input<intptr_t> u;
780 PoisonInput(u);
781 sscanf("12345678", "%" SCNdPTR, &u.mI);
782 MOZ_RELEASE_ASSERT(u.mI == intptr_t(reinterpret_cast<void*>(12345678)));
783 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
785 PoisonInput(u);
786 sscanf("04233357236", "%" SCNiPTR, &u.mI);
787 MOZ_RELEASE_ASSERT(u.mI == intptr_t(reinterpret_cast<void*>(04233357236)));
788 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
791 static void TestScanSigned() {
792 TestScanSignedN();
793 TestScanSignedLeastN();
794 TestScanSignedFastN();
795 TestScanSignedMax();
796 TestScanSignedPtr();
800 * The fscanf macros for unsigned integers are:
802 * SCNoN SCNoLEASTN SCNoFASTN SCNoMAX SCNoPTR
803 * SCNuN SCNuLEASTN SCNuFASTN SCNuMAX SCNuPTR
804 * SCNxN SCNxLEASTN SCNxFASTN SCNxMAX SCNxPTR
806 * In these names N is the width of the type as described in C99 7.18.1.
809 static void TestScanUnsigned8() {
810 # if SHOULD_TEST_8BIT_FORMAT_MACROS
811 Input<uint8_t> u;
813 PoisonInput(u);
814 sscanf("17", "%" SCNo8, &u.mI);
815 MOZ_RELEASE_ASSERT(u.mI == 017);
816 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
818 PoisonInput(u);
819 sscanf("42", "%" SCNu8, &u.mI);
820 MOZ_RELEASE_ASSERT(u.mI == 42);
821 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
823 PoisonInput(u);
824 sscanf("2A", "%" SCNx8, &u.mI);
825 MOZ_RELEASE_ASSERT(u.mI == 0x2A);
826 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
827 # endif
830 static void TestScanUnsigned16() {
831 Input<uint16_t> u;
833 PoisonInput(u);
834 sscanf("1742", "%" SCNo16, &u.mI);
835 MOZ_RELEASE_ASSERT(u.mI == 01742);
836 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
838 PoisonInput(u);
839 sscanf("4217", "%" SCNu16, &u.mI);
840 MOZ_RELEASE_ASSERT(u.mI == 4217);
841 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
843 PoisonInput(u);
844 sscanf("2ABC", "%" SCNx16, &u.mI);
845 MOZ_RELEASE_ASSERT(u.mI == 0x2ABC);
846 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
849 static void TestScanUnsigned32() {
850 Input<uint32_t> u;
852 PoisonInput(u);
853 sscanf("17421742", "%" SCNo32, &u.mI);
854 MOZ_RELEASE_ASSERT(u.mI == 017421742);
855 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
857 PoisonInput(u);
858 sscanf("4217867", "%" SCNu32, &u.mI);
859 MOZ_RELEASE_ASSERT(u.mI == 4217867);
860 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
862 PoisonInput(u);
863 sscanf("2ABCBEEF", "%" SCNx32, &u.mI);
864 MOZ_RELEASE_ASSERT(u.mI == 0x2ABCBEEF);
865 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
868 static void TestScanUnsigned64() {
869 Input<uint64_t> u;
871 PoisonInput(u);
872 sscanf("17421742173", "%" SCNo64, &u.mI);
873 MOZ_RELEASE_ASSERT(u.mI == UINT64_C(017421742173));
874 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
876 PoisonInput(u);
877 sscanf("421786713579", "%" SCNu64, &u.mI);
878 MOZ_RELEASE_ASSERT(u.mI == UINT64_C(421786713579));
879 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
881 PoisonInput(u);
882 sscanf("DEADBEEF7457E", "%" SCNx64, &u.mI);
883 MOZ_RELEASE_ASSERT(u.mI == UINT64_C(0xDEADBEEF7457E));
884 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
887 static void TestScanUnsignedN() {
888 TestScanUnsigned8();
889 TestScanUnsigned16();
890 TestScanUnsigned32();
891 TestScanUnsigned64();
894 static void TestScanUnsignedLeast8() {
895 # if SHOULD_TEST_8BIT_FORMAT_MACROS
896 Input<uint_least8_t> u;
898 PoisonInput(u);
899 sscanf("17", "%" SCNoLEAST8, &u.mI);
900 MOZ_RELEASE_ASSERT(u.mI == 017);
901 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
903 PoisonInput(u);
904 sscanf("42", "%" SCNuLEAST8, &u.mI);
905 MOZ_RELEASE_ASSERT(u.mI == 42);
906 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
908 PoisonInput(u);
909 sscanf("2A", "%" SCNxLEAST8, &u.mI);
910 MOZ_RELEASE_ASSERT(u.mI == 0x2A);
911 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
912 # endif
915 static void TestScanUnsignedLeast16() {
916 Input<uint_least16_t> u;
918 PoisonInput(u);
919 sscanf("1742", "%" SCNoLEAST16, &u.mI);
920 MOZ_RELEASE_ASSERT(u.mI == 01742);
921 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
923 PoisonInput(u);
924 sscanf("4217", "%" SCNuLEAST16, &u.mI);
925 MOZ_RELEASE_ASSERT(u.mI == 4217);
926 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
928 PoisonInput(u);
929 sscanf("2ABC", "%" SCNxLEAST16, &u.mI);
930 MOZ_RELEASE_ASSERT(u.mI == 0x2ABC);
931 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
934 static void TestScanUnsignedLeast32() {
935 Input<uint_least32_t> u;
937 PoisonInput(u);
938 sscanf("17421742", "%" SCNoLEAST32, &u.mI);
939 MOZ_RELEASE_ASSERT(u.mI == 017421742);
940 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
942 PoisonInput(u);
943 sscanf("4217867", "%" SCNuLEAST32, &u.mI);
944 MOZ_RELEASE_ASSERT(u.mI == 4217867);
945 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
947 PoisonInput(u);
948 sscanf("2ABCBEEF", "%" SCNxLEAST32, &u.mI);
949 MOZ_RELEASE_ASSERT(u.mI == 0x2ABCBEEF);
950 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
953 static void TestScanUnsignedLeast64() {
954 Input<uint_least64_t> u;
956 PoisonInput(u);
957 sscanf("17421742173", "%" SCNoLEAST64, &u.mI);
958 MOZ_RELEASE_ASSERT(u.mI == UINT64_C(017421742173));
959 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
961 PoisonInput(u);
962 sscanf("421786713579", "%" SCNuLEAST64, &u.mI);
963 MOZ_RELEASE_ASSERT(u.mI == UINT64_C(421786713579));
964 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
966 PoisonInput(u);
967 sscanf("DEADBEEF7457E", "%" SCNxLEAST64, &u.mI);
968 MOZ_RELEASE_ASSERT(u.mI == UINT64_C(0xDEADBEEF7457E));
969 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
972 static void TestScanUnsignedLeastN() {
973 TestScanUnsignedLeast8();
974 TestScanUnsignedLeast16();
975 TestScanUnsignedLeast32();
976 TestScanUnsignedLeast64();
979 static void TestScanUnsignedFast8() {
980 # if SHOULD_TEST_8BIT_FORMAT_MACROS
981 Input<uint_fast8_t> u;
983 PoisonInput(u);
984 sscanf("17", "%" SCNoFAST8, &u.mI);
985 MOZ_RELEASE_ASSERT(u.mI == 017);
986 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
988 PoisonInput(u);
989 sscanf("42", "%" SCNuFAST8, &u.mI);
990 MOZ_RELEASE_ASSERT(u.mI == 42);
991 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
993 PoisonInput(u);
994 sscanf("2A", "%" SCNxFAST8, &u.mI);
995 MOZ_RELEASE_ASSERT(u.mI == 0x2A);
996 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
997 # endif
1000 static void TestScanUnsignedFast16() {
1001 Input<uint_fast16_t> u;
1003 PoisonInput(u);
1004 sscanf("1742", "%" SCNoFAST16, &u.mI);
1005 MOZ_RELEASE_ASSERT(u.mI == 01742);
1006 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
1008 PoisonInput(u);
1009 sscanf("4217", "%" SCNuFAST16, &u.mI);
1010 MOZ_RELEASE_ASSERT(u.mI == 4217);
1011 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
1013 PoisonInput(u);
1014 sscanf("2ABC", "%" SCNxFAST16, &u.mI);
1015 MOZ_RELEASE_ASSERT(u.mI == 0x2ABC);
1016 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
1019 static void TestScanUnsignedFast32() {
1020 Input<uint_fast32_t> u;
1022 PoisonInput(u);
1023 sscanf("17421742", "%" SCNoFAST32, &u.mI);
1024 MOZ_RELEASE_ASSERT(u.mI == 017421742);
1025 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
1027 PoisonInput(u);
1028 sscanf("4217867", "%" SCNuFAST32, &u.mI);
1029 MOZ_RELEASE_ASSERT(u.mI == 4217867);
1030 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
1032 PoisonInput(u);
1033 sscanf("2ABCBEEF", "%" SCNxFAST32, &u.mI);
1034 MOZ_RELEASE_ASSERT(u.mI == 0x2ABCBEEF);
1035 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
1038 static void TestScanUnsignedFast64() {
1039 Input<uint_fast64_t> u;
1041 PoisonInput(u);
1042 sscanf("17421742173", "%" SCNoFAST64, &u.mI);
1043 MOZ_RELEASE_ASSERT(u.mI == UINT64_C(017421742173));
1044 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
1046 PoisonInput(u);
1047 sscanf("421786713579", "%" SCNuFAST64, &u.mI);
1048 MOZ_RELEASE_ASSERT(u.mI == UINT64_C(421786713579));
1049 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
1051 PoisonInput(u);
1052 sscanf("DEADBEEF7457E", "%" SCNxFAST64, &u.mI);
1053 MOZ_RELEASE_ASSERT(u.mI == UINT64_C(0xDEADBEEF7457E));
1054 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
1057 static void TestScanUnsignedFastN() {
1058 TestScanUnsignedFast8();
1059 TestScanUnsignedFast16();
1060 TestScanUnsignedFast32();
1061 TestScanUnsignedFast64();
1064 static void TestScanUnsignedMax() {
1065 Input<uintmax_t> u;
1067 PoisonInput(u);
1068 sscanf("14220563454333534", "%" SCNoMAX, &u.mI);
1069 MOZ_RELEASE_ASSERT(u.mI == UINTMAX_C(432157943248732));
1070 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
1072 PoisonInput(u);
1073 sscanf("432157943248732", "%" SCNuMAX, &u.mI);
1074 MOZ_RELEASE_ASSERT(u.mI == UINTMAX_C(432157943248732));
1075 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
1077 PoisonInput(u);
1078 sscanf("4c337ca791", "%" SCNxMAX, &u.mI);
1079 MOZ_RELEASE_ASSERT(u.mI == UINTMAX_C(327281321873));
1080 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
1083 static void TestScanUnsignedPtr() {
1084 Input<uintptr_t> u;
1086 PoisonInput(u);
1087 sscanf("57060516", "%" SCNoPTR, &u.mI);
1088 MOZ_RELEASE_ASSERT(u.mI == uintptr_t(reinterpret_cast<void*>(12345678)));
1089 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
1091 PoisonInput(u);
1092 sscanf("87654321", "%" SCNuPTR, &u.mI);
1093 MOZ_RELEASE_ASSERT(u.mI == uintptr_t(reinterpret_cast<void*>(87654321)));
1094 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
1096 PoisonInput(u);
1097 sscanf("4c3a791", "%" SCNxPTR, &u.mI);
1098 MOZ_RELEASE_ASSERT(u.mI == uintptr_t(reinterpret_cast<void*>(0x4c3a791)));
1099 MOZ_RELEASE_ASSERT(ExtraBitsUntouched(u));
1102 static void TestScanUnsigned() {
1103 TestScanUnsignedN();
1104 TestScanUnsignedLeastN();
1105 TestScanUnsignedFastN();
1106 TestScanUnsignedMax();
1107 TestScanUnsignedPtr();
1110 static void TestScan() {
1111 TestScanSigned();
1112 TestScanUnsigned();
1115 #endif /* SHOULD_TEST_SCANF_MACROS */
1117 #if defined(XP_WIN)
1118 int wmain()
1119 #else
1120 int main()
1121 #endif // defined(XP_WIN)
1123 TestPrint();
1124 #if SHOULD_TEST_SCANF_MACROS
1125 TestScan();
1126 #endif
1127 return 0;