Annotation of embedaddon/php/ext/standard/tests/strings/sprintf_variation35_64bit.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test sprintf() function : usage variations - hexa 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() : hexa formats with float values ***\n";
13:
14: // array of float values
15: $float_values = array(
16: 2147483647,
17: 0x800000001, // float value, beyond max positive int
18: 020000000001, // float value, beyond max positive int
19: 0.0,
20: -0.1,
21: 1.0,
22: 1e5,
23: -1e6,
24: 1E8,
25: -1E9,
26: 10.0000000000000000005,
27: 10.5e+5
28: );
29:
30: // array of hexa formats
31: $hexa_formats = array(
32: "%x", "%xx", "%lx",
33: "%Lx", " %x", "%x ",
34: "\t%x", "\n%x", "%4x",
35: "%30x", "%[0-9A-Fa-f]", "%*x"
36: );
37:
38: $count = 1;
39: foreach($float_values as $float_value) {
40: echo "\n-- Iteration $count --\n";
41:
42: foreach($hexa_formats as $format) {
43: // with two arguments
44: var_dump( sprintf($format, $float_value) );
45: }
46: $count++;
47: };
48:
49: echo "Done";
50: ?>
51: --EXPECTF--
52: *** Testing sprintf() : hexa formats with float values ***
53:
54: -- Iteration 1 --
55: string(8) "7fffffff"
56: string(9) "7fffffffx"
57: string(8) "7fffffff"
58: string(1) "x"
59: string(9) " 7fffffff"
60: string(9) "7fffffff "
61: string(9) " 7fffffff"
62: string(9) "
63: 7fffffff"
64: string(8) "7fffffff"
65: string(30) " 7fffffff"
66: string(10) "0-9A-Fa-f]"
67: string(1) "x"
68:
69: -- Iteration 2 --
70: string(9) "800000001"
71: string(10) "800000001x"
72: string(9) "800000001"
73: string(1) "x"
74: string(10) " 800000001"
75: string(10) "800000001 "
76: string(10) " 800000001"
77: string(10) "
78: 800000001"
79: string(9) "800000001"
80: string(30) " 800000001"
81: string(10) "0-9A-Fa-f]"
82: string(1) "x"
83:
84: -- Iteration 3 --
85: string(8) "80000001"
86: string(9) "80000001x"
87: string(8) "80000001"
88: string(1) "x"
89: string(9) " 80000001"
90: string(9) "80000001 "
91: string(9) " 80000001"
92: string(9) "
93: 80000001"
94: string(8) "80000001"
95: string(30) " 80000001"
96: string(10) "0-9A-Fa-f]"
97: string(1) "x"
98:
99: -- Iteration 4 --
100: string(1) "0"
101: string(2) "0x"
102: string(1) "0"
103: string(1) "x"
104: string(2) " 0"
105: string(2) "0 "
106: string(2) " 0"
107: string(2) "
108: 0"
109: string(4) " 0"
110: string(30) " 0"
111: string(10) "0-9A-Fa-f]"
112: string(1) "x"
113:
114: -- Iteration 5 --
115: string(1) "0"
116: string(2) "0x"
117: string(1) "0"
118: string(1) "x"
119: string(2) " 0"
120: string(2) "0 "
121: string(2) " 0"
122: string(2) "
123: 0"
124: string(4) " 0"
125: string(30) " 0"
126: string(10) "0-9A-Fa-f]"
127: string(1) "x"
128:
129: -- Iteration 6 --
130: string(1) "1"
131: string(2) "1x"
132: string(1) "1"
133: string(1) "x"
134: string(2) " 1"
135: string(2) "1 "
136: string(2) " 1"
137: string(2) "
138: 1"
139: string(4) " 1"
140: string(30) " 1"
141: string(10) "0-9A-Fa-f]"
142: string(1) "x"
143:
144: -- Iteration 7 --
145: string(5) "186a0"
146: string(6) "186a0x"
147: string(5) "186a0"
148: string(1) "x"
149: string(6) " 186a0"
150: string(6) "186a0 "
151: string(6) " 186a0"
152: string(6) "
153: 186a0"
154: string(5) "186a0"
155: string(30) " 186a0"
156: string(10) "0-9A-Fa-f]"
157: string(1) "x"
158:
159: -- Iteration 8 --
160: string(16) "fffffffffff0bdc0"
161: string(17) "fffffffffff0bdc0x"
162: string(16) "fffffffffff0bdc0"
163: string(1) "x"
164: string(17) " fffffffffff0bdc0"
165: string(17) "fffffffffff0bdc0 "
166: string(17) " fffffffffff0bdc0"
167: string(17) "
168: fffffffffff0bdc0"
169: string(16) "fffffffffff0bdc0"
170: string(30) " fffffffffff0bdc0"
171: string(10) "0-9A-Fa-f]"
172: string(1) "x"
173:
174: -- Iteration 9 --
175: string(7) "5f5e100"
176: string(8) "5f5e100x"
177: string(7) "5f5e100"
178: string(1) "x"
179: string(8) " 5f5e100"
180: string(8) "5f5e100 "
181: string(8) " 5f5e100"
182: string(8) "
183: 5f5e100"
184: string(7) "5f5e100"
185: string(30) " 5f5e100"
186: string(10) "0-9A-Fa-f]"
187: string(1) "x"
188:
189: -- Iteration 10 --
190: string(16) "ffffffffc4653600"
191: string(17) "ffffffffc4653600x"
192: string(16) "ffffffffc4653600"
193: string(1) "x"
194: string(17) " ffffffffc4653600"
195: string(17) "ffffffffc4653600 "
196: string(17) " ffffffffc4653600"
197: string(17) "
198: ffffffffc4653600"
199: string(16) "ffffffffc4653600"
200: string(30) " ffffffffc4653600"
201: string(10) "0-9A-Fa-f]"
202: string(1) "x"
203:
204: -- Iteration 11 --
205: string(1) "a"
206: string(2) "ax"
207: string(1) "a"
208: string(1) "x"
209: string(2) " a"
210: string(2) "a "
211: string(2) " a"
212: string(2) "
213: a"
214: string(4) " a"
215: string(30) " a"
216: string(10) "0-9A-Fa-f]"
217: string(1) "x"
218:
219: -- Iteration 12 --
220: string(6) "100590"
221: string(7) "100590x"
222: string(6) "100590"
223: string(1) "x"
224: string(7) " 100590"
225: string(7) "100590 "
226: string(7) " 100590"
227: string(7) "
228: 100590"
229: string(6) "100590"
230: string(30) " 100590"
231: string(10) "0-9A-Fa-f]"
232: string(1) "x"
233: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>