1--TEST--
2Test sprintf() function : usage variations - octal formats with float values
3--SKIPIF--
4<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?>
5--FILE--
6<?php
7/* Prototype  : string sprintf(string $format [, mixed $arg1 [, mixed ...]])
8 * Description: Return a formatted string
9 * Source code: ext/standard/formatted_print.c
10*/
11
12echo "*** Testing sprintf() : octal formats with float values ***\n";
13
14// array of float values
15$float_values = array(
16  0.0,
17  -0.1,
18  1.0,
19  1e5,
20  -1e6,
21  1E8,
22  -1E9,
23  10.5e+5
24);
25
26// array of octal formats
27$octal_formats = array(
28  "%o", "%ho", "%lo",
29  "%Lo", " %o", "%o ",
30  "\t%o", "\n%o", "%4o",
31  "%30o", "%[0-7]", "%*o"
32);
33
34$count = 1;
35foreach($float_values as $float_value) {
36  echo "\n-- Iteration $count --\n";
37
38  foreach($octal_formats as $format) {
39    var_dump( sprintf($format, $float_value) );
40  }
41  $count++;
42};
43
44echo "Done";
45?>
46--EXPECT--
47*** Testing sprintf() : octal formats with float values ***
48
49-- Iteration 1 --
50string(1) "0"
51string(1) "o"
52string(1) "0"
53string(1) "o"
54string(2) " 0"
55string(2) "0 "
56string(2) "	0"
57string(2) "
580"
59string(4) "   0"
60string(30) "                             0"
61string(4) "0-7]"
62string(1) "o"
63
64-- Iteration 2 --
65string(1) "0"
66string(1) "o"
67string(1) "0"
68string(1) "o"
69string(2) " 0"
70string(2) "0 "
71string(2) "	0"
72string(2) "
730"
74string(4) "   0"
75string(30) "                             0"
76string(4) "0-7]"
77string(1) "o"
78
79-- Iteration 3 --
80string(1) "1"
81string(1) "o"
82string(1) "1"
83string(1) "o"
84string(2) " 1"
85string(2) "1 "
86string(2) "	1"
87string(2) "
881"
89string(4) "   1"
90string(30) "                             1"
91string(4) "0-7]"
92string(1) "o"
93
94-- Iteration 4 --
95string(6) "303240"
96string(1) "o"
97string(6) "303240"
98string(1) "o"
99string(7) " 303240"
100string(7) "303240 "
101string(7) "	303240"
102string(7) "
103303240"
104string(6) "303240"
105string(30) "                        303240"
106string(4) "0-7]"
107string(1) "o"
108
109-- Iteration 5 --
110string(22) "1777777777777774136700"
111string(1) "o"
112string(22) "1777777777777774136700"
113string(1) "o"
114string(23) " 1777777777777774136700"
115string(23) "1777777777777774136700 "
116string(23) "	1777777777777774136700"
117string(23) "
1181777777777777774136700"
119string(22) "1777777777777774136700"
120string(30) "        1777777777777774136700"
121string(4) "0-7]"
122string(1) "o"
123
124-- Iteration 6 --
125string(9) "575360400"
126string(1) "o"
127string(9) "575360400"
128string(1) "o"
129string(10) " 575360400"
130string(10) "575360400 "
131string(10) "	575360400"
132string(10) "
133575360400"
134string(9) "575360400"
135string(30) "                     575360400"
136string(4) "0-7]"
137string(1) "o"
138
139-- Iteration 7 --
140string(22) "1777777777770431233000"
141string(1) "o"
142string(22) "1777777777770431233000"
143string(1) "o"
144string(23) " 1777777777770431233000"
145string(23) "1777777777770431233000 "
146string(23) "	1777777777770431233000"
147string(23) "
1481777777777770431233000"
149string(22) "1777777777770431233000"
150string(30) "        1777777777770431233000"
151string(4) "0-7]"
152string(1) "o"
153
154-- Iteration 8 --
155string(7) "4002620"
156string(1) "o"
157string(7) "4002620"
158string(1) "o"
159string(8) " 4002620"
160string(8) "4002620 "
161string(8) "	4002620"
162string(8) "
1634002620"
164string(7) "4002620"
165string(30) "                       4002620"
166string(4) "0-7]"
167string(1) "o"
168Done
169