Annotation of embedaddon/php/ext/standard/tests/strings/sprintf_variation44_64bit.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test sprintf() function : usage variations - unsigned formats with string 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() : unsigned formats with string values ***\n";
13:
14: // array of string values
15: $string_values = array(
16: "",
17: '',
18: "0",
19: '0',
20: "1",
21: '1',
22: "-123",
23: "+123",
24: "\x01",
25: '\x01',
26: "\01",
27: '\01',
28: 'string',
29: "string",
30: "true",
31: "FALSE",
32: 'false',
33: 'TRUE',
34: "NULL",
35: 'null'
36: );
37:
38: // array of unsigned formats
39: $unsigned_formats = array(
40: "%u", "%hu", "%lu",
41: "%Lu", " %u", "%u ",
42: "\t%u", "\n%u", "%4u",
43: "%30u", "%[0-9]", "%*u"
44: );
45:
46:
47: $count = 1;
48: foreach($string_values as $string_value) {
49: echo "\n-- Iteration $count --\n";
50:
51: foreach($unsigned_formats as $format) {
52: var_dump( sprintf($format, $string_value) );
53: }
54: $count++;
55: };
56:
57: echo "Done";
58: ?>
59: --EXPECTF--
60: *** Testing sprintf() : unsigned formats with string values ***
61:
62: -- Iteration 1 --
63: string(1) "0"
64: string(1) "u"
65: string(1) "0"
66: string(1) "u"
67: string(2) " 0"
68: string(2) "0 "
69: string(2) " 0"
70: string(2) "
71: 0"
72: string(4) " 0"
73: string(30) " 0"
74: string(4) "0-9]"
75: string(1) "u"
76:
77: -- Iteration 2 --
78: string(1) "0"
79: string(1) "u"
80: string(1) "0"
81: string(1) "u"
82: string(2) " 0"
83: string(2) "0 "
84: string(2) " 0"
85: string(2) "
86: 0"
87: string(4) " 0"
88: string(30) " 0"
89: string(4) "0-9]"
90: string(1) "u"
91:
92: -- Iteration 3 --
93: string(1) "0"
94: string(1) "u"
95: string(1) "0"
96: string(1) "u"
97: string(2) " 0"
98: string(2) "0 "
99: string(2) " 0"
100: string(2) "
101: 0"
102: string(4) " 0"
103: string(30) " 0"
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) "1"
124: string(1) "u"
125: string(1) "1"
126: string(1) "u"
127: string(2) " 1"
128: string(2) "1 "
129: string(2) " 1"
130: string(2) "
131: 1"
132: string(4) " 1"
133: string(30) " 1"
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(20) "18446744073709551493"
154: string(1) "u"
155: string(20) "18446744073709551493"
156: string(1) "u"
157: string(21) " 18446744073709551493"
158: string(21) "18446744073709551493 "
159: string(21) " 18446744073709551493"
160: string(21) "
161: 18446744073709551493"
162: string(20) "18446744073709551493"
163: string(30) " 18446744073709551493"
164: string(4) "0-9]"
165: string(1) "u"
166:
167: -- Iteration 8 --
168: string(3) "123"
169: string(1) "u"
170: string(3) "123"
171: string(1) "u"
172: string(4) " 123"
173: string(4) "123 "
174: string(4) " 123"
175: string(4) "
176: 123"
177: string(4) " 123"
178: string(30) " 123"
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(1) "0"
199: string(1) "u"
200: string(1) "0"
201: string(1) "u"
202: string(2) " 0"
203: string(2) "0 "
204: string(2) " 0"
205: string(2) "
206: 0"
207: string(4) " 0"
208: string(30) " 0"
209: string(4) "0-9]"
210: string(1) "u"
211:
212: -- Iteration 11 --
213: string(1) "0"
214: string(1) "u"
215: string(1) "0"
216: string(1) "u"
217: string(2) " 0"
218: string(2) "0 "
219: string(2) " 0"
220: string(2) "
221: 0"
222: string(4) " 0"
223: string(30) " 0"
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(1) "0"
244: string(1) "u"
245: string(1) "0"
246: string(1) "u"
247: string(2) " 0"
248: string(2) "0 "
249: string(2) " 0"
250: string(2) "
251: 0"
252: string(4) " 0"
253: string(30) " 0"
254: string(4) "0-9]"
255: string(1) "u"
256:
257: -- Iteration 14 --
258: string(1) "0"
259: string(1) "u"
260: string(1) "0"
261: string(1) "u"
262: string(2) " 0"
263: string(2) "0 "
264: string(2) " 0"
265: string(2) "
266: 0"
267: string(4) " 0"
268: string(30) " 0"
269: string(4) "0-9]"
270: string(1) "u"
271:
272: -- Iteration 15 --
273: string(1) "0"
274: string(1) "u"
275: string(1) "0"
276: string(1) "u"
277: string(2) " 0"
278: string(2) "0 "
279: string(2) " 0"
280: string(2) "
281: 0"
282: string(4) " 0"
283: string(30) " 0"
284: string(4) "0-9]"
285: string(1) "u"
286:
287: -- Iteration 16 --
288: string(1) "0"
289: string(1) "u"
290: string(1) "0"
291: string(1) "u"
292: string(2) " 0"
293: string(2) "0 "
294: string(2) " 0"
295: string(2) "
296: 0"
297: string(4) " 0"
298: string(30) " 0"
299: string(4) "0-9]"
300: string(1) "u"
301:
302: -- Iteration 17 --
303: string(1) "0"
304: string(1) "u"
305: string(1) "0"
306: string(1) "u"
307: string(2) " 0"
308: string(2) "0 "
309: string(2) " 0"
310: string(2) "
311: 0"
312: string(4) " 0"
313: string(30) " 0"
314: string(4) "0-9]"
315: string(1) "u"
316:
317: -- Iteration 18 --
318: string(1) "0"
319: string(1) "u"
320: string(1) "0"
321: string(1) "u"
322: string(2) " 0"
323: string(2) "0 "
324: string(2) " 0"
325: string(2) "
326: 0"
327: string(4) " 0"
328: string(30) " 0"
329: string(4) "0-9]"
330: string(1) "u"
331:
332: -- Iteration 19 --
333: string(1) "0"
334: string(1) "u"
335: string(1) "0"
336: string(1) "u"
337: string(2) " 0"
338: string(2) "0 "
339: string(2) " 0"
340: string(2) "
341: 0"
342: string(4) " 0"
343: string(30) " 0"
344: string(4) "0-9]"
345: string(1) "u"
346:
347: -- Iteration 20 --
348: string(1) "0"
349: string(1) "u"
350: string(1) "0"
351: string(1) "u"
352: string(2) " 0"
353: string(2) "0 "
354: string(2) " 0"
355: string(2) "
356: 0"
357: string(4) " 0"
358: string(30) " 0"
359: string(4) "0-9]"
360: string(1) "u"
361: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>