From aecb1354e38cb3872d1a38072fdcf8dde9b0d6f0 Mon Sep 17 00:00:00 2001 From: Raghubansh Kumar Date: Fri, 7 Sep 2007 14:03:33 +0000 Subject: [PATCH] New testcases for stripslashes() function --- .../tests/strings/stripslashes_basic.phpt | Bin 0 -> 2894 bytes .../tests/strings/stripslashes_error.phpt | 58 +++++ .../strings/stripslashes_variation1.phpt | 242 ++++++++++++++++++ .../strings/stripslashes_variation2.phpt | Bin 0 -> 15894 bytes .../strings/stripslashes_variation3.phpt | 188 ++++++++++++++ .../strings/stripslashes_variation4.phpt | 227 ++++++++++++++++ 6 files changed, 715 insertions(+) create mode 100644 ext/standard/tests/strings/stripslashes_basic.phpt create mode 100644 ext/standard/tests/strings/stripslashes_error.phpt create mode 100644 ext/standard/tests/strings/stripslashes_variation1.phpt create mode 100644 ext/standard/tests/strings/stripslashes_variation2.phpt create mode 100644 ext/standard/tests/strings/stripslashes_variation3.phpt create mode 100644 ext/standard/tests/strings/stripslashes_variation4.phpt diff --git a/ext/standard/tests/strings/stripslashes_basic.phpt b/ext/standard/tests/strings/stripslashes_basic.phpt new file mode 100644 index 0000000000000000000000000000000000000000..bfabd8cfef41805ed64932c64b5c3354793c22c8 GIT binary patch literal 2894 zcmds2QBT`25Z-fs#VwjdTCFPuZPU83YJwt|rh!C}_7DlVj@wuZcCj6xoA%##cIq^N zbZyxieP|Q=yYIg9`MY*Hqv6G<(+NgQ8_-7ana+q#nT}d8$ptlB3h2X_Xim!ol5sPK zpwl@%{WiqlPlH)H3%YGMSJFr`pE1A~%O<8ZQi%NOE8K-v0Bty8nqpd;s1KK-bCXNM zG!SqPi4U;Q3z;j*fXamRf!&*~Hbf*uCHP=-y`e$78=w#iwiP|hk44>alh&y9*ez4@u}tRSYXCsD#raVw4B^6+f?pXc)CUN9^x65M7|dl3;n%a1@8MvlPUUJ( zWR6k_65Y%~`!O~&wgUWhXkr=@`g3txR`NKawM+|5>j=Y?Wtoh3@1)9-5UXFFk}FN* z8PJp{LJd<5l3GQZ4zW4q%_wiXW3X)_YMNg&VRSH&iV>PdP-z>{?hRT1zcEFzlO&6C zuw5-*BD;w>!Cru?B)^_T;V5Okv1EcOD{$btkG+4u=;Ga4wH=tJ`sy-WEiqvDBWsUsH?%?i~hCj}ShofU0J5TXyU{i`|wBKvN+Gcog?;V2CrE$%ses_Pr ziK)p literal 0 HcmV?d00001 diff --git a/ext/standard/tests/strings/stripslashes_error.phpt b/ext/standard/tests/strings/stripslashes_error.phpt new file mode 100644 index 0000000000..2ed74bc6a6 --- /dev/null +++ b/ext/standard/tests/strings/stripslashes_error.phpt @@ -0,0 +1,58 @@ +--TEST-- +Test stripslashes() function : error conditions +--FILE-- + +--EXPECTF-- +*** Testing stripslashes() : error conditions *** + +-- Testing stripslashes() function with Zero arguments -- + +Warning: Wrong parameter count for stripslashes() in %s on line %d +NULL + +-- Testing stripslashes() function with more than expected no. of arguments -- + +Warning: Wrong parameter count for stripslashes() in %s on line %d +NULL +string(18) "\"hello\"\"world\"" +Done + +--UEXPECTF-- +*** Testing stripslashes() : error conditions *** + +-- Testing stripslashes() function with Zero arguments -- + +Warning: Wrong parameter count for stripslashes() in %s on line %d +NULL + +-- Testing stripslashes() function with more than expected no. of arguments -- + +Warning: Wrong parameter count for stripslashes() in %s on line %d +NULL +unicode(18) "\"hello\"\"world\"" +Done diff --git a/ext/standard/tests/strings/stripslashes_variation1.phpt b/ext/standard/tests/strings/stripslashes_variation1.phpt new file mode 100644 index 0000000000..af2e7a04f0 --- /dev/null +++ b/ext/standard/tests/strings/stripslashes_variation1.phpt @@ -0,0 +1,242 @@ +--TEST-- +Test stripslashes() function : usage variations - non-string type argument +--FILE-- + 'red', 'item' => 'pen'), + + // boolean values + true, + false, + TRUE, + FALSE, + + // empty string + "", + '', + + // undefined variable + $undefined_var, + + // unset variable + $unset_var, + + // objects + new sample(), + + // resource + $file_handle, + + // NULL values + NULL, + null +); + + +// loop through each element of the array and check the working of stripslashes() +// when $str arugment is supplied with different values +echo "\n--- Testing stripslashes() by supplying different values for 'str' argument ---\n"; +$counter = 1; +for($index = 0; $index < count($values); $index ++) { + echo "-- Iteration $counter --\n"; + $str = $values [$index]; + + var_dump( stripslashes($str) ); + + $counter ++; +} + +// closing the file +fclose($file_handle); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing stripslashes() : with non-string type argument *** + +Notice: Undefined variable: undefined_var in %s on line %d + +Notice: Undefined variable: unset_var in %s on line %d + +--- Testing stripslashes() by supplying different values for 'str' argument --- +-- Iteration 1 -- +string(1) "0" +-- Iteration 2 -- +string(1) "1" +-- Iteration 3 -- +string(5) "12345" +-- Iteration 4 -- +string(5) "-2345" +-- Iteration 5 -- +string(4) "10.5" +-- Iteration 6 -- +string(5) "-10.5" +-- Iteration 7 -- +string(12) "105000000000" +-- Iteration 8 -- +string(7) "1.06E-9" +-- Iteration 9 -- +string(3) "0.5" +-- Iteration 10 -- + +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 +string(5) "Array" +-- Iteration 12 -- + +Notice: Array to string conversion in %s on line %d +string(5) "Array" +-- Iteration 13 -- + +Notice: Array to string conversion in %s on line %d +string(5) "Array" +-- Iteration 14 -- + +Notice: Array to string conversion in %s on line %d +string(5) "Array" +-- Iteration 15 -- +string(1) "1" +-- Iteration 16 -- +string(0) "" +-- Iteration 17 -- +string(1) "1" +-- Iteration 18 -- +string(0) "" +-- Iteration 19 -- +string(0) "" +-- Iteration 20 -- +string(0) "" +-- Iteration 21 -- +string(0) "" +-- Iteration 22 -- +string(0) "" +-- Iteration 23 -- +string(6) "obj'ct" +-- Iteration 24 -- +string(14) "Resource id #%d" +-- Iteration 25 -- +string(0) "" +-- Iteration 26 -- +string(0) "" +Done + +--UEXPECTF-- +*** Testing stripslashes() : with non-string type argument *** + +Notice: Undefined variable: undefined_var in %s on line %d + +Notice: Undefined variable: unset_var in %s on line %d + +--- Testing stripslashes() by supplying different values for 'str' argument --- +-- Iteration 1 -- +unicode(1) "0" +-- Iteration 2 -- +unicode(1) "1" +-- Iteration 3 -- +unicode(5) "12345" +-- Iteration 4 -- +unicode(5) "-2345" +-- Iteration 5 -- +unicode(4) "10.5" +-- Iteration 6 -- +unicode(5) "-10.5" +-- Iteration 7 -- +unicode(12) "105000000000" +-- Iteration 8 -- +unicode(7) "1.06E-9" +-- Iteration 9 -- +unicode(3) "0.5" +-- Iteration 10 -- + +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 +unicode(5) "Array" +-- Iteration 12 -- + +Notice: Array to string conversion in %s on line %d +unicode(5) "Array" +-- Iteration 13 -- + +Notice: Array to string conversion in %s on line %d +unicode(5) "Array" +-- Iteration 14 -- + +Notice: Array to string conversion in %s on line %d +unicode(5) "Array" +-- Iteration 15 -- +unicode(1) "1" +-- Iteration 16 -- +unicode(0) "" +-- Iteration 17 -- +unicode(1) "1" +-- Iteration 18 -- +unicode(0) "" +-- Iteration 19 -- +unicode(0) "" +-- Iteration 20 -- +unicode(0) "" +-- Iteration 21 -- +unicode(0) "" +-- Iteration 22 -- +unicode(0) "" +-- Iteration 23 -- +unicode(6) "obj'ct" +-- Iteration 24 -- +unicode(14) "Resource id #5" +-- Iteration 25 -- +unicode(0) "" +-- Iteration 26 -- +unicode(0) "" +Done diff --git a/ext/standard/tests/strings/stripslashes_variation2.phpt b/ext/standard/tests/strings/stripslashes_variation2.phpt new file mode 100644 index 0000000000000000000000000000000000000000..9f59c8de64bf9421fee4f3819ebe4b84f92d3aca GIT binary patch literal 15894 zcmd5?S#R4$5cX^MD>iIe+OB0?IUT3z5eE%gAVKN^eIQ`aByACuNSCA%8%6(nXLh+G z9!tqPvfDU8Vu`ym-`ul191KoRemfluoYS}{MN#I-RWT2WSzPSyiHl_#mPwY1Be5)k z%UFC0@+81-3NaANbnw?QD`UAUy)1C_x6JT=u`f7IN4EM!{ zJS(&E<|-CI8@Z;J4d!B3fBOiYiakf{i#Kr*0z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cJa)C?$2w!Cw zq#dO^`+~4M|AMf*;9{Agk?7Fl87)dM{G$jf{B?AC#$=a z1^to8yC&jYVfZEL32;Lhd^}gGU$|Cy0i@`B+R-<=NZoas8M6zJ%rk5!MZ0z_$1WuI z0ft=)WZ|#w4wy0gRJuK!XS+Jut}xuO!T6N{CG1>W(9H!m>LwV$9kTj9q!WhhVuI1V zIyEzmjBS>_iRnP&*A@&dIIhbZoYfUh;|_%~z4l;JtxDOv=*NQQo$>Hdw)6*6Q3hY=sO{a6Tn6N9zST<{Qh(13;F<-1e zc7v5&C=|+(kC(72BX6n7oz-=2J6zc%Ls@%O(D-MMvFuN^wL8trlwA(Sm<{|@U4!Nv zl*$cYnfY`fb9XvkIptRh8OBw5h6s|06#{8A9J0Zp=!&AgQQtvo&EhuY*Ap!2hHG_h zRp}$w!pkl$_mC*3?0ParX}i+|wypcfwUo!MGXGigFlE=CXX-u}-p7Eyt5-67{Z59z z=A{h0evt2c`1-XBt|gvgr_gxogZpAgCsNrZZ~MbP&JHkf{Qkd;4VGzwZ#vy_ZlG6p zFZ}hB+uq3Q^<7HMu#zcMFTUMyL$8*3z%)G23#_rqTZGP=D($R~_jberyO>SWwbg3$ zrcDC`B7Msljb6_iA?V$9s-NC=h(P2mh2f47h@X{RRFKnNORQ>l)2(GDCW2OAWUYnv zh<01Tk$rVL0m}SG6#subvbq0)@W?)%hv$}q1tM-~PWEVl7+P6dMmF94<9&S3aDm9% z%7bu-fz5b^h^6{4(XJgy5Mc&78cGlm4!U(?2_kHT zP6ol9``i|X64P*kM6=YHys%!~{I`!PYCJ*2t@LIdP!KI!pvZd#v>U`*oMOyF3N}(~ zA2*FDh`60fQEAXU>#~J|3Zi7IP}${bN}UE#jVg$^9Zbvb +--EXPECTF-- +*** Testing stripslashes() : with strings containing newline and tab characters *** + +-- Iteration 1 -- +string(1) " +" + +-- Iteration 2 -- +string(1) "n" + +-- Iteration 3 -- +string(12) "Hello +world" + +-- Iteration 4 -- +string(12) "Hello nworld" + +-- Iteration 5 -- +string(1) "n" + +-- Iteration 6 -- +string(1) "n" + +-- Iteration 7 -- +string(12) "Hello nworld" + +-- Iteration 8 -- +string(12) "Hello nworld" + +-- Iteration 9 -- +string(71) "This is line 1 +of 'heredoc' string +This is line 2 +of "heredoc" string" + +-- Iteration 10 -- +string(1) " " + +-- Iteration 11 -- +string(1) "t" + +-- Iteration 12 -- +string(12) "Hello world" + +-- Iteration 13 -- +string(12) "Hello tworld" + +-- Iteration 14 -- +string(1) "t" + +-- Iteration 15 -- +string(1) "t" + +-- Iteration 16 -- +string(12) "Hello tworld" + +-- Iteration 17 -- +string(12) "Hello tworld" + +-- Iteration 18 -- +string(71) "This is line 1 of 'heredoc' string +This is line 2 of "heredoc" string" +Done + +--UEXPECTF-- +*** Testing stripslashes() : with strings containing newline and tab characters *** + +-- Iteration 1 -- +unicode(1) " +" + +-- Iteration 2 -- +unicode(1) "n" + +-- Iteration 3 -- +unicode(12) "Hello +world" + +-- Iteration 4 -- +unicode(12) "Hello nworld" + +-- Iteration 5 -- +unicode(1) "n" + +-- Iteration 6 -- +unicode(1) "n" + +-- Iteration 7 -- +unicode(12) "Hello nworld" + +-- Iteration 8 -- +unicode(12) "Hello nworld" + +-- Iteration 9 -- +unicode(71) "This is line 1 +of 'heredoc' string +This is line 2 +of "heredoc" string" + +-- Iteration 10 -- +unicode(1) " " + +-- Iteration 11 -- +unicode(1) "t" + +-- Iteration 12 -- +unicode(12) "Hello world" + +-- Iteration 13 -- +unicode(12) "Hello tworld" + +-- Iteration 14 -- +unicode(1) "t" + +-- Iteration 15 -- +unicode(1) "t" + +-- Iteration 16 -- +unicode(12) "Hello tworld" + +-- Iteration 17 -- +unicode(12) "Hello tworld" + +-- Iteration 18 -- +unicode(71) "This is line 1 of 'heredoc' string +This is line 2 of "heredoc" string" +Done \ No newline at end of file diff --git a/ext/standard/tests/strings/stripslashes_variation4.phpt b/ext/standard/tests/strings/stripslashes_variation4.phpt new file mode 100644 index 0000000000..8469f2b942 --- /dev/null +++ b/ext/standard/tests/strings/stripslashes_variation4.phpt @@ -0,0 +1,227 @@ +--TEST-- +Test stripslashes() function : usage variations - double dimensional arrays +--FILE-- + +--EXPECTF-- +*** Testing stripslashes() : with double dimensional arrays *** + +-- Iteration 1 -- +array(2) { + [0]=> + string(0) "" + [1]=> + array(0) { + } +} + +-- Iteration 2 -- +array(2) { + [0]=> + string(0) "" + [1]=> + array(1) { + [0]=> + string(0) "" + } +} + +-- Iteration 3 -- +array(3) { + [0]=> + string(4) "f'oo" + [1]=> + string(4) "b'ar" + [2]=> + array(2) { + [0]=> + string(4) "fo'o" + [1]=> + string(4) "b'ar" + } +} + +-- Iteration 4 -- +array(3) { + [0]=> + string(4) "f'oo" + [1]=> + string(4) "b'ar" + [2]=> + array(1) { + [0]=> + string(0) "" + } +} + +-- Iteration 5 -- +array(3) { + [0]=> + string(4) "f'oo" + [1]=> + string(4) "b'ar" + [2]=> + array(3) { + [0]=> + string(4) "fo'o" + [1]=> + string(4) "b'ar" + [2]=> + array(1) { + [0]=> + string(0) "" + } + } +} + +-- Iteration 6 -- +array(3) { + [0]=> + string(4) "f'oo" + [1]=> + string(4) "b'ar" + [2]=> + array(3) { + [0]=> + string(4) "fo'o" + [1]=> + string(4) "b'ar" + [2]=> + array(2) { + [0]=> + string(4) "fo'o" + [1]=> + string(4) "b'ar" + } + } +} +Done + +--UEXPECTF-- +*** Testing stripslashes() : with double dimensional arrays *** + +-- Iteration 1 -- +array(2) { + [0]=> + unicode(0) "" + [1]=> + array(0) { + } +} + +-- Iteration 2 -- +array(2) { + [0]=> + unicode(0) "" + [1]=> + array(1) { + [0]=> + unicode(0) "" + } +} + +-- Iteration 3 -- +array(3) { + [0]=> + unicode(4) "f'oo" + [1]=> + unicode(4) "b'ar" + [2]=> + array(2) { + [0]=> + unicode(4) "fo'o" + [1]=> + unicode(4) "b'ar" + } +} + +-- Iteration 4 -- +array(3) { + [0]=> + unicode(4) "f'oo" + [1]=> + unicode(4) "b'ar" + [2]=> + array(1) { + [0]=> + unicode(0) "" + } +} + +-- Iteration 5 -- +array(3) { + [0]=> + unicode(4) "f'oo" + [1]=> + unicode(4) "b'ar" + [2]=> + array(3) { + [0]=> + unicode(4) "fo'o" + [1]=> + unicode(4) "b'ar" + [2]=> + array(1) { + [0]=> + unicode(0) "" + } + } +} + +-- Iteration 6 -- +array(3) { + [0]=> + unicode(4) "f'oo" + [1]=> + unicode(4) "b'ar" + [2]=> + array(3) { + [0]=> + unicode(4) "fo'o" + [1]=> + unicode(4) "b'ar" + [2]=> + array(2) { + [0]=> + unicode(4) "fo'o" + [1]=> + unicode(4) "b'ar" + } + } +} +Done \ No newline at end of file -- 2.40.0