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

1.1       misho       1: --TEST--
                      2: Test chunk_split() function : usage variations - unexpected values for 'chunklen' argument(Bug#42796)
                      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: echo "*** Testing chunk_split() : with unexpected values for 'chunklen' argument ***\n";
                     12: 
                     13: // Initialise function arguments
                     14: $str = 'This is chuklen variation';
                     15: $ending = '*';
                     16: 
                     17: //get an unset variable
                     18: $unset_var = 10;
                     19: unset ($unset_var);
                     20: 
                     21: //get resource variable
                     22: $fp = fopen(__FILE__, 'r');
                     23: 
                     24: //Class to get object variable
                     25: class MyClass
                     26: {
                     27:    public function __toString() {
                     28:      return "object";
                     29:    }
                     30: }
                     31: 
                     32: //array of values to iterate over
                     33: $values = array(
                     34: 
                     35:   // float data
                     36:   10.5,
                     37:   -10.5,
                     38:   (float) PHP_INT_MAX + 1,
                     39:   (float) -PHP_INT_MAX - 1,
                     40:   .5,
                     41:  
                     42:   // array data
                     43:   array(),
                     44:   array(0),
                     45:   array(1),
                     46:   array(1, 2),
                     47:   array('color' => 'red', 'item' => 'pen'),
                     48: 
                     49:   // null data
                     50:   NULL,
                     51:   null,
                     52: 
                     53:   // boolean data
                     54:   true,
                     55:   false,
                     56:   TRUE,
                     57:   FALSE,
                     58: 
                     59:   // empty data
                     60:   "",
                     61:   '',
                     62: 
                     63:   // string data
                     64:   "string",
                     65:   'string',
                     66: 
                     67:   // object data
                     68:   new MyClass(),
                     69: 
                     70:   // undefined data
                     71:   @$undefined_var,
                     72: 
                     73:   // unset data
                     74:   @$unset_var,
                     75: 
                     76:   // resource variable
                     77:   $fp
                     78: );
                     79: 
                     80: // loop through each element of the values for 'chunklen'
                     81: for($count = 0; $count < count($values); $count++) {
                     82:   echo "-- Iteration ".($count+1)." --\n";
                     83:   var_dump( chunk_split($str, $values[$count], $ending) );
                     84: }
                     85: 
                     86: //closing resource
                     87: fclose($fp);
                     88: 
                     89: ?>
                     90: ===DONE===
                     91: --EXPECTF--
                     92: *** Testing chunk_split() : with unexpected values for 'chunklen' argument ***
                     93: -- Iteration 1 --
                     94: string(28) "This is ch*uklen vari*ation*"
                     95: -- Iteration 2 --
                     96: 
                     97: Warning: chunk_split(): Chunk length should be greater than zero in %schunk_split_variation2.php on line %d
                     98: bool(false)
                     99: -- Iteration 3 --
                    100: 
                    101: Warning: chunk_split(): Chunk length should be greater than zero in %schunk_split_variation2.php on line %d
                    102: bool(false)
                    103: -- Iteration 4 --
                    104: 
                    105: Warning: chunk_split(): Chunk length should be greater than zero in %schunk_split_variation2.php on line %d
                    106: bool(false)
                    107: -- Iteration 5 --
                    108: 
                    109: Warning: chunk_split(): Chunk length should be greater than zero in %schunk_split_variation2.php on line %d
                    110: bool(false)
                    111: -- Iteration 6 --
                    112: 
                    113: Warning: chunk_split() expects parameter 2 to be long, array given in %schunk_split_variation2.php on line %d
                    114: NULL
                    115: -- Iteration 7 --
                    116: 
                    117: Warning: chunk_split() expects parameter 2 to be long, array given in %schunk_split_variation2.php on line %d
                    118: NULL
                    119: -- Iteration 8 --
                    120: 
                    121: Warning: chunk_split() expects parameter 2 to be long, array given in %schunk_split_variation2.php on line %d
                    122: NULL
                    123: -- Iteration 9 --
                    124: 
                    125: Warning: chunk_split() expects parameter 2 to be long, array given in %schunk_split_variation2.php on line %d
                    126: NULL
                    127: -- Iteration 10 --
                    128: 
                    129: Warning: chunk_split() expects parameter 2 to be long, array given in %schunk_split_variation2.php on line %d
                    130: NULL
                    131: -- Iteration 11 --
                    132: 
                    133: Warning: chunk_split(): Chunk length should be greater than zero in %schunk_split_variation2.php on line %d
                    134: bool(false)
                    135: -- Iteration 12 --
                    136: 
                    137: Warning: chunk_split(): Chunk length should be greater than zero in %schunk_split_variation2.php on line %d
                    138: bool(false)
                    139: -- Iteration 13 --
                    140: string(50) "T*h*i*s* *i*s* *c*h*u*k*l*e*n* *v*a*r*i*a*t*i*o*n*"
                    141: -- Iteration 14 --
                    142: 
                    143: Warning: chunk_split(): Chunk length should be greater than zero in %schunk_split_variation2.php on line %d
                    144: bool(false)
                    145: -- Iteration 15 --
                    146: string(50) "T*h*i*s* *i*s* *c*h*u*k*l*e*n* *v*a*r*i*a*t*i*o*n*"
                    147: -- Iteration 16 --
                    148: 
                    149: Warning: chunk_split(): Chunk length should be greater than zero in %schunk_split_variation2.php on line %d
                    150: bool(false)
                    151: -- Iteration 17 --
                    152: 
                    153: Warning: chunk_split() expects parameter 2 to be long, string given in %schunk_split_variation2.php on line %d
                    154: NULL
                    155: -- Iteration 18 --
                    156: 
                    157: Warning: chunk_split() expects parameter 2 to be long, string given in %schunk_split_variation2.php on line %d
                    158: NULL
                    159: -- Iteration 19 --
                    160: 
                    161: Warning: chunk_split() expects parameter 2 to be long, string given in %schunk_split_variation2.php on line %d
                    162: NULL
                    163: -- Iteration 20 --
                    164: 
                    165: Warning: chunk_split() expects parameter 2 to be long, string given in %schunk_split_variation2.php on line %d
                    166: NULL
                    167: -- Iteration 21 --
                    168: 
                    169: Warning: chunk_split() expects parameter 2 to be long, object given in %schunk_split_variation2.php on line %d
                    170: NULL
                    171: -- Iteration 22 --
                    172: 
                    173: Warning: chunk_split(): Chunk length should be greater than zero in %schunk_split_variation2.php on line %d
                    174: bool(false)
                    175: -- Iteration 23 --
                    176: 
                    177: Warning: chunk_split(): Chunk length should be greater than zero in %schunk_split_variation2.php on line %d
                    178: bool(false)
                    179: -- Iteration 24 --
                    180: 
                    181: Warning: chunk_split() expects parameter 2 to be long, resource given in %schunk_split_variation2.php on line %d
                    182: NULL
                    183: ===DONE===

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