From 0855be02d784e5f88f9393ede3d9f4d50402d0e0 Mon Sep 17 00:00:00 2001 From: andy wharmby Date: Mon, 17 Aug 2009 22:41:30 +0000 Subject: [PATCH] New str_replace() tests. All tested on Windows, Linux and Linux 64 --- .../tests/strings/str_replace_basic.phpt | 49 +++ .../tests/strings/str_replace_error.phpt | 40 ++ .../tests/strings/str_replace_variation1.phpt | 392 ++++++++++++++++++ .../tests/strings/str_replace_variation2.phpt | Bin 0 -> 12714 bytes .../tests/strings/str_replace_variation3.phpt | 226 ++++++++++ 5 files changed, 707 insertions(+) create mode 100644 ext/standard/tests/strings/str_replace_basic.phpt create mode 100644 ext/standard/tests/strings/str_replace_error.phpt create mode 100644 ext/standard/tests/strings/str_replace_variation1.phpt create mode 100644 ext/standard/tests/strings/str_replace_variation2.phpt create mode 100644 ext/standard/tests/strings/str_replace_variation3.phpt 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 00000000000..1a32a7a6507 --- /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 00000000000..65f3eb373ac --- /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 00000000000..237af167d49 --- /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 0000000000000000000000000000000000000000..d41feaf2bacbcd74da57578f50a6cd762f3939f0 GIT binary patch literal 12714 zcmeHNYfsxq6y+=a6_;$bc{HIOI{^Ys*$RRd3DK&6w%ewQj58swf*sjTOI3A$``)=@ zCvm7vf*nLRK@lF`dHUSP%$b>L^}KapH&Ue;e>!xUp_|C(@#n5Ls zZIgT8biwa&ki!rIwCrp6YWcl8BM`-c;oWfTOO{p2FBFBFJqL1ayId}VfKId#MUPti zVz`zw^uUvY_5jQ0_LO|^4o%4Y$@_h$0$&}s->IlfQ*~Y6)N8eRm2GNzt-iHAM&mt8>i|O`l{q@0NTQ#oC4ocqt{h{qsI-mdJx8MJHR^Irx zvbnprzY7~1LAQU2Zb6|o_9HU0=N8q{rg$)IM<#GQGO<+;1ocs3tArmW%)sWn(?^^w z8w~upuJH|g2d+4n&dtDZ(JC;DR3Nd>2RcAp1LL?v31TDb7KL6ym}tDY3Q7u-qb-mm z`c)*$?MJ?fYUZM7NEy>~O5jtpl?%`(nM~J6F7PB_0pX=CgiDFYs7couUiXBKuenc(#e!0`sM4Kw7KEfV^~1s8+Bg=i$Auz7IgCN_N#8`}p>FF_Rut&u#I*o>oxlr)b81QQ8!CSDwk%290L6sQO z;tZ~y9<${&xUCgK(>U_%Mwgv+qZaP^5Y@vj3Toqz32Pj7$uL zwHUs^(i4sqnxj2CwxS}%hp(ntdM=_*cs99E!hRm*&-G92cT)usM`cZMDzTRANQlgINFI9ecPgYU!EL&t?;XZsM8&z2A4$V4*0= z5zThTATb!m%_drUlEmibm~>f#K209fFBHOAuV^H~7dMw^S+JtJ%bI00#Pp14<uqu1%(qXk`ZO +===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===