Annotation of embedaddon/php/ext/mbstring/tests/mb_split_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test mb_split() function : usage variations - different parameter types for pattern
3: --SKIPIF--
4: <?php
5: extension_loaded('mbstring') or die('skip');
6: function_exists('mb_split') or die("skip mb_split() is not available in this build");
7: ?>
8: --FILE--
9: <?php
10: /* Prototype : proto array mb_split(string pattern, string string [, int limit])
11: * Description: split multibyte string into array by regular expression
12: * Source code: ext/mbstring/php_mbregex.c
13: * Alias to functions:
14: */
15:
16: echo "*** Testing mb_split() : usage variations ***\n";
17:
18: // Initialise function arguments not being substituted (if any)
19: $string = 'a b c d e f g';
20: $limit = 10;
21:
22: //get an unset variable
23: $unset_var = 10;
24: unset ($unset_var);
25:
26: // get a class
27: class classA
28: {
29: public function __toString() {
30: return "UTF-8";
31: }
32: }
33:
34: // heredoc string
35: $heredoc = <<<EOT
36: UTF-8
37: EOT;
38:
39: // get a resource variable
40: $fp = fopen(__FILE__, "r");
41:
42: // unexpected values to be passed to $encoding argument
43: $inputs = array(
44:
45: // int data
46: /*1*/ 0,
47: 1,
48: 12345,
49: -2345,
50:
51: // float data
52: /*5*/ 10.5,
53: -10.5,
54: 12.3456789000e10,
55: 12.3456789000E-10,
56: .5,
57:
58: // null data
59: /*10*/ NULL,
60: null,
61:
62: // boolean data
63: /*12*/ true,
64: false,
65: TRUE,
66: FALSE,
67:
68: // empty data
69: /*16*/ "",
70: '',
71:
72: // string data
73: /*18*/ "UTF-8",
74: 'UTF-8',
75: $heredoc,
76:
77: // object data
78: /*21*/ new classA(),
79:
80: // undefined data
81: /*22*/ @$undefined_var,
82:
83: // unset data
84: /*23*/ @$unset_var,
85:
86: // resource variable
87: /*24*/ $fp
88: );
89:
90: // loop through each element of the array for pattern
91:
92: $iterator = 1;
93: foreach($inputs as $input) {
94: echo "\n-- Iteration $iterator --\n";
95: var_dump( mb_split($input, $string, $limit) );
96: $iterator++;
97: };
98: fclose($fp);
99: echo "Done";
100: ?>
101: --EXPECTF--
102: *** Testing mb_split() : usage variations ***
103:
104: -- Iteration 1 --
105: array(1) {
106: [0]=>
107: string(13) "a b c d e f g"
108: }
109:
110: -- Iteration 2 --
111: array(1) {
112: [0]=>
113: string(13) "a b c d e f g"
114: }
115:
116: -- Iteration 3 --
117: array(1) {
118: [0]=>
119: string(13) "a b c d e f g"
120: }
121:
122: -- Iteration 4 --
123: array(1) {
124: [0]=>
125: string(13) "a b c d e f g"
126: }
127:
128: -- Iteration 5 --
129: array(1) {
130: [0]=>
131: string(13) "a b c d e f g"
132: }
133:
134: -- Iteration 6 --
135: array(1) {
136: [0]=>
137: string(13) "a b c d e f g"
138: }
139:
140: -- Iteration 7 --
141: array(1) {
142: [0]=>
143: string(13) "a b c d e f g"
144: }
145:
146: -- Iteration 8 --
147: array(1) {
148: [0]=>
149: string(13) "a b c d e f g"
150: }
151:
152: -- Iteration 9 --
153: array(1) {
154: [0]=>
155: string(13) "a b c d e f g"
156: }
157:
158: -- Iteration 10 --
159:
160: Warning: mb_split(): Empty regular expression in %s on line %d
161: array(1) {
162: [0]=>
163: string(13) "a b c d e f g"
164: }
165:
166: -- Iteration 11 --
167:
168: Warning: mb_split(): Empty regular expression in %s on line %d
169: array(1) {
170: [0]=>
171: string(13) "a b c d e f g"
172: }
173:
174: -- Iteration 12 --
175: array(1) {
176: [0]=>
177: string(13) "a b c d e f g"
178: }
179:
180: -- Iteration 13 --
181:
182: Warning: mb_split(): Empty regular expression in %s on line %d
183: array(1) {
184: [0]=>
185: string(13) "a b c d e f g"
186: }
187:
188: -- Iteration 14 --
189: array(1) {
190: [0]=>
191: string(13) "a b c d e f g"
192: }
193:
194: -- Iteration 15 --
195:
196: Warning: mb_split(): Empty regular expression in %s on line %d
197: array(1) {
198: [0]=>
199: string(13) "a b c d e f g"
200: }
201:
202: -- Iteration 16 --
203:
204: Warning: mb_split(): Empty regular expression in %s on line %d
205: array(1) {
206: [0]=>
207: string(13) "a b c d e f g"
208: }
209:
210: -- Iteration 17 --
211:
212: Warning: mb_split(): Empty regular expression in %s on line %d
213: array(1) {
214: [0]=>
215: string(13) "a b c d e f g"
216: }
217:
218: -- Iteration 18 --
219: array(1) {
220: [0]=>
221: string(13) "a b c d e f g"
222: }
223:
224: -- Iteration 19 --
225: array(1) {
226: [0]=>
227: string(13) "a b c d e f g"
228: }
229:
230: -- Iteration 20 --
231: array(1) {
232: [0]=>
233: string(13) "a b c d e f g"
234: }
235:
236: -- Iteration 21 --
237: array(1) {
238: [0]=>
239: string(13) "a b c d e f g"
240: }
241:
242: -- Iteration 22 --
243:
244: Warning: mb_split(): Empty regular expression in %s on line %d
245: array(1) {
246: [0]=>
247: string(13) "a b c d e f g"
248: }
249:
250: -- Iteration 23 --
251:
252: Warning: mb_split(): Empty regular expression in %s on line %d
253: array(1) {
254: [0]=>
255: string(13) "a b c d e f g"
256: }
257:
258: -- Iteration 24 --
259:
260: Warning: mb_split() expects parameter 1 to be string, resource given in %s on line %d
261: bool(false)
262: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>