Annotation of embedaddon/php/ext/standard/tests/strings/chunk_split_variation9.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test chunk_split() function : usage variations - different double 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 double quoted strings for 'ending' argument to chunk_split()
13: * here 'chunklen' is set to 6.5
14: */
15:
16: echo "*** Testing chunk_split() : different strings for 'ending' ***\n";
17:
18: //Initializing variables
19: $str = "This is to test chunk_split() with various ending string";
20: $chunklen = 6.5;
21:
22: //different values for 'ending' argument
23: $values = array (
24: "", //empty
25: " ", //space
26: "a", //Single char
27: "ENDING", //regular string
28: "@#$%^", //Special chars
29:
30: // white space chars
31: "\t",
32: "\n",
33: "\r",
34: "\r\n",
35:
36: "\0", //Null char
37: "123", //Numeric
38: "(MSG)", //With ( and )
39: ")ending string(", //sentence as ending string
40: ")numbers 1234(",
41: ")speci@! ch@r$("
42: );
43:
44: //loop through element of values for 'ending'
45: for($count = 0; $count < count($values); $count++) {
46: echo "-- Iteration $count --\n";
47: var_dump( chunk_split($str, $chunklen, $values[$count]) );
48: }
49:
50: echo "Done"
51: ?>
52: --EXPECTF--
53: *** Testing chunk_split() : different strings for 'ending' ***
54: -- Iteration 0 --
55: string(56) "This is to test chunk_split() with various ending string"
56: -- Iteration 1 --
57: string(66) "This i s to t est ch unk_sp lit() with v arious endin g stri ng "
58: -- Iteration 2 --
59: string(66) "This ias to taest chaunk_spalit() awith vaariousa endinag strianga"
60: -- Iteration 3 --
61: string(116) "This iENDINGs to tENDINGest chENDINGunk_spENDINGlit() ENDINGwith vENDINGariousENDING endinENDINGg striENDINGngENDING"
62: -- Iteration 4 --
63: string(106) "This i@#$%^s to t@#$%^est ch@#$%^unk_sp@#$%^lit() @#$%^with v@#$%^arious@#$%^ endin@#$%^g stri@#$%^ng@#$%^"
64: -- Iteration 5 --
65: string(66) "This i s to t est ch unk_sp lit() with v arious endin g stri ng "
66: -- Iteration 6 --
67: string(66) "This i
68: s to t
69: est ch
70: unk_sp
71: lit()
72: with v
73: arious
74: endin
75: g stri
76: ng
77: "
78: -- Iteration 7 --
79: string(66) "This i
s to t
est ch
unk_sp
lit()
with v
arious
endin
g stri
ng
"
80: -- Iteration 8 --
81: string(76) "This i
82: s to t
83: est ch
84: unk_sp
85: lit()
86: with v
87: arious
88: endin
89: g stri
90: ng
91: "
92: -- Iteration 9 --
93: string(66) "This i s to t est ch unk_sp lit() with v arious endin g stri ng "
94: -- Iteration 10 --
95: string(86) "This i123s to t123est ch123unk_sp123lit() 123with v123arious123 endin123g stri123ng123"
96: -- Iteration 11 --
97: string(106) "This i(MSG)s to t(MSG)est ch(MSG)unk_sp(MSG)lit() (MSG)with v(MSG)arious(MSG) endin(MSG)g stri(MSG)ng(MSG)"
98: -- Iteration 12 --
99: string(206) "This i)ending string(s to t)ending string(est ch)ending string(unk_sp)ending string(lit() )ending string(with v)ending string(arious)ending string( endin)ending string(g stri)ending string(ng)ending string("
100: -- Iteration 13 --
101: string(196) "This i)numbers 1234(s to t)numbers 1234(est ch)numbers 1234(unk_sp)numbers 1234(lit() )numbers 1234(with v)numbers 1234(arious)numbers 1234( endin)numbers 1234(g stri)numbers 1234(ng)numbers 1234("
102: -- Iteration 14 --
103: string(206) "This i)speci@! ch@r$(s to t)speci@! ch@r$(est ch)speci@! ch@r$(unk_sp)speci@! ch@r$(lit() )speci@! ch@r$(with v)speci@! ch@r$(arious)speci@! ch@r$( endin)speci@! ch@r$(g stri)speci@! ch@r$(ng)speci@! ch@r$("
104: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>