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