1--TEST--
2Test sprintf() function : usage variations - octal formats with integer 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
11echo "*** Testing sprintf() : octal formats with integer values ***\n";
12
13// array of integer values
14$integer_values = array(
15  0,
16  1,
17  -1,
18  -2147483648, // max negative integer value
19  -2147483647,
20  2147483647,  // max positive integer value
21  2147483640,
22  0x123B,      // integer as hexadecimal
23  0x12ab,
24  0Xfff,
25  0XFA,
26  -0x80000000, // max negative integer as hexadecimal
27  0x7fffffff,  // max positive integer as hexadecimal
28  0x7FFFFFFF,  // max positive integer as hexadecimal
29  0123,        // integer as octal
30  01,       // should be quivalent to octal 1
31  -020000000000, // max negative integer as octal
32  017777777777  // max positive integer as octal
33);
34
35// array of octal formats
36$octal_formats = array(
37  "%o", "%lo", " %o", "%o ",
38  "\t%o", "\n%o", "%4o", "%30o",
39);
40
41$count = 1;
42foreach($integer_values as $integer_value) {
43  echo "\n-- Iteration $count --\n";
44
45  foreach($octal_formats as $format) {
46    var_dump( sprintf($format, $integer_value) );
47  }
48  $count++;
49};
50
51echo "Done";
52?>
53--EXPECT--
54*** Testing sprintf() : octal formats with integer values ***
55
56-- Iteration 1 --
57string(1) "0"
58string(1) "0"
59string(2) " 0"
60string(2) "0 "
61string(2) "	0"
62string(2) "
630"
64string(4) "   0"
65string(30) "                             0"
66
67-- Iteration 2 --
68string(1) "1"
69string(1) "1"
70string(2) " 1"
71string(2) "1 "
72string(2) "	1"
73string(2) "
741"
75string(4) "   1"
76string(30) "                             1"
77
78-- Iteration 3 --
79string(11) "37777777777"
80string(11) "37777777777"
81string(12) " 37777777777"
82string(12) "37777777777 "
83string(12) "	37777777777"
84string(12) "
8537777777777"
86string(11) "37777777777"
87string(30) "                   37777777777"
88
89-- Iteration 4 --
90string(11) "20000000000"
91string(11) "20000000000"
92string(12) " 20000000000"
93string(12) "20000000000 "
94string(12) "	20000000000"
95string(12) "
9620000000000"
97string(11) "20000000000"
98string(30) "                   20000000000"
99
100-- Iteration 5 --
101string(11) "20000000001"
102string(11) "20000000001"
103string(12) " 20000000001"
104string(12) "20000000001 "
105string(12) "	20000000001"
106string(12) "
10720000000001"
108string(11) "20000000001"
109string(30) "                   20000000001"
110
111-- Iteration 6 --
112string(11) "17777777777"
113string(11) "17777777777"
114string(12) " 17777777777"
115string(12) "17777777777 "
116string(12) "	17777777777"
117string(12) "
11817777777777"
119string(11) "17777777777"
120string(30) "                   17777777777"
121
122-- Iteration 7 --
123string(11) "17777777770"
124string(11) "17777777770"
125string(12) " 17777777770"
126string(12) "17777777770 "
127string(12) "	17777777770"
128string(12) "
12917777777770"
130string(11) "17777777770"
131string(30) "                   17777777770"
132
133-- Iteration 8 --
134string(5) "11073"
135string(5) "11073"
136string(6) " 11073"
137string(6) "11073 "
138string(6) "	11073"
139string(6) "
14011073"
141string(5) "11073"
142string(30) "                         11073"
143
144-- Iteration 9 --
145string(5) "11253"
146string(5) "11253"
147string(6) " 11253"
148string(6) "11253 "
149string(6) "	11253"
150string(6) "
15111253"
152string(5) "11253"
153string(30) "                         11253"
154
155-- Iteration 10 --
156string(4) "7777"
157string(4) "7777"
158string(5) " 7777"
159string(5) "7777 "
160string(5) "	7777"
161string(5) "
1627777"
163string(4) "7777"
164string(30) "                          7777"
165
166-- Iteration 11 --
167string(3) "372"
168string(3) "372"
169string(4) " 372"
170string(4) "372 "
171string(4) "	372"
172string(4) "
173372"
174string(4) " 372"
175string(30) "                           372"
176
177-- Iteration 12 --
178string(11) "20000000000"
179string(11) "20000000000"
180string(12) " 20000000000"
181string(12) "20000000000 "
182string(12) "	20000000000"
183string(12) "
18420000000000"
185string(11) "20000000000"
186string(30) "                   20000000000"
187
188-- Iteration 13 --
189string(11) "17777777777"
190string(11) "17777777777"
191string(12) " 17777777777"
192string(12) "17777777777 "
193string(12) "	17777777777"
194string(12) "
19517777777777"
196string(11) "17777777777"
197string(30) "                   17777777777"
198
199-- Iteration 14 --
200string(11) "17777777777"
201string(11) "17777777777"
202string(12) " 17777777777"
203string(12) "17777777777 "
204string(12) "	17777777777"
205string(12) "
20617777777777"
207string(11) "17777777777"
208string(30) "                   17777777777"
209
210-- Iteration 15 --
211string(3) "123"
212string(3) "123"
213string(4) " 123"
214string(4) "123 "
215string(4) "	123"
216string(4) "
217123"
218string(4) " 123"
219string(30) "                           123"
220
221-- Iteration 16 --
222string(1) "1"
223string(1) "1"
224string(2) " 1"
225string(2) "1 "
226string(2) "	1"
227string(2) "
2281"
229string(4) "   1"
230string(30) "                             1"
231
232-- Iteration 17 --
233string(11) "20000000000"
234string(11) "20000000000"
235string(12) " 20000000000"
236string(12) "20000000000 "
237string(12) "	20000000000"
238string(12) "
23920000000000"
240string(11) "20000000000"
241string(30) "                   20000000000"
242
243-- Iteration 18 --
244string(11) "17777777777"
245string(11) "17777777777"
246string(12) " 17777777777"
247string(12) "17777777777 "
248string(12) "	17777777777"
249string(12) "
25017777777777"
251string(11) "17777777777"
252string(30) "                   17777777777"
253Done
254