Annotation of embedaddon/php/ext/standard/tests/strings/sprintf_variation49.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test sprintf() function : usage variations - scientific formats with array 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 array values ***\n";
11:
12: // array of array values
13: $array_values = array(
14: array(),
15: array(0),
16: array(1),
17: array(100000000000),
18: array(.0000001),
19: array(10e2),
20: array(NULL),
21: array(null),
22: array("string"),
23: array(true),
24: array(TRUE),
25: array(false),
26: array(FALSE),
27: array(1,2,3,4),
28: array(1 => "One", "two" => 2)
29: );
30:
31: // array of scientific formats
32: $scientific_formats = array(
33: "%e", "%he", "%le",
34: "%Le", " %e", "%e ",
35: "\t%e", "\n%e", "%4e",
36: "%30e", "%[0-1]", "%*e"
37: );
38:
39: $count = 1;
40: foreach($array_values as $array_value) {
41: echo "\n-- Iteration $count --\n";
42:
43: foreach($scientific_formats as $format) {
44: var_dump( sprintf($format, $array_value) );
45: }
46: $count++;
47: };
48:
49: echo "Done";
50: ?>
51: --EXPECTF--
52: *** Testing sprintf() : scientific formats with array values ***
53:
54: -- Iteration 1 --
55: string(11) "0.000000e+0"
56: string(1) "e"
57: string(11) "0.000000e+0"
58: string(1) "e"
59: string(12) " 0.000000e+0"
60: string(12) "0.000000e+0 "
61: string(12) " 0.000000e+0"
62: string(12) "
63: 0.000000e+0"
64: string(11) "0.000000e+0"
65: string(30) " 0.000000e+0"
66: string(4) "0-1]"
67: string(1) "e"
68:
69: -- Iteration 2 --
70: string(11) "1.000000e+0"
71: string(1) "e"
72: string(11) "1.000000e+0"
73: string(1) "e"
74: string(12) " 1.000000e+0"
75: string(12) "1.000000e+0 "
76: string(12) " 1.000000e+0"
77: string(12) "
78: 1.000000e+0"
79: string(11) "1.000000e+0"
80: string(30) " 1.000000e+0"
81: string(4) "0-1]"
82: string(1) "e"
83:
84: -- Iteration 3 --
85: string(11) "1.000000e+0"
86: string(1) "e"
87: string(11) "1.000000e+0"
88: string(1) "e"
89: string(12) " 1.000000e+0"
90: string(12) "1.000000e+0 "
91: string(12) " 1.000000e+0"
92: string(12) "
93: 1.000000e+0"
94: string(11) "1.000000e+0"
95: string(30) " 1.000000e+0"
96: string(4) "0-1]"
97: string(1) "e"
98:
99: -- Iteration 4 --
100: string(11) "1.000000e+0"
101: string(1) "e"
102: string(11) "1.000000e+0"
103: string(1) "e"
104: string(12) " 1.000000e+0"
105: string(12) "1.000000e+0 "
106: string(12) " 1.000000e+0"
107: string(12) "
108: 1.000000e+0"
109: string(11) "1.000000e+0"
110: string(30) " 1.000000e+0"
111: string(4) "0-1]"
112: string(1) "e"
113:
114: -- Iteration 5 --
115: string(11) "1.000000e+0"
116: string(1) "e"
117: string(11) "1.000000e+0"
118: string(1) "e"
119: string(12) " 1.000000e+0"
120: string(12) "1.000000e+0 "
121: string(12) " 1.000000e+0"
122: string(12) "
123: 1.000000e+0"
124: string(11) "1.000000e+0"
125: string(30) " 1.000000e+0"
126: string(4) "0-1]"
127: string(1) "e"
128:
129: -- Iteration 6 --
130: string(11) "1.000000e+0"
131: string(1) "e"
132: string(11) "1.000000e+0"
133: string(1) "e"
134: string(12) " 1.000000e+0"
135: string(12) "1.000000e+0 "
136: string(12) " 1.000000e+0"
137: string(12) "
138: 1.000000e+0"
139: string(11) "1.000000e+0"
140: string(30) " 1.000000e+0"
141: string(4) "0-1]"
142: string(1) "e"
143:
144: -- Iteration 7 --
145: string(11) "1.000000e+0"
146: string(1) "e"
147: string(11) "1.000000e+0"
148: string(1) "e"
149: string(12) " 1.000000e+0"
150: string(12) "1.000000e+0 "
151: string(12) " 1.000000e+0"
152: string(12) "
153: 1.000000e+0"
154: string(11) "1.000000e+0"
155: string(30) " 1.000000e+0"
156: string(4) "0-1]"
157: string(1) "e"
158:
159: -- Iteration 8 --
160: string(11) "1.000000e+0"
161: string(1) "e"
162: string(11) "1.000000e+0"
163: string(1) "e"
164: string(12) " 1.000000e+0"
165: string(12) "1.000000e+0 "
166: string(12) " 1.000000e+0"
167: string(12) "
168: 1.000000e+0"
169: string(11) "1.000000e+0"
170: string(30) " 1.000000e+0"
171: string(4) "0-1]"
172: string(1) "e"
173:
174: -- Iteration 9 --
175: string(11) "1.000000e+0"
176: string(1) "e"
177: string(11) "1.000000e+0"
178: string(1) "e"
179: string(12) " 1.000000e+0"
180: string(12) "1.000000e+0 "
181: string(12) " 1.000000e+0"
182: string(12) "
183: 1.000000e+0"
184: string(11) "1.000000e+0"
185: string(30) " 1.000000e+0"
186: string(4) "0-1]"
187: string(1) "e"
188:
189: -- Iteration 10 --
190: string(11) "1.000000e+0"
191: string(1) "e"
192: string(11) "1.000000e+0"
193: string(1) "e"
194: string(12) " 1.000000e+0"
195: string(12) "1.000000e+0 "
196: string(12) " 1.000000e+0"
197: string(12) "
198: 1.000000e+0"
199: string(11) "1.000000e+0"
200: string(30) " 1.000000e+0"
201: string(4) "0-1]"
202: string(1) "e"
203:
204: -- Iteration 11 --
205: string(11) "1.000000e+0"
206: string(1) "e"
207: string(11) "1.000000e+0"
208: string(1) "e"
209: string(12) " 1.000000e+0"
210: string(12) "1.000000e+0 "
211: string(12) " 1.000000e+0"
212: string(12) "
213: 1.000000e+0"
214: string(11) "1.000000e+0"
215: string(30) " 1.000000e+0"
216: string(4) "0-1]"
217: string(1) "e"
218:
219: -- Iteration 12 --
220: string(11) "1.000000e+0"
221: string(1) "e"
222: string(11) "1.000000e+0"
223: string(1) "e"
224: string(12) " 1.000000e+0"
225: string(12) "1.000000e+0 "
226: string(12) " 1.000000e+0"
227: string(12) "
228: 1.000000e+0"
229: string(11) "1.000000e+0"
230: string(30) " 1.000000e+0"
231: string(4) "0-1]"
232: string(1) "e"
233:
234: -- Iteration 13 --
235: string(11) "1.000000e+0"
236: string(1) "e"
237: string(11) "1.000000e+0"
238: string(1) "e"
239: string(12) " 1.000000e+0"
240: string(12) "1.000000e+0 "
241: string(12) " 1.000000e+0"
242: string(12) "
243: 1.000000e+0"
244: string(11) "1.000000e+0"
245: string(30) " 1.000000e+0"
246: string(4) "0-1]"
247: string(1) "e"
248:
249: -- Iteration 14 --
250: string(11) "1.000000e+0"
251: string(1) "e"
252: string(11) "1.000000e+0"
253: string(1) "e"
254: string(12) " 1.000000e+0"
255: string(12) "1.000000e+0 "
256: string(12) " 1.000000e+0"
257: string(12) "
258: 1.000000e+0"
259: string(11) "1.000000e+0"
260: string(30) " 1.000000e+0"
261: string(4) "0-1]"
262: string(1) "e"
263:
264: -- Iteration 15 --
265: string(11) "1.000000e+0"
266: string(1) "e"
267: string(11) "1.000000e+0"
268: string(1) "e"
269: string(12) " 1.000000e+0"
270: string(12) "1.000000e+0 "
271: string(12) " 1.000000e+0"
272: string(12) "
273: 1.000000e+0"
274: string(11) "1.000000e+0"
275: string(30) " 1.000000e+0"
276: string(4) "0-1]"
277: string(1) "e"
278: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>