Annotation of embedaddon/php/ext/standard/tests/strings/sprintf_variation29_64bit.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test 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:
12: echo "*** 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;
35: foreach($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:
44: echo "Done";
45: ?>
46: --EXPECTF--
47: *** Testing sprintf() : octal formats with float values ***
48:
49: -- Iteration 1 --
50: string(1) "0"
51: string(1) "o"
52: string(1) "0"
53: string(1) "o"
54: string(2) " 0"
55: string(2) "0 "
56: string(2) " 0"
57: string(2) "
58: 0"
59: string(4) " 0"
60: string(30) " 0"
61: string(4) "0-7]"
62: string(1) "o"
63:
64: -- Iteration 2 --
65: string(1) "0"
66: string(1) "o"
67: string(1) "0"
68: string(1) "o"
69: string(2) " 0"
70: string(2) "0 "
71: string(2) " 0"
72: string(2) "
73: 0"
74: string(4) " 0"
75: string(30) " 0"
76: string(4) "0-7]"
77: string(1) "o"
78:
79: -- Iteration 3 --
80: string(1) "1"
81: string(1) "o"
82: string(1) "1"
83: string(1) "o"
84: string(2) " 1"
85: string(2) "1 "
86: string(2) " 1"
87: string(2) "
88: 1"
89: string(4) " 1"
90: string(30) " 1"
91: string(4) "0-7]"
92: string(1) "o"
93:
94: -- Iteration 4 --
95: string(6) "303240"
96: string(1) "o"
97: string(6) "303240"
98: string(1) "o"
99: string(7) " 303240"
100: string(7) "303240 "
101: string(7) " 303240"
102: string(7) "
103: 303240"
104: string(6) "303240"
105: string(30) " 303240"
106: string(4) "0-7]"
107: string(1) "o"
108:
109: -- Iteration 5 --
110: string(22) "1777777777777774136700"
111: string(1) "o"
112: string(22) "1777777777777774136700"
113: string(1) "o"
114: string(23) " 1777777777777774136700"
115: string(23) "1777777777777774136700 "
116: string(23) " 1777777777777774136700"
117: string(23) "
118: 1777777777777774136700"
119: string(22) "1777777777777774136700"
120: string(30) " 1777777777777774136700"
121: string(4) "0-7]"
122: string(1) "o"
123:
124: -- Iteration 6 --
125: string(9) "575360400"
126: string(1) "o"
127: string(9) "575360400"
128: string(1) "o"
129: string(10) " 575360400"
130: string(10) "575360400 "
131: string(10) " 575360400"
132: string(10) "
133: 575360400"
134: string(9) "575360400"
135: string(30) " 575360400"
136: string(4) "0-7]"
137: string(1) "o"
138:
139: -- Iteration 7 --
140: string(22) "1777777777770431233000"
141: string(1) "o"
142: string(22) "1777777777770431233000"
143: string(1) "o"
144: string(23) " 1777777777770431233000"
145: string(23) "1777777777770431233000 "
146: string(23) " 1777777777770431233000"
147: string(23) "
148: 1777777777770431233000"
149: string(22) "1777777777770431233000"
150: string(30) " 1777777777770431233000"
151: string(4) "0-7]"
152: string(1) "o"
153:
154: -- Iteration 8 --
155: string(7) "4002620"
156: string(1) "o"
157: string(7) "4002620"
158: string(1) "o"
159: string(8) " 4002620"
160: string(8) "4002620 "
161: string(8) " 4002620"
162: string(8) "
163: 4002620"
164: string(7) "4002620"
165: string(30) " 4002620"
166: string(4) "0-7]"
167: string(1) "o"
168: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>