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

1.1       misho       1: --TEST--
                      2: Test strtok() function : usage variations - invalid escape sequences as tokens
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : string strtok ( str $str, str $token )
                      6:  * Description: splits a string (str) into smaller strings (tokens), with each token being delimited by any character from token
                      7:  * Source code: ext/standard/string.c
                      8: */
                      9: 
                     10: /*
                     11:  * Testing strtok() : with invalid escape sequences in token
                     12: */
                     13: 
                     14: echo "*** Testing strtok() : with invalid escape sequences in token ***\n";
                     15: 
                     16: // defining arrays for input strings and tokens
                     17: $string_array = array(
                     18:                       "khellok worldk",
                     19:                       "\khello\k world\k",
                     20:                       "/khello\k world/k",
                     21:                       "/hellok/ world"
                     22:                     );
                     23: $token_array = array( 
                     24:                       "k",
                     25:                       "/ ",
                     26:                       "/k",
                     27:                       "\k",
                     28:                       "\\\\\\\k\h\e\l\o\w\r\l\d" 
                     29:                    );
                     30: 
                     31: // loop through each element of the array and check the working of strtok()
                     32: // when supplied with different string and token values
                     33: 
                     34: $counter =1;
                     35: foreach( $string_array as $string )  {
                     36:   echo "\n--- Iteration $counter ---\n";
                     37:   foreach( $token_array as $token )  { 
                     38:     var_dump( strtok($string, $token) ); 
                     39:     for( $count = 1; $count <=3; $count++ )  {
                     40:       var_dump( strtok($token) );
                     41:     }
                     42:     echo "\n";
                     43:   }
                     44:   $counter++;
                     45: }                    
                     46:                      
                     47: 
                     48: echo "Done\n";
                     49: ?>
                     50: --EXPECTF--
                     51: *** Testing strtok() : with invalid escape sequences in token ***
                     52: 
                     53: --- Iteration 1 ---
                     54: string(5) "hello"
                     55: string(6) " world"
                     56: bool(false)
                     57: bool(false)
                     58: 
                     59: string(7) "khellok"
                     60: string(6) "worldk"
                     61: bool(false)
                     62: bool(false)
                     63: 
                     64: string(5) "hello"
                     65: string(6) " world"
                     66: bool(false)
                     67: bool(false)
                     68: 
                     69: string(5) "hello"
                     70: string(6) " world"
                     71: bool(false)
                     72: bool(false)
                     73: 
                     74: string(1) " "
                     75: string(1) "r"
                     76: bool(false)
                     77: bool(false)
                     78: 
                     79: 
                     80: --- Iteration 2 ---
                     81: string(1) "\"
                     82: string(6) "hello\"
                     83: string(7) " world\"
                     84: bool(false)
                     85: 
                     86: string(9) "\khello\k"
                     87: string(7) "world\k"
                     88: bool(false)
                     89: bool(false)
                     90: 
                     91: string(1) "\"
                     92: string(6) "hello\"
                     93: string(7) " world\"
                     94: bool(false)
                     95: 
                     96: string(5) "hello"
                     97: string(6) " world"
                     98: bool(false)
                     99: bool(false)
                    100: 
                    101: string(1) " "
                    102: string(1) "r"
                    103: bool(false)
                    104: bool(false)
                    105: 
                    106: 
                    107: --- Iteration 3 ---
                    108: string(1) "/"
                    109: string(6) "hello\"
                    110: string(7) " world/"
                    111: bool(false)
                    112: 
                    113: string(8) "khello\k"
                    114: string(5) "world"
                    115: string(1) "k"
                    116: bool(false)
                    117: 
                    118: string(6) "hello\"
                    119: string(6) " world"
                    120: bool(false)
                    121: bool(false)
                    122: 
                    123: string(1) "/"
                    124: string(5) "hello"
                    125: string(7) " world/"
                    126: bool(false)
                    127: 
                    128: string(1) "/"
                    129: string(1) " "
                    130: string(1) "r"
                    131: string(1) "/"
                    132: 
                    133: 
                    134: --- Iteration 4 ---
                    135: string(6) "/hello"
                    136: string(7) "/ world"
                    137: bool(false)
                    138: bool(false)
                    139: 
                    140: string(6) "hellok"
                    141: string(5) "world"
                    142: bool(false)
                    143: bool(false)
                    144: 
                    145: string(5) "hello"
                    146: string(6) " world"
                    147: bool(false)
                    148: bool(false)
                    149: 
                    150: string(6) "/hello"
                    151: string(7) "/ world"
                    152: bool(false)
                    153: bool(false)
                    154: 
                    155: string(1) "/"
                    156: string(2) "/ "
                    157: string(1) "r"
                    158: bool(false)
                    159: 
                    160: Done

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