1 | // SPDX-License-Identifier: GPL-3.0-or-later |
2 | |
3 | #include "test_engine_impl.h" |
4 | |
5 | #include <mos_stdio.h> |
6 | |
7 | static char buffer[2048] = { 0 }; |
8 | |
9 | MOS_TEST_DEFINE_CONDITION(printf_tests_enable_posix, "POSIX exts" ) = false; |
10 | MOS_TEST_DEFINE_CONDITION(printf_tests_enable_floats, "floating points" ) = false; |
11 | MOS_TEST_DEFINE_CONDITION(printf_tests_enable_egp, "e, g, p tests" ) = false; |
12 | MOS_TEST_DEFINE_CONDITION(printf_tests_enable_oxX, "o, x, X tests" ) = true; |
13 | |
14 | #define PRINTF_TEST(expected, format, ...) \ |
15 | do \ |
16 | { \ |
17 | if (MOS_TEST_CURRENT_TEST_SKIPPED) \ |
18 | { \ |
19 | MOS_TEST_SKIP(); \ |
20 | break; \ |
21 | } \ |
22 | sprintf(buffer, format __VA_OPT__(, ) __VA_ARGS__); \ |
23 | MOS_TEST_CHECK_STRING(buffer, expected); \ |
24 | } while (0) |
25 | |
26 | MOS_TEST_CASE(percent_sign) |
27 | { |
28 | MOS_WARNING_PUSH; |
29 | MOS_WARNING_DISABLE("-Wformat" ); |
30 | MOS_WARNING_DISABLE("-Wformat-zero-length" ); |
31 | { |
32 | PRINTF_TEST("" , "" , ); |
33 | PRINTF_TEST("%" , "%%" , ); |
34 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("" , "%" , ), "format string is incomplete" ); |
35 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("incomplete " , "incomplete %" , ), "incomplete format specifier" ); |
36 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("incomplete 100" , "incomplete %d%" , 100), "incomplete format specifier" ); |
37 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("incomplete 'abcde' %" , "incomplete '%s' %%%" , "abcde" ), "incomplete format specifier" ); |
38 | } |
39 | MOS_WARNING_POP; |
40 | } |
41 | |
42 | MOS_TEST_CASE(simple_string) |
43 | { |
44 | PRINTF_TEST("a" , "a" , ); |
45 | PRINTF_TEST("very long string" , "very long string" , ); |
46 | PRINTF_TEST("d6c40101-371d-473e-8880-464eeed9541cd6c40101-371d-473e-8880-464eeed9541cd6c40101-371d-473e-8880-464eeed9541cd6c40101-371d-473e-8880" , |
47 | "d6c40101-371d-473e-8880-464eeed9541cd6c40101-371d-473e-8880-464eeed9541cd6c40101-371d-473e-8880-464eeed9541cd6c40101-371d-473e-8880" , ); |
48 | } |
49 | |
50 | MOS_TEST_CASE(integer_no_precision) |
51 | { |
52 | PRINTF_TEST("-123" , "%d" , -123); |
53 | PRINTF_TEST("0" , "%d" , 0); |
54 | PRINTF_TEST("123" , "%d" , 123); |
55 | |
56 | // With sign and space |
57 | // Negative numbers always have a sign. |
58 | PRINTF_TEST("-123" , "% d" , -123); |
59 | PRINTF_TEST("-123" , "%+d" , -123); |
60 | |
61 | // Positive numbers have a plus if a plus is specified, or a space if a space is specified. |
62 | PRINTF_TEST("+123" , "%+d" , 123); |
63 | PRINTF_TEST(" 123" , "% d" , 123); |
64 | PRINTF_TEST("-123" , "% d" , -123); |
65 | |
66 | // zero is positive !!!! |
67 | PRINTF_TEST("+0" , "%+d" , 0); |
68 | PRINTF_TEST(" 0" , "% d" , 0); |
69 | |
70 | PRINTF_TEST("-0011" , "%05i" , -11); |
71 | |
72 | // Minimum field width |
73 | PRINTF_TEST("123" , "%3d" , 123); |
74 | PRINTF_TEST(" 123" , "%5d" , 123); |
75 | PRINTF_TEST(" 123" , "%6d" , 123); |
76 | PRINTF_TEST(" 123" , "%7d" , 123); |
77 | |
78 | // Minimum field width with sign |
79 | PRINTF_TEST("+123" , "%+3d" , 123); |
80 | PRINTF_TEST(" +123" , "%+5d" , 123); |
81 | PRINTF_TEST(" +123" , "%+6d" , 123); |
82 | PRINTF_TEST(" +123" , "%+7d" , 123); |
83 | |
84 | PRINTF_TEST("-123" , "%3d" , -123); |
85 | PRINTF_TEST("-123" , "%4d" , -123); |
86 | PRINTF_TEST(" -123" , "%5d" , -123); |
87 | PRINTF_TEST(" -123" , "%6d" , -123); |
88 | PRINTF_TEST(" -123" , "%7d" , -123); |
89 | |
90 | // Minimum field width with zero padding |
91 | PRINTF_TEST("123" , "%03d" , 123); |
92 | PRINTF_TEST("00123" , "%05d" , 123); |
93 | PRINTF_TEST("000123" , "%06d" , 123); |
94 | PRINTF_TEST("0000123" , "%07d" , 123); |
95 | |
96 | // Minimum field width with zero padding and sign |
97 | PRINTF_TEST("+123" , "%+03d" , 123); |
98 | PRINTF_TEST("+0123" , "%+05d" , 123); |
99 | PRINTF_TEST("+00123" , "%+06d" , 123); |
100 | PRINTF_TEST("+000123" , "%+07d" , 123); |
101 | |
102 | // Minimum field width with zero padding and sign |
103 | PRINTF_TEST("-123" , "%03d" , -123); |
104 | PRINTF_TEST("-0123" , "%05d" , -123); |
105 | PRINTF_TEST("-00123" , "%06d" , -123); |
106 | PRINTF_TEST("-000123" , "%07d" , -123); |
107 | } |
108 | |
109 | MOS_TEST_CASE(integer_with_precision) |
110 | { |
111 | PRINTF_TEST("-00011" , "%.5i" , -11); |
112 | |
113 | // Precision |
114 | PRINTF_TEST("123" , "%.0d" , 123); |
115 | PRINTF_TEST("123" , "%.1d" , 123); |
116 | PRINTF_TEST("123" , "%.2d" , 123); |
117 | PRINTF_TEST("123" , "%.3d" , 123); |
118 | PRINTF_TEST("0123" , "%.4d" , 123); |
119 | PRINTF_TEST("00123" , "%.5d" , 123); |
120 | PRINTF_TEST("000123" , "%.6d" , 123); |
121 | PRINTF_TEST("0000123" , "%.7d" , 123); |
122 | PRINTF_TEST("00000123" , "%.8d" , 123); |
123 | |
124 | // Precision with sign |
125 | PRINTF_TEST("+123" , "%+.0d" , 123); |
126 | PRINTF_TEST("+123" , "%+.1d" , 123); |
127 | PRINTF_TEST("+123" , "%+.2d" , 123); |
128 | PRINTF_TEST("+123" , "%+.3d" , 123); |
129 | PRINTF_TEST("+0123" , "%+.4d" , 123); |
130 | PRINTF_TEST("+00123" , "%+.5d" , 123); |
131 | PRINTF_TEST("+000123" , "%+.6d" , 123); |
132 | PRINTF_TEST("+0000123" , "%+.7d" , 123); |
133 | PRINTF_TEST("+00000123" , "%+.8d" , 123); |
134 | |
135 | // ! "If a precision is given with a numeric conversion (d, i, o, u, x, and X), the 0 flag is ignored." |
136 | MOS_WARNING_PUSH |
137 | MOS_WARNING_DISABLE("-Wformat" ); |
138 | { |
139 | // Precision with zero padding |
140 | PRINTF_TEST("123" , "%0.0d" , 123); |
141 | PRINTF_TEST("123" , "%0.1d" , 123); |
142 | PRINTF_TEST("123" , "%0.2d" , 123); |
143 | PRINTF_TEST("123" , "%0.3d" , 123); |
144 | PRINTF_TEST("0123" , "%0.4d" , 123); |
145 | PRINTF_TEST("00123" , "%0.5d" , 123); |
146 | PRINTF_TEST("000123" , "%0.6d" , 123); |
147 | PRINTF_TEST("0000123" , "%0.7d" , 123); |
148 | PRINTF_TEST("00000123" , "%0.8d" , 123); |
149 | |
150 | // Precision with zero padding and sign |
151 | PRINTF_TEST("+123" , "%0+.0d" , 123); |
152 | PRINTF_TEST("+123" , "%0+.1d" , 123); |
153 | PRINTF_TEST("+123" , "%0+.2d" , 123); |
154 | PRINTF_TEST("+123" , "%0+.3d" , 123); |
155 | PRINTF_TEST("+0123" , "%0+.4d" , 123); |
156 | PRINTF_TEST("+00123" , "%0+.5d" , 123); |
157 | PRINTF_TEST("+000123" , "%0+.6d" , 123); |
158 | PRINTF_TEST("+0000123" , "%0+.7d" , 123); |
159 | PRINTF_TEST("+00000123" , "%0+.8d" , 123); |
160 | |
161 | PRINTF_TEST("+123" , "%+0.0d" , 123); |
162 | PRINTF_TEST("+123" , "%+0.1d" , 123); |
163 | PRINTF_TEST("+123" , "%+0.2d" , 123); |
164 | PRINTF_TEST("+123" , "%+0.3d" , 123); |
165 | PRINTF_TEST("+0123" , "%+0.4d" , 123); |
166 | PRINTF_TEST("+00123" , "%+0.5d" , 123); |
167 | PRINTF_TEST("+000123" , "%+0.6d" , 123); |
168 | PRINTF_TEST("+0000123" , "%+0.7d" , 123); |
169 | PRINTF_TEST("+00000123" , "%+0.8d" , 123); |
170 | } |
171 | MOS_WARNING_POP |
172 | |
173 | // Precision with space (sign placeholder) |
174 | PRINTF_TEST(" 123" , "% .0d" , 123); |
175 | PRINTF_TEST(" 123" , "% .1d" , 123); |
176 | PRINTF_TEST(" 123" , "% .2d" , 123); |
177 | PRINTF_TEST(" 123" , "% .3d" , 123); |
178 | PRINTF_TEST(" 0123" , "% .4d" , 123); |
179 | PRINTF_TEST(" 00123" , "% .5d" , 123); |
180 | PRINTF_TEST(" 000123" , "% .6d" , 123); |
181 | PRINTF_TEST(" 0000123" , "% .7d" , 123); |
182 | PRINTF_TEST(" 00000123" , "% .8d" , 123); |
183 | |
184 | // Precision with width |
185 | PRINTF_TEST("123" , "%1.0d" , 123); |
186 | PRINTF_TEST("123" , "%1.1d" , 123); |
187 | PRINTF_TEST("123" , "%1.2d" , 123); |
188 | PRINTF_TEST("123" , "%1.3d" , 123); |
189 | PRINTF_TEST("0123" , "%1.4d" , 123); |
190 | PRINTF_TEST("00123" , "%1.5d" , 123); |
191 | PRINTF_TEST("000123" , "%1.6d" , 123); |
192 | PRINTF_TEST("0000123" , "%1.7d" , 123); |
193 | PRINTF_TEST("00000123" , "%1.8d" , 123); |
194 | |
195 | PRINTF_TEST("123" , "%2.0d" , 123); |
196 | PRINTF_TEST("123" , "%2.1d" , 123); |
197 | PRINTF_TEST("123" , "%2.2d" , 123); |
198 | PRINTF_TEST("123" , "%2.3d" , 123); |
199 | PRINTF_TEST("0123" , "%2.4d" , 123); |
200 | PRINTF_TEST("00123" , "%2.5d" , 123); |
201 | PRINTF_TEST("000123" , "%2.6d" , 123); |
202 | PRINTF_TEST("0000123" , "%2.7d" , 123); |
203 | PRINTF_TEST("00000123" , "%2.8d" , 123); |
204 | |
205 | PRINTF_TEST("123" , "%3.0d" , 123); |
206 | PRINTF_TEST("123" , "%3.1d" , 123); |
207 | PRINTF_TEST("123" , "%3.2d" , 123); |
208 | PRINTF_TEST("123" , "%3.3d" , 123); |
209 | PRINTF_TEST("0123" , "%3.4d" , 123); |
210 | PRINTF_TEST("00123" , "%3.5d" , 123); |
211 | PRINTF_TEST("000123" , "%3.6d" , 123); |
212 | PRINTF_TEST("0000123" , "%3.7d" , 123); |
213 | PRINTF_TEST("00000123" , "%3.8d" , 123); |
214 | |
215 | PRINTF_TEST(" 123" , "%4.0d" , 123); |
216 | PRINTF_TEST(" 123" , "%4.1d" , 123); |
217 | PRINTF_TEST(" 123" , "%4.2d" , 123); |
218 | PRINTF_TEST(" 123" , "%4.3d" , 123); |
219 | PRINTF_TEST("0123" , "%4.4d" , 123); |
220 | PRINTF_TEST("00123" , "%4.5d" , 123); |
221 | PRINTF_TEST("000123" , "%4.6d" , 123); |
222 | PRINTF_TEST("0000123" , "%4.7d" , 123); |
223 | PRINTF_TEST("00000123" , "%4.8d" , 123); |
224 | |
225 | PRINTF_TEST(" 123" , "%5.0d" , 123); |
226 | PRINTF_TEST(" 123" , "%5.1d" , 123); |
227 | PRINTF_TEST(" 123" , "%5.2d" , 123); |
228 | PRINTF_TEST(" 123" , "%5.3d" , 123); |
229 | PRINTF_TEST(" 0123" , "%5.4d" , 123); |
230 | PRINTF_TEST("00123" , "%5.5d" , 123); |
231 | PRINTF_TEST("000123" , "%5.6d" , 123); |
232 | PRINTF_TEST("0000123" , "%5.7d" , 123); |
233 | PRINTF_TEST("00000123" , "%5.8d" , 123); |
234 | |
235 | PRINTF_TEST(" 123" , "%6.0d" , 123); |
236 | PRINTF_TEST(" 123" , "%6.1d" , 123); |
237 | PRINTF_TEST(" 123" , "%6.2d" , 123); |
238 | PRINTF_TEST(" 123" , "%6.3d" , 123); |
239 | PRINTF_TEST(" 0123" , "%6.4d" , 123); |
240 | PRINTF_TEST(" 00123" , "%6.5d" , 123); |
241 | PRINTF_TEST("000123" , "%6.6d" , 123); |
242 | PRINTF_TEST("0000123" , "%6.7d" , 123); |
243 | PRINTF_TEST("00000123" , "%6.8d" , 123); |
244 | |
245 | PRINTF_TEST(" 123" , "%7.0d" , 123); |
246 | PRINTF_TEST(" 123" , "%7.1d" , 123); |
247 | PRINTF_TEST(" 123" , "%7.2d" , 123); |
248 | PRINTF_TEST(" 123" , "%7.3d" , 123); |
249 | PRINTF_TEST(" 0123" , "%7.4d" , 123); |
250 | PRINTF_TEST(" 00123" , "%7.5d" , 123); |
251 | PRINTF_TEST(" 000123" , "%7.6d" , 123); |
252 | PRINTF_TEST("0000123" , "%7.7d" , 123); |
253 | PRINTF_TEST("00000123" , "%7.8d" , 123); |
254 | } |
255 | |
256 | MOS_TEST_CASE(integer_left_justified) |
257 | { |
258 | MOS_WARNING_PUSH |
259 | MOS_WARNING_DISABLE("-Wformat" ) |
260 | { |
261 | // Left-justified with zero padding (ignored, warning expected) |
262 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("123" , "%0-d" , 123), "expected a warning about zero-padding" ); |
263 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("-123" , "%0-d" , -123), "expected a warning about zero-padding" ); |
264 | } |
265 | MOS_WARNING_POP |
266 | |
267 | // Left-justified with sign |
268 | PRINTF_TEST("+123" , "%+-d" , 123); |
269 | |
270 | // Left-justified with space (sign placeholder) |
271 | PRINTF_TEST(" 123" , "% -d" , 123); |
272 | |
273 | // Left-justified with width |
274 | PRINTF_TEST("123" , "%-1d" , 123); |
275 | PRINTF_TEST("123" , "%-2d" , 123); |
276 | PRINTF_TEST("123" , "%-3d" , 123); |
277 | PRINTF_TEST("123 " , "%-4d" , 123); |
278 | PRINTF_TEST("123 " , "%-5d" , 123); |
279 | PRINTF_TEST("123 " , "%-6d" , 123); |
280 | PRINTF_TEST("123 " , "%-7d" , 123); |
281 | |
282 | // Left-justified with width and sign |
283 | PRINTF_TEST("+123" , "%-+1d" , 123); |
284 | PRINTF_TEST("+123" , "%-+2d" , 123); |
285 | PRINTF_TEST("+123" , "%-+3d" , 123); |
286 | PRINTF_TEST("+123" , "%-+4d" , 123); |
287 | PRINTF_TEST("+123 " , "%-+5d" , 123); |
288 | PRINTF_TEST("+123 " , "%-+6d" , 123); |
289 | PRINTF_TEST("+123 " , "%-+7d" , 123); |
290 | PRINTF_TEST("+123 " , "%-+8d" , 123); |
291 | |
292 | // Left-justified with width and space (sign placeholder) |
293 | PRINTF_TEST(" 123" , "% -1d" , 123); |
294 | PRINTF_TEST(" 123" , "% -2d" , 123); |
295 | PRINTF_TEST(" 123" , "% -3d" , 123); |
296 | PRINTF_TEST(" 123" , "% -4d" , 123); |
297 | PRINTF_TEST(" 123 " , "% -5d" , 123); |
298 | PRINTF_TEST(" 123 " , "% -6d" , 123); |
299 | PRINTF_TEST(" 123 " , "% -7d" , 123); |
300 | PRINTF_TEST(" 123 " , "% -8d" , 123); |
301 | |
302 | // Left-justified with precision |
303 | PRINTF_TEST("123" , "%-.0d" , 123); |
304 | PRINTF_TEST("123" , "%-.1d" , 123); |
305 | PRINTF_TEST("123" , "%-.2d" , 123); |
306 | PRINTF_TEST("123" , "%-.3d" , 123); |
307 | PRINTF_TEST("0123" , "%-.4d" , 123); |
308 | PRINTF_TEST("00123" , "%-.5d" , 123); |
309 | PRINTF_TEST("000123" , "%-.6d" , 123); |
310 | PRINTF_TEST("0000123" , "%-.7d" , 123); |
311 | PRINTF_TEST("00000123" , "%-.8d" , 123); |
312 | |
313 | // Left-justified with precision and width |
314 | PRINTF_TEST("123" , "%-1.0d" , 123); |
315 | PRINTF_TEST("123" , "%-1.1d" , 123); |
316 | PRINTF_TEST("123" , "%-1.2d" , 123); |
317 | PRINTF_TEST("123" , "%-1.3d" , 123); |
318 | PRINTF_TEST("0123" , "%-1.4d" , 123); |
319 | PRINTF_TEST("00123" , "%-1.5d" , 123); |
320 | PRINTF_TEST("000123" , "%-1.6d" , 123); |
321 | PRINTF_TEST("0000123" , "%-1.7d" , 123); |
322 | PRINTF_TEST("00000123" , "%-1.8d" , 123); |
323 | |
324 | PRINTF_TEST("123" , "%-2.0d" , 123); |
325 | PRINTF_TEST("123" , "%-2.1d" , 123); |
326 | PRINTF_TEST("123" , "%-2.2d" , 123); |
327 | PRINTF_TEST("123" , "%-2.3d" , 123); |
328 | PRINTF_TEST("0123" , "%-2.4d" , 123); |
329 | PRINTF_TEST("00123" , "%-2.5d" , 123); |
330 | PRINTF_TEST("000123" , "%-2.6d" , 123); |
331 | PRINTF_TEST("0000123" , "%-2.7d" , 123); |
332 | PRINTF_TEST("00000123" , "%-2.8d" , 123); |
333 | |
334 | PRINTF_TEST("123" , "%-3.0d" , 123); |
335 | PRINTF_TEST("123" , "%-3.1d" , 123); |
336 | PRINTF_TEST("123" , "%-3.2d" , 123); |
337 | PRINTF_TEST("123" , "%-3.3d" , 123); |
338 | PRINTF_TEST("0123" , "%-3.4d" , 123); |
339 | PRINTF_TEST("00123" , "%-3.5d" , 123); |
340 | PRINTF_TEST("000123" , "%-3.6d" , 123); |
341 | PRINTF_TEST("0000123" , "%-3.7d" , 123); |
342 | PRINTF_TEST("00000123" , "%-3.8d" , 123); |
343 | |
344 | PRINTF_TEST("123 " , "%-4.0d" , 123); |
345 | PRINTF_TEST("123 " , "%-4.1d" , 123); |
346 | PRINTF_TEST("123 " , "%-4.2d" , 123); |
347 | PRINTF_TEST("123 " , "%-4.3d" , 123); |
348 | PRINTF_TEST("0123" , "%-4.4d" , 123); |
349 | PRINTF_TEST("00123" , "%-4.5d" , 123); |
350 | PRINTF_TEST("000123" , "%-4.6d" , 123); |
351 | PRINTF_TEST("0000123" , "%-4.7d" , 123); |
352 | PRINTF_TEST("00000123" , "%-4.8d" , 123); |
353 | |
354 | PRINTF_TEST("123 " , "%-5.0d" , 123); |
355 | PRINTF_TEST("123 " , "%-5.1d" , 123); |
356 | PRINTF_TEST("123 " , "%-5.2d" , 123); |
357 | PRINTF_TEST("123 " , "%-5.3d" , 123); |
358 | PRINTF_TEST("0123 " , "%-5.4d" , 123); |
359 | PRINTF_TEST("00123" , "%-5.5d" , 123); |
360 | PRINTF_TEST("000123" , "%-5.6d" , 123); |
361 | PRINTF_TEST("0000123" , "%-5.7d" , 123); |
362 | PRINTF_TEST("00000123" , "%-5.8d" , 123); |
363 | |
364 | PRINTF_TEST("123 " , "%-6.0d" , 123); |
365 | PRINTF_TEST("123 " , "%-6.1d" , 123); |
366 | PRINTF_TEST("123 " , "%-6.2d" , 123); |
367 | PRINTF_TEST("123 " , "%-6.3d" , 123); |
368 | PRINTF_TEST("0123 " , "%-6.4d" , 123); |
369 | PRINTF_TEST("00123 " , "%-6.5d" , 123); |
370 | PRINTF_TEST("000123" , "%-6.6d" , 123); |
371 | PRINTF_TEST("0000123" , "%-6.7d" , 123); |
372 | PRINTF_TEST("00000123" , "%-6.8d" , 123); |
373 | } |
374 | |
375 | MOS_TEST_CASE(integer_extreme_case) |
376 | { |
377 | PRINTF_TEST("2147483647" , "%d" , 2147483647); |
378 | PRINTF_TEST("-2147483648" , "%d" , -2147483647 - 1); |
379 | PRINTF_TEST("0" , "%d" , +0); |
380 | PRINTF_TEST("0" , "%d" , 0); |
381 | PRINTF_TEST("0" , "%d" , -0); |
382 | } |
383 | |
384 | // https://github.com/BartMassey/printf-tests/blob/master/drivers/c/testcases.c |
385 | // Licensed under the GPLv2 or later. |
386 | MOS_WARNING_PUSH |
387 | MOS_WARNING_DISABLE("-Wformat" ) |
388 | MOS_WARNING_DISABLE("-Wformat-extra-args" ) |
389 | MOS_TEST_CASE(printf_tests_github) |
390 | { |
391 | PRINTF_TEST(" 00004" , "%10.5d" , 4); |
392 | PRINTF_TEST(" 42" , "% d" , 42); |
393 | PRINTF_TEST("-42" , "% d" , -42); |
394 | PRINTF_TEST(" 42" , "% 5d" , 42); |
395 | PRINTF_TEST(" -42" , "% 5d" , -42); |
396 | PRINTF_TEST(" 42" , "% 15d" , 42); |
397 | PRINTF_TEST(" -42" , "% 15d" , -42); |
398 | PRINTF_TEST("+42" , "%+d" , 42); |
399 | PRINTF_TEST("-42" , "%+d" , -42); |
400 | PRINTF_TEST(" +42" , "%+5d" , 42); |
401 | PRINTF_TEST(" -42" , "%+5d" , -42); |
402 | PRINTF_TEST("1234" , "%3d" , 1234); |
403 | PRINTF_TEST(" +42" , "%+15d" , 42); |
404 | PRINTF_TEST(" -42" , "%+15d" , -42); |
405 | PRINTF_TEST("42" , "%0d" , 42); |
406 | PRINTF_TEST("-42" , "%0d" , -42); |
407 | PRINTF_TEST("00042" , "%05d" , 42); |
408 | PRINTF_TEST("-0042" , "%05d" , -42); |
409 | PRINTF_TEST("000000000000042" , "%015d" , 42); |
410 | PRINTF_TEST("-00000000000042" , "%015d" , -42); |
411 | PRINTF_TEST("42" , "%-d" , 42); |
412 | PRINTF_TEST("-42" , "%-d" , -42); |
413 | PRINTF_TEST("2" , "%-1d" , 2); |
414 | PRINTF_TEST("42 " , "%-5d" , 42); |
415 | PRINTF_TEST("-42 " , "%-5d" , -42); |
416 | PRINTF_TEST("42 " , "%-15d" , 42); |
417 | PRINTF_TEST("-42 " , "%-15d" , -42); |
418 | PRINTF_TEST("10" , "%d" , 10); |
419 | PRINTF_TEST("+10+" , "+%d+" , 10); |
420 | PRINTF_TEST("1024" , "%d" , 1024); |
421 | PRINTF_TEST("-1024" , "%d" , -1024); |
422 | PRINTF_TEST(" 0000000000000000000000000000000000000001" , "% .40d" , 1); |
423 | |
424 | PRINTF_TEST("a" , "%c" , 'a'); |
425 | PRINTF_TEST(" " , "%c" , 32); |
426 | PRINTF_TEST("$" , "%c" , 36); |
427 | |
428 | PRINTF_TEST(" a" , "%3c" , 'a'); |
429 | |
430 | PRINTF_TEST("1024" , "%i" , 1024); |
431 | PRINTF_TEST("-1024" , "%i" , -1024); |
432 | PRINTF_TEST("-1" , "%-i" , -1); |
433 | PRINTF_TEST("1" , "%-i" , 1); |
434 | PRINTF_TEST("+1" , "%+i" , 1); |
435 | PRINTF_TEST("1024" , "%u" , 1024); |
436 | PRINTF_TEST("4294967295" , "%u" , -1); |
437 | |
438 | PRINTF_TEST("+hello+" , "+%s+" , "hello" ); |
439 | PRINTF_TEST("%%%%" , "%s" , "%%%%" ); |
440 | PRINTF_TEST("hello" , "hello" , ); |
441 | PRINTF_TEST("Hallo heimur" , "Hallo heimur" , ); |
442 | PRINTF_TEST("Hallo heimur" , "%s" , "Hallo heimur" ); |
443 | PRINTF_TEST("foo" , "%.3s" , "foobar" ); |
444 | PRINTF_TEST(" foo" , "%*s" , 4, "foo" ); |
445 | |
446 | // lld |
447 | PRINTF_TEST(" +100" , "%+8lld" , 100LL); |
448 | PRINTF_TEST("+00000100" , "%+.8lld" , 100LL); |
449 | PRINTF_TEST(" +00000100" , "%+10.8lld" , 100LL); |
450 | PRINTF_TEST("-00100" , "%-1.5lld" , -100LL); |
451 | PRINTF_TEST(" 100" , "%5lld" , 100LL); |
452 | PRINTF_TEST(" -100" , "%5lld" , -100LL); |
453 | PRINTF_TEST("100 " , "%-5lld" , 100LL); |
454 | PRINTF_TEST("-100 " , "%-5lld" , -100LL); |
455 | PRINTF_TEST("00100" , "%-.5lld" , 100LL); |
456 | PRINTF_TEST("-00100" , "%-.5lld" , -100LL); |
457 | PRINTF_TEST("00100 " , "%-8.5lld" , 100LL); |
458 | PRINTF_TEST("-00100 " , "%-8.5lld" , -100LL); |
459 | PRINTF_TEST("00100" , "%05lld" , 100LL); |
460 | PRINTF_TEST("-0100" , "%05lld" , -100LL); |
461 | PRINTF_TEST(" 100" , "% lld" , 100LL); |
462 | PRINTF_TEST("-100" , "% lld" , -100LL); |
463 | PRINTF_TEST(" 100" , "% 5lld" , 100LL); |
464 | PRINTF_TEST(" -100" , "% 5lld" , -100LL); |
465 | PRINTF_TEST(" 00100" , "% .5lld" , 100LL); |
466 | PRINTF_TEST("-00100" , "% .5lld" , -100LL); |
467 | PRINTF_TEST(" 00100" , "% 8.5lld" , 100LL); |
468 | PRINTF_TEST(" -00100" , "% 8.5lld" , -100LL); |
469 | PRINTF_TEST("" , "%.0lld" , 0LL); |
470 | |
471 | PRINTF_TEST("0000000000000000000000000000000000000001" , "%.40lld" , 1LL); |
472 | PRINTF_TEST(" 0000000000000000000000000000000000000001" , "% .40lld" , 1LL); |
473 | |
474 | // star |
475 | PRINTF_TEST(" Hallo" , "%*s" , 20, "Hallo" ); |
476 | PRINTF_TEST(" 1024" , "%*d" , 20, 1024); |
477 | PRINTF_TEST(" -1024" , "%*d" , 20, -1024); |
478 | PRINTF_TEST(" 1024" , "%*i" , 20, 1024); |
479 | PRINTF_TEST(" -1024" , "%*i" , 20, -1024); |
480 | PRINTF_TEST(" 1024" , "%*u" , 20, 1024); |
481 | PRINTF_TEST(" 4294966272" , "%*u" , 20, 4294966272U); |
482 | PRINTF_TEST(" x" , "%*c" , 20, 'x'); |
483 | |
484 | PRINTF_TEST("hi x\\n" , "%*sx\\n" , -3, "hi" ); |
485 | |
486 | PRINTF_TEST("f" , "%.1s" , "foo" ); |
487 | PRINTF_TEST("f" , "%.*s" , 1, "foo" ); |
488 | PRINTF_TEST("foo " , "%*s" , -5, "foo" ); |
489 | PRINTF_TEST("%0" , "%%0" , ); |
490 | PRINTF_TEST("4294966272" , "%u" , 4294966272U); |
491 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("%H" , "%H" , -1), "unknown conversion specifier" ); |
492 | PRINTF_TEST("x" , "%c" , 'x'); |
493 | PRINTF_TEST("%" , "%%" , ); |
494 | PRINTF_TEST("+1024" , "%+d" , 1024); |
495 | PRINTF_TEST("-1024" , "%+d" , -1024); |
496 | PRINTF_TEST("+1024" , "%+i" , 1024); |
497 | PRINTF_TEST("-1024" , "%+i" , -1024); |
498 | PRINTF_TEST(" 1024" , "% d" , 1024); |
499 | PRINTF_TEST("-1024" , "% d" , -1024); |
500 | PRINTF_TEST(" 1024" , "% i" , 1024); |
501 | PRINTF_TEST("-1024" , "% i" , -1024); |
502 | PRINTF_TEST("Hallo heimur" , "%1s" , "Hallo heimur" ); |
503 | PRINTF_TEST("1024" , "%1d" , 1024); |
504 | PRINTF_TEST("-1024" , "%1d" , -1024); |
505 | PRINTF_TEST("1024" , "%1i" , 1024); |
506 | PRINTF_TEST("-1024" , "%1i" , -1024); |
507 | PRINTF_TEST("1024" , "%1u" , 1024); |
508 | PRINTF_TEST("4294966272" , "%1u" , 4294966272U); |
509 | PRINTF_TEST("x" , "%1c" , 'x'); |
510 | PRINTF_TEST(" Hallo" , "%20s" , "Hallo" ); |
511 | PRINTF_TEST(" 1024" , "%20d" , 1024); |
512 | PRINTF_TEST(" -1024" , "%20d" , -1024); |
513 | PRINTF_TEST(" 1024" , "%20i" , 1024); |
514 | PRINTF_TEST(" -1024" , "%20i" , -1024); |
515 | PRINTF_TEST(" 1024" , "%20u" , 1024); |
516 | PRINTF_TEST(" 4294966272" , "%20u" , 4294966272U); |
517 | PRINTF_TEST(" x" , "%20c" , 'x'); |
518 | PRINTF_TEST("Hallo " , "%-20s" , "Hallo" ); |
519 | PRINTF_TEST("1024 " , "%-20d" , 1024); |
520 | PRINTF_TEST("-1024 " , "%-20d" , -1024); |
521 | PRINTF_TEST("1024 " , "%-20i" , 1024); |
522 | PRINTF_TEST("-1024 " , "%-20i" , -1024); |
523 | PRINTF_TEST("1024 " , "%-20u" , 1024); |
524 | PRINTF_TEST("4294966272 " , "%-20u" , 4294966272U); |
525 | PRINTF_TEST("x " , "%-20c" , 'x'); |
526 | PRINTF_TEST("00000000000000001024" , "%020d" , 1024); |
527 | PRINTF_TEST("-0000000000000001024" , "%020d" , -1024); |
528 | PRINTF_TEST("00000000000000001024" , "%020i" , 1024); |
529 | PRINTF_TEST("-0000000000000001024" , "%020i" , -1024); |
530 | PRINTF_TEST("00000000000000001024" , "%020u" , 1024); |
531 | PRINTF_TEST("00000000004294966272" , "%020u" , 4294966272U); |
532 | PRINTF_TEST("Hallo heimur" , "%.20s" , "Hallo heimur" ); |
533 | PRINTF_TEST("00000000000000001024" , "%.20d" , 1024); |
534 | PRINTF_TEST("-00000000000000001024" , "%.20d" , -1024); |
535 | PRINTF_TEST("00000000000000001024" , "%.20i" , 1024); |
536 | PRINTF_TEST("-00000000000000001024" , "%.20i" , -1024); |
537 | PRINTF_TEST("00000000000000001024" , "%.20u" , 1024); |
538 | PRINTF_TEST("00000000004294966272" , "%.20u" , 4294966272U); |
539 | PRINTF_TEST(" Hallo" , "%20.5s" , "Hallo heimur" ); |
540 | PRINTF_TEST(" 01024" , "%20.5d" , 1024); |
541 | PRINTF_TEST(" -01024" , "%20.5d" , -1024); |
542 | PRINTF_TEST(" 01024" , "%20.5i" , 1024); |
543 | PRINTF_TEST(" -01024" , "%20.5i" , -1024); |
544 | PRINTF_TEST(" 01024" , "%20.5u" , 1024); |
545 | PRINTF_TEST(" 4294966272" , "%20.5u" , 4294966272U); |
546 | PRINTF_TEST(" 01024" , "%020.5d" , 1024); |
547 | PRINTF_TEST(" -01024" , "%020.5d" , -1024); |
548 | PRINTF_TEST(" 01024" , "%020.5i" , 1024); |
549 | PRINTF_TEST(" -01024" , "%020.5i" , -1024); |
550 | PRINTF_TEST(" 01024" , "%020.5u" , 1024); |
551 | PRINTF_TEST(" 4294966272" , "%020.5u" , 4294966272U); |
552 | PRINTF_TEST("" , "%.0s" , "Hallo heimur" ); |
553 | PRINTF_TEST(" " , "%20.0s" , "Hallo heimur" ); |
554 | PRINTF_TEST("" , "%.s" , "Hallo heimur" ); |
555 | PRINTF_TEST(" " , "%20.s" , "Hallo heimur" ); |
556 | PRINTF_TEST(" 1024" , "%20.0d" , 1024); |
557 | PRINTF_TEST(" -1024" , "%20.d" , -1024); |
558 | PRINTF_TEST(" " , "%20.d" , 0); |
559 | PRINTF_TEST(" 1024" , "%20.0i" , 1024); |
560 | PRINTF_TEST(" -1024" , "%20.i" , -1024); |
561 | PRINTF_TEST(" " , "%20.i" , 0); |
562 | PRINTF_TEST(" 1024" , "%20.u" , 1024); |
563 | PRINTF_TEST(" 4294966272" , "%20.0u" , 4294966272U); |
564 | PRINTF_TEST(" " , "%20.u" , 0U); |
565 | |
566 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("%w" , "%w" , -1), "unknown format specifier 'w'" ); |
567 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("%b" , "%b" , ), "unknown format specifier 'b'" ); |
568 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("%(foo" , "%(foo" , ), "unknown format specifier" ); |
569 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("%_1lld" , "%_1lld" , 100LL), "unknown format specifier '_'" ); |
570 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("42" , "%-0d" , 42), "0 ignored by '-'" ); |
571 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("-42" , "%-0d" , -42), "0 ignored by '-'" ); |
572 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("42 " , "%-05d" , 42), "0 ignored by '-'" ); |
573 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("-42 " , "%-05d" , -42), "0 ignored by '-'" ); |
574 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("42 " , "%-015d" , 42), "0 ignored by '-'" ); |
575 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("-42 " , "%-015d" , -42), "0 ignored by '-'" ); |
576 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("42" , "%0-d" , 42), "0 ignored by '-'" ); |
577 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("-42" , "%0-d" , -42), "0 ignored by '-'" ); |
578 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("42 " , "%0-5d" , 42), "0 ignored by '-'" ); |
579 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("-42 " , "%0-5d" , -42), "0 ignored by '-'" ); |
580 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("42 " , "%0-15d" , 42), "0 ignored by '-'" ); |
581 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("-42 " , "%0-15d" , -42), "0 ignored by '-'" ); |
582 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST(" -0000000000000000000001" , "%+#25.22lld" , -1LL), "# flag ignored in d" ); |
583 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("Hallo heimur" , "%+s" , "Hallo heimur" ), "+ flag ignored" ); |
584 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("1024" , "%+u" , 1024), "+ flag ignored" ); |
585 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("4294966272" , "%+u" , 4294966272U), "+ flag ignored" ); |
586 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("x" , "%+c" , 'x'), "+ flag ignored" ); |
587 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("Hallo heimur" , "% s" , "Hallo heimur" ), "' ' flag ignored" ); |
588 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("1024" , "% u" , 1024), "' ' flag ignored" ); |
589 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("4294966272" , "% u" , 4294966272U), "' ' flag ignored" ); |
590 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("x" , "% c" , 'x'), "' ' flag ignored" ); |
591 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("+1024" , "%+ d" , 1024), "' ' flag ignored" ); |
592 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("-1024" , "%+ d" , -1024), "' ' flag ignored" ); |
593 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("+1024" , "%+ i" , 1024), "' ' flag ignored" ); |
594 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("-1024" , "%+ i" , -1024), "' ' flag ignored" ); |
595 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("Hallo " , "%0-20s" , "Hallo" ), "0 ignored" ); |
596 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("1024 " , "%0-20d" , 1024), "0 ignored" ); |
597 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("-1024 " , "%0-20d" , -1024), "0 ignored" ); |
598 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("1024 " , "%0-20i" , 1024), "0 ignored" ); |
599 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("-1024 " , "%0-20i" , -1024), "0 ignored" ); |
600 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("1024 " , "%0-20u" , 1024), "0 ignored" ); |
601 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("4294966272 " , "%0-20u" , 4294966272U), "0 ignored" ); |
602 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("x " , "%-020c" , 'x'), "0 ignored" ); |
603 | MOS_TEST_EXPECT_WARNING_N(2, PRINTF_TEST("Hallo heimur" , "%+ s" , "Hallo heimur" ), "+, ' ' flag ignored" ); |
604 | MOS_TEST_EXPECT_WARNING_N(2, PRINTF_TEST("1024" , "%+ u" , 1024), "' ' flag ignored, + ignored" ); |
605 | MOS_TEST_EXPECT_WARNING_N(2, PRINTF_TEST("4294966272" , "%+ u" , 4294966272U), "' ' flag ignored, + ignored" ); |
606 | MOS_TEST_EXPECT_WARNING_N(2, PRINTF_TEST("x" , "%+ c" , 'x'), "' ' flag ignored, + ignored" ); |
607 | MOS_TEST_EXPECT_WARNING_N(2, PRINTF_TEST("+01024 " , "% -0+*.*d" , 20, 5, 1024), "' ' flag and 0 flag ignored" ); |
608 | MOS_TEST_EXPECT_WARNING_N(2, PRINTF_TEST("-01024 " , "% -0+*.*d" , 20, 5, -1024), "' ' flag and 0 flag ignored" ); |
609 | MOS_TEST_EXPECT_WARNING_N(2, PRINTF_TEST("+01024 " , "% -0+*.*i" , 20, 5, 1024), "' ' flag and 0 flag ignored" ); |
610 | MOS_TEST_EXPECT_WARNING_N(2, PRINTF_TEST("-01024 " , "% 0-+*.*i" , 20, 5, -1024), "' ' flag and 0 flag ignored" ); |
611 | MOS_TEST_EXPECT_WARNING_N(2, PRINTF_TEST(" 0018446744073709551615" , "%#+25.22llu" , -1LL), "#, + ignored in u" ); |
612 | MOS_TEST_EXPECT_WARNING_N(2, PRINTF_TEST(" 0018446744073709551615" , "%#+25.22llu" , -1LL), "#, + ignored in u" ); |
613 | MOS_TEST_EXPECT_WARNING_N(3, PRINTF_TEST("+00100 " , "%#-+ 08.5lld" , 100LL), "ignored 0 by -, ' ' by +, # in d" ); |
614 | MOS_TEST_EXPECT_WARNING_N(2, PRINTF_TEST(" 0000018446744073709551615" , "%#+30.25llu" , -1LL), "#, + ignored in u" ); |
615 | MOS_TEST_EXPECT_WARNING_N(3, PRINTF_TEST("4294966272 " , "% 0-+*.*u" , 20, 5, 4294966272U), "' ' and 0 ignored, + ignore in u" ); |
616 | MOS_TEST_EXPECT_WARNING_N(3, PRINTF_TEST("01024 " , "% 0-+*.*u" , 20, 5, 1024), "' ' and 0 ignored, + ignore in u" ); |
617 | MOS_TEST_EXPECT_WARNING_N(3, PRINTF_TEST("Hallo " , "% -0+*.*s" , 20, 5, "Hallo heimur" ), "ignore 0 by -, ' ' by +, + by s" ); |
618 | |
619 | MOS_TEST_CONDITIONAL(printf_tests_enable_posix) |
620 | { |
621 | PRINTF_TEST("Hot Pocket" , "%1$s %2$s" , "Hot" , "Pocket" ); |
622 | PRINTF_TEST("12.0 Hot Pockets" , "%1$.1f %2$s %3$ss" , 12.0, "Hot" , "Pocket" ); |
623 | } |
624 | |
625 | MOS_TEST_CONDITIONAL(printf_tests_enable_floats) |
626 | { |
627 | PRINTF_TEST("0.33" , "%.*f" , 2, 0.33333333); |
628 | PRINTF_TEST("42.90" , "%.2f" , 42.8952); |
629 | PRINTF_TEST("42.90" , "%.2F" , 42.8952); |
630 | PRINTF_TEST("42.8952000000" , "%.10f" , 42.8952); |
631 | PRINTF_TEST("42.90" , "%1.2f" , 42.8952); |
632 | PRINTF_TEST(" 42.90" , "%6.2f" , 42.8952); |
633 | PRINTF_TEST("+42.90" , "%+6.2f" , 42.8952); |
634 | PRINTF_TEST("42.8952000000" , "%5.10f" , 42.8952); |
635 | PRINTF_TEST(" 3.14" , "%*.*f" , 10, 2, 3.14159265); |
636 | PRINTF_TEST("3.14 " , "%-*.*f" , 10, 2, 3.14159265); |
637 | PRINTF_TEST("8.6000" , "%2.4f" , 8.6); |
638 | PRINTF_TEST("0.600000" , "%0f" , 0.6); |
639 | PRINTF_TEST("1" , "%.0f" , 0.6); |
640 | } |
641 | |
642 | MOS_TEST_CONDITIONAL(printf_tests_enable_egp) |
643 | { |
644 | PRINTF_TEST("0x39" , "%p" , (void *) 57ULL); |
645 | PRINTF_TEST("0x39" , "%p" , (void *) 57U); |
646 | PRINTF_TEST("8.6000e+00" , "%2.4e" , 8.6); |
647 | PRINTF_TEST(" 8.6000e+00" , "% 2.4e" , 8.6); |
648 | PRINTF_TEST("-8.6000e+00" , "% 2.4e" , -8.6); |
649 | PRINTF_TEST("+8.6000e+00" , "%+2.4e" , 8.6); |
650 | PRINTF_TEST("8.6" , "%2.4g" , 8.6); |
651 | // e |
652 | PRINTF_TEST("+7.894561230000000e+08" , "%+#22.15e" , 7.89456123e8); |
653 | PRINTF_TEST("7.894561230000000e+08 " , "%-#22.15e" , 7.89456123e8); |
654 | PRINTF_TEST(" 7.894561230000000e+08" , "%#22.15e" , 7.89456123e8); |
655 | |
656 | // g |
657 | PRINTF_TEST("8.e+08" , "%#1.1g" , 7.89456123e8); |
658 | } |
659 | MOS_TEST_CONDITIONAL(printf_tests_enable_oxX) |
660 | { |
661 | PRINTF_TEST("0" , "%#o" , 0U); |
662 | PRINTF_TEST("0" , "%#x" , 0U); |
663 | PRINTF_TEST("0" , "%#X" , 0U); |
664 | PRINTF_TEST("12" , "%o" , 10); |
665 | PRINTF_TEST("61" , "%hhx" , 'a'); |
666 | PRINTF_TEST("777" , "%o" , 511); |
667 | PRINTF_TEST("777" , "%1o" , 511); |
668 | PRINTF_TEST("0777" , "%#o" , 511); |
669 | PRINTF_TEST("2345" , "%hx" , 74565); |
670 | PRINTF_TEST("00000001" , "%#08o" , 1); |
671 | PRINTF_TEST("0x00000001" , "%#04.8x" , 1); |
672 | PRINTF_TEST("0x0000000001" , "%#012x" , 1); |
673 | PRINTF_TEST("1234abcd" , "%x" , 305441741); |
674 | PRINTF_TEST("1234ABCD" , "%X" , 305441741); |
675 | PRINTF_TEST("1234ABCD" , "%1X" , 305441741); |
676 | PRINTF_TEST("1234abcd" , "%1x" , 305441741); |
677 | PRINTF_TEST("edcb5433" , "%x" , 3989525555U); |
678 | PRINTF_TEST("EDCB5433" , "%X" , 3989525555U); |
679 | PRINTF_TEST("edcb5433" , "%1x" , 3989525555U); |
680 | PRINTF_TEST("EDCB5433" , "%1X" , 3989525555U); |
681 | PRINTF_TEST("00144 " , "%#-8.5llo" , 100LL); |
682 | PRINTF_TEST("0x1234abcd" , "%#x" , 305441741); |
683 | PRINTF_TEST("0X1234ABCD" , "%#X" , 305441741); |
684 | PRINTF_TEST("0xedcb5433" , "%#x" , 3989525555U); |
685 | PRINTF_TEST("37777777001" , "%o" , 4294966785U); |
686 | PRINTF_TEST("0XEDCB5433" , "%#X" , 3989525555U); |
687 | PRINTF_TEST("37777777001" , "%1o" , 4294966785U); |
688 | PRINTF_TEST("037777777001" , "%#o" , 4294966785U); |
689 | PRINTF_TEST(" 777" , "%*o" , 20, 511); |
690 | PRINTF_TEST(" 37777777001" , "%*o" , 20, 4294966785U); |
691 | PRINTF_TEST(" 1234abcd" , "%*x" , 20, 305441741); |
692 | PRINTF_TEST(" edcb5433" , "%*x" , 20, 3989525555U); |
693 | PRINTF_TEST(" 1234ABCD" , "%*X" , 20, 305441741); |
694 | PRINTF_TEST(" EDCB5433" , "%*X" , 20, 3989525555U); |
695 | PRINTF_TEST(" 777" , "%20o" , 511); |
696 | PRINTF_TEST(" 1234abcd" , "%20x" , 305441741); |
697 | PRINTF_TEST(" 1234ABCD" , "%20X" , 305441741); |
698 | PRINTF_TEST(" 37777777001" , "%20o" , 4294966785U); |
699 | PRINTF_TEST(" edcb5433" , "%20x" , 3989525555U); |
700 | PRINTF_TEST(" EDCB5433" , "%20X" , 3989525555U); |
701 | PRINTF_TEST("777 " , "%-20o" , 511); |
702 | PRINTF_TEST("1234abcd " , "%-20x" , 305441741); |
703 | PRINTF_TEST("37777777001 " , "%-20o" , 4294966785U); |
704 | PRINTF_TEST("edcb5433 " , "%-20x" , 3989525555U); |
705 | PRINTF_TEST("1234ABCD " , "%-20X" , 305441741); |
706 | PRINTF_TEST("EDCB5433 " , "%-20X" , 3989525555U); |
707 | PRINTF_TEST("00000000000000000777" , "%020o" , 511); |
708 | PRINTF_TEST("00000000037777777001" , "%020o" , 4294966785U); |
709 | PRINTF_TEST("0000000000001234abcd" , "%020x" , 305441741); |
710 | PRINTF_TEST("000000000000edcb5433" , "%020x" , 3989525555U); |
711 | PRINTF_TEST("0000000000001234ABCD" , "%020X" , 305441741); |
712 | PRINTF_TEST("000000000000EDCB5433" , "%020X" , 3989525555U); |
713 | PRINTF_TEST(" 0777" , "%#20o" , 511); |
714 | PRINTF_TEST(" 037777777001" , "%#20o" , 4294966785U); |
715 | PRINTF_TEST(" 0x1234abcd" , "%#20x" , 305441741); |
716 | PRINTF_TEST(" 0xedcb5433" , "%#20x" , 3989525555U); |
717 | PRINTF_TEST(" 0X1234ABCD" , "%#20X" , 305441741); |
718 | PRINTF_TEST(" 0XEDCB5433" , "%#20X" , 3989525555U); |
719 | PRINTF_TEST("00000000000000000777" , "%#020o" , 511); |
720 | PRINTF_TEST("00000000037777777001" , "%#020o" , 4294966785U); |
721 | PRINTF_TEST("0x00000000001234abcd" , "%#020x" , 305441741); |
722 | PRINTF_TEST("0x0000000000edcb5433" , "%#020x" , 3989525555U); |
723 | PRINTF_TEST("0X00000000001234ABCD" , "%#020X" , 305441741); |
724 | PRINTF_TEST("0X0000000000EDCB5433" , "%#020X" , 3989525555U); |
725 | PRINTF_TEST("00000000000000000777" , "%.20o" , 511); |
726 | PRINTF_TEST("00000000037777777001" , "%.20o" , 4294966785U); |
727 | PRINTF_TEST("0000000000001234abcd" , "%.20x" , 305441741); |
728 | PRINTF_TEST("000000000000edcb5433" , "%.20x" , 3989525555U); |
729 | PRINTF_TEST("0000000000001234ABCD" , "%.20X" , 305441741); |
730 | PRINTF_TEST("000000000000EDCB5433" , "%.20X" , 3989525555U); |
731 | PRINTF_TEST(" 00777" , "%20.5o" , 511); |
732 | PRINTF_TEST(" 37777777001" , "%20.5o" , 4294966785U); |
733 | PRINTF_TEST(" 1234abcd" , "%20.5x" , 305441741); |
734 | PRINTF_TEST(" 00edcb5433" , "%20.10x" , 3989525555U); |
735 | PRINTF_TEST(" 1234ABCD" , "%20.5X" , 305441741); |
736 | PRINTF_TEST(" 00EDCB5433" , "%20.10X" , 3989525555U); |
737 | PRINTF_TEST(" 00777" , "%020.5o" , 511); |
738 | PRINTF_TEST(" 37777777001" , "%020.5o" , 4294966785U); |
739 | PRINTF_TEST(" 1234abcd" , "%020.5x" , 305441741); |
740 | PRINTF_TEST(" 00edcb5433" , "%020.10x" , 3989525555U); |
741 | PRINTF_TEST(" 1234ABCD" , "%020.5X" , 305441741); |
742 | PRINTF_TEST(" 00EDCB5433" , "%020.10X" , 3989525555U); |
743 | PRINTF_TEST(" 777" , "%20.o" , 511); |
744 | PRINTF_TEST(" " , "%20.o" , 0U); |
745 | PRINTF_TEST(" 1234abcd" , "%20.x" , 305441741); |
746 | PRINTF_TEST(" " , "%20.x" , 0U); |
747 | PRINTF_TEST(" 1234ABCD" , "%20.X" , 305441741); |
748 | PRINTF_TEST(" " , "%20.X" , 0U); |
749 | PRINTF_TEST(" 37777777001" , "%20.0o" , 4294966785U); |
750 | PRINTF_TEST(" edcb5433" , "%20.0x" , 3989525555U); |
751 | PRINTF_TEST(" EDCB5433" , "%20.0X" , 3989525555U); |
752 | PRINTF_TEST("0001777777777777777777634" , "%#.25llo" , -100LL); |
753 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("0x01 " , "%#-08.2x" , 1), "0 flag ignored by '-'" ); |
754 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST(" 01777777777777777777634" , "%#+24.20llo" , -100LL), "+ ignored in o" ); |
755 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("001777777777777777777634" , "%#+20.24llo" , -100LL), "+ ignored in o" ); |
756 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST(" 0x00ffffffffffffff9c" , "%#+21.18llx" , -100LL), "+ ignored in x" ); |
757 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("0X00000FFFFFFFFFFFFFF9C" , "%#+18.21llX" , -100LL), "+ ignored in X" ); |
758 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("777 " , "%-020o" , 511), "- flag ignored in o mode" ); |
759 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("37777777001 " , "%-020o" , 4294966785U), "- flag ignored in o mode" ); |
760 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("1234abcd " , "%-020x" , 305441741), "- flag ignored in x mode" ); |
761 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("edcb5433 " , "%-020x" , 3989525555U), "- flag ignored in x mode" ); |
762 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("1234ABCD " , "%-020X" , 305441741), "- flag ignored in X mode" ); |
763 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("EDCB5433 " , "%-020X" , 3989525555U), "- flag ignored in X mode" ); |
764 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("777" , "%+o" , 511), "+ flag ignored in o mode" ); |
765 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("37777777001" , "%+o" , 4294966785U), "+ flag ignored in o mode" ); |
766 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("1234abcd" , "%+x" , 305441741), "+ flag ignored in x mode" ); |
767 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("edcb5433" , "%+x" , 3989525555U), "+ flag ignored in x mode" ); |
768 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("1234ABCD" , "%+X" , 305441741), "+ flag ignored in X mode" ); |
769 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("EDCB5433" , "%+X" , 3989525555U), "+ flag ignored in X mode" ); |
770 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("777" , "% o" , 511), "' ' flag ignored in o mode" ); |
771 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("37777777001" , "% o" , 4294966785U), "' ' flag ignored in o mode" ); |
772 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("1234abcd" , "% x" , 305441741), "' ' flag ignored in x mode" ); |
773 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("edcb5433" , "% x" , 3989525555U), "' ' flag ignored in x mode" ); |
774 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("1234ABCD" , "% X" , 305441741), "' ' flag ignored in x mode" ); |
775 | MOS_TEST_EXPECT_WARNING(PRINTF_TEST("EDCB5433" , "% X" , 3989525555U), "' ' flag ignored in x mode" ); |
776 | MOS_TEST_EXPECT_WARNING_N(2, PRINTF_TEST("777" , "%+ o" , 511), "+ and ' ' ignored in o mode" ); |
777 | MOS_TEST_EXPECT_WARNING_N(2, PRINTF_TEST("37777777001" , "%+ o" , 4294966785U), "+ and ' ' ignored in o mode" ); |
778 | MOS_TEST_EXPECT_WARNING_N(2, PRINTF_TEST("1234abcd" , "%+ x" , 305441741), "+ and ' ' ignored in x mode" ); |
779 | MOS_TEST_EXPECT_WARNING_N(2, PRINTF_TEST("edcb5433" , "%+ x" , 3989525555U), "+ and ' ' ignored in x mode" ); |
780 | MOS_TEST_EXPECT_WARNING_N(2, PRINTF_TEST("1234ABCD" , "%+ X" , 305441741), "+ and ' ' ignored in X mode" ); |
781 | MOS_TEST_EXPECT_WARNING_N(2, PRINTF_TEST("EDCB5433" , "%+ X" , 3989525555U), "+ and ' ' ignored in X mode" ); |
782 | MOS_TEST_EXPECT_WARNING_N(3, PRINTF_TEST("00777 " , "%+ -0*.*o" , 20, 5, 511), "ignored ' ' and 0, + in o" ); |
783 | MOS_TEST_EXPECT_WARNING_N(3, PRINTF_TEST("37777777001 " , "%+ -0*.*o" , 20, 5, 4294966785U), "ignored ' ' and 0, + in o" ); |
784 | MOS_TEST_EXPECT_WARNING_N(3, PRINTF_TEST("1234abcd " , "%+ -0*.*x" , 20, 5, 305441741), "ignored ' ' and 0, + in x" ); |
785 | MOS_TEST_EXPECT_WARNING_N(3, PRINTF_TEST("00edcb5433 " , "%+ -0*.*x" , 20, 10, 3989525555U), "ignored ' ' and 0, + in x" ); |
786 | MOS_TEST_EXPECT_WARNING_N(3, PRINTF_TEST("1234ABCD " , "% -+0*.*X" , 20, 5, 305441741), "ignored ' ' and 0, + in X" ); |
787 | MOS_TEST_EXPECT_WARNING_N(3, PRINTF_TEST("00EDCB5433 " , "% -+0*.*X" , 20, 10, 3989525555U), "ignored ' ' and 0, + in X" ); |
788 | } |
789 | } |
790 | MOS_WARNING_POP |
791 | |