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