Annotation of embedaddon/php/ext/standard/tests/strings/chunk_split_variation11.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test chunk_split() function : usage variations - different strings for 'ending' with heredoc 'str'
                      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 strings for 'ending' and heredoc string as 'str' to chunk_split()
                     13: * 'chunklen' is set to 6E0 for this testcase
                     14: */
                     15: 
                     16: echo "*** Testing chunk_split() : different values for 'ending' with heredoc 'str'***\n";
                     17: 
                     18: // Initializing required variables
                     19: // heredoc string for 'str' argument
                     20: $heredoc_str = <<<EOT
                     21: This is heredoc string with \t and \n.It also contains
                     22: sPeci@! ch@r$ :) & numbers 222.This is \k wrong escape char.
                     23: EOT;
                     24: 
                     25: $chunklen = 6E+0;
                     26: 
                     27: //different values for 'ending'
                     28: $values = array (
                     29:   "",  //empty 
                     30:   " ",  //space
                     31:   "a",  //single char
                     32:   "ENDING",  //regular string
                     33:   "\r\n",  //White space char
                     34:   "123",  //Numeric
                     35:   ")speci@! ch@r$(",  //String with special chars
                     36: );
                     37: 
                     38: //loop through each values for 'ending'
                     39: for($count = 0; $count < count($values); $count++) {
                     40:   echo "-- Iteration ".($count+1). " --\n";
                     41:   var_dump( chunk_split($heredoc_str, $chunklen, $values[$count]) );
                     42: }
                     43: 
                     44: echo "Done"
                     45: ?>
                     46: --EXPECTF--
                     47: *** Testing chunk_split() : different values for 'ending' with heredoc 'str'***
                     48: -- Iteration 1 --
                     49: string(113) "This is heredoc string with        and 
                     50: .It also contains
                     51: sPeci@! ch@r$ :) & numbers 222.This is \k wrong escape char."
                     52: -- Iteration 2 --
                     53: string(132) "This i s here doc st ring w ith     and 
                     54: . It als o cont ains
                     55: s Peci@!  ch@r$  :) &  number s 222. This i s \k w rong e scape  char. "
                     56: -- Iteration 3 --
                     57: string(132) "This ias hereadoc staring waith    aand 
                     58: .aIt alsao contaains
                     59: saPeci@!a ch@r$a :) & anumberas 222.aThis ias \k warong eascape achar.a"
                     60: -- Iteration 4 --
                     61: string(227) "This iENDINGs hereENDINGdoc stENDINGring wENDINGith        ENDINGand 
                     62: .ENDINGIt alsENDINGo contENDINGains
                     63: sENDINGPeci@!ENDING ch@r$ENDING :) & ENDINGnumberENDINGs 222.ENDINGThis iENDINGs \k wENDINGrong eENDINGscape ENDINGchar.ENDING"
                     64: -- Iteration 5 --
                     65: string(151) "This i
                     66: s here
                     67: doc st
                     68: ring w
                     69: ith     
                     70: and 
                     71: .
                     72: It als
                     73: o cont
                     74: ains
                     75: s
                     76: Peci@!
                     77:  ch@r$
                     78:  :) & 
                     79: number
                     80: s 222.
                     81: This i
                     82: s \k w
                     83: rong e
                     84: scape 
                     85: char.
                     86: "
                     87: -- Iteration 6 --
                     88: string(170) "This i123s here123doc st123ring w123ith    123and 
                     89: .123It als123o cont123ains
                     90: s123Peci@!123 ch@r$123 :) & 123number123s 222.123This i123s \k w123rong e123scape 123char.123"
                     91: -- Iteration 7 --
                     92: string(398) "This i)speci@! ch@r$(s here)speci@! ch@r$(doc st)speci@! ch@r$(ring w)speci@! ch@r$(ith    )speci@! ch@r$(and 
                     93: .)speci@! ch@r$(It als)speci@! ch@r$(o cont)speci@! ch@r$(ains
                     94: s)speci@! ch@r$(Peci@!)speci@! ch@r$( ch@r$)speci@! ch@r$( :) & )speci@! ch@r$(number)speci@! ch@r$(s 222.)speci@! ch@r$(This i)speci@! ch@r$(s \k w)speci@! ch@r$(rong e)speci@! ch@r$(scape )speci@! ch@r$(char.)speci@! ch@r$("
                     95: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>