Annotation of embedaddon/php/ext/standard/tests/strings/chunk_split_variation10.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test chunk_split() function : usage variations - different single quoted strings for 'ending' argument
3: --FILE--
4: <?php
5: /* Prototype : string chunk_split(string $str [, int $chunklen [, string $ending]])
6: * Description: Returns split line
7: * Source code: ext/standard/string.c
8: * Alias to functions: none
9: */
10:
11: /*
12: * passing different single quoted strings for 'ending' arguments to chunk_split()
13: * 'chunklen' is set to 9.2 for this testcase
14: */
15:
16: echo "*** Testing chunk_split() : different single quoted strings as 'ending' ***\n";
17:
18:
19: //Initializing variables
20: $str = "This is to test chunk_split() with various 'single quoted' ending string.";
21: $chunklen = 9.2;
22:
23: //different values for 'ending' argument
24: $values = array (
25: '', //empty
26: ' ', //space
27: 'a', //Single char
28: 'ENDING', //String
29: '@#$%^', //Special chars
30:
31:
32: '\t',
33: '\n',
34: '\r',
35: '\r\n',
36:
37: '\0', //Null char
38: '123', //Numeric
39: '(MSG)', //With ( and )
40: ') ending string (', //sentence as ending string
41: ') numbers 1234 (', //string with numbers
42: ') speci@! ch@r$ (' //string with special chars
43: );
44:
45:
46: //loop through each element of values for 'ending'
47: for($count = 0; $count < count($values); $count++) {
48: echo "-- Iteration $count --\n";
49: var_dump( chunk_split($str, $chunklen, $values[$count]) );
50: }
51:
52: echo "Done"
53: ?>
54: --EXPECTF--
55: *** Testing chunk_split() : different single quoted strings as 'ending' ***
56: -- Iteration 0 --
57: string(73) "This is to test chunk_split() with various 'single quoted' ending string."
58: -- Iteration 1 --
59: string(82) "This is t o test ch unk_split () with v arious 's ingle quo ted' endi ng string . "
60: -- Iteration 2 --
61: string(82) "This is tao test chaunk_splita() with vaarious 'saingle quoated' endiang stringa.a"
62: -- Iteration 3 --
63: string(127) "This is tENDINGo test chENDINGunk_splitENDING() with vENDINGarious 'sENDINGingle quoENDINGted' endiENDINGng stringENDING.ENDING"
64: -- Iteration 4 --
65: string(118) "This is t@#$%^o test ch@#$%^unk_split@#$%^() with v@#$%^arious 's@#$%^ingle quo@#$%^ted' endi@#$%^ng string@#$%^.@#$%^"
66: -- Iteration 5 --
67: string(91) "This is t\to test ch\tunk_split\t() with v\tarious 's\tingle quo\tted' endi\tng string\t.\t"
68: -- Iteration 6 --
69: string(91) "This is t\no test ch\nunk_split\n() with v\narious 's\ningle quo\nted' endi\nng string\n.\n"
70: -- Iteration 7 --
71: string(91) "This is t\ro test ch\runk_split\r() with v\rarious 's\ringle quo\rted' endi\rng string\r.\r"
72: -- Iteration 8 --
73: string(109) "This is t\r\no test ch\r\nunk_split\r\n() with v\r\narious 's\r\ningle quo\r\nted' endi\r\nng string\r\n.\r\n"
74: -- Iteration 9 --
75: string(91) "This is t\0o test ch\0unk_split\0() with v\0arious 's\0ingle quo\0ted' endi\0ng string\0.\0"
76: -- Iteration 10 --
77: string(100) "This is t123o test ch123unk_split123() with v123arious 's123ingle quo123ted' endi123ng string123.123"
78: -- Iteration 11 --
79: string(118) "This is t(MSG)o test ch(MSG)unk_split(MSG)() with v(MSG)arious 's(MSG)ingle quo(MSG)ted' endi(MSG)ng string(MSG).(MSG)"
80: -- Iteration 12 --
81: string(226) "This is t) ending string (o test ch) ending string (unk_split) ending string (() with v) ending string (arious 's) ending string (ingle quo) ending string (ted' endi) ending string (ng string) ending string (.) ending string ("
82: -- Iteration 13 --
83: string(217) "This is t) numbers 1234 (o test ch) numbers 1234 (unk_split) numbers 1234 (() with v) numbers 1234 (arious 's) numbers 1234 (ingle quo) numbers 1234 (ted' endi) numbers 1234 (ng string) numbers 1234 (.) numbers 1234 ("
84: -- Iteration 14 --
85: string(226) "This is t) speci@! ch@r$ (o test ch) speci@! ch@r$ (unk_split) speci@! ch@r$ (() with v) speci@! ch@r$ (arious 's) speci@! ch@r$ (ingle quo) speci@! ch@r$ (ted' endi) speci@! ch@r$ (ng string) speci@! ch@r$ (.) speci@! ch@r$ ("
86: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>