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

1.1       misho       1: --TEST--
                      2: Test chunk_split() function : usage variations - single quoted strings for 'str' 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 as 'str' argument to the function
                     13: * 'chunklen' is set to 7 and 'ending' is '):('
                     14: */
                     15: 
                     16: echo "*** Testing chunk_split() : with different single quoted 'str' ***\n";
                     17: 
                     18: //Initializing variables
                     19: $chunklen = 7;
                     20: $ending = "):(";
                     21: 
                     22: //different single quoted string for 'str'
                     23: $values = array(
                     24:   '',  //empty
                     25:   ' ',  //space
                     26:   'This is simple string',  //regular string                                   
                     27:   'It\'s string with quotes',                                  
                     28:   'This contains @ # $ % ^ & chars',   //special characters                   
                     29:   'This string\tcontains\rwhite space\nchars',  //with white space chars      
                     30:   'This is string with 1234 numbers',                    
                     31:   'This is string with \0 and ".chr(0)."null chars',  //for binary safe 
                     32:   'This is string with    multiple         space char',  
                     33:   'This is to check string with ()',                           
                     34:   '     Testing with    multiple spaces     ',                           
                     35:   'Testing invalid \k and \m escape char',            
                     36:   'This is to check with \\n and \\t'                     
                     37: );                                                                         
                     38:                                                           
                     39: 
                     40: //Loop through each element of values for 'str'
                     41: for($count = 0;$count < count($values);$count++) {
                     42:   echo "-- Iteration $count --\n";
                     43:   var_dump( chunk_split($values[$count], $chunklen, $ending) );
                     44: }
                     45: 
                     46: echo "Done"
                     47: ?>
                     48: --EXPECTF--
                     49: *** Testing chunk_split() : with different single quoted 'str' ***
                     50: -- Iteration 0 --
                     51: string(3) "):("
                     52: -- Iteration 1 --
                     53: string(4) " ):("
                     54: -- Iteration 2 --
                     55: string(30) "This is):( simple):( string):("
                     56: -- Iteration 3 --
                     57: string(35) "It's st):(ring wi):(th quot):(es):("
                     58: -- Iteration 4 --
                     59: string(46) "This co):(ntains ):(@ # $ %):( ^ & ch):(ars):("
                     60: -- Iteration 5 --
                     61: string(59) "This st):(ring\tc):(ontains):(\rwhite):( space\):(nchars):("
                     62: -- Iteration 6 --
                     63: string(47) "This is):( string):( with 1):(234 num):(bers):("
                     64: -- Iteration 7 --
                     65: string(68) "This is):( string):( with \):(0 and "):(.chr(0)):(."null ):(chars):("
                     66: -- Iteration 8 --
                     67: string(74) "This is):( string):( with  ):(  multi):(ple    ):(     sp):(ace cha):(r):("
                     68: -- Iteration 9 --
                     69: string(46) "This is):( to che):(ck stri):(ng with):( ()):("
                     70: -- Iteration 10 --
                     71: string(59) "     Te):(sting w):(ith    ):(multipl):(e space):(s     ):("
                     72: -- Iteration 11 --
                     73: string(55) "Testing):( invali):(d \k an):(d \m es):(cape ch):(ar):("
                     74: -- Iteration 12 --
                     75: string(46) "This is):( to che):(ck with):( \n and):( \t):("
                     76: Done

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