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