Annotation of embedaddon/php/ext/standard/tests/strings/str_split_variation2_64bit.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test str_split() function : usage variations - unexpected values for 'split_length' argument
3: --SKIPIF--
4: <?php
5: if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
6: ?>
7: --FILE--
8: <?php
9: /* Prototype : array str_split(string $str [, int $split_length])
10: * Description: Convert a string to an array. If split_length is
11: specified, break the string down into chunks each
12: split_length characters long.
13: * Source code: ext/standard/string.c
14: * Alias to functions: none
15: */
16:
17: echo "*** Testing str_split() : unexpected values for 'split_length' ***\n";
18:
19: // Initialise function arguments
20: $str = 'variation2:split_length';
21:
22: //get an unset variable
23: $unset_var = 10;
24: unset ($unset_var);
25:
26: //defining class for object variable
27: class MyClass
28: {
29: public function __toString()
30: {
31: return "object";
32: }
33: }
34:
35: //resource variable
36: $fp = fopen(__FILE__, 'r');
37:
38: //different values for 'split_length'
39: $values = array(
40:
41: // float data
42: 10.5,
43: -10.5,
44: 10.6E10,
45: 10.6E-10,
46: .5,
47:
48: // array data
49: array(),
50: array(0),
51: array(1),
52: array(1, 2),
53: array('color' => 'red', 'item' => 'pen'),
54:
55: // null data
56: NULL,
57: null,
58:
59: // boolean data
60: true,
61: false,
62: TRUE,
63: FALSE,
64:
65: // empty data
66: "",
67: '',
68:
69: // string data
70: "string",
71: 'string',
72:
73: // object data
74: new MyClass(),
75:
76: // undefined data
77: @$undefined_var,
78:
79: // unset data
80: @$unset_var,
81:
82: //resource data
83: $fp
84: );
85:
86: // loop through each element of $values for 'split_length'
87: for($count = 0; $count < count($values); $count++) {
88: echo "--Iteration ".($count+1)." --\n";
89: var_dump( str_split($str, $values[$count]) );
90: }
91:
92: //closing resource
93: fclose($fp);
94:
95: echo "Done";
96: ?>
97: --EXPECTF--
98: *** Testing str_split() : unexpected values for 'split_length' ***
99: --Iteration 1 --
100: array(3) {
101: [0]=>
102: string(10) "variation2"
103: [1]=>
104: string(10) ":split_len"
105: [2]=>
106: string(3) "gth"
107: }
108: --Iteration 2 --
109:
110: Warning: str_split(): The length of each segment must be greater than zero in %s on line %d
111: bool(false)
112: --Iteration 3 --
113: array(1) {
114: [0]=>
115: string(23) "variation2:split_length"
116: }
117: --Iteration 4 --
118:
119: Warning: str_split(): The length of each segment must be greater than zero in %s on line %d
120: bool(false)
121: --Iteration 5 --
122:
123: Warning: str_split(): The length of each segment must be greater than zero in %s on line %d
124: bool(false)
125: --Iteration 6 --
126:
127: Warning: str_split() expects parameter 2 to be long, array given in %s on line %d
128: NULL
129: --Iteration 7 --
130:
131: Warning: str_split() expects parameter 2 to be long, array given in %s on line %d
132: NULL
133: --Iteration 8 --
134:
135: Warning: str_split() expects parameter 2 to be long, array given in %s on line %d
136: NULL
137: --Iteration 9 --
138:
139: Warning: str_split() expects parameter 2 to be long, array given in %s on line %d
140: NULL
141: --Iteration 10 --
142:
143: Warning: str_split() expects parameter 2 to be long, array given in %s on line %d
144: NULL
145: --Iteration 11 --
146:
147: Warning: str_split(): The length of each segment must be greater than zero in %s on line %d
148: bool(false)
149: --Iteration 12 --
150:
151: Warning: str_split(): The length of each segment must be greater than zero in %s on line %d
152: bool(false)
153: --Iteration 13 --
154: array(23) {
155: [0]=>
156: string(1) "v"
157: [1]=>
158: string(1) "a"
159: [2]=>
160: string(1) "r"
161: [3]=>
162: string(1) "i"
163: [4]=>
164: string(1) "a"
165: [5]=>
166: string(1) "t"
167: [6]=>
168: string(1) "i"
169: [7]=>
170: string(1) "o"
171: [8]=>
172: string(1) "n"
173: [9]=>
174: string(1) "2"
175: [10]=>
176: string(1) ":"
177: [11]=>
178: string(1) "s"
179: [12]=>
180: string(1) "p"
181: [13]=>
182: string(1) "l"
183: [14]=>
184: string(1) "i"
185: [15]=>
186: string(1) "t"
187: [16]=>
188: string(1) "_"
189: [17]=>
190: string(1) "l"
191: [18]=>
192: string(1) "e"
193: [19]=>
194: string(1) "n"
195: [20]=>
196: string(1) "g"
197: [21]=>
198: string(1) "t"
199: [22]=>
200: string(1) "h"
201: }
202: --Iteration 14 --
203:
204: Warning: str_split(): The length of each segment must be greater than zero in %s on line %d
205: bool(false)
206: --Iteration 15 --
207: array(23) {
208: [0]=>
209: string(1) "v"
210: [1]=>
211: string(1) "a"
212: [2]=>
213: string(1) "r"
214: [3]=>
215: string(1) "i"
216: [4]=>
217: string(1) "a"
218: [5]=>
219: string(1) "t"
220: [6]=>
221: string(1) "i"
222: [7]=>
223: string(1) "o"
224: [8]=>
225: string(1) "n"
226: [9]=>
227: string(1) "2"
228: [10]=>
229: string(1) ":"
230: [11]=>
231: string(1) "s"
232: [12]=>
233: string(1) "p"
234: [13]=>
235: string(1) "l"
236: [14]=>
237: string(1) "i"
238: [15]=>
239: string(1) "t"
240: [16]=>
241: string(1) "_"
242: [17]=>
243: string(1) "l"
244: [18]=>
245: string(1) "e"
246: [19]=>
247: string(1) "n"
248: [20]=>
249: string(1) "g"
250: [21]=>
251: string(1) "t"
252: [22]=>
253: string(1) "h"
254: }
255: --Iteration 16 --
256:
257: Warning: str_split(): The length of each segment must be greater than zero in %s on line %d
258: bool(false)
259: --Iteration 17 --
260:
261: Warning: str_split() expects parameter 2 to be long, string given in %s on line %d
262: NULL
263: --Iteration 18 --
264:
265: Warning: str_split() expects parameter 2 to be long, string given in %s on line %d
266: NULL
267: --Iteration 19 --
268:
269: Warning: str_split() expects parameter 2 to be long, string given in %s on line %d
270: NULL
271: --Iteration 20 --
272:
273: Warning: str_split() expects parameter 2 to be long, string given in %s on line %d
274: NULL
275: --Iteration 21 --
276:
277: Warning: str_split() expects parameter 2 to be long, object given in %s on line %d
278: NULL
279: --Iteration 22 --
280:
281: Warning: str_split(): The length of each segment must be greater than zero in %s on line %d
282: bool(false)
283: --Iteration 23 --
284:
285: Warning: str_split(): The length of each segment must be greater than zero in %s on line %d
286: bool(false)
287: --Iteration 24 --
288:
289: Warning: str_split() expects parameter 2 to be long, resource given in %s on line %d
290: NULL
291: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>