2 type: INT, LONG, STRING, FLOAT
25 } static const cases[] = {
27 {0xab, "%04x", "00ab"},
28 {0xffff, "0x%02X", "0xFFFF"},
29 {0xffffu, "%u", "65535"},
30 {1234, "%+6d", " +1234"},
31 {12345, "% d", " 12345"},
32 {-1234, "%d", "-1234"},
33 {32767, "%8d", " 32767"},
35 {1001, "%08i", "00001001"},
36 {101, "%-+8d", "+101 "},
37 {01234, "%o(oct)", "1234(oct)"},
39 // do we want to check these:
40 #if defined(SDCC) && !defined(SDCC_z80) && CHECK_B
41 {0x4142, "%bc %bx", "\x41 42"}, /* non-std: print as bytes! */
42 {0xfffe, "0x%02bX%02bx", "0xFFfe"}, /* non-std: print as bytes! */
43 #elif defined(SDCC) && defined(SDCC_z80) && CHECK_B
44 {0x4142, "%bc %bx", "\x42 41"}, /* non-std: print as bytes! */
45 {0xfffe, "0x%02bX%02bx", "0xFEff"}, /* non-std: print as bytes! */
56 } static const cases[] = {
58 {0x12345678, "0x%lx", "0x12345678"},
59 {0x7fffFFFF, "%10lx", " 7fffffff"},
60 {0x789abcde, "0x%-10lX", "0x789ABCDE "},
61 {0x1000a, "0x%02lX", "0x1000A"},
62 {0x80000000, "%lu", "2147483648"},
63 {-2147483648, "%li", "-2147483648"},
64 {-1234, "%+6ld", " -1234"},
65 {012345670123, "%lo(oct)", "12345670123(oct)"},
66 {0xffffFFFF, "%lo(oct)", "37777777777(oct)"},
68 // do we want to check these:
69 #if defined(SDCC) && !defined(SDCC_z80) && CHECK_B
70 {0xfedcba98, "0x%bX%bX%bx%bx", "0xFEDCba98"}, /* non-std: print as bytes! */
71 #elif defined(SDCC) && defined(SDCC_z80) && CHECK_B
72 {0xfedcba98, "0x%bX%bX%bx%bx", "0x98BAdcfe"}, /* non-std: print as bytes! */
83 } static const cases[] = {
85 {"abcd", "%s", "abcd"},
86 {"abcd", "%3s", "abcd"},
87 {"abcd", "%5s", " abcd"},
88 {"abcd", "%-5s", "abcd "},
89 {"abcd", "%.2s", "ab"},
90 {"XYZ\\", "%s", "XYZ\x5c"},
91 {"ab\x1b\x7f", "%s", "ab\x1b\x7f"},
92 {"ab\tcd\n", "%s", "ab\tcd\n"},
102 } static const cases[] = {
104 // ... there should be more ...
105 #if defined(SDCC) && !defined(SDCC_ds390) && !(defined(SDCC_mcs51) && defined(SDCC_USE_XSTACK))
106 {1.0, "%f", "<NO FLOAT>"},
108 {1.0, "%f", "1.000000"},
109 {1.96, "%3.1f", "2.0"},
118 unsigned char buf[32];
121 memset (buf, 0xfe, sizeof buf); /* cookies all over */
123 for (i = 0; i < sizeof cases / sizeof cases[0]; i++)
125 sprintf (buf, cases[i].fmt, cases[i].arg);
126 DEBUG (printf ("Test%d should be: \"%s\" is: \"%s\"\n", i, cases[i].result, buf));
127 ASSERT (!strcmp (buf, cases[i].result));
130 ASSERT (buf[sizeof buf - 10] == 0xfe); /* check for cookie */