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 );
128 /* PDCLIB-20: Verify "unusual" combinations of length and signedness */
129 PRINTF_TEST( 1, "1", "%tu", (ptrdiff_t) 1); // unsigned prtdiff_t
130 PRINTF_TEST( 2, "-1", "%jd", (intmax_t) -1); // intmax_t
131 PRINTF_TEST( 1, "1", "%ju", (uintmax_t) 1); // uintmax_t
132 PRINTF_TEST( 1, "1", "%zd", (size_t) 1); // signed size_t
134 #ifndef TEST_CONVERSION_ONLY
135 /******************************************************************************
136 * NOTE: The following test cases are imported from the Tyndur project. They *
137 * are therefore under the license of said project, not CC0. *
138 * As said code comprises test cases, it does not form part of the *
139 * final compiled library, and has no bearing on its licensing. *
141 * See bug PDCLIB-6 for full details *
142 ******************************************************************************/
144 * Copyright (c) 2011 The tyndur Project. All rights reserved.
146 * This code is derived from software contributed to the tyndur Project
149 * Redistribution and use in source and binary forms, with or without
150 * modification, are permitted provided that the following conditions
152 * 1. Redistributions of source code must retain the above copyright
153 * notice, this list of conditions and the following disclaimer.
154 * 2. Redistributions in binary form must reproduce the above copyright
155 * notice, this list of conditions and the following disclaimer in the
156 * documentation and/or other materials provided with the distribution.
158 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
159 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
160 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
161 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
162 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
163 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
164 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
165 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
166 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
167 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
168 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
171 /* Ein String ohne alles */
172 PRINTF_TEST(12, "Hallo heimur", "Hallo heimur");
173 /* Einfache Konvertierungen */
174 PRINTF_TEST(12, "Hallo heimur", "%s", "Hallo heimur");
175 PRINTF_TEST(4, "1024", "%d", 1024);
176 PRINTF_TEST(5, "-1024", "%d", -1024);
177 PRINTF_TEST(4, "1024", "%i", 1024);
178 PRINTF_TEST(5, "-1024", "%i", -1024);
179 PRINTF_TEST(4, "1024", "%u", 1024u);
180 PRINTF_TEST(10, "4294966272", "%u", -1024u);
181 PRINTF_TEST(3, "777", "%o", 0777u);
182 PRINTF_TEST(11, "37777777001", "%o", -0777u);
183 PRINTF_TEST(8, "1234abcd", "%x", 0x1234abcdu);
184 PRINTF_TEST(8, "edcb5433", "%x", -0x1234abcdu);
185 PRINTF_TEST(8, "1234ABCD", "%X", 0x1234abcdu);
186 PRINTF_TEST(8, "EDCB5433", "%X", -0x1234abcdu);
187 PRINTF_TEST(1, "x", "%c", 'x');
188 PRINTF_TEST(1, "%", "%%");
189 /* Mit %c kann man auch Nullbytes ausgeben */
190 PRINTF_TEST(1, "\0", "%c", '\0');
191 /* Vorzeichen erzwingen (Flag +) */
192 PRINTF_TEST(12, "Hallo heimur", "%+s", "Hallo heimur");
193 PRINTF_TEST(5, "+1024", "%+d", 1024);
194 PRINTF_TEST(5, "-1024", "%+d", -1024);
195 PRINTF_TEST(5, "+1024", "%+i", 1024);
196 PRINTF_TEST(5, "-1024", "%+i", -1024);
197 PRINTF_TEST(4, "1024", "%+u", 1024u);
198 PRINTF_TEST(10, "4294966272", "%+u", -1024u);
199 PRINTF_TEST(3, "777", "%+o", 0777u);
200 PRINTF_TEST(11, "37777777001", "%+o", -0777u);
201 PRINTF_TEST(8, "1234abcd", "%+x", 0x1234abcdu);
202 PRINTF_TEST(8, "edcb5433", "%+x", -0x1234abcdu);
203 PRINTF_TEST(8, "1234ABCD", "%+X", 0x1234abcdu);
204 PRINTF_TEST(8, "EDCB5433", "%+X", -0x1234abcdu);
205 PRINTF_TEST(1, "x", "%+c", 'x');
206 /* Vorzeichenplatzhalter erzwingen (Flag <space>) */
207 PRINTF_TEST(12, "Hallo heimur", "% s", "Hallo heimur");
208 PRINTF_TEST(5, " 1024", "% d", 1024);
209 PRINTF_TEST(5, "-1024", "% d", -1024);
210 PRINTF_TEST(5, " 1024", "% i", 1024);
211 PRINTF_TEST(5, "-1024", "% i", -1024);
212 PRINTF_TEST(4, "1024", "% u", 1024u);
213 PRINTF_TEST(10, "4294966272", "% u", -1024u);
214 PRINTF_TEST(3, "777", "% o", 0777u);
215 PRINTF_TEST(11, "37777777001", "% o", -0777u);
216 PRINTF_TEST(8, "1234abcd", "% x", 0x1234abcdu);
217 PRINTF_TEST(8, "edcb5433", "% x", -0x1234abcdu);
218 PRINTF_TEST(8, "1234ABCD", "% X", 0x1234abcdu);
219 PRINTF_TEST(8, "EDCB5433", "% X", -0x1234abcdu);
220 PRINTF_TEST(1, "x", "% c", 'x');
221 /* Flag + hat Vorrang über <space> */
222 PRINTF_TEST(12, "Hallo heimur", "%+ s", "Hallo heimur");
223 PRINTF_TEST(5, "+1024", "%+ d", 1024);
224 PRINTF_TEST(5, "-1024", "%+ d", -1024);
225 PRINTF_TEST(5, "+1024", "%+ i", 1024);
226 PRINTF_TEST(5, "-1024", "%+ i", -1024);
227 PRINTF_TEST(4, "1024", "%+ u", 1024u);
228 PRINTF_TEST(10, "4294966272", "%+ u", -1024u);
229 PRINTF_TEST(3, "777", "%+ o", 0777u);
230 PRINTF_TEST(11, "37777777001", "%+ o", -0777u);
231 PRINTF_TEST(8, "1234abcd", "%+ x", 0x1234abcdu);
232 PRINTF_TEST(8, "edcb5433", "%+ x", -0x1234abcdu);
233 PRINTF_TEST(8, "1234ABCD", "%+ X", 0x1234abcdu);
234 PRINTF_TEST(8, "EDCB5433", "%+ X", -0x1234abcdu);
235 PRINTF_TEST(1, "x", "%+ c", 'x');
236 /* Alternative Form */
237 PRINTF_TEST(4, "0777", "%#o", 0777u);
238 PRINTF_TEST(12, "037777777001", "%#o", -0777u);
239 PRINTF_TEST(10, "0x1234abcd", "%#x", 0x1234abcdu);
240 PRINTF_TEST(10, "0xedcb5433", "%#x", -0x1234abcdu);
241 PRINTF_TEST(10, "0X1234ABCD", "%#X", 0x1234abcdu);
242 PRINTF_TEST(10, "0XEDCB5433", "%#X", -0x1234abcdu);
243 PRINTF_TEST(1, "0", "%#o", 0u);
244 PRINTF_TEST(1, "0", "%#x", 0u);
245 PRINTF_TEST(1, "0", "%#X", 0u);
246 /* Feldbreite: Kleiner als Ausgabe */
247 PRINTF_TEST(12, "Hallo heimur", "%1s", "Hallo heimur");
248 PRINTF_TEST(4, "1024", "%1d", 1024);
249 PRINTF_TEST(5, "-1024", "%1d", -1024);
250 PRINTF_TEST(4, "1024", "%1i", 1024);
251 PRINTF_TEST(5, "-1024", "%1i", -1024);
252 PRINTF_TEST(4, "1024", "%1u", 1024u);
253 PRINTF_TEST(10, "4294966272", "%1u", -1024u);
254 PRINTF_TEST(3, "777", "%1o", 0777u);
255 PRINTF_TEST(11, "37777777001", "%1o", -0777u);
256 PRINTF_TEST(8, "1234abcd", "%1x", 0x1234abcdu);
257 PRINTF_TEST(8, "edcb5433", "%1x", -0x1234abcdu);
258 PRINTF_TEST(8, "1234ABCD", "%1X", 0x1234abcdu);
259 PRINTF_TEST(8, "EDCB5433", "%1X", -0x1234abcdu);
260 PRINTF_TEST(1, "x", "%1c", 'x');
261 /* Feldbreite: Größer als Ausgabe */
262 PRINTF_TEST(20, " Hallo", "%20s", "Hallo");
263 PRINTF_TEST(20, " 1024", "%20d", 1024);
264 PRINTF_TEST(20, " -1024", "%20d", -1024);
265 PRINTF_TEST(20, " 1024", "%20i", 1024);
266 PRINTF_TEST(20, " -1024", "%20i", -1024);
267 PRINTF_TEST(20, " 1024", "%20u", 1024u);
268 PRINTF_TEST(20, " 4294966272", "%20u", -1024u);
269 PRINTF_TEST(20, " 777", "%20o", 0777u);
270 PRINTF_TEST(20, " 37777777001", "%20o", -0777u);
271 PRINTF_TEST(20, " 1234abcd", "%20x", 0x1234abcdu);
272 PRINTF_TEST(20, " edcb5433", "%20x", -0x1234abcdu);
273 PRINTF_TEST(20, " 1234ABCD", "%20X", 0x1234abcdu);
274 PRINTF_TEST(20, " EDCB5433", "%20X", -0x1234abcdu);
275 PRINTF_TEST(20, " x", "%20c", 'x');
276 /* Feldbreite: Linksbündig */
277 PRINTF_TEST(20, "Hallo ", "%-20s", "Hallo");
278 PRINTF_TEST(20, "1024 ", "%-20d", 1024);
279 PRINTF_TEST(20, "-1024 ", "%-20d", -1024);
280 PRINTF_TEST(20, "1024 ", "%-20i", 1024);
281 PRINTF_TEST(20, "-1024 ", "%-20i", -1024);
282 PRINTF_TEST(20, "1024 ", "%-20u", 1024u);
283 PRINTF_TEST(20, "4294966272 ", "%-20u", -1024u);
284 PRINTF_TEST(20, "777 ", "%-20o", 0777u);
285 PRINTF_TEST(20, "37777777001 ", "%-20o", -0777u);
286 PRINTF_TEST(20, "1234abcd ", "%-20x", 0x1234abcdu);
287 PRINTF_TEST(20, "edcb5433 ", "%-20x", -0x1234abcdu);
288 PRINTF_TEST(20, "1234ABCD ", "%-20X", 0x1234abcdu);
289 PRINTF_TEST(20, "EDCB5433 ", "%-20X", -0x1234abcdu);
290 PRINTF_TEST(20, "x ", "%-20c", 'x');
291 /* Feldbreite: Padding mit 0 */
292 PRINTF_TEST(20, "00000000000000001024", "%020d", 1024);
293 PRINTF_TEST(20, "-0000000000000001024", "%020d", -1024);
294 PRINTF_TEST(20, "00000000000000001024", "%020i", 1024);
295 PRINTF_TEST(20, "-0000000000000001024", "%020i", -1024);
296 PRINTF_TEST(20, "00000000000000001024", "%020u", 1024u);
297 PRINTF_TEST(20, "00000000004294966272", "%020u", -1024u);
298 PRINTF_TEST(20, "00000000000000000777", "%020o", 0777u);
299 PRINTF_TEST(20, "00000000037777777001", "%020o", -0777u);
300 PRINTF_TEST(20, "0000000000001234abcd", "%020x", 0x1234abcdu);
301 PRINTF_TEST(20, "000000000000edcb5433", "%020x", -0x1234abcdu);
302 PRINTF_TEST(20, "0000000000001234ABCD", "%020X", 0x1234abcdu);
303 PRINTF_TEST(20, "000000000000EDCB5433", "%020X", -0x1234abcdu);
304 /* Feldbreite: Padding und alternative Form */
305 PRINTF_TEST(20, " 0777", "%#20o", 0777u);
306 PRINTF_TEST(20, " 037777777001", "%#20o", -0777u);
307 PRINTF_TEST(20, " 0x1234abcd", "%#20x", 0x1234abcdu);
308 PRINTF_TEST(20, " 0xedcb5433", "%#20x", -0x1234abcdu);
309 PRINTF_TEST(20, " 0X1234ABCD", "%#20X", 0x1234abcdu);
310 PRINTF_TEST(20, " 0XEDCB5433", "%#20X", -0x1234abcdu);
311 PRINTF_TEST(20, "00000000000000000777", "%#020o", 0777u);
312 PRINTF_TEST(20, "00000000037777777001", "%#020o", -0777u);
313 PRINTF_TEST(20, "0x00000000001234abcd", "%#020x", 0x1234abcdu);
314 PRINTF_TEST(20, "0x0000000000edcb5433", "%#020x", -0x1234abcdu);
315 PRINTF_TEST(20, "0X00000000001234ABCD", "%#020X", 0x1234abcdu);
316 PRINTF_TEST(20, "0X0000000000EDCB5433", "%#020X", -0x1234abcdu);
317 /* Feldbreite: - hat Vorrang vor 0 */
318 PRINTF_TEST(20, "Hallo ", "%0-20s", "Hallo");
319 PRINTF_TEST(20, "1024 ", "%0-20d", 1024);
320 PRINTF_TEST(20, "-1024 ", "%0-20d", -1024);
321 PRINTF_TEST(20, "1024 ", "%0-20i", 1024);
322 PRINTF_TEST(20, "-1024 ", "%0-20i", -1024);
323 PRINTF_TEST(20, "1024 ", "%0-20u", 1024u);
324 PRINTF_TEST(20, "4294966272 ", "%0-20u", -1024u);
325 PRINTF_TEST(20, "777 ", "%-020o", 0777u);
326 PRINTF_TEST(20, "37777777001 ", "%-020o", -0777u);
327 PRINTF_TEST(20, "1234abcd ", "%-020x", 0x1234abcdu);
328 PRINTF_TEST(20, "edcb5433 ", "%-020x", -0x1234abcdu);
329 PRINTF_TEST(20, "1234ABCD ", "%-020X", 0x1234abcdu);
330 PRINTF_TEST(20, "EDCB5433 ", "%-020X", -0x1234abcdu);
331 PRINTF_TEST(20, "x ", "%-020c", 'x');
332 /* Feldbreite: Aus Parameter */
333 PRINTF_TEST(20, " Hallo", "%*s", 20, "Hallo");
334 PRINTF_TEST(20, " 1024", "%*d", 20, 1024);
335 PRINTF_TEST(20, " -1024", "%*d", 20, -1024);
336 PRINTF_TEST(20, " 1024", "%*i", 20, 1024);
337 PRINTF_TEST(20, " -1024", "%*i", 20, -1024);
338 PRINTF_TEST(20, " 1024", "%*u", 20, 1024u);
339 PRINTF_TEST(20, " 4294966272", "%*u", 20, -1024u);
340 PRINTF_TEST(20, " 777", "%*o", 20, 0777u);
341 PRINTF_TEST(20, " 37777777001", "%*o", 20, -0777u);
342 PRINTF_TEST(20, " 1234abcd", "%*x", 20, 0x1234abcdu);
343 PRINTF_TEST(20, " edcb5433", "%*x", 20, -0x1234abcdu);
344 PRINTF_TEST(20, " 1234ABCD", "%*X", 20, 0x1234abcdu);
345 PRINTF_TEST(20, " EDCB5433", "%*X", 20, -0x1234abcdu);
346 PRINTF_TEST(20, " x", "%*c", 20, 'x');
347 /* Präzision / Mindestanzahl von Ziffern */
348 PRINTF_TEST(12, "Hallo heimur", "%.20s", "Hallo heimur");
349 PRINTF_TEST(20, "00000000000000001024", "%.20d", 1024);
350 PRINTF_TEST(21, "-00000000000000001024", "%.20d", -1024);
351 PRINTF_TEST(20, "00000000000000001024", "%.20i", 1024);
352 PRINTF_TEST(21, "-00000000000000001024", "%.20i", -1024);
353 PRINTF_TEST(20, "00000000000000001024", "%.20u", 1024u);
354 PRINTF_TEST(20, "00000000004294966272", "%.20u", -1024u);
355 PRINTF_TEST(20, "00000000000000000777", "%.20o", 0777u);
356 PRINTF_TEST(20, "00000000037777777001", "%.20o", -0777u);
357 PRINTF_TEST(20, "0000000000001234abcd", "%.20x", 0x1234abcdu);
358 PRINTF_TEST(20, "000000000000edcb5433", "%.20x", -0x1234abcdu);
359 PRINTF_TEST(20, "0000000000001234ABCD", "%.20X", 0x1234abcdu);
360 PRINTF_TEST(20, "000000000000EDCB5433", "%.20X", -0x1234abcdu);
361 /* Feldbreite und Präzision */
362 PRINTF_TEST(20, " Hallo", "%20.5s", "Hallo heimur");
363 PRINTF_TEST(20, " 01024", "%20.5d", 1024);
364 PRINTF_TEST(20, " -01024", "%20.5d", -1024);
365 PRINTF_TEST(20, " 01024", "%20.5i", 1024);
366 PRINTF_TEST(20, " -01024", "%20.5i", -1024);
367 PRINTF_TEST(20, " 01024", "%20.5u", 1024u);
368 PRINTF_TEST(20, " 4294966272", "%20.5u", -1024u);
369 PRINTF_TEST(20, " 00777", "%20.5o", 0777u);
370 PRINTF_TEST(20, " 37777777001", "%20.5o", -0777u);
371 PRINTF_TEST(20, " 1234abcd", "%20.5x", 0x1234abcdu);
372 PRINTF_TEST(20, " 00edcb5433", "%20.10x", -0x1234abcdu);
373 PRINTF_TEST(20, " 1234ABCD", "%20.5X", 0x1234abcdu);
374 PRINTF_TEST(20, " 00EDCB5433", "%20.10X", -0x1234abcdu);
375 /* Präzision: 0 wird ignoriert */
376 PRINTF_TEST(20, " Hallo", "%020.5s", "Hallo heimur");
377 PRINTF_TEST(20, " 01024", "%020.5d", 1024);
378 PRINTF_TEST(20, " -01024", "%020.5d", -1024);
379 PRINTF_TEST(20, " 01024", "%020.5i", 1024);
380 PRINTF_TEST(20, " -01024", "%020.5i", -1024);
381 PRINTF_TEST(20, " 01024", "%020.5u", 1024u);
382 PRINTF_TEST(20, " 4294966272", "%020.5u", -1024u);
383 PRINTF_TEST(20, " 00777", "%020.5o", 0777u);
384 PRINTF_TEST(20, " 37777777001", "%020.5o", -0777u);
385 PRINTF_TEST(20, " 1234abcd", "%020.5x", 0x1234abcdu);
386 PRINTF_TEST(20, " 00edcb5433", "%020.10x", -0x1234abcdu);
387 PRINTF_TEST(20, " 1234ABCD", "%020.5X", 0x1234abcdu);
388 PRINTF_TEST(20, " 00EDCB5433", "%020.10X", -0x1234abcdu);
390 PRINTF_TEST(0, "", "%.0s", "Hallo heimur");
391 PRINTF_TEST(20, " ", "%20.0s", "Hallo heimur");
392 PRINTF_TEST(0, "", "%.s", "Hallo heimur");
393 PRINTF_TEST(20, " ", "%20.s", "Hallo heimur");
394 PRINTF_TEST(20, " 1024", "%20.0d", 1024);
395 PRINTF_TEST(20, " -1024", "%20.d", -1024);
396 PRINTF_TEST(20, " ", "%20.d", 0);
397 PRINTF_TEST(20, " 1024", "%20.0i", 1024);
398 PRINTF_TEST(20, " -1024", "%20.i", -1024);
399 PRINTF_TEST(20, " ", "%20.i", 0);
400 PRINTF_TEST(20, " 1024", "%20.u", 1024u);
401 PRINTF_TEST(20, " 4294966272", "%20.0u", -1024u);
402 PRINTF_TEST(20, " ", "%20.u", 0u);
403 PRINTF_TEST(20, " 777", "%20.o", 0777u);
404 PRINTF_TEST(20, " 37777777001", "%20.0o", -0777u);
405 PRINTF_TEST(20, " ", "%20.o", 0u);
406 PRINTF_TEST(20, " 1234abcd", "%20.x", 0x1234abcdu);
407 PRINTF_TEST(20, " edcb5433", "%20.0x", -0x1234abcdu);
408 PRINTF_TEST(20, " ", "%20.x", 0u);
409 PRINTF_TEST(20, " 1234ABCD", "%20.X", 0x1234abcdu);
410 PRINTF_TEST(20, " EDCB5433", "%20.0X", -0x1234abcdu);
411 PRINTF_TEST(20, " ", "%20.X", 0u);
412 /* Negative Präzision wird ignoriert */
413 /* XXX glibc tut nicht, was ich erwartet habe, vorerst deaktiviert... */
415 * Präzision und Feldbreite aus Parameter.
416 * + hat Vorrang vor <space>, - hat Vorrang vor 0 (das eh ignoriert wird,
417 * weil eine Präzision angegeben ist)
419 PRINTF_TEST(20, "Hallo ", "% -0+*.*s", 20, 5, "Hallo heimur");
420 PRINTF_TEST(20, "+01024 ", "% -0+*.*d", 20, 5, 1024);
421 PRINTF_TEST(20, "-01024 ", "% -0+*.*d", 20, 5, -1024);
422 PRINTF_TEST(20, "+01024 ", "% -0+*.*i", 20, 5, 1024);
423 PRINTF_TEST(20, "-01024 ", "% 0-+*.*i", 20, 5, -1024);
424 PRINTF_TEST(20, "01024 ", "% 0-+*.*u", 20, 5, 1024u);
425 PRINTF_TEST(20, "4294966272 ", "% 0-+*.*u", 20, 5, -1024u);
426 PRINTF_TEST(20, "00777 ", "%+ -0*.*o", 20, 5, 0777u);
427 PRINTF_TEST(20, "37777777001 ", "%+ -0*.*o", 20, 5, -0777u);
428 PRINTF_TEST(20, "1234abcd ", "%+ -0*.*x", 20, 5, 0x1234abcdu);
429 PRINTF_TEST(20, "00edcb5433 ", "%+ -0*.*x", 20, 10, -0x1234abcdu);
430 PRINTF_TEST(20, "1234ABCD ", "% -+0*.*X", 20, 5, 0x1234abcdu);
431 PRINTF_TEST(20, "00EDCB5433 ", "% -+0*.*X", 20, 10, -0x1234abcdu);
433 /******************************************************************************/