file kaio_read.c was initially added on branch fedora-branch.
[glibc/history.git] / stdio-common / tst-printfsz.c
blob5925050b59e90b7951a4071506d52acd49f364be
1 /* Based on code by Larry McVoy <lm@neteng.engr.sgi.com>. */
2 #include <printf.h>
3 #include <stdio.h>
4 #include <string.h>
6 #define V 12345678.12345678
9 int
10 main (int argc, char *argv[])
12 char buf[1024];
13 int result = 0;
15 /* Register the printf handlers. */
16 register_printf_function ('b', printf_size, printf_size_info);
17 register_printf_function ('B', printf_size, printf_size_info);
20 sprintf (buf, "%g %b %B %.0b %.0B %.1b %.1B %8.0b %08.0B",
21 V, 1025., V, V, V, V, V, V, V, V);
22 fputs (buf, stdout);
23 if (strcmp (buf, "\
24 1.23457e+07 1.001k 12.346M 12m 12M 11.8m 12.3M 12m 0000012M"))
26 result = 1;
27 fputs (" -> WRONG\n", stdout);
29 else
30 fputs (" -> OK\n", stdout);
32 sprintf (buf, "%b|%B|%-20.2b|%-10.0b|%-10.8b|%-10.2B|",
33 V, V, V, V, V, V, V, V, V, V, V);
34 fputs (buf, stdout);
35 if (strcmp (buf, "\
36 11.774m|12.346M|11.77m |12m |11.77375614m|12.35M |"))
38 result = 1;
39 fputs (" -> WRONG\n", stdout);
41 else
42 fputs (" -> OK\n", stdout);
44 sprintf (buf, "%#.0B %*.0b %10.*b %*.*B %10.2B",
45 V, 2, V, 2, V, 10, 2, V, V);
46 fputs (buf, stdout);
47 if (strcmp (buf, "12.M 12m 11.77m 12.35M 12.35M"))
49 result = 1;
50 fputs (" -> WRONG\n", stdout);
52 else
53 fputs (" -> OK\n", stdout);
55 sprintf (buf, "%6B %6.1B %b %B %b %B",
56 V, V, 1000.0, 1000.0, 1024.0, 1024.0);
57 fputs (buf, stdout);
58 if (strcmp (buf, "12.346M 12.3M 1000.000 1.000K 1.000k 1.024K"))
60 result = 1;
61 fputs (" -> WRONG\n", stdout);
63 else
64 fputs (" -> OK\n", stdout);
66 return result;