1--TEST--
2Test sprintf() function : usage variations - octal 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() : octal formats with float values ***\n";
17
18// array of float values
19$float_values = array(
20  0.0,
21  -0.1,
22  1.0,
23  1e5,
24  -1e6,
25  1E8,
26  -1E9,
27  10.5e+5
28);
29
30// array of octal formats
31$octal_formats = array(
32  "%o", "%ho", "%lo",
33  "%Lo", " %o", "%o ",
34  "\t%o", "\n%o", "%4o",
35  "%30o", "%[0-7]", "%*o"
36);
37
38$count = 1;
39foreach($float_values as $float_value) {
40  echo "\n-- Iteration $count --\n";
41
42  foreach($octal_formats as $format) {
43    var_dump( sprintf($format, $float_value) );
44  }
45  $count++;
46};
47
48echo "Done";
49?>
50--EXPECTF--
51*** Testing sprintf() : octal formats with float values ***
52
53-- Iteration 1 --
54string(1) "0"
55string(1) "o"
56string(1) "0"
57string(1) "o"
58string(2) " 0"
59string(2) "0 "
60string(2) "	0"
61string(2) "
620"
63string(4) "   0"
64string(30) "                             0"
65string(4) "0-7]"
66string(1) "o"
67
68-- Iteration 2 --
69string(1) "0"
70string(1) "o"
71string(1) "0"
72string(1) "o"
73string(2) " 0"
74string(2) "0 "
75string(2) "	0"
76string(2) "
770"
78string(4) "   0"
79string(30) "                             0"
80string(4) "0-7]"
81string(1) "o"
82
83-- Iteration 3 --
84string(1) "1"
85string(1) "o"
86string(1) "1"
87string(1) "o"
88string(2) " 1"
89string(2) "1 "
90string(2) "	1"
91string(2) "
921"
93string(4) "   1"
94string(30) "                             1"
95string(4) "0-7]"
96string(1) "o"
97
98-- Iteration 4 --
99string(6) "303240"
100string(1) "o"
101string(6) "303240"
102string(1) "o"
103string(7) " 303240"
104string(7) "303240 "
105string(7) "	303240"
106string(7) "
107303240"
108string(6) "303240"
109string(30) "                        303240"
110string(4) "0-7]"
111string(1) "o"
112
113-- Iteration 5 --
114string(11) "37774136700"
115string(1) "o"
116string(11) "37774136700"
117string(1) "o"
118string(12) " 37774136700"
119string(12) "37774136700 "
120string(12) "	37774136700"
121string(12) "
12237774136700"
123string(11) "37774136700"
124string(30) "                   37774136700"
125string(4) "0-7]"
126string(1) "o"
127
128-- Iteration 6 --
129string(9) "575360400"
130string(1) "o"
131string(9) "575360400"
132string(1) "o"
133string(10) " 575360400"
134string(10) "575360400 "
135string(10) "	575360400"
136string(10) "
137575360400"
138string(9) "575360400"
139string(30) "                     575360400"
140string(4) "0-7]"
141string(1) "o"
142
143-- Iteration 7 --
144string(11) "30431233000"
145string(1) "o"
146string(11) "30431233000"
147string(1) "o"
148string(12) " 30431233000"
149string(12) "30431233000 "
150string(12) "	30431233000"
151string(12) "
15230431233000"
153string(11) "30431233000"
154string(30) "                   30431233000"
155string(4) "0-7]"
156string(1) "o"
157
158-- Iteration 8 --
159string(7) "4002620"
160string(1) "o"
161string(7) "4002620"
162string(1) "o"
163string(8) " 4002620"
164string(8) "4002620 "
165string(8) "	4002620"
166string(8) "
1674002620"
168string(7) "4002620"
169string(30) "                       4002620"
170string(4) "0-7]"
171string(1) "o"
172Done
173