Annotation of embedaddon/php/ext/standard/tests/strings/sprintf_variation41.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test sprintf() function : usage variations - unsigned formats with float values
3: --SKIPIF--
4: <?php
5: if (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:
16: echo "*** Testing sprintf() : unsigned formats with float values ***\n";
17:
18: // array of float values
19: $float_values = array(
20: 2147483647,
21: 0x800000001, // float value, beyond max positive int
22: 020000000001, // float value, beyond max positive int
23: 0.0,
24: -0.1,
25: 1.0,
26: +1e5,
27: +5e+5,
28: +0e-5,
29: -1e5,
30: -1e+5,
31: -1e-2,
32: 1e5,
33: 1E8,
34: -1E9,
35: 10.0000000000000000005,
36: 10.5e+5
37: );
38:
39: // array of unsigned formats
40: $unsigned_formats = array(
41: "%u", "%hu", "%lu",
42: "%Lu", " %u", "%u ",
43: "\t%u", "\n%u", "%4u",
44: "%30u", "%[0-9]", "%*u"
45: );
46:
47: $count = 1;
48: foreach($float_values as $float_value) {
49: echo "\n-- Iteration $count --\n";
50:
51: foreach($unsigned_formats as $format) {
52: var_dump( sprintf($format, $float_value) );
53: }
54: $count++;
55: };
56:
57: echo "Done";
58: ?>
59: --EXPECTF--
60: *** Testing sprintf() : unsigned formats with float values ***
61:
62: -- Iteration 1 --
63: string(10) "2147483647"
64: string(1) "u"
65: string(10) "2147483647"
66: string(1) "u"
67: string(11) " 2147483647"
68: string(11) "2147483647 "
69: string(11) " 2147483647"
70: string(11) "
71: 2147483647"
72: string(10) "2147483647"
73: string(30) " 2147483647"
74: string(4) "0-9]"
75: string(1) "u"
76:
77: -- Iteration 2 --
78: string(1) "1"
79: string(1) "u"
80: string(1) "1"
81: string(1) "u"
82: string(2) " 1"
83: string(2) "1 "
84: string(2) " 1"
85: string(2) "
86: 1"
87: string(4) " 1"
88: string(30) " 1"
89: string(4) "0-9]"
90: string(1) "u"
91:
92: -- Iteration 3 --
93: string(10) "2147483649"
94: string(1) "u"
95: string(10) "2147483649"
96: string(1) "u"
97: string(11) " 2147483649"
98: string(11) "2147483649 "
99: string(11) " 2147483649"
100: string(11) "
101: 2147483649"
102: string(10) "2147483649"
103: string(30) " 2147483649"
104: string(4) "0-9]"
105: string(1) "u"
106:
107: -- Iteration 4 --
108: string(1) "0"
109: string(1) "u"
110: string(1) "0"
111: string(1) "u"
112: string(2) " 0"
113: string(2) "0 "
114: string(2) " 0"
115: string(2) "
116: 0"
117: string(4) " 0"
118: string(30) " 0"
119: string(4) "0-9]"
120: string(1) "u"
121:
122: -- Iteration 5 --
123: string(1) "0"
124: string(1) "u"
125: string(1) "0"
126: string(1) "u"
127: string(2) " 0"
128: string(2) "0 "
129: string(2) " 0"
130: string(2) "
131: 0"
132: string(4) " 0"
133: string(30) " 0"
134: string(4) "0-9]"
135: string(1) "u"
136:
137: -- Iteration 6 --
138: string(1) "1"
139: string(1) "u"
140: string(1) "1"
141: string(1) "u"
142: string(2) " 1"
143: string(2) "1 "
144: string(2) " 1"
145: string(2) "
146: 1"
147: string(4) " 1"
148: string(30) " 1"
149: string(4) "0-9]"
150: string(1) "u"
151:
152: -- Iteration 7 --
153: string(6) "100000"
154: string(1) "u"
155: string(6) "100000"
156: string(1) "u"
157: string(7) " 100000"
158: string(7) "100000 "
159: string(7) " 100000"
160: string(7) "
161: 100000"
162: string(6) "100000"
163: string(30) " 100000"
164: string(4) "0-9]"
165: string(1) "u"
166:
167: -- Iteration 8 --
168: string(6) "500000"
169: string(1) "u"
170: string(6) "500000"
171: string(1) "u"
172: string(7) " 500000"
173: string(7) "500000 "
174: string(7) " 500000"
175: string(7) "
176: 500000"
177: string(6) "500000"
178: string(30) " 500000"
179: string(4) "0-9]"
180: string(1) "u"
181:
182: -- Iteration 9 --
183: string(1) "0"
184: string(1) "u"
185: string(1) "0"
186: string(1) "u"
187: string(2) " 0"
188: string(2) "0 "
189: string(2) " 0"
190: string(2) "
191: 0"
192: string(4) " 0"
193: string(30) " 0"
194: string(4) "0-9]"
195: string(1) "u"
196:
197: -- Iteration 10 --
198: string(10) "4294867296"
199: string(1) "u"
200: string(10) "4294867296"
201: string(1) "u"
202: string(11) " 4294867296"
203: string(11) "4294867296 "
204: string(11) " 4294867296"
205: string(11) "
206: 4294867296"
207: string(10) "4294867296"
208: string(30) " 4294867296"
209: string(4) "0-9]"
210: string(1) "u"
211:
212: -- Iteration 11 --
213: string(10) "4294867296"
214: string(1) "u"
215: string(10) "4294867296"
216: string(1) "u"
217: string(11) " 4294867296"
218: string(11) "4294867296 "
219: string(11) " 4294867296"
220: string(11) "
221: 4294867296"
222: string(10) "4294867296"
223: string(30) " 4294867296"
224: string(4) "0-9]"
225: string(1) "u"
226:
227: -- Iteration 12 --
228: string(1) "0"
229: string(1) "u"
230: string(1) "0"
231: string(1) "u"
232: string(2) " 0"
233: string(2) "0 "
234: string(2) " 0"
235: string(2) "
236: 0"
237: string(4) " 0"
238: string(30) " 0"
239: string(4) "0-9]"
240: string(1) "u"
241:
242: -- Iteration 13 --
243: string(6) "100000"
244: string(1) "u"
245: string(6) "100000"
246: string(1) "u"
247: string(7) " 100000"
248: string(7) "100000 "
249: string(7) " 100000"
250: string(7) "
251: 100000"
252: string(6) "100000"
253: string(30) " 100000"
254: string(4) "0-9]"
255: string(1) "u"
256:
257: -- Iteration 14 --
258: string(9) "100000000"
259: string(1) "u"
260: string(9) "100000000"
261: string(1) "u"
262: string(10) " 100000000"
263: string(10) "100000000 "
264: string(10) " 100000000"
265: string(10) "
266: 100000000"
267: string(9) "100000000"
268: string(30) " 100000000"
269: string(4) "0-9]"
270: string(1) "u"
271:
272: -- Iteration 15 --
273: string(10) "3294967296"
274: string(1) "u"
275: string(10) "3294967296"
276: string(1) "u"
277: string(11) " 3294967296"
278: string(11) "3294967296 "
279: string(11) " 3294967296"
280: string(11) "
281: 3294967296"
282: string(10) "3294967296"
283: string(30) " 3294967296"
284: string(4) "0-9]"
285: string(1) "u"
286:
287: -- Iteration 16 --
288: string(2) "10"
289: string(1) "u"
290: string(2) "10"
291: string(1) "u"
292: string(3) " 10"
293: string(3) "10 "
294: string(3) " 10"
295: string(3) "
296: 10"
297: string(4) " 10"
298: string(30) " 10"
299: string(4) "0-9]"
300: string(1) "u"
301:
302: -- Iteration 17 --
303: string(7) "1050000"
304: string(1) "u"
305: string(7) "1050000"
306: string(1) "u"
307: string(8) " 1050000"
308: string(8) "1050000 "
309: string(8) " 1050000"
310: string(8) "
311: 1050000"
312: string(7) "1050000"
313: string(30) " 1050000"
314: string(4) "0-9]"
315: string(1) "u"
316: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>