From: andy wharmby Date: Mon, 17 Aug 2009 22:41:30 +0000 (+0000) Subject: New str_replace() tests. All tested on Windows, Linux and Linux 64 X-Git-Tag: php-5.4.0alpha1~191^2~2787 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0855be02d784e5f88f9393ede3d9f4d50402d0e0;p=php New str_replace() tests. All tested on Windows, Linux and Linux 64 --- diff --git a/ext/standard/tests/strings/str_replace_basic.phpt b/ext/standard/tests/strings/str_replace_basic.phpt new file mode 100644 index 0000000000..1a32a7a650 --- /dev/null +++ b/ext/standard/tests/strings/str_replace_basic.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test str_replace() function basic function +--INI-- +precision=14 +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing str_replace() on basic operations *** +unicode(0) "" +unicode(4) "tbst" +unicode(0) "" +int(0) +unicode(1) "q" +int(1) +unicode(0) "" +int(0) +unicode(%d) "Resource id #%d" +int(1) +===DONE=== diff --git a/ext/standard/tests/strings/str_replace_error.phpt b/ext/standard/tests/strings/str_replace_error.phpt new file mode 100644 index 0000000000..65f3eb373a --- /dev/null +++ b/ext/standard/tests/strings/str_replace_error.phpt @@ -0,0 +1,40 @@ +--TEST-- +Test str_replace() function error conditions +--INI-- +precision=14 +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing str_replace error conditions *** +Warning: str_replace() expects at least 3 parameters, 0 given in %sstr_replace_error.php on line 12 +NULL + +Warning: str_replace() expects at least 3 parameters, 1 given in %sstr_replace_error.php on line 13 +NULL + +Warning: str_replace() expects at least 3 parameters, 1 given in %sstr_replace_error.php on line 14 +NULL + +Warning: str_replace() expects at least 3 parameters, 2 given in %sstr_replace_error.php on line 15 +NULL + +Warning: str_replace() expects at most 4 parameters, 5 given in %sstr_replace_error.php on line 16 +NULL +===DONE=== diff --git a/ext/standard/tests/strings/str_replace_variation1.phpt b/ext/standard/tests/strings/str_replace_variation1.phpt new file mode 100644 index 0000000000..237af167d4 --- /dev/null +++ b/ext/standard/tests/strings/str_replace_variation1.phpt @@ -0,0 +1,392 @@ +--TEST-- +Test str_replace() function - test search values +--INI-- +precision=14 +--FILE-- + +===DONE=== +--EXPECT-- +*** Testing str_replace() with various search values *** +-- Iteration 0 -- +array(12) { + [0]=> + unicode(5) "FOUND" + [1]=> + unicode(0) "" + [2]=> + unicode(5) "FOUND" + [3]=> + unicode(1) "0" + [4]=> + unicode(6) "-FOUND" + [5]=> + unicode(5) "FOUND" + [6]=> + unicode(1) "0" + [7]=> + unicode(6) "-FOUND" + [8]=> + unicode(0) "" + [9]=> + array(0) { + } + [10]=> + unicode(3) "php" + [11]=> + unicode(0) "" +} +int(5) + +-- Iteration 1 -- +array(12) { + [0]=> + unicode(1) "1" + [1]=> + unicode(0) "" + [2]=> + unicode(1) "1" + [3]=> + unicode(1) "0" + [4]=> + unicode(2) "-1" + [5]=> + unicode(1) "1" + [6]=> + unicode(1) "0" + [7]=> + unicode(2) "-1" + [8]=> + unicode(0) "" + [9]=> + array(0) { + } + [10]=> + unicode(3) "php" + [11]=> + unicode(0) "" +} +int(0) + +-- Iteration 2 -- +array(12) { + [0]=> + unicode(5) "FOUND" + [1]=> + unicode(0) "" + [2]=> + unicode(5) "FOUND" + [3]=> + unicode(1) "0" + [4]=> + unicode(6) "-FOUND" + [5]=> + unicode(5) "FOUND" + [6]=> + unicode(1) "0" + [7]=> + unicode(6) "-FOUND" + [8]=> + unicode(0) "" + [9]=> + array(0) { + } + [10]=> + unicode(3) "php" + [11]=> + unicode(0) "" +} +int(5) + +-- Iteration 3 -- +array(12) { + [0]=> + unicode(1) "1" + [1]=> + unicode(0) "" + [2]=> + unicode(1) "1" + [3]=> + unicode(5) "FOUND" + [4]=> + unicode(2) "-1" + [5]=> + unicode(1) "1" + [6]=> + unicode(5) "FOUND" + [7]=> + unicode(2) "-1" + [8]=> + unicode(0) "" + [9]=> + array(0) { + } + [10]=> + unicode(3) "php" + [11]=> + unicode(0) "" +} +int(2) + +-- Iteration 4 -- +array(12) { + [0]=> + unicode(1) "1" + [1]=> + unicode(0) "" + [2]=> + unicode(1) "1" + [3]=> + unicode(1) "0" + [4]=> + unicode(5) "FOUND" + [5]=> + unicode(1) "1" + [6]=> + unicode(1) "0" + [7]=> + unicode(5) "FOUND" + [8]=> + unicode(0) "" + [9]=> + array(0) { + } + [10]=> + unicode(3) "php" + [11]=> + unicode(0) "" +} +int(2) + +-- Iteration 5 -- +array(12) { + [0]=> + unicode(5) "FOUND" + [1]=> + unicode(0) "" + [2]=> + unicode(5) "FOUND" + [3]=> + unicode(1) "0" + [4]=> + unicode(6) "-FOUND" + [5]=> + unicode(5) "FOUND" + [6]=> + unicode(1) "0" + [7]=> + unicode(6) "-FOUND" + [8]=> + unicode(0) "" + [9]=> + array(0) { + } + [10]=> + unicode(3) "php" + [11]=> + unicode(0) "" +} +int(5) + +-- Iteration 6 -- +array(12) { + [0]=> + unicode(1) "1" + [1]=> + unicode(0) "" + [2]=> + unicode(1) "1" + [3]=> + unicode(5) "FOUND" + [4]=> + unicode(2) "-1" + [5]=> + unicode(1) "1" + [6]=> + unicode(5) "FOUND" + [7]=> + unicode(2) "-1" + [8]=> + unicode(0) "" + [9]=> + array(0) { + } + [10]=> + unicode(3) "php" + [11]=> + unicode(0) "" +} +int(2) + +-- Iteration 7 -- +array(12) { + [0]=> + unicode(1) "1" + [1]=> + unicode(0) "" + [2]=> + unicode(1) "1" + [3]=> + unicode(1) "0" + [4]=> + unicode(5) "FOUND" + [5]=> + unicode(1) "1" + [6]=> + unicode(1) "0" + [7]=> + unicode(5) "FOUND" + [8]=> + unicode(0) "" + [9]=> + array(0) { + } + [10]=> + unicode(3) "php" + [11]=> + unicode(0) "" +} +int(2) + +-- Iteration 8 -- +array(12) { + [0]=> + unicode(1) "1" + [1]=> + unicode(0) "" + [2]=> + unicode(1) "1" + [3]=> + unicode(1) "0" + [4]=> + unicode(2) "-1" + [5]=> + unicode(1) "1" + [6]=> + unicode(1) "0" + [7]=> + unicode(2) "-1" + [8]=> + unicode(0) "" + [9]=> + array(0) { + } + [10]=> + unicode(3) "php" + [11]=> + unicode(0) "" +} +int(0) + +-- Iteration 9 -- +array(12) { + [0]=> + unicode(1) "1" + [1]=> + unicode(0) "" + [2]=> + unicode(1) "1" + [3]=> + unicode(1) "0" + [4]=> + unicode(2) "-1" + [5]=> + unicode(1) "1" + [6]=> + unicode(1) "0" + [7]=> + unicode(2) "-1" + [8]=> + unicode(0) "" + [9]=> + array(0) { + } + [10]=> + unicode(3) "php" + [11]=> + unicode(0) "" +} +int(0) + +-- Iteration 10 -- +array(12) { + [0]=> + unicode(1) "1" + [1]=> + unicode(0) "" + [2]=> + unicode(1) "1" + [3]=> + unicode(1) "0" + [4]=> + unicode(2) "-1" + [5]=> + unicode(1) "1" + [6]=> + unicode(1) "0" + [7]=> + unicode(2) "-1" + [8]=> + unicode(0) "" + [9]=> + array(0) { + } + [10]=> + unicode(5) "FOUND" + [11]=> + unicode(0) "" +} +int(1) + +-- Iteration 11 -- +array(12) { + [0]=> + unicode(1) "1" + [1]=> + unicode(0) "" + [2]=> + unicode(1) "1" + [3]=> + unicode(1) "0" + [4]=> + unicode(2) "-1" + [5]=> + unicode(1) "1" + [6]=> + unicode(1) "0" + [7]=> + unicode(2) "-1" + [8]=> + unicode(0) "" + [9]=> + array(0) { + } + [10]=> + unicode(3) "php" + [11]=> + unicode(0) "" +} +int(0) +===DONE=== diff --git a/ext/standard/tests/strings/str_replace_variation2.phpt b/ext/standard/tests/strings/str_replace_variation2.phpt new file mode 100644 index 0000000000..d41feaf2ba Binary files /dev/null and b/ext/standard/tests/strings/str_replace_variation2.phpt differ diff --git a/ext/standard/tests/strings/str_replace_variation3.phpt b/ext/standard/tests/strings/str_replace_variation3.phpt new file mode 100644 index 0000000000..50492dbd20 --- /dev/null +++ b/ext/standard/tests/strings/str_replace_variation3.phpt @@ -0,0 +1,226 @@ +--TEST-- +Test str_replace() function +--INI-- +precision=14 +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing Miscelleneous input data *** +unicode(3) "qqq" +int(5) +array(3) { + [0]=> + unicode(3) "qqq" + [1]=> + unicode(0) "" + [2]=> + unicode(3) "ccc" +} +int(6) + +-- Testing objects -- +unicode(12) "Hello, world" +int(1) + +-- Testing arrays -- +unicode(15) "multimultimulti" +int(3) +unicode(3) "qqq" +int(3) +array(2) { + [0]=> + unicode(3) "qqq" + [1]=> + unicode(3) "ccc" +} +int(6) + +Notice: Array to string conversion in %s on line %d +array(1) { + [0]=> + unicode(15) "ArrayArrayArray" +} +int(3) +array(2) { + [0]=> + unicode(3) "111" + [1]=> + unicode(3) "bbb" +} +int(3) +array(2) { + [0]=> + unicode(4) "aaa3" + [1]=> + unicode(4) "2bbb" +} +int(1) + +-- Testing Resources -- +unicode(%d) "Resource id #%d" +int(0) +unicode(%d) "Resource id #%d" +int(0) + +-- Testing a longer and heredoc string -- +unicode(623) "FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789 +FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789 +FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789 +FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789 +FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789 +FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789 +FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789 +@#$%^&**&^%$#@!~:())))((((&&&**%$###@@@!!!~~~~@###$%^&* +FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789" +int(16) + +-- Testing a heredoc null string -- +unicode(0) "" +int(0) + +-- Testing simple and complex syntax strings -- +unicode(5) "FOUND" +unicode(5) "FOUND" + +Notice: Undefined variable: strS in %s on line %d +unicode(0) "" +unicode(5) "FOUND" +unicode(5) "FOUND" +===DONE===