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