Update.
[glibc.git] / stdio-common / tst-printf.sh
blob7023cfc733ee16c980ff45cac9c893e9a99fa01f
1 #! /bin/sh
2 # Testing of printf.
3 # Copyright (C) 2000 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
6 # The GNU C Library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Library General Public License as
8 # published by the Free Software Foundation; either version 2 of the
9 # License, or (at your option) any later version.
11 # The GNU C Library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Library General Public License for more details.
16 # You should have received a copy of the GNU Library General Public
17 # License along with the GNU C Library; see the file COPYING.LIB. If
18 # not, write to the Free Software Foundation, Inc.,
19 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 common_objpfx=$1; shift
23 status=0
25 LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
26 ${common_objpfx}elf/ld.so --library-path $common_objpfx \
27 ${common_objpfx}stdio-common/tst-printf \
28 > ${common_objpfx}stdio-common/tst-printf.out || status=1
30 cat <<'EOF' |
31 %.4x: `0012'
32 %04x: `0012'
33 %4.4x: `0012'
34 %04.4x: `0012'
35 %4.3x: ` 012'
36 %04.3x: ` 012'
37 %.*x: `0012'
38 %0*x: `0012'
39 %*.*x: `0012'
40 %0*.*x: `0012'
41 bad format: "%b"
42 nil pointer (padded): " (nil)"
43 decimal negative: "-2345"
44 octal negative: "37777773327"
45 hex negative: "fffff6d7"
46 long decimal number: "-123456"
47 long octal negative: "37777773327"
48 long unsigned decimal number: "4294843840"
49 zero-padded LDN: "-000123456"
50 left-adjusted ZLDN: "-123456 "
51 space-padded LDN: " -123456"
52 left-adjusted SLDN: "-123456 "
53 zero-padded string: " Hi, Z."
54 left-adjusted Z string: "Hi, Z. "
55 space-padded string: " Hi, Z."
56 left-adjusted S string: "Hi, Z. "
57 null string: "(null)"
58 limited string: "Good morning, Doctor C"
59 e-style >= 1: "1.234000e+01"
60 e-style >= .1: "1.234000e-01"
61 e-style < .1: "1.234000e-03"
62 e-style big: "1.000000000000000000000000000000000000000000000000000000000000e+20"
63 e-style == .1: "1.000000e-01"
64 f-style >= 1: "12.340000"
65 f-style >= .1: "0.123400"
66 f-style < .1: "0.001234"
67 g-style >= 1: "12.34"
68 g-style >= .1: "0.1234"
69 g-style < .1: "0.001234"
70 g-style big: "100000000000000000000"
71 0.10000
72 0.10000
73 x0.5000x
74 0x1
75 something really insane: 1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
76 5.87747175411143754e-39
77 5.87747175411143754e-39
78 5.87747175411143754e-39
79 5.87747175411143754e-39
80 5.87747175411143754e-39
81 5.87747175411143754e-39
82 5.87747175411143754e-39
83 5.87747175411143754e-39
84 5.87747175411143754e-39
85 5.87747175411143754e-39
86 5.87747175411143754e-39
87 5.87747175411143754e-39
88 5.87747175411143754e-39
89 5.87747175411143754e-39
90 5.87747175411143754e-39
91 5.87747175411143754e-39
92 5.87747175411143754e-39
93 4.94066e-324
94 | 0.0000| 0.0000e+00| 0|
95 | 1.0000| 1.0000e+00| 1|
96 | -1.0000| -1.0000e+00| -1|
97 | 100.0000| 1.0000e+02| 100|
98 | 1000.0000| 1.0000e+03| 1000|
99 | 10000.0000| 1.0000e+04| 1e+04|
100 | 12345.0000| 1.2345e+04| 1.234e+04|
101 | 100000.0000| 1.0000e+05| 1e+05|
102 | 123456.0000| 1.2346e+05| 1.235e+05|
103 snprintf ("%30s", "foo") == 30, " "
104 snprintf ("%.999999u", 10)
106 Formatted output test
107 prefix 6d 6o 6x 6X 6u
108 %-+#0 |-123 |0377 |0xff |0XFF |4294967295 |
109 %-+# |-123 |0377 |0xff |0XFF |4294967295 |
110 %-+0 |-123 |377 |ff |FF |4294967295 |
111 %-+ |-123 |377 |ff |FF |4294967295 |
112 %-#0 |-123 |0377 |0xff |0XFF |4294967295 |
113 %-# |-123 |0377 |0xff |0XFF |4294967295 |
114 %-0 |-123 |377 |ff |FF |4294967295 |
115 %- |-123 |377 |ff |FF |4294967295 |
116 %+#0 |-00123 |000377 |0x00ff |0X00FF |4294967295 |
117 %+# | -123 | 0377 | 0xff | 0XFF |4294967295 |
118 %+0 |-00123 |000377 |0000ff |0000FF |4294967295 |
119 %+ | -123 | 377 | ff | FF |4294967295 |
120 %#0 |-00123 |000377 |0x00ff |0X00FF |4294967295 |
121 %# | -123 | 0377 | 0xff | 0XFF |4294967295 |
122 %0 |-00123 |000377 |0000ff |0000FF |4294967295 |
123 % | -123 | 377 | ff | FF |4294967295 |
124 (null)
125 (null)
126 1.234568e+06 should be 1.234568e+06
127 1234567.800000 should be 1234567.800000
128 1.23457e+06 should be 1.23457e+06
129 123.456 should be 123.456
130 1e+06 should be 1e+06
131 10 should be 10
132 0.02 should be 0.02
133 0.10000000000000009
134 Test ok.
135 sprintf (buf, "%07Lo", 040000000000ll) = 40000000000
136 --- Should be no further output. ---
138 cmp - ${common_objpfx}stdio-common/tst-printf.out || status=1
140 exit $status