powerpc: Regenerate ULPs
[glibc.git] / stdio-common / tst-printfsz.c
blob8a3385f94df9960d62fc35f79312cc4bd04270d4
1 /* Based on code by Larry McVoy <lm@neteng.engr.sgi.com>. */
2 #include <printf.h>
3 #include <stdio.h>
4 #include <string.h>
5 #include <libc-internal.h>
7 #define V 12345678.12345678
10 static int
11 do_test (void)
13 char buf[1024];
14 int result = 0;
16 /* Testing printf_size_info requires using the deprecated
17 register_printf_function, resulting in warnings
18 "'register_printf_function' is deprecated". */
19 DIAG_PUSH_NEEDS_COMMENT;
20 DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdeprecated-declarations");
21 /* Register the printf handlers. */
22 register_printf_function ('b', printf_size, printf_size_info);
23 register_printf_function ('B', printf_size, printf_size_info);
24 DIAG_POP_NEEDS_COMMENT;
26 /* All of the formats here use the nonstandard extension specifier
27 just registered, so compiler checking will never grok them. */
28 DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat");
29 DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wformat-extra-args");
31 sprintf (buf, "%g %b %B %.0b %.0B %.1b %.1B %8.0b %08.0B",
32 V, 1025., V, V, V, V, V, V, V, V);
33 fputs (buf, stdout);
34 if (strcmp (buf, "\
35 1.23457e+07 1.001k 12.346M 12m 12M 11.8m 12.3M 12m 0000012M"))
37 result = 1;
38 fputs (" -> WRONG\n", stdout);
40 else
41 fputs (" -> OK\n", stdout);
43 sprintf (buf, "%b|%B|%-20.2b|%-10.0b|%-10.8b|%-10.2B|",
44 V, V, V, V, V, V, V, V, V, V, V);
45 fputs (buf, stdout);
46 if (strcmp (buf, "\
47 11.774m|12.346M|11.77m |12m |11.77375614m|12.35M |"))
49 result = 1;
50 fputs (" -> WRONG\n", stdout);
52 else
53 fputs (" -> OK\n", stdout);
55 sprintf (buf, "%#.0B %*.0b %10.*b %*.*B %10.2B",
56 V, 2, V, 2, V, 10, 2, V, V);
57 fputs (buf, stdout);
58 if (strcmp (buf, "12.M 12m 11.77m 12.35M 12.35M"))
60 result = 1;
61 fputs (" -> WRONG\n", stdout);
63 else
64 fputs (" -> OK\n", stdout);
66 sprintf (buf, "%6B %6.1B %b %B %b %B",
67 V, V, 1000.0, 1000.0, 1024.0, 1024.0);
68 fputs (buf, stdout);
69 if (strcmp (buf, "12.346M 12.3M 1000.000 1.000K 1.000k 1.024K"))
71 result = 1;
72 fputs (" -> WRONG\n", stdout);
74 else
75 fputs (" -> OK\n", stdout);
77 return result;
80 #define TEST_FUNCTION do_test ()
81 #include "../test-skeleton.c"