From: Raghubansh Kumar Date: Mon, 8 Oct 2007 15:31:06 +0000 (+0000) Subject: New testcases for strtr() function X-Git-Tag: RELEASE_2_0_0a1~1632 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=28d292e580d40de53feac9242c077077612659ee;p=php New testcases for strtr() function --- diff --git a/ext/standard/tests/strings/strtr_basic.phpt b/ext/standard/tests/strings/strtr_basic.phpt new file mode 100644 index 0000000000..7ece869ddc --- /dev/null +++ b/ext/standard/tests/strings/strtr_basic.phpt @@ -0,0 +1,69 @@ +--TEST-- +Test strtr() function : basic functionality +--FILE-- + "T", "e" => "E", "st" => "ST"); +$trans2_arr = array('t' => 'T', 'e' => 'E', 'st' => 'ST'); +$heredoc_str = << +--EXPECTF-- +*** Testing strtr() : basic functionality *** +string(10) "TesT sTrTr" +string(10) "TesT sTrTr" +string(10) "TesT sTrTr" +string(10) "TEST STrTr" +string(10) "TEST STrTr" +string(10) "TEST STrTr" +string(10) "TEST STrTr" +string(10) "TEST STrTr" +string(10) "TEST STrTr" +string(10) "TEST STrTr" +string(10) "TEST STrTr" +string(10) "TEST STrTr" +*** Done *** +--UEXPECTF-- +*** Testing strtr() : basic functionality *** +unicode(10) "TesT sTrTr" +unicode(10) "TesT sTrTr" +unicode(10) "TesT sTrTr" +string(10) "TEST STrTr" +unicode(10) "TEST STrTr" +unicode(10) "TEST STrTr" +unicode(10) "TEST STrTr" +unicode(10) "TEST STrTr" +unicode(10) "TEST STrTr" +unicode(10) "TEST STrTr" +unicode(10) "TEST STrTr" +unicode(10) "TEST STrTr" +*** Done *** diff --git a/ext/standard/tests/strings/strtr_error.phpt b/ext/standard/tests/strings/strtr_error.phpt new file mode 100644 index 0000000000..a2d00c3ffa --- /dev/null +++ b/ext/standard/tests/strings/strtr_error.phpt @@ -0,0 +1,56 @@ +--TEST-- +Test strtr() function : error conditions +--FILE-- + +--EXPECTF-- +*** Testing strtr() : error conditions *** + +-- Testing strtr() function with Zero arguments -- +Warning: Wrong parameter count for strtr() in %s on line %d +NULL + +-- Testing strtr() function with less than expected no. of arguments -- +Warning: Wrong parameter count for strtr() in %s on line %d +NULL + +-- Testing strtr() function with more than expected no. of arguments -- +Warning: Wrong parameter count for strtr() in %s on line %d +NULL +Done +--UEXPECTF-- +*** Testing strtr() : error conditions *** + +-- Testing strtr() function with Zero arguments -- +Warning: Wrong parameter count for strtr() in %s on line %d +NULL + +-- Testing strtr() function with less than expected no. of arguments -- +Warning: Wrong parameter count for strtr() in %s on line %d +NULL + +-- Testing strtr() function with more than expected no. of arguments -- +Warning: Wrong parameter count for strtr() in %s on line %d +NULL +Done diff --git a/ext/standard/tests/strings/strtr_variation1.phpt b/ext/standard/tests/strings/strtr_variation1.phpt new file mode 100644 index 0000000000..b5bbfb0909 --- /dev/null +++ b/ext/standard/tests/strings/strtr_variation1.phpt @@ -0,0 +1,114 @@ +--TEST-- +Test strtr() function : usage variations - regular & numeric strings for 'str' argument +--FILE-- + "a", "a" => 1, "2b3c" => "b2c3", "b2c3" => "3c2b"); + +/* loop through to test strtr() with each element of $str_arr */ +for($index = 0; $index < count($str_arr); $index++) { + echo "-- Iteration $count --\n"; + + $str = $str_arr[$index]; //getting the $str_arr element in $str variable + + //strtr() call in three args syntax form + var_dump( strtr($str, $from, $to) ); + + //strtr() call in two args syntax form + var_dump( strtr($str, $replace_pairs) ); + + $count++; +} +echo "*** Done ***"; +?> +--EXPECTF-- +*** Testing strtr() : numeric & regular double quoted strings *** +-- Iteration 1 -- +string(3) "abc" +string(3) "a23" +-- Iteration 2 -- +string(3) "123" +string(3) "1bc" +-- Iteration 3 -- +string(6) "a1b2c3" +string(6) "a1b2c3" +-- Iteration 4 -- +string(3) "abc" +string(3) "a23" +-- Iteration 5 -- +string(3) "123" +string(3) "1bc" +-- Iteration 6 -- +string(6) "a1b2c3" +string(6) "a1b2c3" +-- Iteration 7 -- +string(14) "abc +123 +a1b2c3" +string(14) "a23 +1bc +a1b2c3" +*** Done *** +--UEXPECTF-- +*** Testing strtr() : numeric & regular double quoted strings *** +-- Iteration 1 -- +unicode(3) "abc" +unicode(3) "a23" +-- Iteration 2 -- +unicode(3) "123" +unicode(3) "1bc" +-- Iteration 3 -- +unicode(6) "a1b2c3" +unicode(6) "a1b2c3" +-- Iteration 4 -- +unicode(3) "abc" +unicode(3) "a23" +-- Iteration 5 -- +unicode(3) "123" +unicode(3) "1bc" +-- Iteration 6 -- +unicode(6) "a1b2c3" +unicode(6) "a1b2c3" +-- Iteration 7 -- +unicode(14) "abc +123 +a1b2c3" +unicode(14) "a23 +1bc +a1b2c3" +*** Done *** diff --git a/ext/standard/tests/strings/strtr_variation2.phpt b/ext/standard/tests/strings/strtr_variation2.phpt new file mode 100644 index 0000000000..8405e2ed12 --- /dev/null +++ b/ext/standard/tests/strings/strtr_variation2.phpt @@ -0,0 +1,118 @@ +--TEST-- +Test strtr() function : usage variations - string containing special chars for 'str' argument +--FILE-- + "%", "%" => "$", "#*&@()" => "()@&*#"); + +/* loop through to test strtr() with each element of $str_arr */ +for($index = 0; $index < count($str_arr); $index++) { + echo "-- Iteration $count --\n"; + + $str = $str_arr[$index]; //getting the array element in 'str' variable + + //strtr() call in three args syntax form + var_dump( strtr($str, $from, $to) ); + + //strtr() call in two args syntax form + var_dump( strtr($str, $replace_pairs) ); + + $count++; +} +echo "*** Done ***"; +?> +--EXPECTF-- +*** Testing strtr() : string containing special chars for 'str' arg *** +-- Iteration 1 -- +string(1) "s" +string(1) "$" +-- Iteration 2 -- +string(3) "pec" +string(3) "#%*" +-- Iteration 3 -- +string(10) "text i als" +string(10) "text & @()" +-- Iteration 4 -- +string(1) "s" +string(1) "$" +-- Iteration 5 -- +string(3) "pec" +string(3) "#%*" +-- Iteration 6 -- +string(10) "text i als" +string(10) "text & @()" +-- Iteration 7 -- +string(17) "s +peci +text i als" +string(17) "$ +#%*& +text & @()" +*** Done *** +--UEXPECTF-- +*** Testing strtr() : string containing special chars for 'str' arg *** +-- Iteration 1 -- +unicode(1) "s" +unicode(1) "$" +-- Iteration 2 -- +unicode(3) "pec" +unicode(3) "#%*" +-- Iteration 3 -- +unicode(10) "text i als" +unicode(10) "text & @()" +-- Iteration 4 -- +unicode(1) "s" +unicode(1) "$" +-- Iteration 5 -- +unicode(3) "pec" +unicode(3) "#%*" +-- Iteration 6 -- +unicode(10) "text i als" +unicode(10) "text & @()" +-- Iteration 7 -- +unicode(17) "s +peci +text i als" +unicode(17) "$ +#%*& +text & @()" +*** Done *** diff --git a/ext/standard/tests/strings/strtr_variation3.phpt b/ext/standard/tests/strings/strtr_variation3.phpt new file mode 100644 index 0000000000..a878a8ee49 --- /dev/null +++ b/ext/standard/tests/strings/strtr_variation3.phpt @@ -0,0 +1,141 @@ +--TEST-- +Test strtr() function : usage variations - string containing escape sequences for 'str' argument +--FILE-- + "t", "\r\n" => "T", "\n\r\t\\" => "TEST"); + +/* loop through to test strtr() with each element of $str_arr */ +for($index = 0; $index < count($str_arr); $index++) { + echo "-- Iteration $count --\n"; + + $str = $str_arr[$index]; //getting the array element in 'str' variable + + //strtr() call in three args syntax form + var_dump( strtr($str, $from, $to) ); + + //strtr() call in two args syntax form + var_dump( strtr($str, $replace_pairs) ); + + $count++; +} +echo "*** Done ***"; +?> +--EXPECTF-- +*** Testing strtr() : string containing escape sequences for 'str' arg *** +-- Iteration 1 -- +string(9) "SesSTsttE" +string(9) " es \stt +" +-- Iteration 2 -- +string(12) "TtestTTstrtr" +string(12) "\test\\strtr" +-- Iteration 3 -- +string(12) "TtestETstrtr" +string(11) "ttestTstrtr" +-- Iteration 4 -- +string(9) "$variable" +string(9) "$variable" +-- Iteration 5 -- +string(7) ""quotes" +string(7) ""quotes" +-- Iteration 6 -- +string(12) "TtesTtTsttTr" +string(12) "\tes\t\stt\r" +-- Iteration 7 -- +string(12) "TtestTTstrtr" +string(12) "\test\\strtr" +-- Iteration 8 -- +string(15) "TntestTrTnstrtr" +string(15) "\ntest\r\nstrtr" +-- Iteration 9 -- +string(10) "T$variable" +string(10) "\$variable" +-- Iteration 10 -- +string(8) "T"quotes" +string(8) "\"quotes" +-- Iteration 11 -- +string(54) "SesSTsttETTtestTTstrtrTTtestETstrtrT$variableTT"quotes" +string(52) " es \sttT\test\\strtrtttestTstrtrt$variablet\"quotes" +*** Done *** +--UEXPECTF-- +*** Testing strtr() : string containing escape sequences for 'str' arg *** +-- Iteration 1 -- +unicode(9) "SesSTsttE" +unicode(9) " es \stt +" +-- Iteration 2 -- +unicode(12) "TtestTTstrtr" +unicode(12) "\test\\strtr" +-- Iteration 3 -- +unicode(12) "TtestETstrtr" +unicode(11) "ttestTstrtr" +-- Iteration 4 -- +unicode(9) "$variable" +unicode(9) "$variable" +-- Iteration 5 -- +unicode(7) ""quotes" +unicode(7) ""quotes" +-- Iteration 6 -- +unicode(12) "TtesTtTsttTr" +unicode(12) "\tes\t\stt\r" +-- Iteration 7 -- +unicode(12) "TtestTTstrtr" +unicode(12) "\test\\strtr" +-- Iteration 8 -- +unicode(15) "TntestTrTnstrtr" +unicode(15) "\ntest\r\nstrtr" +-- Iteration 9 -- +unicode(10) "T$variable" +unicode(10) "\$variable" +-- Iteration 10 -- +unicode(8) "T"quotes" +unicode(8) "\"quotes" +-- Iteration 11 -- +unicode(54) "SesSTsttETTtestTTstrtrTTtestETstrtrT$variableTT"quotes" +unicode(52) " es \sttT\test\\strtrtttestTstrtrt$variablet\"quotes" +*** Done *** diff --git a/ext/standard/tests/strings/strtr_variation4.phpt b/ext/standard/tests/strings/strtr_variation4.phpt new file mode 100644 index 0000000000..341b8d5b4b --- /dev/null +++ b/ext/standard/tests/strings/strtr_variation4.phpt @@ -0,0 +1,103 @@ +--TEST-- +Test strtr() function : usage variations - empty string & null for 'str' argument +--FILE-- + "t", '' => "TEST"); + + +/* loop through to test strtr() with each element of $str_arr */ +for($index = 0; $index < count($str_arr); $index++) { + echo "-- Iteration $count --\n"; + + $str = $str_arr[$index]; //getting the array element in 'str' variable + + //strtr() call in three args syntax form + var_dump( strtr($str, $from, $to) ); + + //strtr() call in two args syntax form + var_dump( strtr($str, $replace_pairs) ); + + $count++; +} +echo "*** Done ***"; +?> +--EXPECTF-- +*** Testing strtr() : empty string & null for 'str' arg *** +-- Iteration 1 -- +string(0) "" +string(0) "" +-- Iteration 2 -- +string(0) "" +string(0) "" +-- Iteration 3 -- +string(0) "" +string(0) "" +-- Iteration 4 -- +string(0) "" +string(0) "" +-- Iteration 5 -- +string(0) "" +string(0) "" +-- Iteration 6 -- +string(0) "" +string(0) "" +-- Iteration 7 -- +string(0) "" +string(0) "" +*** Done *** +--UEXPECTF-- +*** Testing strtr() : empty string & null for 'str' arg *** +-- Iteration 1 -- +unicode(0) "" +unicode(0) "" +-- Iteration 2 -- +unicode(0) "" +unicode(0) "" +-- Iteration 3 -- +unicode(0) "" +unicode(0) "" +-- Iteration 4 -- +unicode(0) "" +unicode(0) "" +-- Iteration 5 -- +unicode(0) "" +unicode(0) "" +-- Iteration 6 -- +unicode(0) "" +unicode(0) "" +-- Iteration 7 -- +unicode(0) "" +unicode(0) "" +*** Done *** diff --git a/ext/standard/tests/strings/strtr_variation5.phpt b/ext/standard/tests/strings/strtr_variation5.phpt new file mode 100644 index 0000000000..04b697689e --- /dev/null +++ b/ext/standard/tests/strings/strtr_variation5.phpt @@ -0,0 +1,184 @@ +--TEST-- +Test strtr() function : usage variations - unexpected inputs for 'str' argument +--FILE-- + +--EXPECTF-- +*** Testing strtr() function: with unexpected inputs for 'str' *** +-- Iteration 1 -- +string(1) "a" +-- Iteration 2 -- +string(1) "t" +-- Iteration 3 -- +string(2) "-m" +-- Iteration 4 -- +string(4) "ta.5" +-- Iteration 5 -- +string(5) "-ma.5" +-- Iteration 6 -- +string(12) "ta5aaaaaaaaa" +-- Iteration 7 -- + +Notice: Array to string conversion in %s on line %d +string(5) "Arr0y" +-- Iteration 8 -- + +Notice: Array to string conversion in %s on line %d +string(5) "Arr0y" +-- Iteration 9 -- + +Notice: Array to string conversion in %s on line %d +string(5) "Arr0y" +-- Iteration 10 -- +string(1) "t" +-- Iteration 11 -- +string(0) "" +-- Iteration 12 -- +string(1) "t" +-- Iteration 13 -- +string(0) "" +-- Iteration 14 -- +string(0) "" +-- Iteration 15 -- +string(0) "" +-- Iteration 16 -- +string(13) "s02ple objec1" +-- Iteration 17 -- +string(14) "Resource id #5" +-- Iteration 18 -- +string(0) "" +-- Iteration 19 -- +string(0) "" +*** Done *** +--UEXPECTF-- +*** Testing strtr() function: with unexpected inputs for 'str' *** +-- Iteration 1 -- +unicode(1) "a" +-- Iteration 2 -- +unicode(1) "t" +-- Iteration 3 -- +unicode(2) "-m" +-- Iteration 4 -- +unicode(4) "ta.5" +-- Iteration 5 -- +unicode(5) "-ma.5" +-- Iteration 6 -- +unicode(12) "ta5aaaaaaaaa" +-- Iteration 7 -- + +Notice: Array to string conversion in %s on line %d +unicode(5) "Arr0y" +-- Iteration 8 -- + +Notice: Array to string conversion in %s on line %d +unicode(5) "Arr0y" +-- Iteration 9 -- + +Notice: Array to string conversion in %s on line %d +unicode(5) "Arr0y" +-- Iteration 10 -- +unicode(1) "t" +-- Iteration 11 -- +unicode(0) "" +-- Iteration 12 -- +unicode(1) "t" +-- Iteration 13 -- +unicode(0) "" +-- Iteration 14 -- +unicode(0) "" +-- Iteration 15 -- +unicode(0) "" +-- Iteration 16 -- +unicode(13) "s02ple objec1" +-- Iteration 17 -- +unicode(14) "Resource id #5" +-- Iteration 18 -- +unicode(0) "" +-- Iteration 19 -- +unicode(0) "" +*** Done *** diff --git a/ext/standard/tests/strings/strtr_variation6.phpt b/ext/standard/tests/strings/strtr_variation6.phpt new file mode 100644 index 0000000000..067f10bae4 --- /dev/null +++ b/ext/standard/tests/strings/strtr_variation6.phpt @@ -0,0 +1,184 @@ +--TEST-- +Test strtr() function : usage variations - unexpected inputs for 'from' argument(Bug #42861) +--FILE-- + +--EXPECTF-- +*** Testing strtr() function: with unexpected inputs for 'from' *** +-- Iteration 1 -- +string(6) "a12atm" +-- Iteration 2 -- +string(6) "0a2atm" +-- Iteration 3 -- +string(6) "01tatm" +-- Iteration 4 -- +string(6) "ta2atm" +-- Iteration 5 -- +string(6) "m1tatm" +-- Iteration 6 -- +string(6) "2a2atm" +-- Iteration 7 -- + +Notice: Array to string conversion in %s on line %d +string(6) "0120tm" +-- Iteration 8 -- + +Notice: Array to string conversion in %s on line %d +string(6) "0120tm" +-- Iteration 9 -- + +Notice: Array to string conversion in %s on line %d +string(6) "0120tm" +-- Iteration 10 -- +string(6) "0a2atm" +-- Iteration 11 -- +string(6) "012atm" +-- Iteration 12 -- +string(6) "0a2atm" +-- Iteration 13 -- +string(6) "012atm" +-- Iteration 14 -- +string(6) "012atm" +-- Iteration 15 -- +string(6) "012atm" +-- Iteration 16 -- +string(6) "012ttm" +-- Iteration 17 -- +string(6) "012atm" +-- Iteration 18 -- +string(6) "012atm" +-- Iteration 19 -- +string(6) "012atm" +*** Done *** +--UEXPECTF-- +*** Testing strtr() function: with unexpected inputs for 'from' *** +-- Iteration 1 -- +unicode(6) "a12atm" +-- Iteration 2 -- +unicode(6) "0a2atm" +-- Iteration 3 -- +unicode(6) "01tatm" +-- Iteration 4 -- +unicode(6) "ta2atm" +-- Iteration 5 -- +unicode(6) "m1tatm" +-- Iteration 6 -- +unicode(6) "2a2atm" +-- Iteration 7 -- + +Notice: Array to string conversion in %s on line %d +unicode(6) "0120tm" +-- Iteration 8 -- + +Notice: Array to string conversion in %s on line %d +unicode(6) "0120tm" +-- Iteration 9 -- + +Notice: Array to string conversion in %s on line %d +unicode(6) "0120tm" +-- Iteration 10 -- +unicode(6) "0a2atm" +-- Iteration 11 -- +unicode(6) "012atm" +-- Iteration 12 -- +unicode(6) "0a2atm" +-- Iteration 13 -- +unicode(6) "012atm" +-- Iteration 14 -- +unicode(6) "012atm" +-- Iteration 15 -- +unicode(6) "012atm" +-- Iteration 16 -- +unicode(6) "012ttm" +-- Iteration 17 -- +unicode(6) "012atm" +-- Iteration 18 -- +unicode(6) "012atm" +-- Iteration 19 -- +unicode(6) "012atm" +*** Done *** diff --git a/ext/standard/tests/strings/strtr_variation7.phpt b/ext/standard/tests/strings/strtr_variation7.phpt new file mode 100644 index 0000000000..136c1f665e --- /dev/null +++ b/ext/standard/tests/strings/strtr_variation7.phpt @@ -0,0 +1,222 @@ +--TEST-- +Test strtr() function : usage variations - unexpected inputs for 'to' argument(Bug #42861) +--FILE-- + +--EXPECTF-- +*** Testing strtr() function: with unexpected inputs for 'to' *** + +-- Iteration 1 -- +string(6) "0120tm" + +-- Iteration 2 -- +string(6) "0121tm" + +-- Iteration 3 -- +string(6) "012-2m" + +-- Iteration 4 -- +string(6) "51210." + +-- Iteration 5 -- +string(6) ".52-20" + +-- Iteration 6 -- +string(6) "000105" + +-- Iteration 7 -- + +Notice: Array to string conversion in %s on line %d +string(6) "ay2Arr" + +-- Iteration 8 -- + +Notice: Array to string conversion in %s on line %d +string(6) "ay2Arr" + +-- Iteration 9 -- + +Notice: Array to string conversion in %s on line %d +string(6) "ay2Arr" + +-- Iteration 10 -- +string(6) "0121tm" + +-- Iteration 11 -- +string(6) "012atm" + +-- Iteration 12 -- +string(6) "0121tm" + +-- Iteration 13 -- +string(6) "012atm" + +-- Iteration 14 -- +string(6) "012atm" + +-- Iteration 15 -- +string(6) "012atm" + +-- Iteration 16 -- +string(6) "plesam" + +-- Iteration 17 -- +string(6) "ourRes" + +-- Iteration 18 -- +string(6) "012atm" + +-- Iteration 19 -- +string(6) "012atm" +*** Done *** +--UEXPECTF-- +*** Testing strtr() function: with unexpected inputs for 'to' *** + +-- Iteration 1 -- +unicode(6) "0120tm" + +-- Iteration 2 -- +unicode(6) "0121tm" + +-- Iteration 3 -- +unicode(6) "012-2m" + +-- Iteration 4 -- +unicode(6) "51210." + +-- Iteration 5 -- +unicode(6) ".52-20" + +-- Iteration 6 -- +unicode(6) "000105" + +-- Iteration 7 -- + +Notice: Array to string conversion in %s on line %d +unicode(6) "ay2Arr" + +-- Iteration 8 -- + +Notice: Array to string conversion in %s on line %d +unicode(6) "ay2Arr" + +-- Iteration 9 -- + +Notice: Array to string conversion in %s on line %d +unicode(6) "ay2Arr" + +-- Iteration 10 -- +unicode(6) "0121tm" + +-- Iteration 11 -- +unicode(6) "012atm" + +-- Iteration 12 -- +unicode(6) "0121tm" + +-- Iteration 13 -- +unicode(6) "012atm" + +-- Iteration 14 -- +unicode(6) "012atm" + +-- Iteration 15 -- +unicode(6) "012atm" + +-- Iteration 16 -- +unicode(6) "plesam" + +-- Iteration 17 -- +unicode(6) "ourRes" + +-- Iteration 18 -- +unicode(6) "012atm" + +-- Iteration 19 -- +unicode(6) "012atm" +*** Done *** diff --git a/ext/standard/tests/strings/strtr_variation8.phpt b/ext/standard/tests/strings/strtr_variation8.phpt new file mode 100644 index 0000000000..667ebb1160 --- /dev/null +++ b/ext/standard/tests/strings/strtr_variation8.phpt @@ -0,0 +1,271 @@ +--TEST-- +Test strtr() function : usage variations - unexpected inputs for 'replace_pairs' argument +--FILE-- + +--EXPECTF-- +*** Testing strtr() function: with unexpected inputs for 'replace_pairs' *** + +-- Iteration 1 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 2 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 3 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 4 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 5 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 6 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 7 -- +string(6) "012atm" + +-- Iteration 8 -- +string(6) "012atm" + +-- Iteration 9 -- +string(6) "122atm" + +-- Iteration 10 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 11 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 12 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 13 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 14 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 15 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 16 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 17 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 18 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 19 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) +*** Done *** +--UEXPECTF-- +*** Testing strtr() function: with unexpected inputs for 'replace_pairs' *** + +-- Iteration 1 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 2 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 3 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 4 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 5 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 6 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 7 -- +unicode(6) "012atm" + +-- Iteration 8 -- +unicode(6) "012atm" + +-- Iteration 9 -- +unicode(6) "122atm" + +-- Iteration 10 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 11 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 12 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 13 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 14 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 15 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 16 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 17 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 18 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 19 -- + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) +*** Done *** diff --git a/ext/standard/tests/strings/strtr_variation9.phpt b/ext/standard/tests/strings/strtr_variation9.phpt new file mode 100644 index 0000000000..19d48cfd50 --- /dev/null +++ b/ext/standard/tests/strings/strtr_variation9.phpt @@ -0,0 +1,402 @@ +--TEST-- +Test strtr() function : usage variations - unexpected inputs for all arguments +--FILE-- + '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 +); + +// loop through with each element of the $values array to test strtr() function +$count = 1; +for($index = 0; $index < count($values); $index++) { + echo "\n-- Iteration $count --\n"; + var_dump( strtr($values[$index], $values[$index], $values[$index]) ); //fn call with three args + var_dump( strtr($values[$index], $values[$index]) ); //fn call with two args + $count ++; +} + +fclose($file_handle); //closing the file handle + +echo "*** Done ***"; +?> +--EXPECTF-- +*** Testing strtr() function: with unexpected inputs for all arguments *** + +-- Iteration 1 -- +string(1) "0" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 2 -- +string(1) "1" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 3 -- +string(2) "-2" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 4 -- +string(4) "10.5" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 5 -- +string(5) "-20.5" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 6 -- +string(12) "105000000000" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 7 -- + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d +string(5) "Array" + +Notice: Array to string conversion in %s on line %d +string(5) "Array" + +-- Iteration 8 -- + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d +string(5) "Array" + +Notice: Array to string conversion in %s on line %d +string(5) "Array" + +-- Iteration 9 -- + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d +string(5) "Array" + +Notice: Array to string conversion in %s on line %d +string(5) "Array" + +-- Iteration 10 -- + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d +string(5) "Array" + +Notice: Array to string conversion in %s on line %d +string(5) "Array" + +-- Iteration 11 -- + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d +string(5) "Array" + +Notice: Array to string conversion in %s on line %d +string(5) "Array" + +-- Iteration 12 -- +string(1) "1" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 13 -- +string(0) "" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 14 -- +string(1) "1" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 15 -- +string(0) "" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 16 -- +string(0) "" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 17 -- +string(0) "" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 18 -- +string(9) "My String" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 19 -- +string(14) "Resource id #5" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 20 -- +string(0) "" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 21 -- +string(0) "" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) +*** Done *** +--UEXPECTF-- +*** Testing strtr() function: with unexpected inputs for all arguments *** + +-- Iteration 1 -- +unicode(1) "0" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 2 -- +unicode(1) "1" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 3 -- +unicode(2) "-2" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 4 -- +unicode(4) "10.5" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 5 -- +unicode(5) "-20.5" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 6 -- +unicode(12) "105000000000" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 7 -- + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d +unicode(5) "Array" + +Notice: Array to string conversion in %s on line %d +unicode(5) "Array" + +-- Iteration 8 -- + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d +unicode(5) "Array" + +Notice: Array to string conversion in %s on line %d +unicode(5) "Array" + +-- Iteration 9 -- + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d +unicode(5) "Array" + +Notice: Array to string conversion in %s on line %d +unicode(5) "Array" + +-- Iteration 10 -- + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d +unicode(5) "Array" + +Notice: Array to string conversion in %s on line %d +unicode(5) "Array" + +-- Iteration 11 -- + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d + +Notice: Array to string conversion in %s on line %d +unicode(5) "Array" + +Notice: Array to string conversion in %s on line %d +unicode(5) "Array" + +-- Iteration 12 -- +unicode(1) "1" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 13 -- +unicode(0) "" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 14 -- +unicode(1) "1" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 15 -- +unicode(0) "" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 16 -- +unicode(0) "" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 17 -- +unicode(0) "" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 18 -- +unicode(9) "My String" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 19 -- +unicode(14) "Resource id #5" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 20 -- +unicode(0) "" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) + +-- Iteration 21 -- +unicode(0) "" + +Warning: strtr(): The second argument is not an array in %s on line %d +bool(false) +*** Done ***