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