wharmby Mon Jan 19 15:46:38 2009 UTC Modified files: /php-src/ext/standard/tests/strings str_pad_variation2.phpt stristr_variation2.phpt stristr_variation1.phpt strlen_basic.phpt str_shuffle_variation1.phpt stristr_basic.phpt str_pad_variation5.phpt str_pad_variation1.phpt strlen_error.phpt strlen_variation1.phpt str_pad_variation4.phpt str_pad_variation3.phpt str_shuffle_basic.phpt stristr_error.phpt str_shuffle_error.phpt strtr_variation9.phpt strtr_variation6.phpt strtr_variation7.phpt strtr_variation5.phpt Log: New tests for str_pad(), str_shuffle(), stristr() and strlen(). Tested on WIndows, Linux and Linux 64 bit
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/str_pad_variation2.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/str_pad_variation2.phpt diff -u /dev/null php-src/ext/standard/tests/strings/str_pad_variation2.phpt:1.2 --- /dev/null Mon Jan 19 15:46:36 2009 +++ php-src/ext/standard/tests/strings/str_pad_variation2.phpt Mon Jan 19 15:46:35 2009 @@ -0,0 +1,139 @@ +--TEST-- +Test str_pad() function : usage variations - unexpected inputs for '$pad_length' argument +--FILE-- +<?php +/* Prototype : string str_pad ( string $input , int $pad_length [, string $pad_string [, int $pad_type ]] ) + * Description: Pad a string to a certain length with another string + * Source code: ext/standard/string.c +*/ + +/* Test str_pad() function: with unexpected inputs for '$pad_length' + * and expected type for '$input' +*/ + +echo "*** Testing str_pad() function: with unexpected inputs for 'pad_length' argument ***\n"; + +//get an unset variable +$unset_var = 'string_val'; +unset($unset_var); + +//defining a class +class sample { + public function __toString() { + return "sample object"; + } +} + +//getting the resource +$file_handle = fopen(__FILE__, "r"); + +// array with different values for $input +$pad_lengths = array ( + + // integer values +/*1*/ 0, + 1, + -2, + 255, + + // float values +/*5*/ 10.5, + -20.5, + 10.12345e2, + + // array values +/*8*/ array(), + array(0), + array(1, 2), + + // boolean values +/*11*/ true, + false, + TRUE, + FALSE, + + // null vlaues +/*15*/ NULL, + null, + + // objects +/*17*/ new sample(), + + // resource +/*18*/ $file_handle, + + // undefined variable +/*19*/ @$undefined_var, + + // unset variable +/*20*/ @$unset_var +); + +//defining '$input' argument +$input = "Test string"; + +// loop through with each element of the $pad_lengths array to test str_pad() function +$count = 1; +foreach($pad_lengths as $pad_length) { + echo "-- Iteration $count --\n"; + var_dump( str_pad($input, $pad_length) ); + $count ++; +} + +fclose($file_handle); //closing the file handle + +?> +===DONE=== +--EXPECTF-- +*** Testing str_pad() function: with unexpected inputs for 'pad_length' argument *** +-- Iteration 1 -- +unicode(11) "Test string" +-- Iteration 2 -- +unicode(11) "Test string" +-- Iteration 3 -- +unicode(11) "Test string" +-- Iteration 4 -- +unicode(255) "Test string " +-- Iteration 5 -- +unicode(11) "Test string" +-- Iteration 6 -- +unicode(11) "Test string" +-- Iteration 7 -- +unicode(1012) "Test string ! " +-- Iteration 8 -- + +Warning: str_pad() expects parameter 2 to be long, array given in %s on line %d +NULL +-- Iteration 9 -- + +Warning: str_pad() expects parameter 2 to be long, array given in %s on line %d +NULL +-- Iteration 10 -- + +Warning: str_pad() expects parameter 2 to be long, array given in %s on line %d +NULL +-- Iteration 11 -- +unicode(11) "Test string" +-- Iteration 12 -- +unicode(11) "Test string" +-- Iteration 13 -- +unicode(11) "Test string" +-- Iteration 14 -- +unicode(11) "Test string" +-- Iteration 15 -- +unicode(11) "Test string" +-- Iteration 16 -- +unicode(11) "Test string" +-- Iteration 17 -- + +Warning: str_pad() expects parameter 2 to be long, object given in %s on line %d +NULL +-- Iteration 18 -- + +Warning: str_pad() expects parameter 2 to be long, resource given in %s on line %d +NULL +-- Iteration 19 -- +unicode(11) "Test string" +-- Iteration 20 -- +unicode(11) "Test string" +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/stristr_variation2.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/stristr_variation2.phpt diff -u /dev/null php-src/ext/standard/tests/strings/stristr_variation2.phpt:1.2 --- /dev/null Mon Jan 19 15:46:36 2009 +++ php-src/ext/standard/tests/strings/stristr_variation2.phpt Mon Jan 19 15:46:35 2009 @@ -0,0 +1,135 @@ +--TEST-- +Test stristr() function : usage variations - test values for $needle argument +--FILE-- +<?php + +/* Prototype: string stristr ( string $haystack, string $needle ); + Description: Case-insensitive strstr(). +*/ + +echo "*** Testing stristr() function: with unexpected inputs for 'needle' argument ***\n"; + +//get an unset variable +$unset_var = 'string_val'; +unset($unset_var); + +//defining a class +class sample { + public function __toString() { + return "sample object"; + } +} + +//getting the resource +$file_handle = fopen(__FILE__, "r"); + +// array with different values for $input +$inputs = array ( + + // integer values +/*1*/ 0, + 1, + -2, + -PHP_INT_MAX, + + // float values +/*5*/ 10.5, + -20.5, + 10.1234567e10, + + // array values +/*8*/ array(), + array(0), + array(1, 2), + + // boolean values +/*11*/ true, + false, + TRUE, + FALSE, + + // null vlaues +/*15*/ NULL, + null, + + // objects +/*17*/ new sample(), + + // resource +/*18*/ $file_handle, + + // undefined variable +/*19*/ @$undefined_var, + + // unset variable +/*20*/ @$unset_var +); + +//defining '$pad_length' argument +$pad_length = "20"; + +// loop through with each element of the $inputs array to test stristr() function +$count = 1; +foreach($inputs as $input) { + echo "-- Iteration $count --\n"; + var_dump( stristr("Hello World", $input) ); + $count ++; +} + +fclose($file_handle); //closing the file handle + +?> +===DONE=== +--EXPECTF-- +*** Testing stristr() function: with unexpected inputs for 'needle' argument *** +-- Iteration 1 -- +bool(false) +-- Iteration 2 -- +bool(false) +-- Iteration 3 -- + +Warning: Needle argument codepoint value out of range (0 - 0x10FFFF) in %s on line %d +bool(false) +-- Iteration 4 -- + +Warning: Needle argument codepoint value out of range (0 - 0x10FFFF) in %s on line %d +bool(false) +-- Iteration 5 -- +bool(false) +-- Iteration 6 -- + +Warning: Needle argument codepoint value out of range (0 - 0x10FFFF) in %s on line %d +bool(false) +-- Iteration 7 -- + +Warning: Needle argument codepoint value out of range (0 - 0x10FFFF) in %s on line %d +bool(false) +-- Iteration 8 -- +bool(false) +-- Iteration 9 -- +bool(false) +-- Iteration 10 -- +bool(false) +-- Iteration 11 -- +bool(false) +-- Iteration 12 -- +bool(false) +-- Iteration 13 -- +bool(false) +-- Iteration 14 -- +bool(false) +-- Iteration 15 -- +bool(false) +-- Iteration 16 -- +bool(false) +-- Iteration 17 -- + +Notice: Object of class sample could not be converted to int in %s on line %d +bool(false) +-- Iteration 18 -- +bool(false) +-- Iteration 19 -- +bool(false) +-- Iteration 20 -- +bool(false) +===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/stristr_variation1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/stristr_variation1.phpt diff -u /dev/null php-src/ext/standard/tests/strings/stristr_variation1.phpt:1.2 --- /dev/null Mon Jan 19 15:46:36 2009 +++ php-src/ext/standard/tests/strings/stristr_variation1.phpt Mon Jan 19 15:46:35 2009 @@ -0,0 +1,131 @@ +--TEST-- +Test stristr() function : usage variations - test values for $haystack argument +--FILE-- +<?php + +/* Prototype: string stristr ( string $haystack, string $needle ); + Description: Case-insensitive strstr(). +*/ + +echo "*** Testing stristr() function: with unexpected inputs for 'string' argument ***\n"; + +//get an unset variable +$unset_var = 'string_val'; +unset($unset_var); + +//defining a class +class sample { + public function __toString() { + return "sample object"; + } +} + +//getting the resource +$file_handle = fopen(__FILE__, "r"); + +// array with different values for $input +$inputs = array ( + + // integer values +/*1*/ 0, + 1, + -2, + -PHP_INT_MAX, + + // float values +/*5*/ 10.5, + -20.5, + 10.1234567e10, + + // array values +/*8*/ array(), + array(0), + array(1, 2), + + // boolean values +/*11*/ true, + false, + TRUE, + FALSE, + + // null vlaues +/*15*/ NULL, + null, + + // objects +/*17*/ new sample(), + + // resource +/*18*/ $file_handle, + + // undefined variable +/*19*/ @$undefined_var, + + // unset variable +/*20*/ @$unset_var +); + +//defining '$pad_length' argument +$pad_length = "20"; + +// loop through with each element of the $inputs array to test stristr() function +$count = 1; +foreach($inputs as $input) { + echo "-- Iteration $count --\n"; + var_dump( stristr($input, " ") ); + $count ++; +} + +fclose($file_handle); //closing the file handle + +?> +===DONE=== +--EXPECTF-- +*** Testing stristr() function: with unexpected inputs for 'string' argument *** +-- Iteration 1 -- +bool(false) +-- Iteration 2 -- +bool(false) +-- Iteration 3 -- +bool(false) +-- Iteration 4 -- +bool(false) +-- Iteration 5 -- +bool(false) +-- Iteration 6 -- +bool(false) +-- Iteration 7 -- +bool(false) +-- Iteration 8 -- + +Notice: Array to string conversion in %s on line %d2 +bool(false) +-- Iteration 9 -- + +Notice: Array to string conversion in %s on line %d2 +bool(false) +-- Iteration 10 -- + +Notice: Array to string conversion in %s on line %d2 +bool(false) +-- Iteration 11 -- +bool(false) +-- Iteration 12 -- +bool(false) +-- Iteration 13 -- +bool(false) +-- Iteration 14 -- +bool(false) +-- Iteration 15 -- +bool(false) +-- Iteration 16 -- +bool(false) +-- Iteration 17 -- +unicode(7) " object" +-- Iteration 18 -- +unicode(%d) " id #%d" +-- Iteration 19 -- +bool(false) +-- Iteration 20 -- +bool(false) +===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strlen_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/strlen_basic.phpt diff -u /dev/null php-src/ext/standard/tests/strings/strlen_basic.phpt:1.2 --- /dev/null Mon Jan 19 15:46:36 2009 +++ php-src/ext/standard/tests/strings/strlen_basic.phpt Mon Jan 19 15:46:35 2009 @@ -0,0 +1,24 @@ +--TEST-- +Test strlen() function : basic functionality +--FILE-- +<?php + +/* Prototype : int strlen ( string $string ) + * Description: Get string length + * Source code: ext/standard/string.c +*/ + +echo "*** Testing strlen() : basic functionality ***\n"; +var_dump(strlen("abcdef")); +var_dump(strlen(" ab de ")); +var_dump(strlen("")); +var_dump(strlen("\x90\x91\x00\x93\x94\x90\x91\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f")); +?> +===DONE=== +--EXPECTF-- +*** Testing strlen() : basic functionality *** +int(6) +int(7) +int(0) +int(18) +===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/str_shuffle_variation1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/str_shuffle_variation1.phpt diff -u /dev/null php-src/ext/standard/tests/strings/str_shuffle_variation1.phpt:1.2 --- /dev/null Mon Jan 19 15:46:36 2009 +++ php-src/ext/standard/tests/strings/str_shuffle_variation1.phpt Mon Jan 19 15:46:35 2009 @@ -0,0 +1,135 @@ +--TEST-- +Test str_shuffle() function : usage variations - test values for $haystack argument +--FILE-- +<?php + +/* Prototype : string str_shuffle ( string $str ) + * Description: Randomly shuffles a string + * Source code: ext/standard/string.c +*/ + +echo "*** Testing str_shuffle() function: with unexpected inputs for 'string' argument ***\n"; + +//get an unset variable +$unset_var = 'string_val'; +unset($unset_var); + +//defining a class +class sample { + public function __toString() { + return "sample object"; + } +} + +//getting the resource +$file_handle = fopen(__FILE__, "r"); + +// array with different values for $input +$inputs = array ( + + // integer values +/*1*/ 0, + 1, + -2, + 2147483647, + -2147483648, + + // float values +/*6*/ 10.5, + -20.5, + 10.1234567e10, + + // array values +/*9*/ array(), + array(0), + array(1, 2), + + // boolean values +/*12*/ true, + false, + TRUE, + FALSE, + + // null vlaues +/*16*/ NULL, + null, + + // objects +/*18*/ new sample(), + + // resource +/*19*/ $file_handle, + + // undefined variable +/*20*/ @$undefined_var, + + // unset variable +/*21*/ @$unset_var +); + + +// loop through with each element of the $inputs array to test str_shuffle() function +$count = 1; +foreach($inputs as $input) { + echo "-- Iteration $count --\n"; + var_dump( str_shuffle($input) ); + $count ++; +} + +fclose($file_handle); //closing the file handle + +?> +===DONE=== +--EXPECTF-- +*** Testing str_shuffle() function: with unexpected inputs for 'string' argument *** +-- Iteration 1 -- +unicode(1) "0" +-- Iteration 2 -- +unicode(1) "1" +-- Iteration 3 -- +unicode(2) "%s" +-- Iteration 4 -- +unicode(10) "%s" +-- Iteration 5 -- +unicode(11) "%s" +-- Iteration 6 -- +unicode(4) "%s" +-- Iteration 7 -- +unicode(5) "%s" +-- Iteration 8 -- +unicode(12) "%s" +-- Iteration 9 -- + +Warning: str_shuffle() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 10 -- + +Warning: str_shuffle() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: str_shuffle() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- +unicode(1) "1" +-- Iteration 13 -- +unicode(0) "" +-- Iteration 14 -- +unicode(1) "1" +-- Iteration 15 -- +unicode(0) "" +-- Iteration 16 -- +unicode(0) "" +-- Iteration 17 -- +unicode(0) "" +-- Iteration 18 -- +unicode(13) "%s" +-- Iteration 19 -- + +Warning: str_shuffle() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d +NULL +-- Iteration 20 -- +unicode(0) "" +-- Iteration 21 -- +unicode(0) "" +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/stristr_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/stristr_basic.phpt diff -u /dev/null php-src/ext/standard/tests/strings/stristr_basic.phpt:1.2 --- /dev/null Mon Jan 19 15:46:37 2009 +++ php-src/ext/standard/tests/strings/stristr_basic.phpt Mon Jan 19 15:46:35 2009 @@ -0,0 +1,36 @@ +--TEST-- +Test stristr() function : basic functionality +--FILE-- +<?php +/* Prototype: string stristr ( string $haystack , mixed $needle [, bool $before_needle ] ) + Description: Case-insensitive strstr(). +*/ + +echo "*** Testing stristr() : basic functionality ***\n"; + +var_dump( stristr("Test string", "teSt") ); +var_dump( stristr("test stRIng", "striNG") ); +var_dump( stristr("teST StrinG", "stRIn") ); +var_dump( stristr("tesT string", "t S") ); +var_dump( stristr("test strinG", "g") ); +var_dump( bin2hex((binary)stristr(b"te".chr(0).b"St", chr(0))) ); +var_dump( stristr("tEst", "test") ); +var_dump( stristr("teSt", "test") ); + +var_dump( stristr("Test String", "String", false) ); +var_dump( stristr("Test String", "String", true) ); +?> +===DONE=== +--EXPECTF-- +*** Testing stristr() : basic functionality *** +unicode(11) "Test string" +unicode(6) "stRIng" +unicode(6) "StrinG" +unicode(8) "T string" +unicode(1) "G" +unicode(6) "005374" +unicode(4) "tEst" +unicode(4) "teSt" +unicode(6) "String" +unicode(5) "Test " +===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/str_pad_variation5.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/str_pad_variation5.phpt diff -u /dev/null php-src/ext/standard/tests/strings/str_pad_variation5.phpt:1.2 --- /dev/null Mon Jan 19 15:46:37 2009 +++ php-src/ext/standard/tests/strings/str_pad_variation5.phpt Mon Jan 19 15:46:35 2009 @@ -0,0 +1,31 @@ +--TEST-- +Test str_pad() function : usage variations - unexpected large value for '$pad_length' argument +--INI-- +memory_limit=128M +--SKIPIF-- +<?php +if (PHP_INT_SIZE != 4) die("skip this test is for 32bit platform only"); +?> +--FILE-- +<?php +/* Prototype : string str_pad ( string $input , int $pad_length [, string $pad_string [, int $pad_type ]] ) + * Description: Pad a string to a certain length with another string + * Source code: ext/standard/string.c +*/ + +/* Test str_pad() function: with unexpected inputs for '$pad_length' + * and expected type for '$input' +*/ + +echo "*** Testing str_pad() function: with large value for for 'pad_length' argument ***\n"; + +//defining '$input' argument +$input = "Test string"; +$pad_length = PHP_INT_MAX; +var_dump( str_pad($input, $pad_length) ); + +?> +--EXPECTF-- +*** Testing str_pad() function: with large value for for 'pad_length' argument *** + +Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4294967272 bytes) in %s on line %d \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/str_pad_variation1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/str_pad_variation1.phpt diff -u /dev/null php-src/ext/standard/tests/strings/str_pad_variation1.phpt:1.2 --- /dev/null Mon Jan 19 15:46:37 2009 +++ php-src/ext/standard/tests/strings/str_pad_variation1.phpt Mon Jan 19 15:46:35 2009 @@ -0,0 +1,140 @@ +--TEST-- +Test str_pad() function : usage variations - unexpected inputs for '$input' argument +--FILE-- +<?php +/* Prototype : string str_pad ( string $input , int $pad_length [, string $pad_string [, int $pad_type ]] ) + * Description: Pad a string to a certain length with another string + * Source code: ext/standard/string.c +*/ + +/* Test str_pad() function: with unexpected inputs for '$input' + * and expected type for '$pad_length' +*/ + +echo "*** Testing str_pad() function: with unexpected inputs for 'input' argument ***\n"; + +//get an unset variable +$unset_var = 'string_val'; +unset($unset_var); + +//defining a class +class sample { + public function __toString() { + return "sample object"; + } +} + +//getting the resource +$file_handle = fopen(__FILE__, "r"); + +// array with different values for $input +$inputs = array ( + + // integer values +/*1*/ 0, + 1, + -2, + 2147483647, + -2147483648, + + // float values +/*6*/ 10.5, + -20.5, + 10.1234567e10, + + // array values +/*9*/ array(), + array(0), + array(1, 2), + + // boolean values +/*12*/ true, + false, + TRUE, + FALSE, + + // null vlaues +/*16*/ NULL, + null, + + // objects +/*18*/ new sample(), + + // resource +/*19*/ $file_handle, + + // undefined variable +/*20*/ @$undefined_var, + + // unset variable +/*21*/ @$unset_var +); + +//defining '$pad_length' argument +$pad_length = "20"; + +// loop through with each element of the $inputs array to test str_pad() function +$count = 1; +foreach($inputs as $input) { + echo "-- Iteration $count --\n"; + var_dump( str_pad($input, $pad_length) ); + $count ++; +} + +fclose($file_handle); //closing the file handle + +?> +===DONE=== +--EXPECTF-- +*** Testing str_pad() function: with unexpected inputs for 'input' argument *** +-- Iteration 1 -- +unicode(20) "0 " +-- Iteration 2 -- +unicode(20) "1 " +-- Iteration 3 -- +unicode(20) "-2 " +-- Iteration 4 -- +unicode(20) "2147483647 " +-- Iteration 5 -- +unicode(20) "-2147483648 " +-- Iteration 6 -- +unicode(20) "10.5 " +-- Iteration 7 -- +unicode(20) "-20.5 " +-- Iteration 8 -- +unicode(20) "101234567000 " +-- Iteration 9 -- + +Warning: str_pad() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 10 -- + +Warning: str_pad() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: str_pad() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- +unicode(20) "1 " +-- Iteration 13 -- +unicode(20) " " +-- Iteration 14 -- +unicode(20) "1 " +-- Iteration 15 -- +unicode(20) " " +-- Iteration 16 -- +unicode(20) " " +-- Iteration 17 -- +unicode(20) " " +-- Iteration 18 -- +unicode(20) "sample object " +-- Iteration 19 -- + +Warning: str_pad() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d +NULL +-- Iteration 20 -- +unicode(20) " " +-- Iteration 21 -- +unicode(20) " " +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strlen_error.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/strlen_error.phpt diff -u /dev/null php-src/ext/standard/tests/strings/strlen_error.phpt:1.2 --- /dev/null Mon Jan 19 15:46:37 2009 +++ php-src/ext/standard/tests/strings/strlen_error.phpt Mon Jan 19 15:46:35 2009 @@ -0,0 +1,33 @@ +--TEST-- +Test strlen() function : error conditions +--FILE-- +<?php + +/* Prototype : int strlen ( string $string ) + * Description: Get string length + * Source code: ext/standard/string.c +*/ + +echo "*** Testing strlen() : unexpected number of arguments ***"; + + +echo "\n-- Testing strlen() function with no arguments --\n"; +var_dump( strlen() ); + +echo "\n-- Testing strlen() function with more than expected no. of arguments --\n"; +$extra_arg = 10; +var_dump( strlen("abc def", $extra_arg) ); +?> +===DONE=== +--EXPECTF-- +*** Testing strlen() : unexpected number of arguments *** +-- Testing strlen() function with no arguments -- + +Warning: strlen() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing strlen() function with more than expected no. of arguments -- + +Warning: strlen() expects exactly 1 parameter, 2 given in %s on line %d +NULL +===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strlen_variation1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/strlen_variation1.phpt diff -u /dev/null php-src/ext/standard/tests/strings/strlen_variation1.phpt:1.2 --- /dev/null Mon Jan 19 15:46:37 2009 +++ php-src/ext/standard/tests/strings/strlen_variation1.phpt Mon Jan 19 15:46:36 2009 @@ -0,0 +1,137 @@ +--TEST-- +Test strlen() function : usage variations - unexpected input for '$string' argument +--FILE-- +<?php + +/* Prototype : int strlen ( string $string ) + * Description: Get string length + * Source code: ext/standard/string.c +*/ + +echo "*** Testing strlen() : with unexpected input for 'string' argument ***\n"; + +//get an unset variable +$unset_var = 'string_val'; +unset($unset_var); + +//defining a class +class sample { + public function __toString() { + return "sample object"; + } +} + +//getting the resource +$file_handle = fopen(__FILE__, "r"); + +// array with different values for $input +$inputs = array ( + + // integer values +/*1*/ 0, + 1, + -2, + 2147483647, + -2147483648, + + // float values +/*6*/ 10.5, + -20.5, + 10.1234567e10, + + // array values +/*9*/ array(), + array(0), + array(1, 2), + + // boolean values +/*12*/ true, + false, + TRUE, + FALSE, + + // null values +/*16*/ NULL, + null, + + // objects +/*18*/ new sample(), + + // resource +/*19*/ $file_handle, + + // undefined variable +/*20*/ @$undefined_var, + + // unset variable +/*21*/ @$unset_var +); + +//defining '$pad_length' argument +$pad_length = "20"; + +// loop through with each element of the $inputs array to test strlen() function +$count = 1; +foreach($inputs as $input) { + echo "-- Iteration $count --\n"; + var_dump( strlen($input) ); + $count ++; +} + +fclose($file_handle); //closing the file handle + +?> +===Done=== +--EXPECTF-- +*** Testing strlen() : with unexpected input for 'string' argument *** +-- Iteration 1 -- +int(1) +-- Iteration 2 -- +int(1) +-- Iteration 3 -- +int(2) +-- Iteration 4 -- +int(10) +-- Iteration 5 -- +int(11) +-- Iteration 6 -- +int(4) +-- Iteration 7 -- +int(5) +-- Iteration 8 -- +int(12) +-- Iteration 9 -- + +Warning: strlen() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 10 -- + +Warning: strlen() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: strlen() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- +int(1) +-- Iteration 13 -- +int(0) +-- Iteration 14 -- +int(1) +-- Iteration 15 -- +int(0) +-- Iteration 16 -- +int(0) +-- Iteration 17 -- +int(0) +-- Iteration 18 -- +int(13) +-- Iteration 19 -- + +Warning: strlen() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d +NULL +-- Iteration 20 -- +int(0) +-- Iteration 21 -- +int(0) +===Done=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/str_pad_variation4.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/str_pad_variation4.phpt diff -u /dev/null php-src/ext/standard/tests/strings/str_pad_variation4.phpt:1.2 --- /dev/null Mon Jan 19 15:46:37 2009 +++ php-src/ext/standard/tests/strings/str_pad_variation4.phpt Mon Jan 19 15:46:36 2009 @@ -0,0 +1,168 @@ +--TEST-- +Test str_pad() function : usage variations - unexpected inputs for '$pad_type' argument +--FILE-- +<?php +/* Prototype : string str_pad ( string $input , int $pad_length [, string $pad_string [, int $pad_type ]] ) + * Description: Pad a string to a certain length with another string + * Source code: ext/standard/string.c +*/ + +/* Test str_pad() function: with unexpected inputs for '$pad_type' + * and expected type for '$input', '$pad_length' and '$pad_string' +*/ + +echo "*** Testing str_pad() function: with unexpected inputs for 'pad_type' argument ***\n"; + +//get an unset variable +$unset_var = 'string_val'; +unset($unset_var); + +//defining a class +class sample { + public function __toString() { + return "sample object"; + } +} + +// array with different values for $input +$pad_types = array ( + + // integer values +/*1*/ 0, // == STR_PAD_LEFT + 1, // == STR_PAD_RIGHT + 2, // == STR_PAD_BOTH + -2, + 2147483647, + -2147483648, + + // float values +/*7*/ 10.5, + -20.5, + 10.1234567e10, + + // string data +/*10*/ "abc", + "STR_PAD_LEFT", + "2", + "0x2", + "02", + + // array values +/*15*/ array(), + array(0), + array(1, 2), + + // boolean values +/*18*/ true, + false, + TRUE, + FALSE, + + // null vlaues +/*22*/ NULL, + null, + + // objects +/*24*/ new sample(), + + // undefined variable +/*25*/ @$undefined_var, + + // unset variable +/*26*/ @$unset_var +); + +//defining '$input' argument +$input = "Test string"; +$pad_length = 20; +$pad_string = "*"; + +// loop through with each element of the $pad_types array to test str_pad() function +$count = 1; +foreach($pad_types as $pad_type) { + echo "-- Iteration $count --\n"; + var_dump( str_pad($input, $pad_length, $pad_string, $pad_type) ); + $count ++; +} + +?> +===DONE=== +--EXPECTF-- +*** Testing str_pad() function: with unexpected inputs for 'pad_type' argument *** +-- Iteration 1 -- +unicode(20) "*********Test string" +-- Iteration 2 -- +unicode(20) "Test string*********" +-- Iteration 3 -- +unicode(20) "****Test string*****" +-- Iteration 4 -- + +Warning: str_pad(): Padding type has to be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH in %s on line %d +NULL +-- Iteration 5 -- + +Warning: str_pad(): Padding type has to be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH in %s on line %d +NULL +-- Iteration 6 -- + +Warning: str_pad(): Padding type has to be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH in %s on line %d +NULL +-- Iteration 7 -- + +Warning: str_pad(): Padding type has to be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH in %s on line %d +NULL +-- Iteration 8 -- + +Warning: str_pad(): Padding type has to be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH in %s on line %d +NULL +-- Iteration 9 -- + +Warning: str_pad(): Padding type has to be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH in %s on line %d +NULL +-- Iteration 10 -- + +Warning: str_pad() expects parameter 4 to be long, Unicode string given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: str_pad() expects parameter 4 to be long, Unicode string given in %s on line %d +NULL +-- Iteration 12 -- +unicode(20) "****Test string*****" +-- Iteration 13 -- +unicode(20) "****Test string*****" +-- Iteration 14 -- +unicode(20) "****Test string*****" +-- Iteration 15 -- + +Warning: str_pad() expects parameter 4 to be long, array given in %s on line %d +NULL +-- Iteration 16 -- + +Warning: str_pad() expects parameter 4 to be long, array given in %s on line %d +NULL +-- Iteration 17 -- + +Warning: str_pad() expects parameter 4 to be long, array given in %s on line %d +NULL +-- Iteration 18 -- +unicode(20) "Test string*********" +-- Iteration 19 -- +unicode(20) "*********Test string" +-- Iteration 20 -- +unicode(20) "Test string*********" +-- Iteration 21 -- +unicode(20) "*********Test string" +-- Iteration 22 -- +unicode(20) "*********Test string" +-- Iteration 23 -- +unicode(20) "*********Test string" +-- Iteration 24 -- + +Warning: str_pad() expects parameter 4 to be long, object given in %s on line %d +NULL +-- Iteration 25 -- +unicode(20) "*********Test string" +-- Iteration 26 -- +unicode(20) "*********Test string" +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/str_pad_variation3.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/str_pad_variation3.phpt diff -u /dev/null php-src/ext/standard/tests/strings/str_pad_variation3.phpt:1.2 --- /dev/null Mon Jan 19 15:46:37 2009 +++ php-src/ext/standard/tests/strings/str_pad_variation3.phpt Mon Jan 19 15:46:36 2009 @@ -0,0 +1,153 @@ +--TEST-- +Test str_pad() function : usage variations - unexpected inputs for '$pad_string' argument +--FILE-- +<?php +/* Prototype : string str_pad ( string $input , int $pad_length [, string $pad_string [, int $pad_type ]] ) + * Description: Pad a string to a certain length with another string + * Source code: ext/standard/string.c +*/ + +/* Test str_pad() function: with unexpected inputs for '$pad_string' + * and expected type for '$input' and '$pad_length' +*/ + +echo "*** Testing str_pad() function: with unexpected inputs for 'pad_string' argument ***\n"; + +//get an unset variable +$unset_var = 'string_val'; +unset($unset_var); + +//defining a class +class sample { + public function __toString() { + return "sample object"; + } +} + +//getting the resource +$file_handle = fopen(__FILE__, "r"); + +// array with different values for $input +$pad_strings = array ( + + // integer values +/*1*/ 0, + 1, + -2, + 2147483647, + -2147483648, + + // float values +/*6*/ 10.5, + -20.5, + 10.1234567e10, + + // array values +/*9*/ array(), + array(0), + array(1, 2), + + // boolean values +/*12*/ true, + false, + TRUE, + FALSE, + + // null vlaues +/*16*/ NULL, + null, + + // objects +/*18*/ new sample(), + + // resource +/*19*/ $file_handle, + + // undefined variable +/*20*/ @$undefined_var, + + // unset variable +/*21*/ @$unset_var +); + +//defining '$input' argument +$input = "Test string"; +$pad_length = 20; + +// loop through with each element of the $pad_strings array to test str_pad() function +$count = 1; +foreach($pad_strings as $pad_string) { + echo "-- Iteration $count --\n"; + var_dump( str_pad($input, $pad_length, $pad_string) ); + $count ++; +} + +fclose($file_handle); //closing the file handle + +?> +===DONE=== +--EXPECTF-- +*** Testing str_pad() function: with unexpected inputs for 'pad_string' argument *** +-- Iteration 1 -- +unicode(20) "Test string000000000" +-- Iteration 2 -- +unicode(20) "Test string111111111" +-- Iteration 3 -- +unicode(20) "Test string-2-2-2-2-" +-- Iteration 4 -- +unicode(20) "Test string214748364" +-- Iteration 5 -- +unicode(20) "Test string-21474836" +-- Iteration 6 -- +unicode(20) "Test string10.510.51" +-- Iteration 7 -- +unicode(20) "Test string-20.5-20." +-- Iteration 8 -- +unicode(20) "Test string101234567" +-- Iteration 9 -- + +Warning: str_pad() expects parameter 3 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 10 -- + +Warning: str_pad() expects parameter 3 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: str_pad() expects parameter 3 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- +unicode(20) "Test string111111111" +-- Iteration 13 -- + +Warning: str_pad(): Padding string cannot be empty in %s on line %d +NULL +-- Iteration 14 -- +unicode(20) "Test string111111111" +-- Iteration 15 -- + +Warning: str_pad(): Padding string cannot be empty in %s on line %d +NULL +-- Iteration 16 -- + +Warning: str_pad(): Padding string cannot be empty in %s on line %d +NULL +-- Iteration 17 -- + +Warning: str_pad(): Padding string cannot be empty in %s on line %d +NULL +-- Iteration 18 -- +unicode(20) "Test stringsample ob" +-- Iteration 19 -- + +Warning: str_pad() expects parameter 3 to be string (Unicode or binary), resource given in %s on line %d +NULL +-- Iteration 20 -- + +Warning: str_pad(): Padding string cannot be empty in %s on line %d +NULL +-- Iteration 21 -- + +Warning: str_pad(): Padding string cannot be empty in %s on line %d +NULL +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/str_shuffle_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/str_shuffle_basic.phpt diff -u /dev/null php-src/ext/standard/tests/strings/str_shuffle_basic.phpt:1.2 --- /dev/null Mon Jan 19 15:46:37 2009 +++ php-src/ext/standard/tests/strings/str_shuffle_basic.phpt Mon Jan 19 15:46:36 2009 @@ -0,0 +1,59 @@ +--TEST-- +Test str_shuffle() function : basic functionality +--FILE-- +<?php +/* Prototype : string str_shuffle ( string $str ) + * Description: Randomly shuffles a string + * Source code: ext/standard/string.c +*/ + +/* + * Testing str_shuffle() : basic functionality +*/ + +echo "*** Testing str_shuffle() : basic functionality ***\n"; + +// Initialize all required variables +$str = 'This testcase tests the str_shuffle() function.'; +var_dump(str_shuffle($str)); + + +// For a given i/p string ensure that all combinations are +// generated given a reasonable sample of calls +$a = array(); +$trys = 1000; +$ip = 'abcd'; +$len_ip = strlen($ip); + +for ($i = 0; $i < $trys; $i++) { + $op = str_shuffle($ip); + + if (!is_string($op) || strlen($op) != $len_ip) { + echo "TEST FAILED\n"; + } + + // Combination already hit ? + if (empty($a[$op])) { + // No first time init + $a[$op] = 0; + } + + // Increment count for this combination + $a[$op]++; +} + +$combinations = count($a); + +if ($combinations != 24) { + echo "TEST FAILED.. Only $combinations out of a possible 24 combinations used\n"; +} else { + echo "TEST PASSED\n"; +} + +?> +===DONE=== +--EXPECTF-- +*** Testing str_shuffle() : basic functionality *** +unicode(47) "%s" +TEST PASSED +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/stristr_error.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/stristr_error.phpt diff -u /dev/null php-src/ext/standard/tests/strings/stristr_error.phpt:1.2 --- /dev/null Mon Jan 19 15:46:37 2009 +++ php-src/ext/standard/tests/strings/stristr_error.phpt Mon Jan 19 15:46:36 2009 @@ -0,0 +1,60 @@ +--TEST-- +Test stristr() function : error conditions +--FILE-- +<?php + +/* Prototype: string stristr ( string $haystack , mixed $needle [, bool $before_needle ] ) + Description: Case-insensitive strstr() +*/ +echo "*** Testing stristr() : error conditions ***\n"; + +echo "\n-- Testing stristr() function with no arguments --\n"; +var_dump( stristr() ); +var_dump( stristr("") ); + +echo "\n-- Testing stristr() function with no needle --\n"; +var_dump( stristr("Hello World") ); // without "needle" + +echo "\n-- Testing stristr() function with more than expected no. of arguments --\n"; +$extra_arg = 10; +var_dump( stristr("Hello World", "World", true, $extra_arg) ); + +echo "\n-- Testing stristr() function with empty haystack --\n"; +var_dump( stristr(NULL, "") ); + +echo "\n-- Testing stristr() function with empty needle --\n"; +var_dump( stristr("Hello World", "") ); + +?> +===DONE=== +--EXPECTF-- +*** Testing stristr() : error conditions *** + +-- Testing stristr() function with no arguments -- + +Warning: stristr() expects at least 2 parameters, 0 given in %s on line %d +NULL + +Warning: stristr() expects at least 2 parameters, 1 given in %s on line %d +NULL + +-- Testing stristr() function with no needle -- + +Warning: stristr() expects at least 2 parameters, 1 given in %s on line %d +NULL + +-- Testing stristr() function with more than expected no. of arguments -- + +Warning: stristr() expects at most 3 parameters, 4 given in %s on line %d +NULL + +-- Testing stristr() function with empty haystack -- + +Warning: stristr(): Empty delimiter in %s on line %d +bool(false) + +-- Testing stristr() function with empty needle -- + +Warning: stristr(): Empty delimiter in %s on line %d +bool(false) +===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/str_shuffle_error.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/str_shuffle_error.phpt diff -u /dev/null php-src/ext/standard/tests/strings/str_shuffle_error.phpt:1.2 --- /dev/null Mon Jan 19 15:46:37 2009 +++ php-src/ext/standard/tests/strings/str_shuffle_error.phpt Mon Jan 19 15:46:36 2009 @@ -0,0 +1,33 @@ +--TEST-- +Test str_shuffle() function : error conditions +--FILE-- +<?php + +/* Prototype : string str_shuffle ( string $str ) + * Description: Randomly shuffles a string + * Source code: ext/standard/string.c +*/ +echo "*** Testing str_shuffle() : error conditions ***\n"; + +echo "\n-- Testing str_shuffle() function with no arguments --\n"; +var_dump( str_shuffle() ); + +echo "\n-- Testing str_shuffle() function with more than expected no. of arguments --\n"; +$extra_arg = 10; +var_dump( str_shuffle("Hello World", $extra_arg) ); + +?> +===DONE=== +--EXPECTF-- +*** Testing str_shuffle() : error conditions *** + +-- Testing str_shuffle() function with no arguments -- + +Warning: str_shuffle() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing str_shuffle() function with more than expected no. of arguments -- + +Warning: str_shuffle() expects exactly 1 parameter, 2 given in %s on line %d +NULL +===DONE=== \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strtr_variation9.phpt?r1=1.6&r2=1.7&diff_format=u Index: php-src/ext/standard/tests/strings/strtr_variation9.phpt diff -u php-src/ext/standard/tests/strings/strtr_variation9.phpt:1.6 php-src/ext/standard/tests/strings/strtr_variation9.phpt:1.7 --- php-src/ext/standard/tests/strings/strtr_variation9.phpt:1.6 Sat Aug 16 21:16:25 2008 +++ php-src/ext/standard/tests/strings/strtr_variation9.phpt Mon Jan 19 15:46:35 2009 @@ -19,7 +19,7 @@ //defining a class class sample { public function __toString() { - return "My String"; + return "sample object"; } } @@ -29,44 +29,44 @@ // array with different values $values = array ( - // integer values - 0, - 1, - -2, - - // float values - 10.5, - -20.5, - 10.5e10, - - // array values - array(), - array(0), - array(1), - array(1, 2), - array('color' => 'red', 'item' => 'pen'), - - // boolean values - true, - false, - TRUE, - FALSE, - - // null vlaues - NULL, - null, - - // objects - new sample(), - - // resource - $file_handle, - - // undefined variable - @$undefined_var, - - // unset variable - @$unset_var + // integer values +/*1*/ 0, + 1, + -2, + + // float values +/*4*/ 10.5, + -20.5, + 10.1234567e10, + + // array values +/*7*/ array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // boolean values +/*12*/ true, + false, + TRUE, + FALSE, + + // null vlaues +/*16*/ NULL, + null, + + // objects +/*18*/ new sample(), + + // resource +/*19*/ $file_handle, + + // undefined variable +/*20*/ @$undefined_var, + + // unset variable +/*21*/ @$unset_var ); // loop through with each element of the $values array to test strtr() function @@ -80,8 +80,8 @@ fclose($file_handle); //closing the file handle -echo "*** Done ***"; ?> +===DONE=== --EXPECTF-- *** Testing strtr() function: with unexpected inputs for all arguments *** @@ -116,7 +116,7 @@ bool(false) -- Iteration 6 -- -unicode(12) "105000000000" +unicode(12) "101234567000" Warning: strtr(): The second argument is not an array in %s on line %d bool(false) @@ -198,7 +198,7 @@ bool(false) -- Iteration 18 -- -unicode(9) "My String" +unicode(13) "sample object" Warning: strtr(): The second argument is not an array in %s on line %d bool(false) @@ -222,4 +222,4 @@ Warning: strtr(): The second argument is not an array in %s on line %d bool(false) -*** Done *** +===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strtr_variation6.phpt?r1=1.3&r2=1.4&diff_format=u Index: php-src/ext/standard/tests/strings/strtr_variation6.phpt diff -u php-src/ext/standard/tests/strings/strtr_variation6.phpt:1.3 php-src/ext/standard/tests/strings/strtr_variation6.phpt:1.4 --- php-src/ext/standard/tests/strings/strtr_variation6.phpt:1.3 Tue May 27 10:50:47 2008 +++ php-src/ext/standard/tests/strings/strtr_variation6.phpt Mon Jan 19 15:46:36 2009 @@ -1,5 +1,5 @@ --TEST-- -Test strtr() function : usage variations - unexpected inputs for 'from' argument(Bug #42861) +Test strtr() function : usage variations - unexpected inputs for 'from' argument --FILE-- <?php /* Prototype : string strtr(string $str, string $from[, string $to]); @@ -34,42 +34,42 @@ // array of values for 'from' $from_arr = array ( - // integer values - 0, - 1, - -2, - - // float values - 10.5, - -20.5, - 10.5e10, - - // array values - array(), - array(0), - array(1, 2), - - // boolean values - true, - false, - TRUE, - FALSE, - - // null vlaues - NULL, - null, - - // objects - new sample(), - - // resource - $file_handle, - - // undefined variable - @$undefined_var, - - // unset variable - @$unset_var + // integer values +/*1*/ 0, + 1, + -2, + + // float values +/*4*/ 10.5, + -20.5, + 10.1234567e10, + + // array values +/*7*/ array(), + array(0), + array(1, 2), + + // boolean values +/*10*/ true, + false, + TRUE, + FALSE, + + // null vlaues +/*14*/ NULL, + null, + + // objects +/*16*/ new sample(), + + // resource +/*17*/ $file_handle, + + // undefined variable +/*18*/ @$undefined_var, + + // unset variable +/*19*/ @$unset_var ); //defining 'to' argument @@ -85,9 +85,8 @@ } fclose($file_handle); //closing the file handle - -echo "*** Done ***"; ?> +===DONE=== --EXPECTF-- *** Testing strtr() function: with unexpected inputs for 'from' *** -- Iteration 1 -- @@ -101,7 +100,7 @@ -- Iteration 5 -- unicode(6) "m1tatm" -- Iteration 6 -- -unicode(6) "2a2atm" +unicode(6) "tm0atm" -- Iteration 7 -- Notice: Array to string conversion in %s on line %d @@ -134,4 +133,4 @@ unicode(6) "012atm" -- Iteration 19 -- unicode(6) "012atm" -*** Done *** +===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strtr_variation7.phpt?r1=1.4&r2=1.5&diff_format=u Index: php-src/ext/standard/tests/strings/strtr_variation7.phpt diff -u php-src/ext/standard/tests/strings/strtr_variation7.phpt:1.4 php-src/ext/standard/tests/strings/strtr_variation7.phpt:1.5 --- php-src/ext/standard/tests/strings/strtr_variation7.phpt:1.4 Sat Aug 16 21:16:24 2008 +++ php-src/ext/standard/tests/strings/strtr_variation7.phpt Mon Jan 19 15:46:36 2009 @@ -1,5 +1,5 @@ --TEST-- -Test strtr() function : usage variations - unexpected inputs for 'to' argument(Bug #42861) +Test strtr() function : usage variations - unexpected inputs for 'to' argument --FILE-- <?php /* Prototype : string strtr(string $str, string $from[, string $to]); @@ -37,42 +37,42 @@ // array of values for 'to' argument $to_arr = array ( - // integer values - 0, - 1, - -2, - - // float values - 10.5, - -20.5, - 10.5e10, - - // array values - array(), - array(0), - array(1, 2), - - // boolean values - true, - false, - TRUE, - FALSE, - - // null vlaues - NULL, - null, - - // objects - new sample(), - - // resource - $file_handle, - - // undefined variable - @$undefined_var, - - // unset variable - @$unset_var + // integer values +/*1*/ 0, + 1, + -2, + + // float values +/*4*/ 10.5, + -20.5, + 10.12345675e10, + + // array values +/*7*/ array(), + array(0), + array(1, 2), + + // boolean values +/*10*/ true, + false, + TRUE, + FALSE, + + // null vlaues +/*14*/ NULL, + null, + + // objects +/*16*/ new sample(), + + // resource +/*17*/ $file_handle, + + // undefined variable +/*18*/ @$undefined_var, + + // unset variable +/*19*/ @$unset_var ); // loop through with each element of the $to array to test strtr() function @@ -86,8 +86,8 @@ fclose($file_handle); //closing the file handle -echo "*** Done ***"; ?> +===DONE=== --EXPECTF-- *** Testing strtr() function: with unexpected inputs for 'to' *** @@ -107,7 +107,7 @@ unicode(6) ".52-20" -- Iteration 6 -- -unicode(6) "000105" +unicode(6) "234101" -- Iteration 7 -- @@ -155,4 +155,4 @@ -- Iteration 19 -- unicode(6) "012atm" -*** Done *** +===DONE=== http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strtr_variation5.phpt?r1=1.6&r2=1.7&diff_format=u Index: php-src/ext/standard/tests/strings/strtr_variation5.phpt diff -u php-src/ext/standard/tests/strings/strtr_variation5.phpt:1.6 php-src/ext/standard/tests/strings/strtr_variation5.phpt:1.7 --- php-src/ext/standard/tests/strings/strtr_variation5.phpt:1.6 Sat Aug 16 21:16:24 2008 +++ php-src/ext/standard/tests/strings/strtr_variation5.phpt Mon Jan 19 15:46:36 2009 @@ -31,42 +31,42 @@ // array with different values $strings = array ( - // integer values - 0, - 1, - -2, - - // float values - 10.5, - -20.5, - 10.5e10, - - // array values - array(), - array(0), - array(1, 2), - - // boolean values - true, - false, - TRUE, - FALSE, - - // null vlaues - NULL, - null, - - // objects - new sample(), - - // resource - $file_handle, - - // undefined variable - @$undefined_var, - - // unset variable - @$unset_var + // integer values +/*1*/ 0, + 1, + -2, + + // float values +/*4*/ 10.5, + -20.5, + 10.1234567e10, + + // array values +/*7*/ array(), + array(0), + array(1, 2), + + // boolean values +/*10*/ true, + false, + TRUE, + FALSE, + + // null vlaues +/*14*/ NULL, + null, + + // objects +/*16*/ new sample(), + + // resource +/*17*/ $file_handle, + + // undefined variable +/*18*/ @$undefined_var, + + // unset variable +/*19*/ @$unset_var ); //defining 'from' argument @@ -86,8 +86,8 @@ fclose($file_handle); //closing the file handle -echo "*** Done ***"; ?> +===DONE=== --EXPECTF-- *** Testing strtr() function: with unexpected inputs for 'str' *** -- Iteration 1 -- @@ -101,7 +101,7 @@ -- Iteration 5 -- unicode(5) "-ma.5" -- Iteration 6 -- -unicode(12) "ta5aaaaaaaaa" +unicode(12) "tatm34567aaa" -- Iteration 7 -- Warning: strtr() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d @@ -136,4 +136,4 @@ unicode(0) "" -- Iteration 19 -- unicode(0) "" -*** Done *** +===DONE===
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php