Annotation of embedaddon/php/ext/standard/tests/strings/sprintf_variation13.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test sprintf() function : usage variations - float formats with strings
3: --FILE--
4: <?php
5: /* Prototype : string sprintf(string $format [, mixed $arg1 [, mixed ...]])
6: * Description: Return a formatted string
7: * Source code: ext/standard/formatted_print.c
8: */
9:
10: echo "*** Testing sprintf() : float formats with strings ***\n";
11:
12: // array of string type values
13: $string_values = array (
14: "",
15: '',
16: "0",
17: '0',
18: "1",
19: '1',
20: "\x01",
21: '\x01',
22: "\01",
23: '\01',
24: 'string',
25: "string",
26: "true",
27: "FALSE",
28: 'false',
29: 'TRUE',
30: "NULL",
31: 'null',
32: "123.456abc",
33: "+123.456abc"
34: );
35:
36: // various float formats
37: $float_formats = array(
38: "%f", "%hf", "%lf",
39: "%Lf", " %f", "%f ",
40: "\t%f", "\n%f", "%4f",
41: "%30f", "%[0-9]", "%*f"
42: );
43:
44: $count = 1;
45: foreach($string_values as $string_value) {
46: echo "\n-- Iteration $count --\n";
47:
48: foreach($float_formats as $format) {
49: var_dump( sprintf($format, $string_value) );
50: }
51: $count++;
52: };
53:
54: echo "Done";
55: ?>
56: --EXPECTF--
57: *** Testing sprintf() : float formats with strings ***
58:
59: -- Iteration 1 --
60: string(8) "0.000000"
61: string(1) "f"
62: string(8) "0.000000"
63: string(1) "f"
64: string(9) " 0.000000"
65: string(9) "0.000000 "
66: string(9) " 0.000000"
67: string(9) "
68: 0.000000"
69: string(8) "0.000000"
70: string(30) " 0.000000"
71: string(4) "0-9]"
72: string(1) "f"
73:
74: -- Iteration 2 --
75: string(8) "0.000000"
76: string(1) "f"
77: string(8) "0.000000"
78: string(1) "f"
79: string(9) " 0.000000"
80: string(9) "0.000000 "
81: string(9) " 0.000000"
82: string(9) "
83: 0.000000"
84: string(8) "0.000000"
85: string(30) " 0.000000"
86: string(4) "0-9]"
87: string(1) "f"
88:
89: -- Iteration 3 --
90: string(8) "0.000000"
91: string(1) "f"
92: string(8) "0.000000"
93: string(1) "f"
94: string(9) " 0.000000"
95: string(9) "0.000000 "
96: string(9) " 0.000000"
97: string(9) "
98: 0.000000"
99: string(8) "0.000000"
100: string(30) " 0.000000"
101: string(4) "0-9]"
102: string(1) "f"
103:
104: -- Iteration 4 --
105: string(8) "0.000000"
106: string(1) "f"
107: string(8) "0.000000"
108: string(1) "f"
109: string(9) " 0.000000"
110: string(9) "0.000000 "
111: string(9) " 0.000000"
112: string(9) "
113: 0.000000"
114: string(8) "0.000000"
115: string(30) " 0.000000"
116: string(4) "0-9]"
117: string(1) "f"
118:
119: -- Iteration 5 --
120: string(8) "1.000000"
121: string(1) "f"
122: string(8) "1.000000"
123: string(1) "f"
124: string(9) " 1.000000"
125: string(9) "1.000000 "
126: string(9) " 1.000000"
127: string(9) "
128: 1.000000"
129: string(8) "1.000000"
130: string(30) " 1.000000"
131: string(4) "0-9]"
132: string(1) "f"
133:
134: -- Iteration 6 --
135: string(8) "1.000000"
136: string(1) "f"
137: string(8) "1.000000"
138: string(1) "f"
139: string(9) " 1.000000"
140: string(9) "1.000000 "
141: string(9) " 1.000000"
142: string(9) "
143: 1.000000"
144: string(8) "1.000000"
145: string(30) " 1.000000"
146: string(4) "0-9]"
147: string(1) "f"
148:
149: -- Iteration 7 --
150: string(8) "0.000000"
151: string(1) "f"
152: string(8) "0.000000"
153: string(1) "f"
154: string(9) " 0.000000"
155: string(9) "0.000000 "
156: string(9) " 0.000000"
157: string(9) "
158: 0.000000"
159: string(8) "0.000000"
160: string(30) " 0.000000"
161: string(4) "0-9]"
162: string(1) "f"
163:
164: -- Iteration 8 --
165: string(8) "0.000000"
166: string(1) "f"
167: string(8) "0.000000"
168: string(1) "f"
169: string(9) " 0.000000"
170: string(9) "0.000000 "
171: string(9) " 0.000000"
172: string(9) "
173: 0.000000"
174: string(8) "0.000000"
175: string(30) " 0.000000"
176: string(4) "0-9]"
177: string(1) "f"
178:
179: -- Iteration 9 --
180: string(8) "0.000000"
181: string(1) "f"
182: string(8) "0.000000"
183: string(1) "f"
184: string(9) " 0.000000"
185: string(9) "0.000000 "
186: string(9) " 0.000000"
187: string(9) "
188: 0.000000"
189: string(8) "0.000000"
190: string(30) " 0.000000"
191: string(4) "0-9]"
192: string(1) "f"
193:
194: -- Iteration 10 --
195: string(8) "0.000000"
196: string(1) "f"
197: string(8) "0.000000"
198: string(1) "f"
199: string(9) " 0.000000"
200: string(9) "0.000000 "
201: string(9) " 0.000000"
202: string(9) "
203: 0.000000"
204: string(8) "0.000000"
205: string(30) " 0.000000"
206: string(4) "0-9]"
207: string(1) "f"
208:
209: -- Iteration 11 --
210: string(8) "0.000000"
211: string(1) "f"
212: string(8) "0.000000"
213: string(1) "f"
214: string(9) " 0.000000"
215: string(9) "0.000000 "
216: string(9) " 0.000000"
217: string(9) "
218: 0.000000"
219: string(8) "0.000000"
220: string(30) " 0.000000"
221: string(4) "0-9]"
222: string(1) "f"
223:
224: -- Iteration 12 --
225: string(8) "0.000000"
226: string(1) "f"
227: string(8) "0.000000"
228: string(1) "f"
229: string(9) " 0.000000"
230: string(9) "0.000000 "
231: string(9) " 0.000000"
232: string(9) "
233: 0.000000"
234: string(8) "0.000000"
235: string(30) " 0.000000"
236: string(4) "0-9]"
237: string(1) "f"
238:
239: -- Iteration 13 --
240: string(8) "0.000000"
241: string(1) "f"
242: string(8) "0.000000"
243: string(1) "f"
244: string(9) " 0.000000"
245: string(9) "0.000000 "
246: string(9) " 0.000000"
247: string(9) "
248: 0.000000"
249: string(8) "0.000000"
250: string(30) " 0.000000"
251: string(4) "0-9]"
252: string(1) "f"
253:
254: -- Iteration 14 --
255: string(8) "0.000000"
256: string(1) "f"
257: string(8) "0.000000"
258: string(1) "f"
259: string(9) " 0.000000"
260: string(9) "0.000000 "
261: string(9) " 0.000000"
262: string(9) "
263: 0.000000"
264: string(8) "0.000000"
265: string(30) " 0.000000"
266: string(4) "0-9]"
267: string(1) "f"
268:
269: -- Iteration 15 --
270: string(8) "0.000000"
271: string(1) "f"
272: string(8) "0.000000"
273: string(1) "f"
274: string(9) " 0.000000"
275: string(9) "0.000000 "
276: string(9) " 0.000000"
277: string(9) "
278: 0.000000"
279: string(8) "0.000000"
280: string(30) " 0.000000"
281: string(4) "0-9]"
282: string(1) "f"
283:
284: -- Iteration 16 --
285: string(8) "0.000000"
286: string(1) "f"
287: string(8) "0.000000"
288: string(1) "f"
289: string(9) " 0.000000"
290: string(9) "0.000000 "
291: string(9) " 0.000000"
292: string(9) "
293: 0.000000"
294: string(8) "0.000000"
295: string(30) " 0.000000"
296: string(4) "0-9]"
297: string(1) "f"
298:
299: -- Iteration 17 --
300: string(8) "0.000000"
301: string(1) "f"
302: string(8) "0.000000"
303: string(1) "f"
304: string(9) " 0.000000"
305: string(9) "0.000000 "
306: string(9) " 0.000000"
307: string(9) "
308: 0.000000"
309: string(8) "0.000000"
310: string(30) " 0.000000"
311: string(4) "0-9]"
312: string(1) "f"
313:
314: -- Iteration 18 --
315: string(8) "0.000000"
316: string(1) "f"
317: string(8) "0.000000"
318: string(1) "f"
319: string(9) " 0.000000"
320: string(9) "0.000000 "
321: string(9) " 0.000000"
322: string(9) "
323: 0.000000"
324: string(8) "0.000000"
325: string(30) " 0.000000"
326: string(4) "0-9]"
327: string(1) "f"
328:
329: -- Iteration 19 --
330: string(10) "123.456000"
331: string(1) "f"
332: string(10) "123.456000"
333: string(1) "f"
334: string(11) " 123.456000"
335: string(11) "123.456000 "
336: string(11) " 123.456000"
337: string(11) "
338: 123.456000"
339: string(10) "123.456000"
340: string(30) " 123.456000"
341: string(4) "0-9]"
342: string(1) "f"
343:
344: -- Iteration 20 --
345: string(10) "123.456000"
346: string(1) "f"
347: string(10) "123.456000"
348: string(1) "f"
349: string(11) " 123.456000"
350: string(11) "123.456000 "
351: string(11) " 123.456000"
352: string(11) "
353: 123.456000"
354: string(10) "123.456000"
355: string(30) " 123.456000"
356: string(4) "0-9]"
357: string(1) "f"
358: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>