Annotation of embedaddon/php/ext/standard/tests/strings/strcspn_variation11.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test strcspn() function : usage variations - with 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 varying start and default len arguments
14: */
15:
16: echo "*** Testing strcspn() : with different start and default len values ***\n";
17:
18: // initialing required variables
19: // initialing required variables
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: // defining array of mask strings
41: $mask_array = array(
42: "",
43: '',
44: "\n\trsti \l",
45: '\n\trsti \l',
46: "\t",
47: "t\ ",
48: '\t',
49: "\t\ ",
50: " \t",
51: "\t\i\100\xa"
52: );
53:
54: //defining array of start values
55: $start_array = array(
56: 0,
57: 1,
58: 2,
59: -1,
60: -2,
61: 2147483647, // max positive integer
62: -2147483648, // min negative integer
63: );
64:
65:
66: // loop through each element of the arrays for str,mask and start arguments
67: $count = 1;
68: foreach($strings as $str) {
69: echo "\n-- Iteration $count --\n";
70: foreach($mask_array as $mask) {
71: foreach($start_array as $start) {
72: var_dump( strcspn($str,$mask,$start) );
73: }
74: }
75: $count++;
76: }
77:
78: echo "Done"
79: ?>
80: --EXPECTF--
81: *** Testing strcspn() : with different start and default len values ***
82:
83: -- Iteration 1 --
84: int(0)
85: bool(false)
86: bool(false)
87: int(0)
88: int(0)
89: bool(false)
90: int(0)
91: int(0)
92: bool(false)
93: bool(false)
94: int(0)
95: int(0)
96: bool(false)
97: int(0)
98: int(0)
99: bool(false)
100: bool(false)
101: int(0)
102: int(0)
103: bool(false)
104: int(0)
105: int(0)
106: bool(false)
107: bool(false)
108: int(0)
109: int(0)
110: bool(false)
111: int(0)
112: int(0)
113: bool(false)
114: bool(false)
115: int(0)
116: int(0)
117: bool(false)
118: int(0)
119: int(0)
120: bool(false)
121: bool(false)
122: int(0)
123: int(0)
124: bool(false)
125: int(0)
126: int(0)
127: bool(false)
128: bool(false)
129: int(0)
130: int(0)
131: bool(false)
132: int(0)
133: int(0)
134: bool(false)
135: bool(false)
136: int(0)
137: int(0)
138: bool(false)
139: int(0)
140: int(0)
141: bool(false)
142: bool(false)
143: int(0)
144: int(0)
145: bool(false)
146: int(0)
147: int(0)
148: bool(false)
149: bool(false)
150: int(0)
151: int(0)
152: bool(false)
153: int(0)
154:
155: -- Iteration 2 --
156: int(0)
157: bool(false)
158: bool(false)
159: int(0)
160: int(0)
161: bool(false)
162: int(0)
163: int(0)
164: bool(false)
165: bool(false)
166: int(0)
167: int(0)
168: bool(false)
169: int(0)
170: int(0)
171: bool(false)
172: bool(false)
173: int(0)
174: int(0)
175: bool(false)
176: int(0)
177: int(0)
178: bool(false)
179: bool(false)
180: int(0)
181: int(0)
182: bool(false)
183: int(0)
184: int(0)
185: bool(false)
186: bool(false)
187: int(0)
188: int(0)
189: bool(false)
190: int(0)
191: int(0)
192: bool(false)
193: bool(false)
194: int(0)
195: int(0)
196: bool(false)
197: int(0)
198: int(0)
199: bool(false)
200: bool(false)
201: int(0)
202: int(0)
203: bool(false)
204: int(0)
205: int(0)
206: bool(false)
207: bool(false)
208: int(0)
209: int(0)
210: bool(false)
211: int(0)
212: int(0)
213: bool(false)
214: bool(false)
215: int(0)
216: int(0)
217: bool(false)
218: int(0)
219: int(0)
220: bool(false)
221: bool(false)
222: int(0)
223: int(0)
224: bool(false)
225: int(0)
226:
227: -- Iteration 3 --
228: int(1)
229: int(0)
230: bool(false)
231: int(1)
232: int(1)
233: bool(false)
234: int(1)
235: int(1)
236: int(0)
237: bool(false)
238: int(1)
239: int(1)
240: bool(false)
241: int(1)
242: int(0)
243: int(0)
244: bool(false)
245: int(0)
246: int(0)
247: bool(false)
248: int(0)
249: int(1)
250: int(0)
251: bool(false)
252: int(1)
253: int(1)
254: bool(false)
255: int(1)
256: int(1)
257: int(0)
258: bool(false)
259: int(1)
260: int(1)
261: bool(false)
262: int(1)
263: int(1)
264: int(0)
265: bool(false)
266: int(1)
267: int(1)
268: bool(false)
269: int(1)
270: int(1)
271: int(0)
272: bool(false)
273: int(1)
274: int(1)
275: bool(false)
276: int(1)
277: int(1)
278: int(0)
279: bool(false)
280: int(1)
281: int(1)
282: bool(false)
283: int(1)
284: int(1)
285: int(0)
286: bool(false)
287: int(1)
288: int(1)
289: bool(false)
290: int(1)
291: int(0)
292: int(0)
293: bool(false)
294: int(0)
295: int(0)
296: bool(false)
297: int(0)
298:
299: -- Iteration 4 --
300: int(2)
301: int(1)
302: int(0)
303: int(1)
304: int(2)
305: bool(false)
306: int(2)
307: int(2)
308: int(1)
309: int(0)
310: int(1)
311: int(2)
312: bool(false)
313: int(2)
314: int(0)
315: int(1)
316: int(0)
317: int(1)
318: int(0)
319: bool(false)
320: int(0)
321: int(0)
322: int(0)
323: int(0)
324: int(0)
325: int(0)
326: bool(false)
327: int(0)
328: int(2)
329: int(1)
330: int(0)
331: int(1)
332: int(2)
333: bool(false)
334: int(2)
335: int(0)
336: int(1)
337: int(0)
338: int(1)
339: int(0)
340: bool(false)
341: int(0)
342: int(0)
343: int(1)
344: int(0)
345: int(1)
346: int(0)
347: bool(false)
348: int(0)
349: int(0)
350: int(1)
351: int(0)
352: int(1)
353: int(0)
354: bool(false)
355: int(0)
356: int(2)
357: int(1)
358: int(0)
359: int(1)
360: int(2)
361: bool(false)
362: int(2)
363: int(0)
364: int(1)
365: int(0)
366: int(1)
367: int(0)
368: bool(false)
369: int(0)
370:
371: -- Iteration 5 --
372: int(24)
373: int(23)
374: int(22)
375: int(1)
376: int(2)
377: bool(false)
378: int(24)
379: int(24)
380: int(23)
381: int(22)
382: int(1)
383: int(2)
384: bool(false)
385: int(24)
386: int(2)
387: int(1)
388: int(0)
389: int(0)
390: int(1)
391: bool(false)
392: int(2)
393: int(2)
394: int(1)
395: int(0)
396: int(1)
397: int(2)
398: bool(false)
399: int(2)
400: int(5)
401: int(4)
402: int(3)
403: int(1)
404: int(2)
405: bool(false)
406: int(5)
407: int(24)
408: int(23)
409: int(22)
410: int(1)
411: int(2)
412: bool(false)
413: int(24)
414: int(24)
415: int(23)
416: int(22)
417: int(1)
418: int(2)
419: bool(false)
420: int(24)
421: int(5)
422: int(4)
423: int(3)
424: int(1)
425: int(2)
426: bool(false)
427: int(5)
428: int(5)
429: int(4)
430: int(3)
431: int(1)
432: int(2)
433: bool(false)
434: int(5)
435: int(5)
436: int(4)
437: int(3)
438: int(0)
439: int(1)
440: bool(false)
441: int(5)
442:
443: -- Iteration 6 --
444: int(28)
445: int(27)
446: int(26)
447: int(1)
448: int(2)
449: bool(false)
450: int(28)
451: int(28)
452: int(27)
453: int(26)
454: int(1)
455: int(2)
456: bool(false)
457: int(28)
458: int(2)
459: int(1)
460: int(0)
461: int(1)
462: int(0)
463: bool(false)
464: int(2)
465: int(2)
466: int(1)
467: int(0)
468: int(0)
469: int(0)
470: bool(false)
471: int(2)
472: int(28)
473: int(27)
474: int(26)
475: int(1)
476: int(2)
477: bool(false)
478: int(28)
479: int(5)
480: int(4)
481: int(3)
482: int(1)
483: int(0)
484: bool(false)
485: int(5)
486: int(5)
487: int(4)
488: int(3)
489: int(1)
490: int(0)
491: bool(false)
492: int(5)
493: int(5)
494: int(4)
495: int(3)
496: int(1)
497: int(0)
498: bool(false)
499: int(5)
500: int(28)
501: int(27)
502: int(26)
503: int(1)
504: int(2)
505: bool(false)
506: int(28)
507: int(5)
508: int(4)
509: int(3)
510: int(1)
511: int(0)
512: bool(false)
513: int(5)
514:
515: -- Iteration 7 --
516: int(20)
517: int(19)
518: int(18)
519: int(1)
520: int(2)
521: bool(false)
522: int(20)
523: int(20)
524: int(19)
525: int(18)
526: int(1)
527: int(2)
528: bool(false)
529: int(20)
530: int(6)
531: int(5)
532: int(4)
533: int(1)
534: int(2)
535: bool(false)
536: int(6)
537: int(6)
538: int(5)
539: int(4)
540: int(1)
541: int(2)
542: bool(false)
543: int(6)
544: int(16)
545: int(15)
546: int(14)
547: int(1)
548: int(2)
549: bool(false)
550: int(16)
551: int(20)
552: int(19)
553: int(18)
554: int(1)
555: int(2)
556: bool(false)
557: int(20)
558: int(20)
559: int(19)
560: int(18)
561: int(1)
562: int(2)
563: bool(false)
564: int(20)
565: int(16)
566: int(15)
567: int(14)
568: int(1)
569: int(2)
570: bool(false)
571: int(16)
572: int(16)
573: int(15)
574: int(14)
575: int(1)
576: int(2)
577: bool(false)
578: int(16)
579: int(16)
580: int(15)
581: int(14)
582: int(1)
583: int(2)
584: bool(false)
585: int(16)
586:
587: -- Iteration 8 --
588: int(21)
589: int(20)
590: int(19)
591: int(1)
592: int(2)
593: bool(false)
594: int(21)
595: int(21)
596: int(20)
597: int(19)
598: int(1)
599: int(2)
600: bool(false)
601: int(21)
602: int(6)
603: int(5)
604: int(4)
605: int(1)
606: int(2)
607: bool(false)
608: int(6)
609: int(6)
610: int(5)
611: int(4)
612: int(1)
613: int(2)
614: bool(false)
615: int(6)
616: int(21)
617: int(20)
618: int(19)
619: int(1)
620: int(2)
621: bool(false)
622: int(21)
623: int(16)
624: int(15)
625: int(14)
626: int(1)
627: int(2)
628: bool(false)
629: int(16)
630: int(16)
631: int(15)
632: int(14)
633: int(1)
634: int(2)
635: bool(false)
636: int(16)
637: int(16)
638: int(15)
639: int(14)
640: int(1)
641: int(2)
642: bool(false)
643: int(16)
644: int(21)
645: int(20)
646: int(19)
647: int(1)
648: int(2)
649: bool(false)
650: int(21)
651: int(16)
652: int(15)
653: int(14)
654: int(1)
655: int(2)
656: bool(false)
657: int(16)
658:
659: -- Iteration 9 --
660: int(5)
661: int(4)
662: int(3)
663: int(1)
664: int(2)
665: bool(false)
666: int(5)
667: int(5)
668: int(4)
669: int(3)
670: int(1)
671: int(2)
672: bool(false)
673: int(5)
674: int(2)
675: int(1)
676: int(0)
677: int(0)
678: int(1)
679: bool(false)
680: int(2)
681: int(2)
682: int(1)
683: int(0)
684: int(1)
685: int(2)
686: bool(false)
687: int(2)
688: int(12)
689: int(11)
690: int(10)
691: int(1)
692: int(2)
693: bool(false)
694: int(12)
695: int(12)
696: int(11)
697: int(10)
698: int(1)
699: int(2)
700: bool(false)
701: int(12)
702: int(12)
703: int(11)
704: int(10)
705: int(1)
706: int(2)
707: bool(false)
708: int(12)
709: int(12)
710: int(11)
711: int(10)
712: int(1)
713: int(2)
714: bool(false)
715: int(12)
716: int(12)
717: int(11)
718: int(10)
719: int(1)
720: int(2)
721: bool(false)
722: int(12)
723: int(11)
724: int(10)
725: int(9)
726: int(0)
727: int(1)
728: bool(false)
729: int(11)
730:
731: -- Iteration 10 --
732: int(16)
733: int(15)
734: int(14)
735: int(1)
736: int(2)
737: bool(false)
738: int(16)
739: int(16)
740: int(15)
741: int(14)
742: int(1)
743: int(2)
744: bool(false)
745: int(16)
746: int(2)
747: int(1)
748: int(0)
749: int(1)
750: int(2)
751: bool(false)
752: int(2)
753: int(2)
754: int(1)
755: int(0)
756: int(1)
757: int(2)
758: bool(false)
759: int(2)
760: int(16)
761: int(15)
762: int(14)
763: int(1)
764: int(2)
765: bool(false)
766: int(16)
767: int(5)
768: int(4)
769: int(3)
770: int(1)
771: int(2)
772: bool(false)
773: int(5)
774: int(5)
775: int(4)
776: int(3)
777: int(1)
778: int(2)
779: bool(false)
780: int(5)
781: int(5)
782: int(4)
783: int(3)
784: int(1)
785: int(2)
786: bool(false)
787: int(5)
788: int(16)
789: int(15)
790: int(14)
791: int(1)
792: int(2)
793: bool(false)
794: int(16)
795: int(5)
796: int(4)
797: int(3)
798: int(1)
799: int(2)
800: bool(false)
801: int(5)
802:
803: -- Iteration 11 --
804: int(0)
805: int(0)
806: int(0)
807: int(0)
808: int(0)
809: bool(false)
810: int(0)
811: int(0)
812: int(0)
813: int(0)
814: int(0)
815: int(0)
816: bool(false)
817: int(0)
818: int(2)
819: int(1)
820: int(0)
821: int(1)
822: int(2)
823: bool(false)
824: int(2)
825: int(2)
826: int(1)
827: int(0)
828: int(1)
829: int(2)
830: bool(false)
831: int(2)
832: int(2)
833: int(1)
834: int(0)
835: int(1)
836: int(2)
837: bool(false)
838: int(2)
839: int(2)
840: int(1)
841: int(0)
842: int(1)
843: int(2)
844: bool(false)
845: int(2)
846: int(2)
847: int(1)
848: int(0)
849: int(1)
850: int(2)
851: bool(false)
852: int(2)
853: int(2)
854: int(1)
855: int(0)
856: int(1)
857: int(2)
858: bool(false)
859: int(2)
860: int(2)
861: int(1)
862: int(0)
863: int(1)
864: int(2)
865: bool(false)
866: int(2)
867: int(2)
868: int(1)
869: int(0)
870: int(1)
871: int(2)
872: bool(false)
873: int(2)
874:
875: -- Iteration 12 --
876: int(0)
877: int(5)
878: int(4)
879: int(0)
880: int(1)
881: bool(false)
882: int(0)
883: int(0)
884: int(5)
885: int(4)
886: int(0)
887: int(1)
888: bool(false)
889: int(0)
890: int(3)
891: int(2)
892: int(1)
893: int(1)
894: int(2)
895: bool(false)
896: int(3)
897: int(3)
898: int(2)
899: int(1)
900: int(1)
901: int(2)
902: bool(false)
903: int(3)
904: int(13)
905: int(12)
906: int(11)
907: int(1)
908: int(2)
909: bool(false)
910: int(13)
911: int(13)
912: int(12)
913: int(11)
914: int(1)
915: int(2)
916: bool(false)
917: int(13)
918: int(13)
919: int(12)
920: int(11)
921: int(1)
922: int(2)
923: bool(false)
924: int(13)
925: int(13)
926: int(12)
927: int(11)
928: int(1)
929: int(2)
930: bool(false)
931: int(13)
932: int(13)
933: int(12)
934: int(11)
935: int(1)
936: int(2)
937: bool(false)
938: int(13)
939: int(13)
940: int(12)
941: int(11)
942: int(1)
943: int(2)
944: bool(false)
945: int(13)
946:
947: -- Iteration 13 --
948: int(0)
949: int(12)
950: int(11)
951: int(0)
952: int(1)
953: bool(false)
954: int(0)
955: int(0)
956: int(12)
957: int(11)
958: int(0)
959: int(1)
960: bool(false)
961: int(0)
962: int(3)
963: int(2)
964: int(1)
965: int(1)
966: int(2)
967: bool(false)
968: int(3)
969: int(3)
970: int(2)
971: int(1)
972: int(1)
973: int(2)
974: bool(false)
975: int(3)
976: int(14)
977: int(13)
978: int(12)
979: int(1)
980: int(2)
981: bool(false)
982: int(14)
983: int(6)
984: int(5)
985: int(4)
986: int(1)
987: int(2)
988: bool(false)
989: int(6)
990: int(6)
991: int(5)
992: int(4)
993: int(1)
994: int(2)
995: bool(false)
996: int(6)
997: int(6)
998: int(5)
999: int(4)
1000: int(1)
1001: int(2)
1002: bool(false)
1003: int(6)
1004: int(14)
1005: int(13)
1006: int(12)
1007: int(1)
1008: int(2)
1009: bool(false)
1010: int(14)
1011: int(6)
1012: int(5)
1013: int(4)
1014: int(1)
1015: int(2)
1016: bool(false)
1017: int(6)
1018:
1019: -- Iteration 14 --
1020: int(5)
1021: int(4)
1022: int(3)
1023: int(1)
1024: int(2)
1025: bool(false)
1026: int(5)
1027: int(5)
1028: int(4)
1029: int(3)
1030: int(1)
1031: int(2)
1032: bool(false)
1033: int(5)
1034: int(2)
1035: int(1)
1036: int(0)
1037: int(1)
1038: int(0)
1039: bool(false)
1040: int(2)
1041: int(2)
1042: int(1)
1043: int(0)
1044: int(1)
1045: int(0)
1046: bool(false)
1047: int(2)
1048: int(11)
1049: int(10)
1050: int(9)
1051: int(1)
1052: int(2)
1053: bool(false)
1054: int(11)
1055: int(11)
1056: int(10)
1057: int(9)
1058: int(1)
1059: int(2)
1060: bool(false)
1061: int(11)
1062: int(11)
1063: int(10)
1064: int(9)
1065: int(1)
1066: int(2)
1067: bool(false)
1068: int(11)
1069: int(11)
1070: int(10)
1071: int(9)
1072: int(1)
1073: int(2)
1074: bool(false)
1075: int(11)
1076: int(11)
1077: int(10)
1078: int(9)
1079: int(1)
1080: int(2)
1081: bool(false)
1082: int(11)
1083: int(11)
1084: int(10)
1085: int(9)
1086: int(1)
1087: int(2)
1088: bool(false)
1089: int(11)
1090:
1091: -- Iteration 15 --
1092: int(5)
1093: int(4)
1094: int(3)
1095: int(1)
1096: int(2)
1097: bool(false)
1098: int(5)
1099: int(5)
1100: int(4)
1101: int(3)
1102: int(1)
1103: int(2)
1104: bool(false)
1105: int(5)
1106: int(2)
1107: int(1)
1108: int(0)
1109: int(1)
1110: int(0)
1111: bool(false)
1112: int(2)
1113: int(2)
1114: int(1)
1115: int(0)
1116: int(1)
1117: int(0)
1118: bool(false)
1119: int(2)
1120: int(11)
1121: int(10)
1122: int(9)
1123: int(1)
1124: int(2)
1125: bool(false)
1126: int(11)
1127: int(11)
1128: int(10)
1129: int(9)
1130: int(1)
1131: int(2)
1132: bool(false)
1133: int(11)
1134: int(11)
1135: int(10)
1136: int(9)
1137: int(1)
1138: int(2)
1139: bool(false)
1140: int(11)
1141: int(11)
1142: int(10)
1143: int(9)
1144: int(1)
1145: int(2)
1146: bool(false)
1147: int(11)
1148: int(11)
1149: int(10)
1150: int(9)
1151: int(1)
1152: int(2)
1153: bool(false)
1154: int(11)
1155: int(11)
1156: int(10)
1157: int(9)
1158: int(1)
1159: int(2)
1160: bool(false)
1161: int(11)
1162:
1163: -- Iteration 16 --
1164: int(5)
1165: int(4)
1166: int(3)
1167: int(1)
1168: int(2)
1169: bool(false)
1170: int(5)
1171: int(5)
1172: int(4)
1173: int(3)
1174: int(1)
1175: int(2)
1176: bool(false)
1177: int(5)
1178: int(2)
1179: int(1)
1180: int(0)
1181: int(1)
1182: int(0)
1183: bool(false)
1184: int(2)
1185: int(2)
1186: int(1)
1187: int(0)
1188: int(1)
1189: int(0)
1190: bool(false)
1191: int(2)
1192: int(14)
1193: int(13)
1194: int(12)
1195: int(1)
1196: int(2)
1197: bool(false)
1198: int(14)
1199: int(14)
1200: int(13)
1201: int(12)
1202: int(1)
1203: int(2)
1204: bool(false)
1205: int(14)
1206: int(14)
1207: int(13)
1208: int(12)
1209: int(1)
1210: int(2)
1211: bool(false)
1212: int(14)
1213: int(14)
1214: int(13)
1215: int(12)
1216: int(1)
1217: int(2)
1218: bool(false)
1219: int(14)
1220: int(14)
1221: int(13)
1222: int(12)
1223: int(1)
1224: int(2)
1225: bool(false)
1226: int(14)
1227: int(6)
1228: int(5)
1229: int(4)
1230: int(1)
1231: int(2)
1232: bool(false)
1233: int(6)
1234:
1235: -- Iteration 17 --
1236: int(21)
1237: int(20)
1238: int(19)
1239: int(1)
1240: int(2)
1241: bool(false)
1242: int(21)
1243: int(21)
1244: int(20)
1245: int(19)
1246: int(1)
1247: int(2)
1248: bool(false)
1249: int(21)
1250: int(2)
1251: int(1)
1252: int(0)
1253: int(1)
1254: int(0)
1255: bool(false)
1256: int(2)
1257: int(2)
1258: int(1)
1259: int(0)
1260: int(1)
1261: int(0)
1262: bool(false)
1263: int(2)
1264: int(21)
1265: int(20)
1266: int(19)
1267: int(1)
1268: int(2)
1269: bool(false)
1270: int(21)
1271: int(5)
1272: int(4)
1273: int(3)
1274: int(1)
1275: int(2)
1276: bool(false)
1277: int(5)
1278: int(5)
1279: int(4)
1280: int(3)
1281: int(1)
1282: int(2)
1283: bool(false)
1284: int(5)
1285: int(5)
1286: int(4)
1287: int(3)
1288: int(1)
1289: int(2)
1290: bool(false)
1291: int(5)
1292: int(21)
1293: int(20)
1294: int(19)
1295: int(1)
1296: int(2)
1297: bool(false)
1298: int(21)
1299: int(5)
1300: int(4)
1301: int(3)
1302: int(1)
1303: int(2)
1304: bool(false)
1305: int(5)
1306: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>