kraghuba Fri Oct 5 18:20:57 2007 UTC Modified files: /php-src/ext/standard/tests/strings str_split_variation1.phpt str_split_basic.phpt str_split_variation2.phpt str_split_variation3.phpt str_split_variation4.phpt str_split_variation5.phpt str_split_variation6.phpt str_split_variation7.phpt str_split_error.phpt Log: New testcases for str_split() function
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/str_split_variation1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/str_split_variation1.phpt diff -u /dev/null php-src/ext/standard/tests/strings/str_split_variation1.phpt:1.2 --- /dev/null Fri Oct 5 18:20:57 2007 +++ php-src/ext/standard/tests/strings/str_split_variation1.phpt Fri Oct 5 18:20:57 2007 @@ -0,0 +1,388 @@ +--TEST-- +Test str_split() function : usage variations - unexpected values for 'str' argument(Bug#42866) +--FILE-- +<?php +/* Prototype : array str_split( $str [, int $split_length]) + * Description: Convert a string to an array. If split_length is + specified, break the string down into chunks each + split_length characters long. + * Source code: ext/standard/string.c + * Alias to functions: none +*/ + +echo "*** Testing str_split() : unexpected values for 'str' ***\n"; + +// Initialise function arguments +$split_length = 3; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//defining class for object variable +class MyClass +{ + public function __toString() + { + return "object"; + } +} + +//resource variable +$fp = fopen(__FILE__, 'r'); + +//different values for 'str' argument +$values = array( + + // int data + 0, + 1, + 12345, + -2345, + + // float data + 10.5, + -10.5, + 10.5e10, + 10.6E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // object data + new MyClass(), + + // undefined data + @$undefined_var, + + // unset data + @$unset_var, + + //resource data + $fp +); + +// loop through each element of $values for 'str' argument +for($count = 0; $count < count($values); $count++) { + echo "-- Iteration ".($count+1)." --\n"; + var_dump( str_split($values[$count], $split_length) ); +} + +//closing resource +fclose($fp); + +echo "Done"; +?> +--EXPECTF-- +*** Testing str_split() : unexpected values for 'str' *** +-- Iteration 1 -- +array(1) { + [0]=> + string(1) "0" +} +-- Iteration 2 -- +array(1) { + [0]=> + string(1) "1" +} +-- Iteration 3 -- +array(2) { + [0]=> + string(3) "123" + [1]=> + string(2) "45" +} +-- Iteration 4 -- +array(2) { + [0]=> + string(3) "-23" + [1]=> + string(2) "45" +} +-- Iteration 5 -- +array(2) { + [0]=> + string(3) "10." + [1]=> + string(1) "5" +} +-- Iteration 6 -- +array(2) { + [0]=> + string(3) "-10" + [1]=> + string(2) ".5" +} +-- Iteration 7 -- +array(4) { + [0]=> + string(3) "105" + [1]=> + string(3) "000" + [2]=> + string(3) "000" + [3]=> + string(3) "000" +} +-- Iteration 8 -- +array(3) { + [0]=> + string(3) "1.0" + [1]=> + string(3) "6E-" + [2]=> + string(1) "9" +} +-- Iteration 9 -- +array(1) { + [0]=> + string(3) "0.5" +} +-- Iteration 10 -- + +Warning: str_split() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: str_split() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: str_split() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 13 -- + +Warning: str_split() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 14 -- + +Warning: str_split() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 15 -- +array(1) { + [0]=> + string(0) "" +} +-- Iteration 16 -- +array(1) { + [0]=> + string(0) "" +} +-- Iteration 17 -- +array(1) { + [0]=> + string(1) "1" +} +-- Iteration 18 -- +array(1) { + [0]=> + string(0) "" +} +-- Iteration 19 -- +array(1) { + [0]=> + string(1) "1" +} +-- Iteration 20 -- +array(1) { + [0]=> + string(0) "" +} +-- Iteration 21 -- +array(1) { + [0]=> + string(0) "" +} +-- Iteration 22 -- +array(1) { + [0]=> + string(0) "" +} +-- Iteration 23 -- +array(2) { + [0]=> + string(3) "obj" + [1]=> + string(3) "ect" +} +-- Iteration 24 -- +array(1) { + [0]=> + string(0) "" +} +-- Iteration 25 -- +array(1) { + [0]=> + string(0) "" +} +-- Iteration 26 -- + +Warning: str_split() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing str_split() : unexpected values for 'str' *** +-- Iteration 1 -- +array(1) { + [0]=> + unicode(1) "0" +} +-- Iteration 2 -- +array(1) { + [0]=> + unicode(1) "1" +} +-- Iteration 3 -- +array(2) { + [0]=> + unicode(3) "123" + [1]=> + unicode(2) "45" +} +-- Iteration 4 -- +array(2) { + [0]=> + unicode(3) "-23" + [1]=> + unicode(2) "45" +} +-- Iteration 5 -- +array(2) { + [0]=> + unicode(3) "10." + [1]=> + unicode(1) "5" +} +-- Iteration 6 -- +array(2) { + [0]=> + unicode(3) "-10" + [1]=> + unicode(2) ".5" +} +-- Iteration 7 -- +array(4) { + [0]=> + unicode(3) "105" + [1]=> + unicode(3) "000" + [2]=> + unicode(3) "000" + [3]=> + unicode(3) "000" +} +-- Iteration 8 -- +array(3) { + [0]=> + unicode(3) "1.0" + [1]=> + unicode(3) "6E-" + [2]=> + unicode(1) "9" +} +-- Iteration 9 -- +array(1) { + [0]=> + unicode(3) "0.5" +} +-- Iteration 10 -- + +Warning: str_split() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: str_split() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: str_split() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 13 -- + +Warning: str_split() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 14 -- + +Warning: str_split() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 15 -- +array(1) { + [0]=> + unicode(0) "" +} +-- Iteration 16 -- +array(1) { + [0]=> + unicode(0) "" +} +-- Iteration 17 -- +array(1) { + [0]=> + unicode(1) "1" +} +-- Iteration 18 -- +array(1) { + [0]=> + unicode(0) "" +} +-- Iteration 19 -- +array(1) { + [0]=> + unicode(1) "1" +} +-- Iteration 20 -- +array(1) { + [0]=> + unicode(0) "" +} +-- Iteration 21 -- +array(1) { + [0]=> + unicode(0) "" +} +-- Iteration 22 -- +array(1) { + [0]=> + unicode(0) "" +} +-- Iteration 23 -- +array(2) { + [0]=> + unicode(3) "obj" + [1]=> + unicode(3) "ect" +} +-- Iteration 24 -- +array(1) { + [0]=> + unicode(0) "" +} +-- Iteration 25 -- +array(1) { + [0]=> + unicode(0) "" +} +-- Iteration 26 -- + +Warning: str_split() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d +NULL +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/str_split_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/str_split_basic.phpt diff -u /dev/null php-src/ext/standard/tests/strings/str_split_basic.phpt:1.2 --- /dev/null Fri Oct 5 18:20:57 2007 +++ php-src/ext/standard/tests/strings/str_split_basic.phpt Fri Oct 5 18:20:57 2007 @@ -0,0 +1,154 @@ +--TEST-- +Test str_split() function : basic functionality(Bug#42866) +--FILE-- +<?php +/* Prototype : array str_split(string $str [, int $split_length]) + * Description: Convert a string to an array. If split_length is + specified, break the string down into chunks each + split_length characters long. + * Source code: ext/standard/string.c + * Alias to functions: none +*/ + +echo "*** Testing str_split() : basic functionality ***\n"; + +// Initialise all required variables +$str = 'This is basic testcase'; +$split_length = 5; + +// Calling str_split() with all possible arguments +echo "-- With all possible arguments --\n"; +var_dump( str_split($str,$split_length) ); + +// Calling str_split() with default arguments +echo "-- With split_length as default argument --\n"; +var_dump( str_split($str) ); + +echo "Done" +?> +--EXPECTF-- +*** Testing str_split() : basic functionality *** +-- With all possible arguments -- +array(5) { + [0]=> + string(5) "This " + [1]=> + string(5) "is ba" + [2]=> + string(5) "sic t" + [3]=> + string(5) "estca" + [4]=> + string(2) "se" +} +-- With split_length as default argument -- +array(22) { + [0]=> + string(1) "T" + [1]=> + string(1) "h" + [2]=> + string(1) "i" + [3]=> + string(1) "s" + [4]=> + string(1) " " + [5]=> + string(1) "i" + [6]=> + string(1) "s" + [7]=> + string(1) " " + [8]=> + string(1) "b" + [9]=> + string(1) "a" + [10]=> + string(1) "s" + [11]=> + string(1) "i" + [12]=> + string(1) "c" + [13]=> + string(1) " " + [14]=> + string(1) "t" + [15]=> + string(1) "e" + [16]=> + string(1) "s" + [17]=> + string(1) "t" + [18]=> + string(1) "c" + [19]=> + string(1) "a" + [20]=> + string(1) "s" + [21]=> + string(1) "e" +} +Done +--UEXPECTF-- +*** Testing str_split() : basic functionality *** +-- With all possible arguments -- +array(5) { + [0]=> + unicode(5) "This " + [1]=> + unicode(5) "is ba" + [2]=> + unicode(5) "sic t" + [3]=> + unicode(5) "estca" + [4]=> + string(2) "se" +} +-- With split_length as default argument -- +array(22) { + [0]=> + unicode(1) "T" + [1]=> + unicode(1) "h" + [2]=> + unicode(1) "i" + [3]=> + unicode(1) "s" + [4]=> + unicode(1) " " + [5]=> + unicode(1) "i" + [6]=> + unicode(1) "s" + [7]=> + unicode(1) " " + [8]=> + unicode(1) "b" + [9]=> + unicode(1) "a" + [10]=> + unicode(1) "s" + [11]=> + unicode(1) "i" + [12]=> + unicode(1) "c" + [13]=> + unicode(1) " " + [14]=> + unicode(1) "t" + [15]=> + unicode(1) "e" + [16]=> + unicode(1) "s" + [17]=> + unicode(1) "t" + [18]=> + unicode(1) "c" + [19]=> + unicode(1) "a" + [20]=> + unicode(1) "s" + [21]=> + unicode(1) "e" +} +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/str_split_variation2.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/str_split_variation2.phpt diff -u /dev/null php-src/ext/standard/tests/strings/str_split_variation2.phpt:1.2 --- /dev/null Fri Oct 5 18:20:57 2007 +++ php-src/ext/standard/tests/strings/str_split_variation2.phpt Fri Oct 5 18:20:57 2007 @@ -0,0 +1,471 @@ +--TEST-- +Test str_split() function : usage variations - unexpected values for 'split_length' argument(Bug#42866) +--FILE-- +<?php +/* Prototype : array str_split(string $str [, int $split_length]) + * Description: Convert a string to an array. If split_length is + specified, break the string down into chunks each + split_length characters long. + * Source code: ext/standard/string.c + * Alias to functions: none +*/ + +echo "*** Testing str_split() : unexpected values for 'split_length' ***\n"; + +// Initialise function arguments +$str = 'variation2:split_length'; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//defining class for object variable +class MyClass +{ + public function __toString() + { + return "object"; + } +} + +//resource variable +$fp = fopen(__FILE__, 'r'); + +//different values for 'split_length' +$values = array( + + // float data + 10.5, + -10.5, + 10.6E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // object data + new MyClass(), + + // undefined data + @$undefined_var, + + // unset data + @$unset_var, + + //resource data + $fp +); + +// loop through each element of $values for 'split_length' +for($count = 0; $count < count($values); $count++) { + echo "--Iteration ".($count+1)." --\n"; + var_dump( str_split($str, $values[$count]) ); +} + +//closing resource +fclose($fp); + +echo "Done"; +?> +--EXPECTF-- +*** Testing str_split() : unexpected values for 'split_length' *** +--Iteration 1 -- +array(3) { + [0]=> + string(10) "variation2" + [1]=> + string(10) ":split_len" + [2]=> + string(3) "gth" +} +--Iteration 2 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +--Iteration 3 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +--Iteration 4 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +--Iteration 5 -- + +Warning: str_split() expects parameter 2 to be long, array given in %s on line %d +NULL +--Iteration 6 -- + +Warning: str_split() expects parameter 2 to be long, array given in %s on line %d +NULL +--Iteration 7 -- + +Warning: str_split() expects parameter 2 to be long, array given in %s on line %d +NULL +--Iteration 8 -- + +Warning: str_split() expects parameter 2 to be long, array given in %s on line %d +NULL +--Iteration 9 -- + +Warning: str_split() expects parameter 2 to be long, array given in %s on line %d +NULL +--Iteration 10 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +--Iteration 11 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +--Iteration 12 -- +array(23) { + [0]=> + string(1) "v" + [1]=> + string(1) "a" + [2]=> + string(1) "r" + [3]=> + string(1) "i" + [4]=> + string(1) "a" + [5]=> + string(1) "t" + [6]=> + string(1) "i" + [7]=> + string(1) "o" + [8]=> + string(1) "n" + [9]=> + string(1) "2" + [10]=> + string(1) ":" + [11]=> + string(1) "s" + [12]=> + string(1) "p" + [13]=> + string(1) "l" + [14]=> + string(1) "i" + [15]=> + string(1) "t" + [16]=> + string(1) "_" + [17]=> + string(1) "l" + [18]=> + string(1) "e" + [19]=> + string(1) "n" + [20]=> + string(1) "g" + [21]=> + string(1) "t" + [22]=> + string(1) "h" +} +--Iteration 13 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +--Iteration 14 -- +array(23) { + [0]=> + string(1) "v" + [1]=> + string(1) "a" + [2]=> + string(1) "r" + [3]=> + string(1) "i" + [4]=> + string(1) "a" + [5]=> + string(1) "t" + [6]=> + string(1) "i" + [7]=> + string(1) "o" + [8]=> + string(1) "n" + [9]=> + string(1) "2" + [10]=> + string(1) ":" + [11]=> + string(1) "s" + [12]=> + string(1) "p" + [13]=> + string(1) "l" + [14]=> + string(1) "i" + [15]=> + string(1) "t" + [16]=> + string(1) "_" + [17]=> + string(1) "l" + [18]=> + string(1) "e" + [19]=> + string(1) "n" + [20]=> + string(1) "g" + [21]=> + string(1) "t" + [22]=> + string(1) "h" +} +--Iteration 15 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +--Iteration 16 -- + +Warning: str_split() expects parameter 2 to be long, string given in %s on line %d +NULL +--Iteration 17 -- + +Warning: str_split() expects parameter 2 to be long, string given in %s on line %d +NULL +--Iteration 18 -- + +Warning: str_split() expects parameter 2 to be long, string given in %s on line %d +NULL +--Iteration 19 -- + +Warning: str_split() expects parameter 2 to be long, string given in %s on line %d +NULL +--Iteration 20 -- + +Warning: str_split() expects parameter 2 to be long, object given in %s on line %d +NULL +--Iteration 21 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +--Iteration 22 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +--Iteration 23 -- + +Warning: str_split() expects parameter 2 to be long, resource given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing str_split() : unexpected values for 'split_length' *** +--Iteration 1 -- +array(3) { + [0]=> + unicode(10) "variation2" + [1]=> + unicode(10) ":split_len" + [2]=> + unicode(3) "gth" +} +--Iteration 2 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +--Iteration 3 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +--Iteration 4 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +--Iteration 5 -- + +Warning: str_split() expects parameter 2 to be long, array given in %s on line %d +NULL +--Iteration 6 -- + +Warning: str_split() expects parameter 2 to be long, array given in %s on line %d +NULL +--Iteration 7 -- + +Warning: str_split() expects parameter 2 to be long, array given in %s on line %d +NULL +--Iteration 8 -- + +Warning: str_split() expects parameter 2 to be long, array given in %s on line %d +NULL +--Iteration 9 -- + +Warning: str_split() expects parameter 2 to be long, array given in %s on line %d +NULL +--Iteration 10 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +--Iteration 11 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +--Iteration 12 -- +array(23) { + [0]=> + unicode(1) "v" + [1]=> + unicode(1) "a" + [2]=> + unicode(1) "r" + [3]=> + unicode(1) "i" + [4]=> + unicode(1) "a" + [5]=> + unicode(1) "t" + [6]=> + unicode(1) "i" + [7]=> + unicode(1) "o" + [8]=> + unicode(1) "n" + [9]=> + unicode(1) "2" + [10]=> + unicode(1) ":" + [11]=> + unicode(1) "s" + [12]=> + unicode(1) "p" + [13]=> + unicode(1) "l" + [14]=> + unicode(1) "i" + [15]=> + unicode(1) "t" + [16]=> + unicode(1) "_" + [17]=> + unicode(1) "l" + [18]=> + unicode(1) "e" + [19]=> + unicode(1) "n" + [20]=> + unicode(1) "g" + [21]=> + unicode(1) "t" + [22]=> + unicode(1) "h" +} +--Iteration 13 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +--Iteration 14 -- +array(23) { + [0]=> + unicode(1) "v" + [1]=> + unicode(1) "a" + [2]=> + unicode(1) "r" + [3]=> + unicode(1) "i" + [4]=> + unicode(1) "a" + [5]=> + unicode(1) "t" + [6]=> + unicode(1) "i" + [7]=> + unicode(1) "o" + [8]=> + unicode(1) "n" + [9]=> + unicode(1) "2" + [10]=> + unicode(1) ":" + [11]=> + unicode(1) "s" + [12]=> + unicode(1) "p" + [13]=> + unicode(1) "l" + [14]=> + unicode(1) "i" + [15]=> + unicode(1) "t" + [16]=> + unicode(1) "_" + [17]=> + unicode(1) "l" + [18]=> + unicode(1) "e" + [19]=> + unicode(1) "n" + [20]=> + unicode(1) "g" + [21]=> + unicode(1) "t" + [22]=> + unicode(1) "h" +} +--Iteration 15 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +--Iteration 16 -- + +Warning: str_split() expects parameter 2 to be long, Unicode string given in %s on line %d +NULL +--Iteration 17 -- + +Warning: str_split() expects parameter 2 to be long, Unicode string given in %s on line %d +NULL +--Iteration 18 -- + +Warning: str_split() expects parameter 2 to be long, Unicode string given in %s on line %d +NULL +--Iteration 19 -- + +Warning: str_split() expects parameter 2 to be long, Unicode string given in %s on line %d +NULL +--Iteration 20 -- + +Warning: str_split() expects parameter 2 to be long, object given in %s on line %d +NULL +--Iteration 21 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +--Iteration 22 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +--Iteration 23 -- + +Warning: str_split() expects parameter 2 to be long, resource given in %s on line %d +NULL +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/str_split_variation3.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/str_split_variation3.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/str_split_variation4.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/str_split_variation4.phpt diff -u /dev/null php-src/ext/standard/tests/strings/str_split_variation4.phpt:1.2 --- /dev/null Fri Oct 5 18:20:57 2007 +++ php-src/ext/standard/tests/strings/str_split_variation4.phpt Fri Oct 5 18:20:57 2007 @@ -0,0 +1,347 @@ +--TEST-- +Test str_split() function : usage variations - different single quoted strings for 'str' argument(Bug#42866) +--FILE-- +<?php +/* Prototype : array str_split(string $str [, int $split_length]) + * Description: Convert a string to an array. If split_length is + specified, break the string down into chunks each + split_length characters long. + * Source code: ext/standard/string.c + * Alias to functions: none +*/ + +/* +* passing different single quoted strings as 'str' argument to str_split() +* split_length is set to 5 +*/ + +echo "*** Testing str_split() : single quoted strings for 'str' ***\n"; + +//Initialize variables +$split_length = 5; + +// different values for 'str' +$values = array( + '', //empty + ' ', //space + '1234', //with only numbers + 'simple string', //regular string + 'It\'s string with quote', //string containing single quote + 'string\tcontains\rwhite space\nchars', + 'containing @ # $ % ^ & chars', + 'with 1234 numbers', + 'with \0 and ".chr(0)."null chars', //for binary safe + 'with multiple space char', + 'Testing invalid \k and \m escape char', + 'to check with \\n and \\t' //ignoring \n and \t results +); + +//loop through each element of $values for 'str' argument +for($count = 0; $count < count($values); $count++) { + echo "-- Iteration ".($count+1)." --\n"; + var_dump( str_split($values[$count], $split_length) ); +} +echo "Done" +?> +--EXPECTF-- +*** Testing str_split() : single quoted strings for 'str' *** +-- Iteration 1 -- +array(1) { + [0]=> + string(0) "" +} +-- Iteration 2 -- +array(1) { + [0]=> + string(1) " " +} +-- Iteration 3 -- +array(1) { + [0]=> + string(4) "1234" +} +-- Iteration 4 -- +array(3) { + [0]=> + string(5) "simpl" + [1]=> + string(5) "e str" + [2]=> + string(3) "ing" +} +-- Iteration 5 -- +array(5) { + [0]=> + string(5) "It's " + [1]=> + string(5) "strin" + [2]=> + string(5) "g wit" + [3]=> + string(5) "h quo" + [4]=> + string(2) "te" +} +-- Iteration 6 -- +array(8) { + [0]=> + string(5) "strin" + [1]=> + string(5) "g\tco" + [2]=> + string(5) "ntain" + [3]=> + string(5) "s\rwh" + [4]=> + string(5) "ite s" + [5]=> + string(5) "pace\" + [6]=> + string(5) "nchar" + [7]=> + string(1) "s" +} +-- Iteration 7 -- +array(6) { + [0]=> + string(5) "conta" + [1]=> + string(5) "ining" + [2]=> + string(5) " @ # " + [3]=> + string(5) "$ % ^" + [4]=> + string(5) " & ch" + [5]=> + string(3) "ars" +} +-- Iteration 8 -- +array(4) { + [0]=> + string(5) "with " + [1]=> + string(5) "1234 " + [2]=> + string(5) "numbe" + [3]=> + string(2) "rs" +} +-- Iteration 9 -- +array(7) { + [0]=> + string(5) "with " + [1]=> + string(5) "\0 an" + [2]=> + string(5) "d ".c" + [3]=> + string(5) "hr(0)" + [4]=> + string(5) "."nul" + [5]=> + string(5) "l cha" + [6]=> + string(2) "rs" +} +-- Iteration 10 -- +array(7) { + [0]=> + string(5) "with " + [1]=> + string(5) " mu" + [2]=> + string(5) "ltipl" + [3]=> + string(5) "e " + [4]=> + string(5) " spac" + [5]=> + string(5) "e cha" + [6]=> + string(1) "r" +} +-- Iteration 11 -- +array(8) { + [0]=> + string(5) "Testi" + [1]=> + string(5) "ng in" + [2]=> + string(5) "valid" + [3]=> + string(5) " \k a" + [4]=> + string(5) "nd \m" + [5]=> + string(5) " esca" + [6]=> + string(5) "pe ch" + [7]=> + string(2) "ar" +} +-- Iteration 12 -- +array(5) { + [0]=> + string(5) "to ch" + [1]=> + string(5) "eck w" + [2]=> + string(5) "ith \" + [3]=> + string(5) "n and" + [4]=> + string(3) " \t" +} +Done +--UEXPECTF-- +*** Testing str_split() : single quoted strings for 'str' *** +-- Iteration 1 -- +array(1) { + [0]=> + unicode(0) "" +} +-- Iteration 2 -- +array(1) { + [0]=> + unicode(1) " " +} +-- Iteration 3 -- +array(1) { + [0]=> + unicode(4) "1234" +} +-- Iteration 4 -- +array(3) { + [0]=> + unicode(5) "simpl" + [1]=> + unicode(5) "e str" + [2]=> + unicode(3) "ing" +} +-- Iteration 5 -- +array(5) { + [0]=> + unicode(5) "It's " + [1]=> + unicode(5) "strin" + [2]=> + unicode(5) "g wit" + [3]=> + unicode(5) "h quo" + [4]=> + unicode(2) "te" +} +-- Iteration 6 -- +array(8) { + [0]=> + unicode(5) "strin" + [1]=> + unicode(5) "g\tco" + [2]=> + unicode(5) "ntain" + [3]=> + unicode(5) "s\rwh" + [4]=> + unicode(5) "ite s" + [5]=> + unicode(5) "pace\" + [6]=> + unicode(5) "nchar" + [7]=> + unicode(1) "s" +} +-- Iteration 7 -- +array(6) { + [0]=> + unicode(5) "conta" + [1]=> + unicode(5) "ining" + [2]=> + unicode(5) " @ # " + [3]=> + unicode(5) "$ % ^" + [4]=> + unicode(5) " & ch" + [5]=> + unicode(3) "ars" +} +-- Iteration 8 -- +array(4) { + [0]=> + unicode(5) "with " + [1]=> + unicode(5) "1234 " + [2]=> + unicode(5) "numbe" + [3]=> + unicode(2) "rs" +} +-- Iteration 9 -- +array(7) { + [0]=> + unicode(5) "with " + [1]=> + unicode(5) "\0 an" + [2]=> + unicode(5) "d ".c" + [3]=> + unicode(5) "hr(0)" + [4]=> + unicode(5) "."nul" + [5]=> + unicode(5) "l cha" + [6]=> + unicode(2) "rs" +} +-- Iteration 10 -- +array(7) { + [0]=> + unicode(5) "with " + [1]=> + unicode(5) " mu" + [2]=> + unicode(5) "ltipl" + [3]=> + unicode(5) "e " + [4]=> + unicode(5) " spac" + [5]=> + unicode(5) "e cha" + [6]=> + unicode(1) "r" +} +-- Iteration 11 -- +array(8) { + [0]=> + unicode(5) "Testi" + [1]=> + unicode(5) "ng in" + [2]=> + unicode(5) "valid" + [3]=> + unicode(5) " \k a" + [4]=> + unicode(5) "nd \m" + [5]=> + unicode(5) " esca" + [6]=> + unicode(5) "pe ch" + [7]=> + unicode(2) "ar" +} +-- Iteration 12 -- +array(5) { + [0]=> + unicode(5) "to ch" + [1]=> + unicode(5) "eck w" + [2]=> + unicode(5) "ith \" + [3]=> + unicode(5) "n and" + [4]=> + unicode(3) " \t" +} +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/str_split_variation5.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/str_split_variation5.phpt diff -u /dev/null php-src/ext/standard/tests/strings/str_split_variation5.phpt:1.2 --- /dev/null Fri Oct 5 18:20:57 2007 +++ php-src/ext/standard/tests/strings/str_split_variation5.phpt Fri Oct 5 18:20:57 2007 @@ -0,0 +1,264 @@ +--TEST-- +Test str_split() function : usage variations - different heredoc strings as 'str' argument(Bug#42866) +--FILE-- +<?php +/* Prototype : array str_split(string $str [, int $split_length] ) + * Description: Convert a string to an array. If split_length is + specified, break the string down into chunks each + split_length characters long. + * Source code: ext/standard/string.c + * Alias to functions: none +*/ + +/* +* Passing different heredoc strings as 'str' argument to the str_split() +* with 'split_length' 10 +*/ + +echo "*** Testing str_split() : heredoc strings as 'str' argument ***\n"; + +// Initializing required variables +$split_length = 10; + +// Null heredoc string +$heredoc_null = <<<EOT1 +EOT1; + +// heredoc string with single character +$heredoc_char = <<<EOT2 +a +EOT2; + +// simple heredoc string +$heredoc_str = <<<EOT3 +This is simple heredoc string +EOT3; + +// heredoc with special characters +$heredoc_spchar = <<<EOT4 +This checks heredoc with $, %, &, chars +EOT4; + +// blank heredoc string +$heredoc_blank = <<<EOT5 + +EOT5; + +// heredoc with different white space characters +$heredoc_escchar = <<<EOT6 +This checks\t str_split()\nEscape\rchars +EOT6; + +// heredoc with multiline +$heredoc_multiline= <<<EOT7 +This is to check str_split +function with multiline +heredoc +EOT7; + +// heredoc with quotes and slashes +$heredoc_quote_slash = <<<EOT8 +"To check " in heredoc" +I'm sure it'll work also with \ +which is single slash +EOT8; + +//different heredoc strings for 'str' +$heredoc_array = array( + $heredoc_null, + $heredoc_blank, + $heredoc_char, + $heredoc_str, + $heredoc_multiline, + $heredoc_spchar, + $heredoc_escchar, + $heredoc_quote_slash +); + + +// loop through each element of the 'heredoc_array' for 'str' +$count = 0; +foreach($heredoc_array as $str) { + echo "-- Iteration ".($count+1). " --\n"; + var_dump( str_split($str, $split_length) ); + $count++; +}; + +echo "Done" +?> +--EXPECTF-- +*** Testing str_split() : heredoc strings as 'str' argument *** +-- Iteration 1 -- +array(1) { + [0]=> + string(0) "" +} +-- Iteration 2 -- +array(1) { + [0]=> + string(0) "" +} +-- Iteration 3 -- +array(1) { + [0]=> + string(1) "a" +} +-- Iteration 4 -- +array(3) { + [0]=> + string(10) "This is si" + [1]=> + string(10) "mple hered" + [2]=> + string(9) "oc string" +} +-- Iteration 5 -- +array(6) { + [0]=> + string(10) "This is to" + [1]=> + string(10) " check str" + [2]=> + string(10) "_split +fun" + [3]=> + string(10) "ction with" + [4]=> + string(10) " multiline" + [5]=> + string(8) " +heredoc" +} +-- Iteration 6 -- +array(4) { + [0]=> + string(10) "This check" + [1]=> + string(10) "s heredoc " + [2]=> + string(10) "with $, %," + [3]=> + string(9) " &, chars" +} +-- Iteration 7 -- +array(4) { + [0]=> + string(10) "This check" + [1]=> + string(10) "s str_spl" + [2]=> + string(10) "it() +Escap" + [3]=> + string(7) "echars" +} +-- Iteration 8 -- +array(8) { + [0]=> + string(10) ""To check " + [1]=> + string(10) "" in hered" + [2]=> + string(10) "oc" +I'm su" + [3]=> + string(10) "re it'll w" + [4]=> + string(10) "ork also w" + [5]=> + string(10) "ith \ +whic" + [6]=> + string(10) "h is singl" + [7]=> + string(7) "e slash" +} +Done +--UEXPECTF-- +*** Testing str_split() : heredoc strings as 'str' argument *** +-- Iteration 1 -- +array(1) { + [0]=> + unicode(0) "" +} +-- Iteration 2 -- +array(1) { + [0]=> + unicode(0) "" +} +-- Iteration 3 -- +array(1) { + [0]=> + unicode(1) "a" +} +-- Iteration 4 -- +array(3) { + [0]=> + unicode(10) "This is si" + [1]=> + unicode(10) "mple hered" + [2]=> + unicode(9) "oc string" +} +-- Iteration 5 -- +array(6) { + [0]=> + unicode(10) "This is to" + [1]=> + unicode(10) " check str" + [2]=> + unicode(10) "_split +fun" + [3]=> + unicode(10) "ction with" + [4]=> + unicode(10) " multiline" + [5]=> + unicode(8) " +heredoc" +} +-- Iteration 6 -- +array(4) { + [0]=> + unicode(10) "This check" + [1]=> + unicode(10) "s heredoc " + [2]=> + unicode(10) "with $, %," + [3]=> + unicode(9) " &, chars" +} +-- Iteration 7 -- +array(4) { + [0]=> + unicode(10) "This check" + [1]=> + unicode(10) "s str_spl" + [2]=> + unicode(10) "it() +Escap" + [3]=> + unicode(7) "echars" +} +-- Iteration 8 -- +array(8) { + [0]=> + unicode(10) ""To check " + [1]=> + unicode(10) "" in hered" + [2]=> + unicode(10) "oc" +I'm su" + [3]=> + unicode(10) "re it'll w" + [4]=> + unicode(10) "ork also w" + [5]=> + unicode(10) "ith \ +whic" + [6]=> + unicode(10) "h is singl" + [7]=> + unicode(7) "e slash" +} +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/str_split_variation6.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/str_split_variation6.phpt diff -u /dev/null php-src/ext/standard/tests/strings/str_split_variation6.phpt:1.2 --- /dev/null Fri Oct 5 18:20:57 2007 +++ php-src/ext/standard/tests/strings/str_split_variation6.phpt Fri Oct 5 18:20:57 2007 @@ -0,0 +1,285 @@ +--TEST-- +Test str_split() function : usage variations - different integer values for 'split_length' argument(Bug#42866) +--FILE-- +<?php +/* Prototype : array str_split(string $str [, int $split_length]) + * Description: Convert a string to an array. If split_length is + specified, break the string down into chunks each + split_length characters long. + * Source code: ext/standard/string.c + * Alias to functions: none +*/ + +/* +* passing different integer values for 'split_length' argument to str_split() +*/ + +echo "*** Testing str_split() : different intger values for 'split_length' ***\n"; +//Initialise variables +$str = 'This is a string with 123 & escape char \t'; + +//different values for 'split_length' +$values = array ( + 0, + 1, + -123, //negative integer + 0234, //octal number + 0x1A, //hexadecimal number + 2147483647, //max positive integer number + 2147483648, //max positive integer+1 + -2147483648, //min negative integer +); + +//loop through each element of $values for 'split_length' +for($count = 0; $count < count($values); $count++) { + echo "-- Iteration ".($count + 1)." --\n"; + var_dump( str_split($str, $values[$count]) ); +} +echo "Done" +?> +--EXPECTF-- +*** Testing str_split() : different intger values for 'split_length' *** +-- Iteration 1 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +-- Iteration 2 -- +array(42) { + [0]=> + string(1) "T" + [1]=> + string(1) "h" + [2]=> + string(1) "i" + [3]=> + string(1) "s" + [4]=> + string(1) " " + [5]=> + string(1) "i" + [6]=> + string(1) "s" + [7]=> + string(1) " " + [8]=> + string(1) "a" + [9]=> + string(1) " " + [10]=> + string(1) "s" + [11]=> + string(1) "t" + [12]=> + string(1) "r" + [13]=> + string(1) "i" + [14]=> + string(1) "n" + [15]=> + string(1) "g" + [16]=> + string(1) " " + [17]=> + string(1) "w" + [18]=> + string(1) "i" + [19]=> + string(1) "t" + [20]=> + string(1) "h" + [21]=> + string(1) " " + [22]=> + string(1) "1" + [23]=> + string(1) "2" + [24]=> + string(1) "3" + [25]=> + string(1) " " + [26]=> + string(1) "&" + [27]=> + string(1) " " + [28]=> + string(1) "e" + [29]=> + string(1) "s" + [30]=> + string(1) "c" + [31]=> + string(1) "a" + [32]=> + string(1) "p" + [33]=> + string(1) "e" + [34]=> + string(1) " " + [35]=> + string(1) "c" + [36]=> + string(1) "h" + [37]=> + string(1) "a" + [38]=> + string(1) "r" + [39]=> + string(1) " " + [40]=> + string(1) "\" + [41]=> + string(1) "t" +} +-- Iteration 3 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +-- Iteration 4 -- +array(1) { + [0]=> + string(42) "This is a string with 123 & escape char \t" +} +-- Iteration 5 -- +array(2) { + [0]=> + string(26) "This is a string with 123 " + [1]=> + string(16) "& escape char \t" +} +-- Iteration 6 -- +array(1) { + [0]=> + string(42) "This is a string with 123 & escape char \t" +} +-- Iteration 7 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +-- Iteration 8 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +Done +--UEXPECTF-- +*** Testing str_split() : different intger values for 'split_length' *** +-- Iteration 1 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +-- Iteration 2 -- +array(42) { + [0]=> + unicode(1) "T" + [1]=> + unicode(1) "h" + [2]=> + unicode(1) "i" + [3]=> + unicode(1) "s" + [4]=> + unicode(1) " " + [5]=> + unicode(1) "i" + [6]=> + unicode(1) "s" + [7]=> + unicode(1) " " + [8]=> + unicode(1) "a" + [9]=> + unicode(1) " " + [10]=> + unicode(1) "s" + [11]=> + unicode(1) "t" + [12]=> + unicode(1) "r" + [13]=> + unicode(1) "i" + [14]=> + unicode(1) "n" + [15]=> + unicode(1) "g" + [16]=> + unicode(1) " " + [17]=> + unicode(1) "w" + [18]=> + unicode(1) "i" + [19]=> + unicode(1) "t" + [20]=> + unicode(1) "h" + [21]=> + unicode(1) " " + [22]=> + unicode(1) "1" + [23]=> + unicode(1) "2" + [24]=> + unicode(1) "3" + [25]=> + unicode(1) " " + [26]=> + unicode(1) "&" + [27]=> + unicode(1) " " + [28]=> + unicode(1) "e" + [29]=> + unicode(1) "s" + [30]=> + unicode(1) "c" + [31]=> + unicode(1) "a" + [32]=> + unicode(1) "p" + [33]=> + unicode(1) "e" + [34]=> + unicode(1) " " + [35]=> + unicode(1) "c" + [36]=> + unicode(1) "h" + [37]=> + unicode(1) "a" + [38]=> + unicode(1) "r" + [39]=> + unicode(1) " " + [40]=> + unicode(1) "\" + [41]=> + unicode(1) "t" +} +-- Iteration 3 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +-- Iteration 4 -- +array(1) { + [0]=> + unicode(42) "This is a string with 123 & escape char \t" +} +-- Iteration 5 -- +array(2) { + [0]=> + unicode(26) "This is a string with 123 " + [1]=> + unicode(16) "& escape char \t" +} +-- Iteration 6 -- +array(1) { + [0]=> + unicode(42) "This is a string with 123 & escape char \t" +} +-- Iteration 7 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +-- Iteration 8 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/str_split_variation7.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/str_split_variation7.phpt diff -u /dev/null php-src/ext/standard/tests/strings/str_split_variation7.phpt:1.2 --- /dev/null Fri Oct 5 18:20:57 2007 +++ php-src/ext/standard/tests/strings/str_split_variation7.phpt Fri Oct 5 18:20:57 2007 @@ -0,0 +1,239 @@ +--TEST-- +Test str_split() function : usage variations - different integer values for 'split_length' with heredoc 'str'(Bug#42866) +--FILE-- +<?php +/* Prototype : array str_split(string $str [, int $split_length]) + * Description: Convert a string to an array. If split_length is + specified, break the string down into chunks each + split_length characters long. + * Source code: ext/standard/string.c + * Alias to functions: none +*/ + +/* +* passing different integer values for 'split_length' and heredoc string as 'str' argument to str_split() +*/ + +echo "*** Testing str_split() : different intger values for 'split_length' with heredoc 'str' ***\n"; +//Initialise variables +$str = <<<EOT +string with 123,escape char \t. +EOT; + +//different values for 'split_length' +$values = array ( + 0, + 1, + -123, //negative integer + 0234, //octal number + 0x1A, //hexadecimal number + 2147483647, //max positive integer number + 2147483648, //max positive integer+1 + -2147483648, //min negative integer +); + +//loop through each element of $values for 'split_length' +for($count = 0; $count < count($values); $count++) { + echo "-- Iteration ".($count + 1)." --\n"; + var_dump( str_split($str, $values[$count]) ); +} +echo "Done" +?> +--EXPECTF-- +*** Testing str_split() : different intger values for 'split_length' with heredoc 'str' *** +-- Iteration 1 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +-- Iteration 2 -- +array(30) { + [0]=> + string(1) "s" + [1]=> + string(1) "t" + [2]=> + string(1) "r" + [3]=> + string(1) "i" + [4]=> + string(1) "n" + [5]=> + string(1) "g" + [6]=> + string(1) " " + [7]=> + string(1) "w" + [8]=> + string(1) "i" + [9]=> + string(1) "t" + [10]=> + string(1) "h" + [11]=> + string(1) " " + [12]=> + string(1) "1" + [13]=> + string(1) "2" + [14]=> + string(1) "3" + [15]=> + string(1) "," + [16]=> + string(1) "e" + [17]=> + string(1) "s" + [18]=> + string(1) "c" + [19]=> + string(1) "a" + [20]=> + string(1) "p" + [21]=> + string(1) "e" + [22]=> + string(1) " " + [23]=> + string(1) "c" + [24]=> + string(1) "h" + [25]=> + string(1) "a" + [26]=> + string(1) "r" + [27]=> + string(1) " " + [28]=> + string(1) " " + [29]=> + string(1) "." +} +-- Iteration 3 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +-- Iteration 4 -- +array(1) { + [0]=> + string(30) "string with 123,escape char ." +} +-- Iteration 5 -- +array(2) { + [0]=> + string(26) "string with 123,escape cha" + [1]=> + string(4) "r ." +} +-- Iteration 6 -- +array(1) { + [0]=> + string(30) "string with 123,escape char ." +} +-- Iteration 7 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +-- Iteration 8 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +Done +--UEXPECTF-- +*** Testing str_split() : different intger values for 'split_length' with heredoc 'str' *** +-- Iteration 1 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +-- Iteration 2 -- +array(30) { + [0]=> + unicode(1) "s" + [1]=> + unicode(1) "t" + [2]=> + unicode(1) "r" + [3]=> + unicode(1) "i" + [4]=> + unicode(1) "n" + [5]=> + unicode(1) "g" + [6]=> + unicode(1) " " + [7]=> + unicode(1) "w" + [8]=> + unicode(1) "i" + [9]=> + unicode(1) "t" + [10]=> + unicode(1) "h" + [11]=> + unicode(1) " " + [12]=> + unicode(1) "1" + [13]=> + unicode(1) "2" + [14]=> + unicode(1) "3" + [15]=> + unicode(1) "," + [16]=> + unicode(1) "e" + [17]=> + unicode(1) "s" + [18]=> + unicode(1) "c" + [19]=> + unicode(1) "a" + [20]=> + unicode(1) "p" + [21]=> + unicode(1) "e" + [22]=> + unicode(1) " " + [23]=> + unicode(1) "c" + [24]=> + unicode(1) "h" + [25]=> + unicode(1) "a" + [26]=> + unicode(1) "r" + [27]=> + unicode(1) " " + [28]=> + unicode(1) " " + [29]=> + unicode(1) "." +} +-- Iteration 3 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +-- Iteration 4 -- +array(1) { + [0]=> + unicode(30) "string with 123,escape char ." +} +-- Iteration 5 -- +array(2) { + [0]=> + unicode(26) "string with 123,escape cha" + [1]=> + unicode(4) "r ." +} +-- Iteration 6 -- +array(1) { + [0]=> + unicode(30) "string with 123,escape char ." +} +-- Iteration 7 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +-- Iteration 8 -- + +Warning: str_split(): The length of each segment must be greater than zero in %s on line %d +bool(false) +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/str_split_error.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/str_split_error.phpt diff -u /dev/null php-src/ext/standard/tests/strings/str_split_error.phpt:1.2 --- /dev/null Fri Oct 5 18:20:57 2007 +++ php-src/ext/standard/tests/strings/str_split_error.phpt Fri Oct 5 18:20:57 2007 @@ -0,0 +1,49 @@ +--TEST-- +Test str_split() function : error conditions +--FILE-- +<?php +/* Prototype : array str_split(string $str [, int $split_length]) + * Description: Convert a string to an array. If split_length is + specified, break the string down into chunks each + split_length characters long. + * Source code: ext/standard/string.c + * Alias to functions: none +*/ + +echo "*** Testing str_split() : error conditions ***\n"; + +// Zero arguments +echo "-- Testing str_split() function with Zero arguments --\n"; +var_dump( str_split() ); + +//Test str_split with one more than the expected number of arguments +echo "-- Testing str_split() function with more than expected no. of arguments --\n"; +$str = 'This is error testcase'; +$split_length = 4; +$extra_arg = 10; +var_dump( str_split( $str, $split_length, $extra_arg) ); + +echo "Done" +?> +--EXPECTF-- +*** Testing str_split() : error conditions *** +-- Testing str_split() function with Zero arguments -- + +Warning: str_split() expects at least 1 parameter, 0 given in %s on line %d +NULL +-- Testing str_split() function with more than expected no. of arguments -- + +Warning: str_split() expects at most 2 parameters, 3 given in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing str_split() : error conditions *** +-- Testing str_split() function with Zero arguments -- + +Warning: str_split() expects at least 1 parameter, 0 given in %s on line %d +NULL +-- Testing str_split() function with more than expected no. of arguments -- + +Warning: str_split() expects at most 2 parameters, 3 given in %s on line %d +NULL +Done
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php