Annotation of embedaddon/php/ext/standard/tests/strings/strcspn_variation10.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test strcspn() function : usage variations - with varying mask & default start and len args
3: --FILE--
4: <?php
5: /* Prototype : proto int strcspn(string str, string mask [, int start [, int len]])
6: * Description: Finds length of initial segment consisting entirely of characters not found in mask.
7: If start or/and length is provided works like strcspn(substr($s,$start,$len),$bad_chars)
8: * Source code: ext/standard/string.c
9: * Alias to functions: none
10: */
11:
12: /*
13: * Testing strcspn() : with varying mask and default start and len arguments
14: */
15:
16: echo "*** Testing strcspn() : with different mask strings and default start and len arguments ***\n";
17:
18: // initialing required variables
19: $strings = array(
20: "",
21: '',
22: "\n",
23: '\n',
24: "hello\tworld\nhello\nworld\n",
25: 'hello\tworld\nhello\nworld\n',
26: "1234hello45world\t123",
27: '1234hello45world\t123',
28: "hello\0world\012",
29: 'hello\0world\012',
30: chr(0).chr(0),
31: chr(0)."hello\0world".chr(0),
32: chr(0).'hello\0world'.chr(0),
33: "hello".chr(0)."world",
34: 'hello'.chr(0).'world',
35: "hello\0\100\xaaaworld",
36: 'hello\0\100\xaaaworld'
37: );
38:
39: // defining array of mask strings
40: $mask_array = array(
41: "",
42: '',
43: "\n\trsti \l",
44: '\n\trsti \l',
45: "\t",
46: "t\ ",
47: '\t',
48: "\t\ ",
49: " \t",
50: "\t\i\100\xa"
51: );
52:
53:
54: // loop through each element of the array for mask argument
55: $count = 1;
56: foreach($strings as $str) {
57: echo "\n-- Itearation $count --\n";
58: foreach($mask_array as $mask) {
59: var_dump( strcspn($str,$mask) );
60: }
61: $count++;
62: }
63:
64: echo "Done"
65: ?>
66: --EXPECTF--
67: *** Testing strcspn() : with different mask strings and default start and len arguments ***
68:
69: -- Itearation 1 --
70: int(0)
71: int(0)
72: int(0)
73: int(0)
74: int(0)
75: int(0)
76: int(0)
77: int(0)
78: int(0)
79: int(0)
80:
81: -- Itearation 2 --
82: int(0)
83: int(0)
84: int(0)
85: int(0)
86: int(0)
87: int(0)
88: int(0)
89: int(0)
90: int(0)
91: int(0)
92:
93: -- Itearation 3 --
94: int(1)
95: int(1)
96: int(0)
97: int(1)
98: int(1)
99: int(1)
100: int(1)
101: int(1)
102: int(1)
103: int(0)
104:
105: -- Itearation 4 --
106: int(2)
107: int(2)
108: int(0)
109: int(0)
110: int(2)
111: int(0)
112: int(0)
113: int(0)
114: int(2)
115: int(0)
116:
117: -- Itearation 5 --
118: int(24)
119: int(24)
120: int(2)
121: int(2)
122: int(5)
123: int(24)
124: int(24)
125: int(5)
126: int(5)
127: int(5)
128:
129: -- Itearation 6 --
130: int(28)
131: int(28)
132: int(2)
133: int(2)
134: int(28)
135: int(5)
136: int(5)
137: int(5)
138: int(28)
139: int(5)
140:
141: -- Itearation 7 --
142: int(20)
143: int(20)
144: int(6)
145: int(6)
146: int(16)
147: int(20)
148: int(20)
149: int(16)
150: int(16)
151: int(16)
152:
153: -- Itearation 8 --
154: int(21)
155: int(21)
156: int(6)
157: int(6)
158: int(21)
159: int(16)
160: int(16)
161: int(16)
162: int(21)
163: int(16)
164:
165: -- Itearation 9 --
166: int(5)
167: int(5)
168: int(2)
169: int(2)
170: int(12)
171: int(12)
172: int(12)
173: int(12)
174: int(12)
175: int(11)
176:
177: -- Itearation 10 --
178: int(16)
179: int(16)
180: int(2)
181: int(2)
182: int(16)
183: int(5)
184: int(5)
185: int(5)
186: int(16)
187: int(5)
188:
189: -- Itearation 11 --
190: int(0)
191: int(0)
192: int(2)
193: int(2)
194: int(2)
195: int(2)
196: int(2)
197: int(2)
198: int(2)
199: int(2)
200:
201: -- Itearation 12 --
202: int(0)
203: int(0)
204: int(3)
205: int(3)
206: int(13)
207: int(13)
208: int(13)
209: int(13)
210: int(13)
211: int(13)
212:
213: -- Itearation 13 --
214: int(0)
215: int(0)
216: int(3)
217: int(3)
218: int(14)
219: int(6)
220: int(6)
221: int(6)
222: int(14)
223: int(6)
224:
225: -- Itearation 14 --
226: int(5)
227: int(5)
228: int(2)
229: int(2)
230: int(11)
231: int(11)
232: int(11)
233: int(11)
234: int(11)
235: int(11)
236:
237: -- Itearation 15 --
238: int(5)
239: int(5)
240: int(2)
241: int(2)
242: int(11)
243: int(11)
244: int(11)
245: int(11)
246: int(11)
247: int(11)
248:
249: -- Itearation 16 --
250: int(5)
251: int(5)
252: int(2)
253: int(2)
254: int(14)
255: int(14)
256: int(14)
257: int(14)
258: int(14)
259: int(6)
260:
261: -- Itearation 17 --
262: int(21)
263: int(21)
264: int(2)
265: int(2)
266: int(21)
267: int(5)
268: int(5)
269: int(5)
270: int(21)
271: int(5)
272: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>