1--TEST--
2Test sprintf() function : usage variations - unsigned formats with integer values
3--SKIPIF--
4<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?>
5--FILE--
6<?php
7echo "*** Testing sprintf() : unsigned formats with integer values ***\n";
8
9// array of integer values
10$integer_values = array(
11  0,
12  1,
13  -1,
14  -2147483648, // max negative integer value
15  -2147483647,
16  2147483647,  // max positive integer value
17  +2147483640,
18  0x123B,      // integer as hexadecimal
19  0x12ab,
20  0Xfff,
21  0XFA,
22  -0x80000000, // max negative integer as hexadecimal
23  0x7fffffff,  // max positive integer as hexadecimal
24  0x7FFFFFFF,  // max positive integer as hexadecimal
25  0123,        // integer as octal
26  01,       // should be quivalent to octal 1
27  -020000000000, // max negative integer as octal
28  017777777777  // max positive integer as octal
29);
30
31// array of unsigned formats
32$unsigned_formats = array(
33  "%u", "%lu", " %u", "%u ",
34  "\t%u", "\n%u", "%4u", "%30u",
35);
36
37
38$count = 1;
39foreach($integer_values as $integer_value) {
40  echo "\n-- Iteration $count --\n";
41
42  foreach($unsigned_formats as $format) {
43    var_dump( sprintf($format, $integer_value) );
44  }
45  $count++;
46};
47
48echo "Done";
49?>
50--EXPECT--
51*** Testing sprintf() : unsigned formats with integer values ***
52
53-- Iteration 1 --
54string(1) "0"
55string(1) "0"
56string(2) " 0"
57string(2) "0 "
58string(2) "	0"
59string(2) "
600"
61string(4) "   0"
62string(30) "                             0"
63
64-- Iteration 2 --
65string(1) "1"
66string(1) "1"
67string(2) " 1"
68string(2) "1 "
69string(2) "	1"
70string(2) "
711"
72string(4) "   1"
73string(30) "                             1"
74
75-- Iteration 3 --
76string(20) "18446744073709551615"
77string(20) "18446744073709551615"
78string(21) " 18446744073709551615"
79string(21) "18446744073709551615 "
80string(21) "	18446744073709551615"
81string(21) "
8218446744073709551615"
83string(20) "18446744073709551615"
84string(30) "          18446744073709551615"
85
86-- Iteration 4 --
87string(20) "18446744071562067968"
88string(20) "18446744071562067968"
89string(21) " 18446744071562067968"
90string(21) "18446744071562067968 "
91string(21) "	18446744071562067968"
92string(21) "
9318446744071562067968"
94string(20) "18446744071562067968"
95string(30) "          18446744071562067968"
96
97-- Iteration 5 --
98string(20) "18446744071562067969"
99string(20) "18446744071562067969"
100string(21) " 18446744071562067969"
101string(21) "18446744071562067969 "
102string(21) "	18446744071562067969"
103string(21) "
10418446744071562067969"
105string(20) "18446744071562067969"
106string(30) "          18446744071562067969"
107
108-- Iteration 6 --
109string(10) "2147483647"
110string(10) "2147483647"
111string(11) " 2147483647"
112string(11) "2147483647 "
113string(11) "	2147483647"
114string(11) "
1152147483647"
116string(10) "2147483647"
117string(30) "                    2147483647"
118
119-- Iteration 7 --
120string(10) "2147483640"
121string(10) "2147483640"
122string(11) " 2147483640"
123string(11) "2147483640 "
124string(11) "	2147483640"
125string(11) "
1262147483640"
127string(10) "2147483640"
128string(30) "                    2147483640"
129
130-- Iteration 8 --
131string(4) "4667"
132string(4) "4667"
133string(5) " 4667"
134string(5) "4667 "
135string(5) "	4667"
136string(5) "
1374667"
138string(4) "4667"
139string(30) "                          4667"
140
141-- Iteration 9 --
142string(4) "4779"
143string(4) "4779"
144string(5) " 4779"
145string(5) "4779 "
146string(5) "	4779"
147string(5) "
1484779"
149string(4) "4779"
150string(30) "                          4779"
151
152-- Iteration 10 --
153string(4) "4095"
154string(4) "4095"
155string(5) " 4095"
156string(5) "4095 "
157string(5) "	4095"
158string(5) "
1594095"
160string(4) "4095"
161string(30) "                          4095"
162
163-- Iteration 11 --
164string(3) "250"
165string(3) "250"
166string(4) " 250"
167string(4) "250 "
168string(4) "	250"
169string(4) "
170250"
171string(4) " 250"
172string(30) "                           250"
173
174-- Iteration 12 --
175string(20) "18446744071562067968"
176string(20) "18446744071562067968"
177string(21) " 18446744071562067968"
178string(21) "18446744071562067968 "
179string(21) "	18446744071562067968"
180string(21) "
18118446744071562067968"
182string(20) "18446744071562067968"
183string(30) "          18446744071562067968"
184
185-- Iteration 13 --
186string(10) "2147483647"
187string(10) "2147483647"
188string(11) " 2147483647"
189string(11) "2147483647 "
190string(11) "	2147483647"
191string(11) "
1922147483647"
193string(10) "2147483647"
194string(30) "                    2147483647"
195
196-- Iteration 14 --
197string(10) "2147483647"
198string(10) "2147483647"
199string(11) " 2147483647"
200string(11) "2147483647 "
201string(11) "	2147483647"
202string(11) "
2032147483647"
204string(10) "2147483647"
205string(30) "                    2147483647"
206
207-- Iteration 15 --
208string(2) "83"
209string(2) "83"
210string(3) " 83"
211string(3) "83 "
212string(3) "	83"
213string(3) "
21483"
215string(4) "  83"
216string(30) "                            83"
217
218-- Iteration 16 --
219string(1) "1"
220string(1) "1"
221string(2) " 1"
222string(2) "1 "
223string(2) "	1"
224string(2) "
2251"
226string(4) "   1"
227string(30) "                             1"
228
229-- Iteration 17 --
230string(20) "18446744071562067968"
231string(20) "18446744071562067968"
232string(21) " 18446744071562067968"
233string(21) "18446744071562067968 "
234string(21) "	18446744071562067968"
235string(21) "
23618446744071562067968"
237string(20) "18446744071562067968"
238string(30) "          18446744071562067968"
239
240-- Iteration 18 --
241string(10) "2147483647"
242string(10) "2147483647"
243string(11) " 2147483647"
244string(11) "2147483647 "
245string(11) "	2147483647"
246string(11) "
2472147483647"
248string(10) "2147483647"
249string(30) "                    2147483647"
250Done
251