1--TEST--
2Test sprintf() function : usage variations - unsigned formats with string 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 string values ***\n";
17
18// array of string values
19$string_values = array(
20  "",
21  '',
22  "0",
23  '0',
24  "1",
25  '1',
26  "-123",
27  "+123",
28  "\x01",
29  '\x01',
30  "\01",
31  '\01',
32  'string',
33  "string",
34  "true",
35  "FALSE",
36  'false',
37  'TRUE',
38  "NULL",
39  'null'
40);
41
42// array of unsigned formats
43$unsigned_formats = array(
44  "%u", "%hu", "%lu",
45  "%Lu", " %u", "%u ",
46  "\t%u", "\n%u", "%4u",
47   "%30u", "%[0-9]", "%*u"
48);
49
50
51$count = 1;
52foreach($string_values as $string_value) {
53  echo "\n-- Iteration $count --\n";
54
55  foreach($unsigned_formats as $format) {
56    var_dump( sprintf($format, $string_value) );
57  }
58  $count++;
59};
60
61echo "Done";
62?>
63--EXPECT--
64*** Testing sprintf() : unsigned formats with string values ***
65
66-- Iteration 1 --
67string(1) "0"
68string(1) "u"
69string(1) "0"
70string(1) "u"
71string(2) " 0"
72string(2) "0 "
73string(2) "	0"
74string(2) "
750"
76string(4) "   0"
77string(30) "                             0"
78string(4) "0-9]"
79string(1) "u"
80
81-- Iteration 2 --
82string(1) "0"
83string(1) "u"
84string(1) "0"
85string(1) "u"
86string(2) " 0"
87string(2) "0 "
88string(2) "	0"
89string(2) "
900"
91string(4) "   0"
92string(30) "                             0"
93string(4) "0-9]"
94string(1) "u"
95
96-- Iteration 3 --
97string(1) "0"
98string(1) "u"
99string(1) "0"
100string(1) "u"
101string(2) " 0"
102string(2) "0 "
103string(2) "	0"
104string(2) "
1050"
106string(4) "   0"
107string(30) "                             0"
108string(4) "0-9]"
109string(1) "u"
110
111-- Iteration 4 --
112string(1) "0"
113string(1) "u"
114string(1) "0"
115string(1) "u"
116string(2) " 0"
117string(2) "0 "
118string(2) "	0"
119string(2) "
1200"
121string(4) "   0"
122string(30) "                             0"
123string(4) "0-9]"
124string(1) "u"
125
126-- Iteration 5 --
127string(1) "1"
128string(1) "u"
129string(1) "1"
130string(1) "u"
131string(2) " 1"
132string(2) "1 "
133string(2) "	1"
134string(2) "
1351"
136string(4) "   1"
137string(30) "                             1"
138string(4) "0-9]"
139string(1) "u"
140
141-- Iteration 6 --
142string(1) "1"
143string(1) "u"
144string(1) "1"
145string(1) "u"
146string(2) " 1"
147string(2) "1 "
148string(2) "	1"
149string(2) "
1501"
151string(4) "   1"
152string(30) "                             1"
153string(4) "0-9]"
154string(1) "u"
155
156-- Iteration 7 --
157string(10) "4294967173"
158string(1) "u"
159string(10) "4294967173"
160string(1) "u"
161string(11) " 4294967173"
162string(11) "4294967173 "
163string(11) "	4294967173"
164string(11) "
1654294967173"
166string(10) "4294967173"
167string(30) "                    4294967173"
168string(4) "0-9]"
169string(1) "u"
170
171-- Iteration 8 --
172string(3) "123"
173string(1) "u"
174string(3) "123"
175string(1) "u"
176string(4) " 123"
177string(4) "123 "
178string(4) "	123"
179string(4) "
180123"
181string(4) " 123"
182string(30) "                           123"
183string(4) "0-9]"
184string(1) "u"
185
186-- Iteration 9 --
187string(1) "0"
188string(1) "u"
189string(1) "0"
190string(1) "u"
191string(2) " 0"
192string(2) "0 "
193string(2) "	0"
194string(2) "
1950"
196string(4) "   0"
197string(30) "                             0"
198string(4) "0-9]"
199string(1) "u"
200
201-- Iteration 10 --
202string(1) "0"
203string(1) "u"
204string(1) "0"
205string(1) "u"
206string(2) " 0"
207string(2) "0 "
208string(2) "	0"
209string(2) "
2100"
211string(4) "   0"
212string(30) "                             0"
213string(4) "0-9]"
214string(1) "u"
215
216-- Iteration 11 --
217string(1) "0"
218string(1) "u"
219string(1) "0"
220string(1) "u"
221string(2) " 0"
222string(2) "0 "
223string(2) "	0"
224string(2) "
2250"
226string(4) "   0"
227string(30) "                             0"
228string(4) "0-9]"
229string(1) "u"
230
231-- Iteration 12 --
232string(1) "0"
233string(1) "u"
234string(1) "0"
235string(1) "u"
236string(2) " 0"
237string(2) "0 "
238string(2) "	0"
239string(2) "
2400"
241string(4) "   0"
242string(30) "                             0"
243string(4) "0-9]"
244string(1) "u"
245
246-- Iteration 13 --
247string(1) "0"
248string(1) "u"
249string(1) "0"
250string(1) "u"
251string(2) " 0"
252string(2) "0 "
253string(2) "	0"
254string(2) "
2550"
256string(4) "   0"
257string(30) "                             0"
258string(4) "0-9]"
259string(1) "u"
260
261-- Iteration 14 --
262string(1) "0"
263string(1) "u"
264string(1) "0"
265string(1) "u"
266string(2) " 0"
267string(2) "0 "
268string(2) "	0"
269string(2) "
2700"
271string(4) "   0"
272string(30) "                             0"
273string(4) "0-9]"
274string(1) "u"
275
276-- Iteration 15 --
277string(1) "0"
278string(1) "u"
279string(1) "0"
280string(1) "u"
281string(2) " 0"
282string(2) "0 "
283string(2) "	0"
284string(2) "
2850"
286string(4) "   0"
287string(30) "                             0"
288string(4) "0-9]"
289string(1) "u"
290
291-- Iteration 16 --
292string(1) "0"
293string(1) "u"
294string(1) "0"
295string(1) "u"
296string(2) " 0"
297string(2) "0 "
298string(2) "	0"
299string(2) "
3000"
301string(4) "   0"
302string(30) "                             0"
303string(4) "0-9]"
304string(1) "u"
305
306-- Iteration 17 --
307string(1) "0"
308string(1) "u"
309string(1) "0"
310string(1) "u"
311string(2) " 0"
312string(2) "0 "
313string(2) "	0"
314string(2) "
3150"
316string(4) "   0"
317string(30) "                             0"
318string(4) "0-9]"
319string(1) "u"
320
321-- Iteration 18 --
322string(1) "0"
323string(1) "u"
324string(1) "0"
325string(1) "u"
326string(2) " 0"
327string(2) "0 "
328string(2) "	0"
329string(2) "
3300"
331string(4) "   0"
332string(30) "                             0"
333string(4) "0-9]"
334string(1) "u"
335
336-- Iteration 19 --
337string(1) "0"
338string(1) "u"
339string(1) "0"
340string(1) "u"
341string(2) " 0"
342string(2) "0 "
343string(2) "	0"
344string(2) "
3450"
346string(4) "   0"
347string(30) "                             0"
348string(4) "0-9]"
349string(1) "u"
350
351-- Iteration 20 --
352string(1) "0"
353string(1) "u"
354string(1) "0"
355string(1) "u"
356string(2) " 0"
357string(2) "0 "
358string(2) "	0"
359string(2) "
3600"
361string(4) "   0"
362string(30) "                             0"
363string(4) "0-9]"
364string(1) "u"
365Done
366