From aafdc266bf15822143e1385d42c644f7cfc60a1e Mon Sep 17 00:00:00 2001 From: Raghubansh Kumar Date: Fri, 14 Sep 2007 18:24:47 +0000 Subject: [PATCH] New testscases for chop() function --- ext/standard/tests/file/chop_basic.phpt | Bin 0 -> 861 bytes ext/standard/tests/file/chop_error.phpt | 44 ++++ ext/standard/tests/file/chop_variation1.phpt | 210 +++++++++++++++++++ ext/standard/tests/file/chop_variation2.phpt | 173 +++++++++++++++ ext/standard/tests/file/chop_variation3.phpt | Bin 0 -> 1974 bytes ext/standard/tests/file/chop_variation4.phpt | Bin 0 -> 1836 bytes ext/standard/tests/file/chop_variation5.phpt | 39 ++++ 7 files changed, 466 insertions(+) create mode 100644 ext/standard/tests/file/chop_basic.phpt create mode 100644 ext/standard/tests/file/chop_error.phpt create mode 100644 ext/standard/tests/file/chop_variation1.phpt create mode 100644 ext/standard/tests/file/chop_variation2.phpt create mode 100644 ext/standard/tests/file/chop_variation3.phpt create mode 100644 ext/standard/tests/file/chop_variation4.phpt create mode 100644 ext/standard/tests/file/chop_variation5.phpt diff --git a/ext/standard/tests/file/chop_basic.phpt b/ext/standard/tests/file/chop_basic.phpt new file mode 100644 index 0000000000000000000000000000000000000000..2b8d3daab73ecf1043d0b08e49f6a5f9357e3728 GIT binary patch literal 861 zcmb7CU2hXH5abo}Cx)m}?xGxNUl0nEO0=m|iHAzb0}_Xjd$;LXa%^Mok(OW2UXENT zN-ObZ@5k)y%ofFJv0N2}T2W$DjSpFlb?YiN-eHa#olG?Zv^9JWRTP(3pBK{f;Vd*k z%_g{xo;}|Og7hSg#@+6~knMj*62;f)@U0phtx5b1xxxe&l&WY#H+7Ds00e9s!<2%q z2$_%Y+)xxy9d*SNlhBNQ1BrrM4Znu|1K!~+eH*2*@-@vtcRWk1U9Dp+kB;4&N=;@; zsCUKP?t8{resJksHHkhLO(y?#JfV{mmTvT3rp$2V3>%T}7eQN#NIzN=sm4zojlQvz z)J~vNj2g1mW9y@>ODdy0Y2vp}6i199gWAyN`b(EPW3#)X#m79Jow#rXBO zAJiLh;T`P+KKm#qx%hIuIA2}LRsN4bsy~P9?xBVwLK+ Fso!&56ZilC literal 0 HcmV?d00001 diff --git a/ext/standard/tests/file/chop_error.phpt b/ext/standard/tests/file/chop_error.phpt new file mode 100644 index 0000000000..4269993a2a --- /dev/null +++ b/ext/standard/tests/file/chop_error.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test chop() function : error conditions +--FILE-- + +--EXPECTF-- +*** Testing chop() : error conditions *** + +-- Testing chop() function with Zero arguments -- + +Warning: Wrong parameter count for chop() in %s on line %d +NULL + +-- Testing chop() function with more than expected no. of arguments -- + +Warning: Wrong parameter count for chop() in %s on line %d +NULL +string(11) "string_val " +Done diff --git a/ext/standard/tests/file/chop_variation1.phpt b/ext/standard/tests/file/chop_variation1.phpt new file mode 100644 index 0000000000..cbacd435a5 --- /dev/null +++ b/ext/standard/tests/file/chop_variation1.phpt @@ -0,0 +1,210 @@ +--TEST-- +Test chop() function : usage variations - unexpected values for str argument +--FILE-- + 'red', 'item' => 'pen'), + + // boolean values + true, + false, + TRUE, + FALSE, + + // empty string + "", + '', + + // null vlaues + NULL, + null, + + // undefined variable + $undefined_var, + + // unset variable + $unset_var, + + // object + $sample_obj, + + // resource + $file_handle +); + + +// loop through each element of the array and check the working of chop() +// when $str arugment is supplied with different values + +echo "\n--- Testing chop() 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( chop($str) ); + var_dump( chop($str, $charlist) ); + + $counter ++; +} + +// closing the resource +fclose( $file_handle); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing chop() : with unexpected values for str argument *** + +Notice: Undefined variable: undefined_var in %s on line %d + +Notice: Undefined variable: unset_var in %s on line %d + +--- Testing chop() by supplying different values for 'str' argument --- +-- Iteration 1 -- +string(1) "0" +string(0) "" +-- Iteration 2 -- +string(1) "1" +string(0) "" +-- Iteration 3 -- +string(5) "12345" +string(0) "" +-- Iteration 4 -- +string(5) "-2345" +string(1) "-" +-- Iteration 5 -- +string(4) "10.5" +string(3) "10." +-- Iteration 6 -- +string(5) "-10.5" +string(4) "-10." +-- Iteration 7 -- +string(12) "105000000000" +string(0) "" +-- Iteration 8 -- +string(7) "1.06E-9" +string(6) "1.06E-" +-- Iteration 9 -- +string(3) "0.5" +string(2) "0." +-- Iteration 10 -- + +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 +string(5) "Array" + +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" + +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" + +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" + +Notice: Array to string conversion in %s on line %d +string(5) "Array" +-- Iteration 15 -- +string(1) "1" +string(0) "" +-- Iteration 16 -- +string(0) "" +string(0) "" +-- Iteration 17 -- +string(1) "1" +string(0) "" +-- Iteration 18 -- +string(0) "" +string(0) "" +-- Iteration 19 -- +string(0) "" +string(0) "" +-- Iteration 20 -- +string(0) "" +string(0) "" +-- Iteration 21 -- +string(0) "" +string(0) "" +-- Iteration 22 -- +string(0) "" +string(0) "" +-- Iteration 23 -- +string(0) "" +string(0) "" +-- Iteration 24 -- +string(0) "" +string(0) "" +-- Iteration 25 -- +string(16) " @#$%Object @#$%" +string(11) " @#$%Object" +-- Iteration 26 -- +string(14) "Resource id #%d" +string(11) "Resource id" +Done diff --git a/ext/standard/tests/file/chop_variation2.phpt b/ext/standard/tests/file/chop_variation2.phpt new file mode 100644 index 0000000000..ca520b0e01 --- /dev/null +++ b/ext/standard/tests/file/chop_variation2.phpt @@ -0,0 +1,173 @@ +--TEST-- +Test chop() function : usage variations - unexpected values for charlist argument +--FILE-- + 'red', 'item' => 'pen'), + + // boolean values + true, + false, + TRUE, + FALSE, + + // objects + new sample(), + + // empty string + "", + '', + + // null vlaues + NULL, + null, + + // resource + $file_handle, + + // undefined variable + $undefined_var, + + // unset variable + $unset_var + +); + + +// loop through each element of the array and check the working of chop() +// when $charlist arugment is supplied with different values + +echo "\n--- Testing chop() by supplying different values for 'charlist' argument ---\n"; +$counter = 1; +for($index = 0; $index < count($values); $index ++) { + echo "-- Iteration $counter --\n"; + $charlist = $values [$index]; + + var_dump( chop($str, $charlist) ); + + $counter ++; +} + +// closing the resource +fclose($file_handle); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing chop() : with different unexpected values for charlist argument *** + +Notice: Undefined variable: undefined_var in %s on line %d + +Notice: Undefined variable: unset_var in %s on line %d + +--- Testing chop() by supplying different values for 'charlist' argument --- +-- Iteration 1 -- +string(17) "hello world12345 " +-- Iteration 2 -- +string(17) "hello world12345 " +-- Iteration 3 -- +string(17) "hello world12345 " +-- Iteration 4 -- +string(17) "hello world12345 " +-- Iteration 5 -- +string(17) "hello world12345 " +-- Iteration 6 -- +string(17) "hello world12345 " +-- Iteration 7 -- +string(17) "hello world12345 " +-- Iteration 8 -- +string(17) "hello world12345 " +-- Iteration 9 -- +string(17) "hello world12345 " +-- Iteration 10 -- + +Notice: Array to string conversion in %s on line %d +string(17) "hello world12345 " +-- Iteration 11 -- + +Notice: Array to string conversion in %s on line %d +string(17) "hello world12345 " +-- Iteration 12 -- + +Notice: Array to string conversion in %s on line %d +string(17) "hello world12345 " +-- Iteration 13 -- + +Notice: Array to string conversion in %s on line %d +string(17) "hello world12345 " +-- Iteration 14 -- + +Notice: Array to string conversion in %s on line %d +string(17) "hello world12345 " +-- Iteration 15 -- +string(17) "hello world12345 " +-- Iteration 16 -- +string(17) "hello world12345 " +-- Iteration 17 -- +string(17) "hello world12345 " +-- Iteration 18 -- +string(17) "hello world12345 " +-- Iteration 19 -- +string(11) "hello world" +-- Iteration 20 -- +string(17) "hello world12345 " +-- Iteration 21 -- +string(17) "hello world12345 " +-- Iteration 22 -- +string(17) "hello world12345 " +-- Iteration 23 -- +string(17) "hello world12345 " +-- Iteration 24 -- +string(15) "hello world1234" +-- Iteration 25 -- +string(17) "hello world12345 " +-- Iteration 26 -- +string(17) "hello world12345 " +Done diff --git a/ext/standard/tests/file/chop_variation3.phpt b/ext/standard/tests/file/chop_variation3.phpt new file mode 100644 index 0000000000000000000000000000000000000000..9509fb80a4d49c593627a0652dd9e4b2dc7f7d5b GIT binary patch literal 1974 zcmcIkU2EGg6zyyDD=sDvP8u)YWhCkPu%=KLtk66R=3!J@t__Z4BzajG`|rE5VkdFk z(mpg0tdDcgx%Ws{p0`=wZ#<7|n9>j?B6oWb7d+Id;IM!~(MJZqsZ6O^QQ*NY)d?g_ zvPguWv`qOU@w}VcZ)>DkUFAtmhJCn`LJR$rGe8!LD(S(kW?fu`pM!cDCRApr(!Zcb zpbytfg)+^J>H_XjCWl>;YNm1;GH`_ip)m_2rILo4Nrj0^u?1WO#v>3h&?-OVyBCGT zz)(bN0ql<+DouGrWrPD$!>5q+hXhkM;>HbJs|;DR6|G7 zEKa$RiPAVmL%DAFsz{e@bNv)lc3;A3wOW7Q5d0%YcfTH(GYL4`WhrM+gM3a}fd|VD z*f^DV0m^tZuF|vC5XC})j=r#~lT<$2+(*8WXMpwxnm(vQ5(&#P;p?4{S>$s&61&~`S0{h2d$8{gM9 zs6jtJrk{>0`qn3-W3JFaX8s!3X zgk7oj%f@m-)yAidG`;W=ZO1on*RYC_fMy`!Ukk5C(OGxjaUHZ}H0xYrLiN4) zb>GL;t9@*z`O7x6{@@OvUA19R%iF6a(#P60>ENJOq&wvMe@i~o$=&ShX7(!^QLd^s S$2?aT7x+!y|5$4M0sa96^&PnY literal 0 HcmV?d00001 diff --git a/ext/standard/tests/file/chop_variation5.phpt b/ext/standard/tests/file/chop_variation5.phpt new file mode 100644 index 0000000000..8f283e3c3f --- /dev/null +++ b/ext/standard/tests/file/chop_variation5.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test chop() function : usage variations - miscellaneous arguments +--FILE-- + +--EXPECTF-- +*** Testing chop() : with miscellaneous arguments *** +string(9) "chop test" +string(12) "chop test " +string(17) "chop test " +string(17) "chop test " +string(9) "chop test" +string(10) "chop test " +string(9) "chop test" +string(9) "chop test" +string(9) "chop test" +Done -- 2.50.1