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