Annotation of embedaddon/php/ext/standard/tests/strings/vprintf_variation2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test vprintf() function : usage variations - unexpected values for args argument
3: --FILE--
4: <?php
5: /* Prototype : string vprintf(string format, array args)
6: * Description: Output a formatted string
7: * Source code: ext/standard/formatted_print.c
8: */
9:
10: /*
11: * Test vprintf() when different unexpected values are passed to
12: * the '$args' arguments of the function
13: */
14:
15: echo "*** Testing vprintf() : with unexpected values for args argument ***\n";
16:
17: // initialising the required variables
18: $format = '%s';
19:
20: //get an unset variable
21: $unset_var = 10;
22: unset ($unset_var);
23:
24: // declaring a class
25: class sample
26: {
27: public function __toString() {
28: return "object";
29: }
30: }
31:
32: // Defining resource
33: $file_handle = fopen(__FILE__, 'r');
34:
35:
36: //array of values to iterate over
37: $values = array(
38:
39: // int data
40: /*1*/ 0,
41: 1,
42: 12345,
43: -2345,
44:
45: // float data
46: /*5*/ 10.5,
47: -10.5,
48: 10.1234567e10,
49: 10.7654321E-10,
50: .5,
51:
52: // null data
53: /*10*/ NULL,
54: null,
55:
56: // boolean data
57: /*12*/ true,
58: false,
59: TRUE,
60: FALSE,
61:
62: // empty data
63: /*16*/ "",
64: '',
65:
66: // string data
67: /*18*/ "string",
68: 'string',
69:
70: // object data
71: /*20*/ new sample(),
72:
73: // undefined data
74: /*21*/ @$undefined_var,
75:
76: // unset data
77: /*22*/ @$unset_var,
78:
79: // resource data
80: /*23*/ $file_handle
81: );
82:
83: // loop through each element of the array for args
84: $counter = 1;
85: foreach($values as $value) {
86: echo "\n-- Iteration $counter --\n";
87: $result = vprintf($format,$value);
88: echo "\n";
89: var_dump($result);
90: $counter++;
91: };
92:
93: // closing the resource
94: fclose($file_handle);
95:
96: ?>
97: ===DONE===
98: --EXPECTF--
99: *** Testing vprintf() : with unexpected values for args argument ***
100:
101: -- Iteration 1 --
102: 0
103: int(1)
104:
105: -- Iteration 2 --
106: 1
107: int(1)
108:
109: -- Iteration 3 --
110: 12345
111: int(5)
112:
113: -- Iteration 4 --
114: -2345
115: int(5)
116:
117: -- Iteration 5 --
118: 10.5
119: int(4)
120:
121: -- Iteration 6 --
122: -10.5
123: int(5)
124:
125: -- Iteration 7 --
126: 101234567000
127: int(12)
128:
129: -- Iteration 8 --
130: 1.07654321E-9
131: int(13)
132:
133: -- Iteration 9 --
134: 0.5
135: int(3)
136:
137: -- Iteration 10 --
138:
139: Warning: vprintf(): Too few arguments in %s on line %d
140:
141: bool(false)
142:
143: -- Iteration 11 --
144:
145: Warning: vprintf(): Too few arguments in %s on line %d
146:
147: bool(false)
148:
149: -- Iteration 12 --
150: 1
151: int(1)
152:
153: -- Iteration 13 --
154:
155: int(0)
156:
157: -- Iteration 14 --
158: 1
159: int(1)
160:
161: -- Iteration 15 --
162:
163: int(0)
164:
165: -- Iteration 16 --
166:
167: int(0)
168:
169: -- Iteration 17 --
170:
171: int(0)
172:
173: -- Iteration 18 --
174: string
175: int(6)
176:
177: -- Iteration 19 --
178: string
179: int(6)
180:
181: -- Iteration 20 --
182:
183: Warning: vprintf(): Too few arguments in %s on line %d
184:
185: bool(false)
186:
187: -- Iteration 21 --
188:
189: Warning: vprintf(): Too few arguments in %s on line %d
190:
191: bool(false)
192:
193: -- Iteration 22 --
194:
195: Warning: vprintf(): Too few arguments in %s on line %d
196:
197: bool(false)
198:
199: -- Iteration 23 --
200: Resource id #%d
201: int(%d)
202: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>