Annotation of embedaddon/php/ext/standard/tests/strings/chunk_split_variation1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test chunk_split() function : usage variations - with unexpected values for 'str' argument
3: --FILE--
4: <?php
5: /* Prototype : string chunk_split(string $str [, int $chunklen [, string $ending]])
6: * Description: Returns split line %d%d
7: * Source code: ext/standard/string.c
8: * Alias to functions: none
9: */
10:
11: echo "*** Testing chunk_split() : with unexpected values for 'str' argument ***\n";
12:
13: // Initialising variables
14: $chunklen = 2;
15: $ending = ' ';
16:
17: //get an unset variable
18: $unset_var = 10;
19: unset ($unset_var);
20:
21: //class for object variable
22: class MyClass
23: {
24: public function __toString()
25: {
26: return "object";
27: }
28: }
29:
30: //resource variable
31: $fp = fopen(__FILE__, 'r');
32:
33: //different values for 'str'
34: $values = array(
35:
36: // int data
37: 0,
38: 1,
39: 12345,
40: -2345,
41:
42: // float data
43: 10.5,
44: -10.5,
45: 10.1234567e10,
46: 10.7654321E-10,
47: .5,
48:
49: // array data
50: array(),
51: array(0),
52: array(1),
53: array(1, 2),
54: array('color' => 'red', 'item' => 'pen'),
55:
56: // null data
57: NULL,
58: null,
59:
60: // boolean data
61: true,
62: false,
63: TRUE,
64: FALSE,
65:
66: // empty data
67: "",
68: '',
69:
70: // string data
71: "string",
72: 'string',
73:
74: // object data
75: new MyClass(),
76:
77: // undefined data
78: @$undefined_var,
79:
80: // unset data
81: @$unset_var,
82:
83: // resource data
84: $fp
85: );
86:
87: // loop through each element of the array for 'str'
88: for($count = 0; $count < count($values); $count++) {
89: echo "-- Iteration ".($count+1)." --\n";
90: var_dump( chunk_split($values[$count], $chunklen, $ending) );
91: };
92:
93: echo "Done";
94:
95: // close the resource
96: fclose($fp);
97:
98: ?>
99: --EXPECTF--
100: *** Testing chunk_split() : with unexpected values for 'str' argument ***
101: -- Iteration 1 --
102: string(2) "0 "
103: -- Iteration 2 --
104: string(2) "1 "
105: -- Iteration 3 --
106: string(8) "12 34 5 "
107: -- Iteration 4 --
108: string(8) "-2 34 5 "
109: -- Iteration 5 --
110: string(6) "10 .5 "
111: -- Iteration 6 --
112: string(8) "-1 0. 5 "
113: -- Iteration 7 --
114: string(18) "10 12 34 56 70 00 "
115: -- Iteration 8 --
116: string(20) "1. 07 65 43 21 E- 9 "
117: -- Iteration 9 --
118: string(5) "0. 5 "
119: -- Iteration 10 --
120:
121: Warning: chunk_split() expects parameter 1 to be string, array given in %s on line 87
122: NULL
123: -- Iteration 11 --
124:
125: Warning: chunk_split() expects parameter 1 to be string, array given in %s on line 87
126: NULL
127: -- Iteration 12 --
128:
129: Warning: chunk_split() expects parameter 1 to be string, array given in %s on line 87
130: NULL
131: -- Iteration 13 --
132:
133: Warning: chunk_split() expects parameter 1 to be string, array given in %s on line 87
134: NULL
135: -- Iteration 14 --
136:
137: Warning: chunk_split() expects parameter 1 to be string, array given in %s on line 87
138: NULL
139: -- Iteration 15 --
140: string(1) " "
141: -- Iteration 16 --
142: string(1) " "
143: -- Iteration 17 --
144: string(2) "1 "
145: -- Iteration 18 --
146: string(1) " "
147: -- Iteration 19 --
148: string(2) "1 "
149: -- Iteration 20 --
150: string(1) " "
151: -- Iteration 21 --
152: string(1) " "
153: -- Iteration 22 --
154: string(1) " "
155: -- Iteration 23 --
156: string(9) "st ri ng "
157: -- Iteration 24 --
158: string(9) "st ri ng "
159: -- Iteration 25 --
160: string(9) "ob je ct "
161: -- Iteration 26 --
162: string(1) " "
163: -- Iteration 27 --
164: string(1) " "
165: -- Iteration 28 --
166:
167: Warning: chunk_split() expects parameter 1 to be string, resource given in %s on line 87
168: NULL
169: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>