1--TEST--
2Test sprintf() function : usage variations - unsigned formats with float values
3--SKIPIF--
4<?php
5if (PHP_INT_SIZE != 4) {
6	    die("skip this test is for 32bit platform only");
7}
8?>
9--FILE--
10<?php
11/* Prototype  : string sprintf(string $format [, mixed $arg1 [, mixed ...]])
12 * Description: Return a formatted string
13 * Source code: ext/standard/formatted_print.c
14*/
15
16echo "*** Testing sprintf() : unsigned formats with float values ***\n";
17
18// array of float values
19$float_values = array(
20  2147483647,
21  0x800000001, // float value, beyond max positive int
22  020000000001, // float value, beyond max positive int
23  0.0,
24  -0.1,
25  1.0,
26  +1e5,
27  +5e+5,
28  +0e-5,
29  -1e5,
30  -1e+5,
31  -1e-2,
32  1e5,
33  1E8,
34  -1E9,
35  10.0000000000000000005,
36  10.5e+5
37);
38
39// array of unsigned formats
40$unsigned_formats = array(
41  "%u", "%hu", "%lu",
42  "%Lu", " %u", "%u ",
43  "\t%u", "\n%u", "%4u",
44  "%30u", "%[0-9]", "%*u"
45);
46
47$count = 1;
48foreach($float_values as $float_value) {
49  echo "\n-- Iteration $count --\n";
50
51  foreach($unsigned_formats as $format) {
52    var_dump( sprintf($format, $float_value) );
53  }
54  $count++;
55};
56
57echo "Done";
58?>
59--EXPECT--
60*** Testing sprintf() : unsigned formats with float values ***
61
62-- Iteration 1 --
63string(10) "2147483647"
64string(1) "u"
65string(10) "2147483647"
66string(1) "u"
67string(11) " 2147483647"
68string(11) "2147483647 "
69string(11) "	2147483647"
70string(11) "
712147483647"
72string(10) "2147483647"
73string(30) "                    2147483647"
74string(4) "0-9]"
75string(1) "u"
76
77-- Iteration 2 --
78string(1) "1"
79string(1) "u"
80string(1) "1"
81string(1) "u"
82string(2) " 1"
83string(2) "1 "
84string(2) "	1"
85string(2) "
861"
87string(4) "   1"
88string(30) "                             1"
89string(4) "0-9]"
90string(1) "u"
91
92-- Iteration 3 --
93string(10) "2147483649"
94string(1) "u"
95string(10) "2147483649"
96string(1) "u"
97string(11) " 2147483649"
98string(11) "2147483649 "
99string(11) "	2147483649"
100string(11) "
1012147483649"
102string(10) "2147483649"
103string(30) "                    2147483649"
104string(4) "0-9]"
105string(1) "u"
106
107-- Iteration 4 --
108string(1) "0"
109string(1) "u"
110string(1) "0"
111string(1) "u"
112string(2) " 0"
113string(2) "0 "
114string(2) "	0"
115string(2) "
1160"
117string(4) "   0"
118string(30) "                             0"
119string(4) "0-9]"
120string(1) "u"
121
122-- Iteration 5 --
123string(1) "0"
124string(1) "u"
125string(1) "0"
126string(1) "u"
127string(2) " 0"
128string(2) "0 "
129string(2) "	0"
130string(2) "
1310"
132string(4) "   0"
133string(30) "                             0"
134string(4) "0-9]"
135string(1) "u"
136
137-- Iteration 6 --
138string(1) "1"
139string(1) "u"
140string(1) "1"
141string(1) "u"
142string(2) " 1"
143string(2) "1 "
144string(2) "	1"
145string(2) "
1461"
147string(4) "   1"
148string(30) "                             1"
149string(4) "0-9]"
150string(1) "u"
151
152-- Iteration 7 --
153string(6) "100000"
154string(1) "u"
155string(6) "100000"
156string(1) "u"
157string(7) " 100000"
158string(7) "100000 "
159string(7) "	100000"
160string(7) "
161100000"
162string(6) "100000"
163string(30) "                        100000"
164string(4) "0-9]"
165string(1) "u"
166
167-- Iteration 8 --
168string(6) "500000"
169string(1) "u"
170string(6) "500000"
171string(1) "u"
172string(7) " 500000"
173string(7) "500000 "
174string(7) "	500000"
175string(7) "
176500000"
177string(6) "500000"
178string(30) "                        500000"
179string(4) "0-9]"
180string(1) "u"
181
182-- Iteration 9 --
183string(1) "0"
184string(1) "u"
185string(1) "0"
186string(1) "u"
187string(2) " 0"
188string(2) "0 "
189string(2) "	0"
190string(2) "
1910"
192string(4) "   0"
193string(30) "                             0"
194string(4) "0-9]"
195string(1) "u"
196
197-- Iteration 10 --
198string(10) "4294867296"
199string(1) "u"
200string(10) "4294867296"
201string(1) "u"
202string(11) " 4294867296"
203string(11) "4294867296 "
204string(11) "	4294867296"
205string(11) "
2064294867296"
207string(10) "4294867296"
208string(30) "                    4294867296"
209string(4) "0-9]"
210string(1) "u"
211
212-- Iteration 11 --
213string(10) "4294867296"
214string(1) "u"
215string(10) "4294867296"
216string(1) "u"
217string(11) " 4294867296"
218string(11) "4294867296 "
219string(11) "	4294867296"
220string(11) "
2214294867296"
222string(10) "4294867296"
223string(30) "                    4294867296"
224string(4) "0-9]"
225string(1) "u"
226
227-- Iteration 12 --
228string(1) "0"
229string(1) "u"
230string(1) "0"
231string(1) "u"
232string(2) " 0"
233string(2) "0 "
234string(2) "	0"
235string(2) "
2360"
237string(4) "   0"
238string(30) "                             0"
239string(4) "0-9]"
240string(1) "u"
241
242-- Iteration 13 --
243string(6) "100000"
244string(1) "u"
245string(6) "100000"
246string(1) "u"
247string(7) " 100000"
248string(7) "100000 "
249string(7) "	100000"
250string(7) "
251100000"
252string(6) "100000"
253string(30) "                        100000"
254string(4) "0-9]"
255string(1) "u"
256
257-- Iteration 14 --
258string(9) "100000000"
259string(1) "u"
260string(9) "100000000"
261string(1) "u"
262string(10) " 100000000"
263string(10) "100000000 "
264string(10) "	100000000"
265string(10) "
266100000000"
267string(9) "100000000"
268string(30) "                     100000000"
269string(4) "0-9]"
270string(1) "u"
271
272-- Iteration 15 --
273string(10) "3294967296"
274string(1) "u"
275string(10) "3294967296"
276string(1) "u"
277string(11) " 3294967296"
278string(11) "3294967296 "
279string(11) "	3294967296"
280string(11) "
2813294967296"
282string(10) "3294967296"
283string(30) "                    3294967296"
284string(4) "0-9]"
285string(1) "u"
286
287-- Iteration 16 --
288string(2) "10"
289string(1) "u"
290string(2) "10"
291string(1) "u"
292string(3) " 10"
293string(3) "10 "
294string(3) "	10"
295string(3) "
29610"
297string(4) "  10"
298string(30) "                            10"
299string(4) "0-9]"
300string(1) "u"
301
302-- Iteration 17 --
303string(7) "1050000"
304string(1) "u"
305string(7) "1050000"
306string(1) "u"
307string(8) " 1050000"
308string(8) "1050000 "
309string(8) "	1050000"
310string(8) "
3111050000"
312string(7) "1050000"
313string(30) "                       1050000"
314string(4) "0-9]"
315string(1) "u"
316Done
317