Annotation of embedaddon/php/ext/standard/tests/strings/strcspn_variation7.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test strcspn() function : usage variations - with heredoc strings, varying start and default 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 heredoc string, varying start and default len arguments
14: */
15:
16: echo "*** Testing strcspn() : with different start values ***\n";
17:
18: // initialing required variables
19: // defining different heredoc strings
20: $empty_heredoc = <<<EOT
21: EOT;
22:
23: $heredoc_with_newline = <<<EOT
24: \n
25:
26: EOT;
27:
28: $heredoc_with_characters = <<<EOT
29: first line of heredoc string
30: second line of heredoc string
31: third line of heredocstring
32: EOT;
33:
34: $heredoc_with_newline_and_tabs = <<<EOT
35: hello\tworld\nhello\nworld\n
36: EOT;
37:
38: $heredoc_with_alphanumerics = <<<EOT
39: hello123world456
40: 1234hello\t1234
41: EOT;
42:
43: $heredoc_with_embedded_nulls = <<<EOT
44: hello\0world\0hello
45: \0hello\0
46: EOT;
47:
48: $heredoc_with_hexa_octal = <<<EOT
49: hello\0\100\xaaworld\0hello
50: \0hello\0
51: EOT;
52:
53: $heredoc_strings = array(
54: $empty_heredoc,
55: $heredoc_with_newline,
56: $heredoc_with_characters,
57: $heredoc_with_newline_and_tabs,
58: $heredoc_with_alphanumerics,
59: $heredoc_with_embedded_nulls,
60: $heredoc_with_hexa_octal
61: );
62:
63:
64: // defining array of mask strings
65:
66: $mask_array = array(
67: "",
68: '',
69: "\n\trsti \l",
70: '\n\trsti \l',
71: "\t",
72: "t\ ",
73: '\t',
74: "\t\ ",
75: " \t",
76: "\t\i\100\xaa"
77: );
78:
79: // definig array of start values
80: $start_array = array(
81: 0,
82: 1,
83: 2,
84: -1,
85: -2,
86: 2147483647, // max positive integer
87: -2147483648, // min negative integer
88: );
89:
90:
91: // loop through each element of the arrays for str, mask and start arguments
92:
93: $count = 1;
94: foreach($heredoc_strings as $str) {
95: echo "\n-- Iteration $count --\n";
96: foreach($mask_array as $mask) {
97: foreach($start_array as $start) {
98: var_dump( strcspn($str,$mask,$start) ); // with default len value
99: }
100: }
101: $count++;
102: }
103:
104: echo "Done"
105: ?>
106: --EXPECTF--
107: *** Testing strcspn() : with different start values ***
108:
109: -- Iteration 1 --
110: int(0)
111: bool(false)
112: bool(false)
113: int(0)
114: int(0)
115: bool(false)
116: int(0)
117: int(0)
118: bool(false)
119: bool(false)
120: int(0)
121: int(0)
122: bool(false)
123: int(0)
124: int(0)
125: bool(false)
126: bool(false)
127: int(0)
128: int(0)
129: bool(false)
130: int(0)
131: int(0)
132: bool(false)
133: bool(false)
134: int(0)
135: int(0)
136: bool(false)
137: int(0)
138: int(0)
139: bool(false)
140: bool(false)
141: int(0)
142: int(0)
143: bool(false)
144: int(0)
145: int(0)
146: bool(false)
147: bool(false)
148: int(0)
149: int(0)
150: bool(false)
151: int(0)
152: int(0)
153: bool(false)
154: bool(false)
155: int(0)
156: int(0)
157: bool(false)
158: int(0)
159: int(0)
160: bool(false)
161: bool(false)
162: int(0)
163: int(0)
164: bool(false)
165: int(0)
166: int(0)
167: bool(false)
168: bool(false)
169: int(0)
170: int(0)
171: bool(false)
172: int(0)
173: int(0)
174: bool(false)
175: bool(false)
176: int(0)
177: int(0)
178: bool(false)
179: int(0)
180:
181: -- Iteration 2 --
182: int(2)
183: int(1)
184: int(0)
185: int(1)
186: int(2)
187: bool(false)
188: int(2)
189: int(2)
190: int(1)
191: int(0)
192: int(1)
193: int(2)
194: bool(false)
195: int(2)
196: int(0)
197: int(0)
198: int(0)
199: int(0)
200: int(0)
201: bool(false)
202: int(0)
203: int(2)
204: int(1)
205: int(0)
206: int(1)
207: int(2)
208: bool(false)
209: int(2)
210: int(2)
211: int(1)
212: int(0)
213: int(1)
214: int(2)
215: bool(false)
216: int(2)
217: int(2)
218: int(1)
219: int(0)
220: int(1)
221: int(2)
222: bool(false)
223: int(2)
224: int(2)
225: int(1)
226: int(0)
227: int(1)
228: int(2)
229: bool(false)
230: int(2)
231: int(2)
232: int(1)
233: int(0)
234: int(1)
235: int(2)
236: bool(false)
237: int(2)
238: int(2)
239: int(1)
240: int(0)
241: int(1)
242: int(2)
243: bool(false)
244: int(2)
245: int(2)
246: int(1)
247: int(0)
248: int(1)
249: int(2)
250: bool(false)
251: int(2)
252:
253: -- Iteration 3 --
254: int(86)
255: int(85)
256: int(84)
257: int(1)
258: int(2)
259: bool(false)
260: int(86)
261: int(86)
262: int(85)
263: int(84)
264: int(1)
265: int(2)
266: bool(false)
267: int(86)
268: int(1)
269: int(0)
270: int(0)
271: int(1)
272: int(2)
273: bool(false)
274: int(1)
275: int(1)
276: int(0)
277: int(0)
278: int(1)
279: int(0)
280: bool(false)
281: int(1)
282: int(86)
283: int(85)
284: int(84)
285: int(1)
286: int(2)
287: bool(false)
288: int(86)
289: int(4)
290: int(3)
291: int(2)
292: int(1)
293: int(2)
294: bool(false)
295: int(4)
296: int(4)
297: int(3)
298: int(2)
299: int(1)
300: int(2)
301: bool(false)
302: int(4)
303: int(5)
304: int(4)
305: int(3)
306: int(1)
307: int(2)
308: bool(false)
309: int(5)
310: int(5)
311: int(4)
312: int(3)
313: int(1)
314: int(2)
315: bool(false)
316: int(5)
317: int(1)
318: int(0)
319: int(5)
320: int(1)
321: int(2)
322: bool(false)
323: int(1)
324:
325: -- Iteration 4 --
326: int(24)
327: int(23)
328: int(22)
329: int(1)
330: int(2)
331: bool(false)
332: int(24)
333: int(24)
334: int(23)
335: int(22)
336: int(1)
337: int(2)
338: bool(false)
339: int(24)
340: int(2)
341: int(1)
342: int(0)
343: int(0)
344: int(1)
345: bool(false)
346: int(2)
347: int(2)
348: int(1)
349: int(0)
350: int(1)
351: int(2)
352: bool(false)
353: int(2)
354: int(5)
355: int(4)
356: int(3)
357: int(1)
358: int(2)
359: bool(false)
360: int(5)
361: int(24)
362: int(23)
363: int(22)
364: int(1)
365: int(2)
366: bool(false)
367: int(24)
368: int(24)
369: int(23)
370: int(22)
371: int(1)
372: int(2)
373: bool(false)
374: int(24)
375: int(5)
376: int(4)
377: int(3)
378: int(1)
379: int(2)
380: bool(false)
381: int(5)
382: int(5)
383: int(4)
384: int(3)
385: int(1)
386: int(2)
387: bool(false)
388: int(5)
389: int(5)
390: int(4)
391: int(3)
392: int(1)
393: int(2)
394: bool(false)
395: int(5)
396:
397: -- Iteration 5 --
398: int(31)
399: int(30)
400: int(29)
401: int(1)
402: int(2)
403: bool(false)
404: int(31)
405: int(31)
406: int(30)
407: int(29)
408: int(1)
409: int(2)
410: bool(false)
411: int(31)
412: int(2)
413: int(1)
414: int(0)
415: int(1)
416: int(2)
417: bool(false)
418: int(2)
419: int(2)
420: int(1)
421: int(0)
422: int(1)
423: int(2)
424: bool(false)
425: int(2)
426: int(26)
427: int(25)
428: int(24)
429: int(1)
430: int(2)
431: bool(false)
432: int(26)
433: int(31)
434: int(30)
435: int(29)
436: int(1)
437: int(2)
438: bool(false)
439: int(31)
440: int(31)
441: int(30)
442: int(29)
443: int(1)
444: int(2)
445: bool(false)
446: int(31)
447: int(26)
448: int(25)
449: int(24)
450: int(1)
451: int(2)
452: bool(false)
453: int(26)
454: int(26)
455: int(25)
456: int(24)
457: int(1)
458: int(2)
459: bool(false)
460: int(26)
461: int(26)
462: int(25)
463: int(24)
464: int(1)
465: int(2)
466: bool(false)
467: int(26)
468:
469: -- Iteration 6 --
470: int(5)
471: int(4)
472: int(3)
473: int(0)
474: int(1)
475: bool(false)
476: int(5)
477: int(5)
478: int(4)
479: int(3)
480: int(0)
481: int(1)
482: bool(false)
483: int(5)
484: int(2)
485: int(1)
486: int(0)
487: int(1)
488: int(2)
489: bool(false)
490: int(2)
491: int(2)
492: int(1)
493: int(0)
494: int(1)
495: int(2)
496: bool(false)
497: int(2)
498: int(25)
499: int(24)
500: int(23)
501: int(1)
502: int(2)
503: bool(false)
504: int(25)
505: int(25)
506: int(24)
507: int(23)
508: int(1)
509: int(2)
510: bool(false)
511: int(25)
512: int(25)
513: int(24)
514: int(23)
515: int(1)
516: int(2)
517: bool(false)
518: int(25)
519: int(25)
520: int(24)
521: int(23)
522: int(1)
523: int(2)
524: bool(false)
525: int(25)
526: int(25)
527: int(24)
528: int(23)
529: int(1)
530: int(2)
531: bool(false)
532: int(25)
533: int(25)
534: int(24)
535: int(23)
536: int(1)
537: int(2)
538: bool(false)
539: int(25)
540:
541: -- Iteration 7 --
542: int(5)
543: int(4)
544: int(3)
545: int(0)
546: int(1)
547: bool(false)
548: int(5)
549: int(5)
550: int(4)
551: int(3)
552: int(0)
553: int(1)
554: bool(false)
555: int(5)
556: int(2)
557: int(1)
558: int(0)
559: int(1)
560: int(2)
561: bool(false)
562: int(2)
563: int(2)
564: int(1)
565: int(0)
566: int(1)
567: int(2)
568: bool(false)
569: int(2)
570: int(27)
571: int(26)
572: int(25)
573: int(1)
574: int(2)
575: bool(false)
576: int(27)
577: int(27)
578: int(26)
579: int(25)
580: int(1)
581: int(2)
582: bool(false)
583: int(27)
584: int(27)
585: int(26)
586: int(25)
587: int(1)
588: int(2)
589: bool(false)
590: int(27)
591: int(27)
592: int(26)
593: int(25)
594: int(1)
595: int(2)
596: bool(false)
597: int(27)
598: int(27)
599: int(26)
600: int(25)
601: int(1)
602: int(2)
603: bool(false)
604: int(27)
605: int(6)
606: int(5)
607: int(4)
608: int(1)
609: int(2)
610: bool(false)
611: int(6)
612: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>