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