3 assert(CHAR_MIN == -128);
4 PRINTF_TEST( 4, "-128", "%hhd", CHAR_MIN );
5 assert(CHAR_MAX == 127);
6 PRINTF_TEST( 3, "127", "%hhd", CHAR_MAX );
9 PRINTF_TEST( 1, "0", "%hhd", CHAR_MIN );
10 assert(CHAR_MAX == 255);
11 PRINTF_TEST( 3, "255", "%hhd", CHAR_MAX );
13 PRINTF_TEST( 1, "0", "%hhd", 0 );
14 assert(SHRT_MIN == -32768);
15 PRINTF_TEST( 6, "-32768", "%hd", SHRT_MIN );
16 assert(SHRT_MAX == 32767);
17 PRINTF_TEST( 5, "32767", "%hd", SHRT_MAX );
18 PRINTF_TEST( 1, "0", "%hd", 0 );
19 PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%d", INT_MIN );
20 PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%d", INT_MAX );
21 PRINTF_TEST( 1, "0", "%d", 0 );
22 PRINTF_TEST( LONG_DIG + 1, "-" LONG_MIN_DEZ_STR, "%ld", LONG_MIN );
23 PRINTF_TEST( LONG_DIG, LONG_MAX_DEZ_STR, "%ld", LONG_MAX );
24 PRINTF_TEST( 1, "0", "%ld", 0l );
25 PRINTF_TEST( LLONG_DIG + 1, "-" LLONG_MIN_DEZ_STR, "%lld", LLONG_MIN );
26 PRINTF_TEST( LLONG_DIG, LLONG_MAX_DEZ_STR, "%lld", LLONG_MAX );
27 PRINTF_TEST( 1, "0", "%lld", 0ll );
28 PRINTF_TEST( 3, "255", "%hhu", UCHAR_MAX );
29 PRINTF_TEST( 3, "255", "%hhu", (unsigned char)-1 );
30 PRINTF_TEST( 5, "65535", "%hu", USHRT_MAX );
31 PRINTF_TEST( 5, "65535", "%hu", (unsigned short)-1 );
32 PRINTF_TEST( UINT_DIG, UINT_MAX_DEZ_STR, "%u", UINT_MAX );
33 PRINTF_TEST( UINT_DIG, UINT_MAX_DEZ_STR, "%u", -1u );
34 PRINTF_TEST( ULONG_DIG, ULONG_MAX_DEZ_STR, "%lu", ULONG_MAX );
35 PRINTF_TEST( ULONG_DIG, ULONG_MAX_DEZ_STR, "%lu", -1ul );
36 PRINTF_TEST( ULLONG_DIG, ULLONG_MAX_DEZ_STR, "%llu", ULLONG_MAX );
37 PRINTF_TEST( ULLONG_DIG, ULLONG_MAX_DEZ_STR, "%llu", -1ull );
38 PRINTF_TEST( (int)strlen( INT_HEXDIG ) + 1, "F" INT_HEXDIG, "%X", UINT_MAX );
39 PRINTF_TEST( (int)strlen( INT_HEXDIG ) + 3, "0XF" INT_HEXDIG, "%#X", -1u );
40 PRINTF_TEST( (int)strlen( INT_HEXDIG ) + 1, "f" INT_hexdig, "%x", UINT_MAX );
41 PRINTF_TEST( (int)strlen( INT_HEXDIG ) + 3, "0xf" INT_hexdig, "%#x", -1u );
42 PRINTF_TEST( (int)strlen( INT_OCTDIG ), INT_OCTDIG, "%o", UINT_MAX );
43 PRINTF_TEST( (int)strlen( INT_OCTDIG ) + 1, "0" INT_OCTDIG, "%#o", -1u );
45 /* TODO: This test case is broken, doesn't test what it was intended to. */
46 PRINTF_TEST( 5, "%.0#o", "%.0#o", 0 );
48 PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%+d", INT_MIN );
49 PRINTF_TEST( INT_DIG + 1, "+" INT_MAX_DEZ_STR, "%+d", INT_MAX );
50 PRINTF_TEST( 2, "+0", "%+d", 0 );
51 PRINTF_TEST( UINT_DIG, UINT_MAX_DEZ_STR, "%+u", UINT_MAX );
52 PRINTF_TEST( UINT_DIG, UINT_MAX_DEZ_STR, "%+u", -1u );
53 PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "% d", INT_MIN );
54 PRINTF_TEST( INT_DIG + 1, " " INT_MAX_DEZ_STR, "% d", INT_MAX );
55 PRINTF_TEST( 2, " 0", "% d", 0 );
56 PRINTF_TEST( UINT_DIG, UINT_MAX_DEZ_STR, "% u", UINT_MAX );
57 PRINTF_TEST( UINT_DIG, UINT_MAX_DEZ_STR, "% u", -1u );
58 PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%" INT_DIG_LESS1 "d", INT_MIN );
59 PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%" INT_DIG_LESS1 "d", INT_MAX );
60 PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%" sym2s(INT_DIG) "d", INT_MIN );
61 PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%" sym2s(INT_DIG) "d", INT_MAX );
62 PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%" INT_DIG_PLUS1 "d", INT_MIN );
63 PRINTF_TEST( INT_DIG + 1, " " INT_MAX_DEZ_STR, "%" INT_DIG_PLUS1 "d", INT_MAX );
64 PRINTF_TEST( INT_DIG + 2, " -" INT_MIN_DEZ_STR, "%" INT_DIG_PLUS2 "d", INT_MIN );
65 PRINTF_TEST( INT_DIG + 2, " " INT_MAX_DEZ_STR, "%" INT_DIG_PLUS2 "d", INT_MAX );
66 PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%-" INT_DIG_LESS1 "d", INT_MIN );
67 PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%-" INT_DIG_LESS1 "d", INT_MAX );
68 PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%-" sym2s(INT_DIG) "d", INT_MIN );
69 PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%-" sym2s(INT_DIG) "d", INT_MAX );
70 PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%-" INT_DIG_PLUS1 "d", INT_MIN );
71 PRINTF_TEST( INT_DIG + 1, INT_MAX_DEZ_STR " ", "%-" INT_DIG_PLUS1 "d", INT_MAX );
72 PRINTF_TEST( INT_DIG + 2, "-" INT_MIN_DEZ_STR " ", "%-" INT_DIG_PLUS2 "d", INT_MIN );
73 PRINTF_TEST( INT_DIG + 2, INT_MAX_DEZ_STR " ", "%-" INT_DIG_PLUS2 "d", INT_MAX );
74 PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%0" INT_DIG_LESS1 "d", INT_MIN );
75 PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%0" INT_DIG_LESS1 "d", INT_MAX );
76 PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%0" sym2s(INT_DIG) "d", INT_MIN );
77 PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%0" sym2s(INT_DIG) "d", INT_MAX );
78 PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%0" INT_DIG_PLUS1 "d", INT_MIN );
79 PRINTF_TEST( INT_DIG + 1, "0" INT_MAX_DEZ_STR, "%0" INT_DIG_PLUS1 "d", INT_MAX );
80 PRINTF_TEST( INT_DIG + 2, "-0" INT_MIN_DEZ_STR, "%0" INT_DIG_PLUS2 "d", INT_MIN );
81 PRINTF_TEST( INT_DIG + 2, "00" INT_MAX_DEZ_STR, "%0" INT_DIG_PLUS2 "d", INT_MAX );
82 PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%-0" INT_DIG_LESS1 "d", INT_MIN );
83 PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%-0" INT_DIG_LESS1 "d", INT_MAX );
84 PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%-0" sym2s(INT_DIG) "d", INT_MIN );
85 PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%-0" sym2s(INT_DIG) "d", INT_MAX );
86 PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%-0" INT_DIG_PLUS1 "d", INT_MIN );
87 PRINTF_TEST( INT_DIG + 1, INT_MAX_DEZ_STR " ", "%-0" INT_DIG_PLUS1 "d", INT_MAX );
88 PRINTF_TEST( INT_DIG + 2, "-" INT_MIN_DEZ_STR " ", "%-0" INT_DIG_PLUS2 "d", INT_MIN );
89 PRINTF_TEST( INT_DIG + 2, INT_MAX_DEZ_STR " ", "%-0" INT_DIG_PLUS2 "d", INT_MAX );
90 /* FIXME: This test not yet 32/64 bit agnostic */
91 PRINTF_TEST( 30, " 00000000002147483647", "%030.20d", INT_MAX );
92 PRINTF_TEST( (int)strlen( INT_HEXDIG ) + 1, "f" INT_hexdig, "%.6x", UINT_MAX );
93 PRINTF_TEST( (int)strlen( INT_HEXDIG ) + 3, "0xf" INT_hexdig, "%#6.3x", UINT_MAX );
94 PRINTF_TEST( (int)strlen( INT_HEXDIG ) + 3, "0xf" INT_hexdig, "%#3.6x", UINT_MAX );
95 PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%.6d", INT_MIN );
96 PRINTF_TEST( INT_DIG + 1, "-" INT_MIN_DEZ_STR, "%6.3d", INT_MIN );
97 PRINTF_TEST( INT_DIG + 1., "-" INT_MIN_DEZ_STR, "%3.6d", INT_MIN );
98 PRINTF_TEST( UINT_DIG, "0xf" INT_hexdig, "%#0.6x", UINT_MAX );
99 PRINTF_TEST( UINT_DIG, "0xf" INT_hexdig, "%#06.3x", UINT_MAX );
100 PRINTF_TEST( UINT_DIG, "0xf" INT_hexdig, "%#03.6x", UINT_MAX );
101 PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%#0.6d", INT_MAX );
102 PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%#06.3d", INT_MAX );
103 PRINTF_TEST( INT_DIG, INT_MAX_DEZ_STR, "%#03.6d", INT_MAX );
104 PRINTF_TEST( INT_DIG + 1, "+" INT_MAX_DEZ_STR, "%#+.6d", INT_MAX );
105 PRINTF_TEST( INT_DIG + 1, "+" INT_MAX_DEZ_STR, "%#+6.3d", INT_MAX );
106 PRINTF_TEST( INT_DIG + 1, "+" INT_MAX_DEZ_STR, "%#+3.6d", INT_MAX );
107 PRINTF_TEST( INT_DIG + 1, "+" INT_MAX_DEZ_STR, "%+0.6d", INT_MAX );
108 PRINTF_TEST( INT_DIG + 1, "+" INT_MAX_DEZ_STR, "%+06.3d", INT_MAX );
109 PRINTF_TEST( INT_DIG + 1, "+" INT_MAX_DEZ_STR, "%+03.6d", INT_MAX );
110 #ifndef TEST_CONVERSION_ONLY
111 PRINTF_TEST( INT_DIG + 2, "- " INT_MAX_DEZ_STR, "- %d", INT_MAX );
112 PRINTF_TEST( INT_DIG * 2 + 6, "- " INT_MAX_DEZ_STR " % -" INT_MIN_DEZ_STR, "- %d %% %d", INT_MAX, INT_MIN );
114 PRINTF_TEST( 1, "x", "%c", 'x' );
115 PRINTF_TEST( 6, "abcdef", "%s", "abcdef" );
116 /* FIXME: This test not yet 32/64 bit agnostic */
117 PRINTF_TEST( 10, "0xdeadbeef", "%p", (void *)0xdeadbeef );
118 PRINTF_TEST( 6, " 0x1", "%#6x", 1 );
119 #ifndef TEST_CONVERSION_ONLY
122 PRINTF_TEST( 9, "123456789", "123456%n789%n", &val1, &val2 );
123 TESTCASE( val1 == 6 );
124 TESTCASE( val2 == 9 );
129 #ifndef TEST_CONVERSION_ONLY
130 /******************************************************************************
131 * NOTE: The following test cases are imported from the Tyndur project. They *
132 * are therefore under the license of said project, not CC0. *
133 * As said code comprises test cases, it does not form part of the *
134 * final compiled library, and has no bearing on its licensing. *
136 * See bug PDCLIB-6 for full details *
137 ******************************************************************************/
139 * Copyright (c) 2011 The tyndur Project. All rights reserved.
141 * This code is derived from software contributed to the tyndur Project
144 * Redistribution and use in source and binary forms, with or without
145 * modification, are permitted provided that the following conditions
147 * 1. Redistributions of source code must retain the above copyright
148 * notice, this list of conditions and the following disclaimer.
149 * 2. Redistributions in binary form must reproduce the above copyright
150 * notice, this list of conditions and the following disclaimer in the
151 * documentation and/or other materials provided with the distribution.
153 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
154 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
155 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
156 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
157 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
158 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
159 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
160 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
161 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
162 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
163 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
166 /* Ein String ohne alles */
167 PRINTF_TEST(12, "Hallo heimur", "Hallo heimur");
168 /* Einfache Konvertierungen */
169 PRINTF_TEST(12, "Hallo heimur", "%s", "Hallo heimur");
170 PRINTF_TEST(4, "1024", "%d", 1024);
171 PRINTF_TEST(5, "-1024", "%d", -1024);
172 PRINTF_TEST(4, "1024", "%i", 1024);
173 PRINTF_TEST(5, "-1024", "%i", -1024);
174 PRINTF_TEST(4, "1024", "%u", 1024u);
175 PRINTF_TEST(10, "4294966272", "%u", -1024u);
176 PRINTF_TEST(3, "777", "%o", 0777u);
177 PRINTF_TEST(11, "37777777001", "%o", -0777u);
178 PRINTF_TEST(8, "1234abcd", "%x", 0x1234abcdu);
179 PRINTF_TEST(8, "edcb5433", "%x", -0x1234abcdu);
180 PRINTF_TEST(8, "1234ABCD", "%X", 0x1234abcdu);
181 PRINTF_TEST(8, "EDCB5433", "%X", -0x1234abcdu);
182 PRINTF_TEST(1, "x", "%c", 'x');
183 PRINTF_TEST(1, "%", "%%");
184 /* Mit %c kann man auch Nullbytes ausgeben */
185 PRINTF_TEST(1, "\0", "%c", '\0');
186 /* Vorzeichen erzwingen (Flag +) */
187 PRINTF_TEST(12, "Hallo heimur", "%+s", "Hallo heimur");
188 PRINTF_TEST(5, "+1024", "%+d", 1024);
189 PRINTF_TEST(5, "-1024", "%+d", -1024);
190 PRINTF_TEST(5, "+1024", "%+i", 1024);
191 PRINTF_TEST(5, "-1024", "%+i", -1024);
192 PRINTF_TEST(4, "1024", "%+u", 1024u);
193 PRINTF_TEST(10, "4294966272", "%+u", -1024u);
194 PRINTF_TEST(3, "777", "%+o", 0777u);
195 PRINTF_TEST(11, "37777777001", "%+o", -0777u);
196 PRINTF_TEST(8, "1234abcd", "%+x", 0x1234abcdu);
197 PRINTF_TEST(8, "edcb5433", "%+x", -0x1234abcdu);
198 PRINTF_TEST(8, "1234ABCD", "%+X", 0x1234abcdu);
199 PRINTF_TEST(8, "EDCB5433", "%+X", -0x1234abcdu);
200 PRINTF_TEST(1, "x", "%+c", 'x');
201 /* Vorzeichenplatzhalter erzwingen (Flag <space>) */
202 PRINTF_TEST(12, "Hallo heimur", "% s", "Hallo heimur");
203 PRINTF_TEST(5, " 1024", "% d", 1024);
204 PRINTF_TEST(5, "-1024", "% d", -1024);
205 PRINTF_TEST(5, " 1024", "% i", 1024);
206 PRINTF_TEST(5, "-1024", "% i", -1024);
207 PRINTF_TEST(4, "1024", "% u", 1024u);
208 PRINTF_TEST(10, "4294966272", "% u", -1024u);
209 PRINTF_TEST(3, "777", "% o", 0777u);
210 PRINTF_TEST(11, "37777777001", "% o", -0777u);
211 PRINTF_TEST(8, "1234abcd", "% x", 0x1234abcdu);
212 PRINTF_TEST(8, "edcb5433", "% x", -0x1234abcdu);
213 PRINTF_TEST(8, "1234ABCD", "% X", 0x1234abcdu);
214 PRINTF_TEST(8, "EDCB5433", "% X", -0x1234abcdu);
215 PRINTF_TEST(1, "x", "% c", 'x');
216 /* Flag + hat Vorrang über <space> */
217 PRINTF_TEST(12, "Hallo heimur", "%+ s", "Hallo heimur");
218 PRINTF_TEST(5, "+1024", "%+ d", 1024);
219 PRINTF_TEST(5, "-1024", "%+ d", -1024);
220 PRINTF_TEST(5, "+1024", "%+ i", 1024);
221 PRINTF_TEST(5, "-1024", "%+ i", -1024);
222 PRINTF_TEST(4, "1024", "%+ u", 1024u);
223 PRINTF_TEST(10, "4294966272", "%+ u", -1024u);
224 PRINTF_TEST(3, "777", "%+ o", 0777u);
225 PRINTF_TEST(11, "37777777001", "%+ o", -0777u);
226 PRINTF_TEST(8, "1234abcd", "%+ x", 0x1234abcdu);
227 PRINTF_TEST(8, "edcb5433", "%+ x", -0x1234abcdu);
228 PRINTF_TEST(8, "1234ABCD", "%+ X", 0x1234abcdu);
229 PRINTF_TEST(8, "EDCB5433", "%+ X", -0x1234abcdu);
230 PRINTF_TEST(1, "x", "%+ c", 'x');
231 /* Alternative Form */
232 PRINTF_TEST(4, "0777", "%#o", 0777u);
233 PRINTF_TEST(12, "037777777001", "%#o", -0777u);
234 PRINTF_TEST(10, "0x1234abcd", "%#x", 0x1234abcdu);
235 PRINTF_TEST(10, "0xedcb5433", "%#x", -0x1234abcdu);
236 PRINTF_TEST(10, "0X1234ABCD", "%#X", 0x1234abcdu);
237 PRINTF_TEST(10, "0XEDCB5433", "%#X", -0x1234abcdu);
238 PRINTF_TEST(1, "0", "%#o", 0u);
239 PRINTF_TEST(1, "0", "%#x", 0u);
240 PRINTF_TEST(1, "0", "%#X", 0u);
241 /* Feldbreite: Kleiner als Ausgabe */
242 PRINTF_TEST(12, "Hallo heimur", "%1s", "Hallo heimur");
243 PRINTF_TEST(4, "1024", "%1d", 1024);
244 PRINTF_TEST(5, "-1024", "%1d", -1024);
245 PRINTF_TEST(4, "1024", "%1i", 1024);
246 PRINTF_TEST(5, "-1024", "%1i", -1024);
247 PRINTF_TEST(4, "1024", "%1u", 1024u);
248 PRINTF_TEST(10, "4294966272", "%1u", -1024u);
249 PRINTF_TEST(3, "777", "%1o", 0777u);
250 PRINTF_TEST(11, "37777777001", "%1o", -0777u);
251 PRINTF_TEST(8, "1234abcd", "%1x", 0x1234abcdu);
252 PRINTF_TEST(8, "edcb5433", "%1x", -0x1234abcdu);
253 PRINTF_TEST(8, "1234ABCD", "%1X", 0x1234abcdu);
254 PRINTF_TEST(8, "EDCB5433", "%1X", -0x1234abcdu);
255 PRINTF_TEST(1, "x", "%1c", 'x');
256 /* Feldbreite: Größer als Ausgabe */
257 PRINTF_TEST(20, " Hallo", "%20s", "Hallo");
258 PRINTF_TEST(20, " 1024", "%20d", 1024);
259 PRINTF_TEST(20, " -1024", "%20d", -1024);
260 PRINTF_TEST(20, " 1024", "%20i", 1024);
261 PRINTF_TEST(20, " -1024", "%20i", -1024);
262 PRINTF_TEST(20, " 1024", "%20u", 1024u);
263 PRINTF_TEST(20, " 4294966272", "%20u", -1024u);
264 PRINTF_TEST(20, " 777", "%20o", 0777u);
265 PRINTF_TEST(20, " 37777777001", "%20o", -0777u);
266 PRINTF_TEST(20, " 1234abcd", "%20x", 0x1234abcdu);
267 PRINTF_TEST(20, " edcb5433", "%20x", -0x1234abcdu);
268 PRINTF_TEST(20, " 1234ABCD", "%20X", 0x1234abcdu);
269 PRINTF_TEST(20, " EDCB5433", "%20X", -0x1234abcdu);
270 PRINTF_TEST(20, " x", "%20c", 'x');
271 /* Feldbreite: Linksbündig */
272 PRINTF_TEST(20, "Hallo ", "%-20s", "Hallo");
273 PRINTF_TEST(20, "1024 ", "%-20d", 1024);
274 PRINTF_TEST(20, "-1024 ", "%-20d", -1024);
275 PRINTF_TEST(20, "1024 ", "%-20i", 1024);
276 PRINTF_TEST(20, "-1024 ", "%-20i", -1024);
277 PRINTF_TEST(20, "1024 ", "%-20u", 1024u);
278 PRINTF_TEST(20, "4294966272 ", "%-20u", -1024u);
279 PRINTF_TEST(20, "777 ", "%-20o", 0777u);
280 PRINTF_TEST(20, "37777777001 ", "%-20o", -0777u);
281 PRINTF_TEST(20, "1234abcd ", "%-20x", 0x1234abcdu);
282 PRINTF_TEST(20, "edcb5433 ", "%-20x", -0x1234abcdu);
283 PRINTF_TEST(20, "1234ABCD ", "%-20X", 0x1234abcdu);
284 PRINTF_TEST(20, "EDCB5433 ", "%-20X", -0x1234abcdu);
285 PRINTF_TEST(20, "x ", "%-20c", 'x');
286 /* Feldbreite: Padding mit 0 */
287 PRINTF_TEST(20, "00000000000000001024", "%020d", 1024);
288 PRINTF_TEST(20, "-0000000000000001024", "%020d", -1024);
289 PRINTF_TEST(20, "00000000000000001024", "%020i", 1024);
290 PRINTF_TEST(20, "-0000000000000001024", "%020i", -1024);
291 PRINTF_TEST(20, "00000000000000001024", "%020u", 1024u);
292 PRINTF_TEST(20, "00000000004294966272", "%020u", -1024u);
293 PRINTF_TEST(20, "00000000000000000777", "%020o", 0777u);
294 PRINTF_TEST(20, "00000000037777777001", "%020o", -0777u);
295 PRINTF_TEST(20, "0000000000001234abcd", "%020x", 0x1234abcdu);
296 PRINTF_TEST(20, "000000000000edcb5433", "%020x", -0x1234abcdu);
297 PRINTF_TEST(20, "0000000000001234ABCD", "%020X", 0x1234abcdu);
298 PRINTF_TEST(20, "000000000000EDCB5433", "%020X", -0x1234abcdu);
299 /* Feldbreite: Padding und alternative Form */
300 PRINTF_TEST(20, " 0777", "%#20o", 0777u);
301 PRINTF_TEST(20, " 037777777001", "%#20o", -0777u);
302 PRINTF_TEST(20, " 0x1234abcd", "%#20x", 0x1234abcdu);
303 PRINTF_TEST(20, " 0xedcb5433", "%#20x", -0x1234abcdu);
304 PRINTF_TEST(20, " 0X1234ABCD", "%#20X", 0x1234abcdu);
305 PRINTF_TEST(20, " 0XEDCB5433", "%#20X", -0x1234abcdu);
306 PRINTF_TEST(20, "00000000000000000777", "%#020o", 0777u);
307 PRINTF_TEST(20, "00000000037777777001", "%#020o", -0777u);
308 PRINTF_TEST(20, "0x00000000001234abcd", "%#020x", 0x1234abcdu);
309 PRINTF_TEST(20, "0x0000000000edcb5433", "%#020x", -0x1234abcdu);
310 PRINTF_TEST(20, "0X00000000001234ABCD", "%#020X", 0x1234abcdu);
311 PRINTF_TEST(20, "0X0000000000EDCB5433", "%#020X", -0x1234abcdu);
312 /* Feldbreite: - hat Vorrang vor 0 */
313 PRINTF_TEST(20, "Hallo ", "%0-20s", "Hallo");
314 PRINTF_TEST(20, "1024 ", "%0-20d", 1024);
315 PRINTF_TEST(20, "-1024 ", "%0-20d", -1024);
316 PRINTF_TEST(20, "1024 ", "%0-20i", 1024);
317 PRINTF_TEST(20, "-1024 ", "%0-20i", -1024);
318 PRINTF_TEST(20, "1024 ", "%0-20u", 1024u);
319 PRINTF_TEST(20, "4294966272 ", "%0-20u", -1024u);
320 PRINTF_TEST(20, "777 ", "%-020o", 0777u);
321 PRINTF_TEST(20, "37777777001 ", "%-020o", -0777u);
322 PRINTF_TEST(20, "1234abcd ", "%-020x", 0x1234abcdu);
323 PRINTF_TEST(20, "edcb5433 ", "%-020x", -0x1234abcdu);
324 PRINTF_TEST(20, "1234ABCD ", "%-020X", 0x1234abcdu);
325 PRINTF_TEST(20, "EDCB5433 ", "%-020X", -0x1234abcdu);
326 PRINTF_TEST(20, "x ", "%-020c", 'x');
327 /* Feldbreite: Aus Parameter */
328 PRINTF_TEST(20, " Hallo", "%*s", 20, "Hallo");
329 PRINTF_TEST(20, " 1024", "%*d", 20, 1024);
330 PRINTF_TEST(20, " -1024", "%*d", 20, -1024);
331 PRINTF_TEST(20, " 1024", "%*i", 20, 1024);
332 PRINTF_TEST(20, " -1024", "%*i", 20, -1024);
333 PRINTF_TEST(20, " 1024", "%*u", 20, 1024u);
334 PRINTF_TEST(20, " 4294966272", "%*u", 20, -1024u);
335 PRINTF_TEST(20, " 777", "%*o", 20, 0777u);
336 PRINTF_TEST(20, " 37777777001", "%*o", 20, -0777u);
337 PRINTF_TEST(20, " 1234abcd", "%*x", 20, 0x1234abcdu);
338 PRINTF_TEST(20, " edcb5433", "%*x", 20, -0x1234abcdu);
339 PRINTF_TEST(20, " 1234ABCD", "%*X", 20, 0x1234abcdu);
340 PRINTF_TEST(20, " EDCB5433", "%*X", 20, -0x1234abcdu);
341 PRINTF_TEST(20, " x", "%*c", 20, 'x');
342 /* Präzision / Mindestanzahl von Ziffern */
343 PRINTF_TEST(12, "Hallo heimur", "%.20s", "Hallo heimur");
344 PRINTF_TEST(20, "00000000000000001024", "%.20d", 1024);
345 PRINTF_TEST(21, "-00000000000000001024", "%.20d", -1024);
346 PRINTF_TEST(20, "00000000000000001024", "%.20i", 1024);
347 PRINTF_TEST(21, "-00000000000000001024", "%.20i", -1024);
348 PRINTF_TEST(20, "00000000000000001024", "%.20u", 1024u);
349 PRINTF_TEST(20, "00000000004294966272", "%.20u", -1024u);
350 PRINTF_TEST(20, "00000000000000000777", "%.20o", 0777u);
351 PRINTF_TEST(20, "00000000037777777001", "%.20o", -0777u);
352 PRINTF_TEST(20, "0000000000001234abcd", "%.20x", 0x1234abcdu);
353 PRINTF_TEST(20, "000000000000edcb5433", "%.20x", -0x1234abcdu);
354 PRINTF_TEST(20, "0000000000001234ABCD", "%.20X", 0x1234abcdu);
355 PRINTF_TEST(20, "000000000000EDCB5433", "%.20X", -0x1234abcdu);
356 /* Feldbreite und Präzision */
357 PRINTF_TEST(20, " Hallo", "%20.5s", "Hallo heimur");
358 PRINTF_TEST(20, " 01024", "%20.5d", 1024);
359 PRINTF_TEST(20, " -01024", "%20.5d", -1024);
360 PRINTF_TEST(20, " 01024", "%20.5i", 1024);
361 PRINTF_TEST(20, " -01024", "%20.5i", -1024);
362 PRINTF_TEST(20, " 01024", "%20.5u", 1024u);
363 PRINTF_TEST(20, " 4294966272", "%20.5u", -1024u);
364 PRINTF_TEST(20, " 00777", "%20.5o", 0777u);
365 PRINTF_TEST(20, " 37777777001", "%20.5o", -0777u);
366 PRINTF_TEST(20, " 1234abcd", "%20.5x", 0x1234abcdu);
367 PRINTF_TEST(20, " 00edcb5433", "%20.10x", -0x1234abcdu);
368 PRINTF_TEST(20, " 1234ABCD", "%20.5X", 0x1234abcdu);
369 PRINTF_TEST(20, " 00EDCB5433", "%20.10X", -0x1234abcdu);
370 /* Präzision: 0 wird ignoriert */
371 PRINTF_TEST(20, " Hallo", "%020.5s", "Hallo heimur");
372 PRINTF_TEST(20, " 01024", "%020.5d", 1024);
373 PRINTF_TEST(20, " -01024", "%020.5d", -1024);
374 PRINTF_TEST(20, " 01024", "%020.5i", 1024);
375 PRINTF_TEST(20, " -01024", "%020.5i", -1024);
376 PRINTF_TEST(20, " 01024", "%020.5u", 1024u);
377 PRINTF_TEST(20, " 4294966272", "%020.5u", -1024u);
378 PRINTF_TEST(20, " 00777", "%020.5o", 0777u);
379 PRINTF_TEST(20, " 37777777001", "%020.5o", -0777u);
380 PRINTF_TEST(20, " 1234abcd", "%020.5x", 0x1234abcdu);
381 PRINTF_TEST(20, " 00edcb5433", "%020.10x", -0x1234abcdu);
382 PRINTF_TEST(20, " 1234ABCD", "%020.5X", 0x1234abcdu);
383 PRINTF_TEST(20, " 00EDCB5433", "%020.10X", -0x1234abcdu);
385 PRINTF_TEST(0, "", "%.0s", "Hallo heimur");
386 PRINTF_TEST(20, " ", "%20.0s", "Hallo heimur");
387 PRINTF_TEST(0, "", "%.s", "Hallo heimur");
388 PRINTF_TEST(20, " ", "%20.s", "Hallo heimur");
389 PRINTF_TEST(20, " 1024", "%20.0d", 1024);
390 PRINTF_TEST(20, " -1024", "%20.d", -1024);
391 PRINTF_TEST(20, " ", "%20.d", 0);
392 PRINTF_TEST(20, " 1024", "%20.0i", 1024);
393 PRINTF_TEST(20, " -1024", "%20.i", -1024);
394 PRINTF_TEST(20, " ", "%20.i", 0);
395 PRINTF_TEST(20, " 1024", "%20.u", 1024u);
396 PRINTF_TEST(20, " 4294966272", "%20.0u", -1024u);
397 PRINTF_TEST(20, " ", "%20.u", 0u);
398 PRINTF_TEST(20, " 777", "%20.o", 0777u);
399 PRINTF_TEST(20, " 37777777001", "%20.0o", -0777u);
400 PRINTF_TEST(20, " ", "%20.o", 0u);
401 PRINTF_TEST(20, " 1234abcd", "%20.x", 0x1234abcdu);
402 PRINTF_TEST(20, " edcb5433", "%20.0x", -0x1234abcdu);
403 PRINTF_TEST(20, " ", "%20.x", 0u);
404 PRINTF_TEST(20, " 1234ABCD", "%20.X", 0x1234abcdu);
405 PRINTF_TEST(20, " EDCB5433", "%20.0X", -0x1234abcdu);
406 PRINTF_TEST(20, " ", "%20.X", 0u);
407 /* Negative Präzision wird ignoriert */
408 /* XXX glibc tut nicht, was ich erwartet habe, vorerst deaktiviert... */
410 * Präzision und Feldbreite aus Parameter.
411 * + hat Vorrang vor <space>, - hat Vorrang vor 0 (das eh ignoriert wird,
412 * weil eine Präzision angegeben ist)
414 PRINTF_TEST(20, "Hallo ", "% -0+*.*s", 20, 5, "Hallo heimur");
415 PRINTF_TEST(20, "+01024 ", "% -0+*.*d", 20, 5, 1024);
416 PRINTF_TEST(20, "-01024 ", "% -0+*.*d", 20, 5, -1024);
417 PRINTF_TEST(20, "+01024 ", "% -0+*.*i", 20, 5, 1024);
418 PRINTF_TEST(20, "-01024 ", "% 0-+*.*i", 20, 5, -1024);
419 PRINTF_TEST(20, "01024 ", "% 0-+*.*u", 20, 5, 1024u);
420 PRINTF_TEST(20, "4294966272 ", "% 0-+*.*u", 20, 5, -1024u);
421 PRINTF_TEST(20, "00777 ", "%+ -0*.*o", 20, 5, 0777u);
422 PRINTF_TEST(20, "37777777001 ", "%+ -0*.*o", 20, 5, -0777u);
423 PRINTF_TEST(20, "1234abcd ", "%+ -0*.*x", 20, 5, 0x1234abcdu);
424 PRINTF_TEST(20, "00edcb5433 ", "%+ -0*.*x", 20, 10, -0x1234abcdu);
425 PRINTF_TEST(20, "1234ABCD ", "% -+0*.*X", 20, 5, 0x1234abcdu);
426 PRINTF_TEST(20, "00EDCB5433 ", "% -+0*.*X", 20, 10, -0x1234abcdu);
428 /******************************************************************************/