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