From 78fdb307186931dae1f8156841d9d8c214c78713 Mon Sep 17 00:00:00 2001 From: Raghubansh Kumar Date: Fri, 14 Sep 2007 19:14:52 +0000 Subject: [PATCH] New testcases for chop() --- ext/standard/tests/strings/chop_basic.phpt | Bin 0 -> 1015 bytes ext/standard/tests/strings/chop_error.phpt | 59 ++++ .../tests/strings/chop_variation1.phpt | 326 ++++++++++++++++++ .../tests/strings/chop_variation2.phpt | 248 +++++++++++++ .../tests/strings/chop_variation3.phpt | Bin 0 -> 2649 bytes .../tests/strings/chop_variation4.phpt | Bin 0 -> 2816 bytes .../tests/strings/chop_variation5.phpt | 52 +++ 7 files changed, 685 insertions(+) create mode 100644 ext/standard/tests/strings/chop_basic.phpt create mode 100644 ext/standard/tests/strings/chop_error.phpt create mode 100644 ext/standard/tests/strings/chop_variation1.phpt create mode 100644 ext/standard/tests/strings/chop_variation2.phpt create mode 100644 ext/standard/tests/strings/chop_variation3.phpt create mode 100644 ext/standard/tests/strings/chop_variation4.phpt create mode 100644 ext/standard/tests/strings/chop_variation5.phpt diff --git a/ext/standard/tests/strings/chop_basic.phpt b/ext/standard/tests/strings/chop_basic.phpt new file mode 100644 index 0000000000000000000000000000000000000000..d08059f6013704917b83b4a35a5bce6e42e45f60 GIT binary patch literal 1015 zcmbV~QE$^Q6oq-k{E0&~sY%t)?FFI2n8emelX#faA|VlkyySMVZh+mNlOmIP=^2(*Db1YfFVcV!k z!O4n{Sq~c<@+>O7tRnfqnBH!{ryx_qt|5PmC%vU@JvUaira9;?&O(%?mcHhXME9x^ zlbK-jbUD3!Pn_k0kKWxT_6MWMUaUSfRqUSj%lp^ZEjg4@g0wY1jKjTxzwQ(Qe0PGaw zm*Z|w7sQ1%v@`hZJ+I{A^Y!9?{E_vezVP~S;kgjcUOZIa3{*KP ak=O)Nefm$V)~K|*16+M&7_2WJB>M$z&_Lh- literal 0 HcmV?d00001 diff --git a/ext/standard/tests/strings/chop_error.phpt b/ext/standard/tests/strings/chop_error.phpt new file mode 100644 index 0000000000..ae6fad5bbe --- /dev/null +++ b/ext/standard/tests/strings/chop_error.phpt @@ -0,0 +1,59 @@ +--TEST-- +Test chop() function : error conditions +--FILE-- + +--EXPECTF-- +*** Testing chop() : error conditions *** + +-- Testing chop() function with Zero arguments -- + +Warning: chop() expects at least 1 parameter, 0 given in %s on line %d +NULL + +-- Testing chop() function with more than expected no. of arguments -- + +Warning: chop() expects at most 2 parameters, 3 given in %s on line %d +NULL +string(11) "string_val " +Done + +--UEXPECTF-- +*** Testing chop() : error conditions *** + +-- Testing chop() function with Zero arguments -- + +Warning: chop() expects at least 1 parameter, 0 given in %s on line %d +NULL + +-- Testing chop() function with more than expected no. of arguments -- + +Warning: chop() expects at most 2 parameters, 3 given in %s on line %d +NULL +unicode(11) "string_val " +Done diff --git a/ext/standard/tests/strings/chop_variation1.phpt b/ext/standard/tests/strings/chop_variation1.phpt new file mode 100644 index 0000000000..1c46f3b1ff --- /dev/null +++ b/ext/standard/tests/strings/chop_variation1.phpt @@ -0,0 +1,326 @@ +--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 passed to the function *** + +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 -- + +Warning: chop() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL + +Warning: chop() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: chop() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL + +Warning: chop() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: chop() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL + +Warning: chop() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 13 -- + +Warning: chop() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL + +Warning: chop() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 14 -- + +Warning: chop() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL + +Warning: chop() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- 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 -- + +Warning: chop() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d +NULL + +Warning: chop() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d +NULL +Done + +--UEXPECTF-- +*** Testing chop() : with unexpected values for str argument passed to the function *** + +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 -- +unicode(1) "0" +unicode(0) "" +-- Iteration 2 -- +unicode(1) "1" +unicode(0) "" +-- Iteration 3 -- +unicode(5) "12345" +unicode(0) "" +-- Iteration 4 -- +unicode(5) "-2345" +unicode(1) "-" +-- Iteration 5 -- +unicode(4) "10.5" +unicode(3) "10." +-- Iteration 6 -- +unicode(5) "-10.5" +unicode(4) "-10." +-- Iteration 7 -- +unicode(12) "105000000000" +unicode(0) "" +-- Iteration 8 -- +unicode(7) "1.06E-9" +unicode(6) "1.06E-" +-- Iteration 9 -- +unicode(3) "0.5" +unicode(2) "0." +-- Iteration 10 -- + +Warning: chop() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL + +Warning: chop() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: chop() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL + +Warning: chop() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: chop() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL + +Warning: chop() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 13 -- + +Warning: chop() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL + +Warning: chop() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 14 -- + +Warning: chop() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL + +Warning: chop() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 15 -- +unicode(1) "1" +unicode(0) "" +-- Iteration 16 -- +unicode(0) "" +unicode(0) "" +-- Iteration 17 -- +unicode(1) "1" +unicode(0) "" +-- Iteration 18 -- +unicode(0) "" +unicode(0) "" +-- Iteration 19 -- +unicode(0) "" +unicode(0) "" +-- Iteration 20 -- +unicode(0) "" +unicode(0) "" +-- Iteration 21 -- +unicode(0) "" +unicode(0) "" +-- Iteration 22 -- +unicode(0) "" +unicode(0) "" +-- Iteration 23 -- +unicode(0) "" +unicode(0) "" +-- Iteration 24 -- +unicode(0) "" +unicode(0) "" +-- Iteration 25 -- +unicode(16) " @#$%Object @#$%" +unicode(11) " @#$%Object" +-- Iteration 26 -- + +Warning: chop() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d +NULL + +Warning: chop() expects parameter 1 to be string (Unicode or binary), resource given in %s on line %d +NULL +Done diff --git a/ext/standard/tests/strings/chop_variation2.phpt b/ext/standard/tests/strings/chop_variation2.phpt new file mode 100644 index 0000000000..b202ebf13d --- /dev/null +++ b/ext/standard/tests/strings/chop_variation2.phpt @@ -0,0 +1,248 @@ +--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 unexpected values of charlist argument passed to the function *** + +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 -- + +Warning: chop() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: chop() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: chop() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 13 -- + +Warning: chop() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 14 -- + +Warning: chop() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- 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 -- + +Warning: chop() expects parameter 2 to be string (Unicode or binary), resource given in %s on line %d +NULL +-- Iteration 25 -- +string(17) "hello world12345 " +-- Iteration 26 -- +string(17) "hello world12345 " +Done + +--UEXPECTF-- +*** Testing chop() : with unexpected values of charlist argument passed to the function *** + +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 -- +unicode(17) "hello world12345 " +-- Iteration 2 -- +unicode(17) "hello world12345 " +-- Iteration 3 -- +unicode(17) "hello world12345 " +-- Iteration 4 -- +unicode(17) "hello world12345 " +-- Iteration 5 -- +unicode(17) "hello world12345 " +-- Iteration 6 -- +unicode(17) "hello world12345 " +-- Iteration 7 -- +unicode(17) "hello world12345 " +-- Iteration 8 -- +unicode(17) "hello world12345 " +-- Iteration 9 -- +unicode(17) "hello world12345 " +-- Iteration 10 -- + +Warning: chop() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: chop() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: chop() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 13 -- + +Warning: chop() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 14 -- + +Warning: chop() expects parameter 2 to be string (Unicode or binary), array given in %s on line %d +NULL +-- Iteration 15 -- +unicode(17) "hello world12345 " +-- Iteration 16 -- +unicode(17) "hello world12345 " +-- Iteration 17 -- +unicode(17) "hello world12345 " +-- Iteration 18 -- +unicode(17) "hello world12345 " +-- Iteration 19 -- +unicode(11) "hello world" +-- Iteration 20 -- +unicode(17) "hello world12345 " +-- Iteration 21 -- +unicode(17) "hello world12345 " +-- Iteration 22 -- +unicode(17) "hello world12345 " +-- Iteration 23 -- +unicode(17) "hello world12345 " +-- Iteration 24 -- + +Warning: chop() expects parameter 2 to be string (Unicode or binary), resource given in %s on line %d +NULL +-- Iteration 25 -- +unicode(17) "hello world12345 " +-- Iteration 26 -- +unicode(17) "hello world12345 " +Done diff --git a/ext/standard/tests/strings/chop_variation3.phpt b/ext/standard/tests/strings/chop_variation3.phpt new file mode 100644 index 0000000000000000000000000000000000000000..1f2abc6cf0aa3113d7fd6875186a7f359cd6b0d4 GIT binary patch literal 2649 zcmcgt?`zvI5bf9KuQ*ITIBC56E+fg-4{HjA!3xb_Fpr?xaxHKqBP+|w*#Ewh6+4OR zX6aZL2(jdM@7x@1y_)Zn4W+wv=HeAOL zGsQv~K&BNJ55)7XZ$8eEW_FpzDe1Q1R!J@OW6A(oEGnl5w^%iC7ru7NWe`)9@JxS$ z7J)Wgu`EzLHL4T1LzxsdG1n|hX~4jh3Z%v?kd!JKXr?kuT*(#SE-(>-jDQyTA>W-` zD+~-|$R@yk=x(N|2&oG3!PM|3Anh)})Q!052JRINnbZ}X<#>iY1E<|SF$NIn3ulT# zT?kpkg^>w)6k$V!uJkn{O}0w)!F#uo&iM_Y39Sj)v$_bd!qxD@Losgn6Un?^5ZA-?_f zdsQY|wuz=n(MOlS)6e0Vc4{GY2YUi?cd`g>G*G+NB4z9AQ3qY^kQ$!DURgwIN}3!C z?@vi26{A7ymf}TQXa;8N(eo{UpIEsaA76N$2RAsx`7Hy;gB$srfVq5@;d+(2b{flg z)O+q_2OM+EW9j#N;cKS_Ik?Hs&!^-UAy)ND3YKeJzQ+q}{^fT5VR4Oj*o%glVCa78 zeUmw{HM+ePIL_gs0w25#KHP`Dy+HccncFhySJkNWVzgh}V2H)#!`8?rkJ!P>pUdoy zgDUjnefnX)ps&3q8pb|5nej2OQ?O>&rYGN_9@CC#;8W*^FQ_I zT5$7cxHakFs?s{^(nHAMsuEy*T0maaME^ykQl52cp?uthr=cnW)~iM6X=W|ZgTHZW N8GPKXCG3xW{SC8|MBe}a literal 0 HcmV?d00001 diff --git a/ext/standard/tests/strings/chop_variation4.phpt b/ext/standard/tests/strings/chop_variation4.phpt new file mode 100644 index 0000000000000000000000000000000000000000..656e598af309f126766a43e6309e4a8fb5be5e1c GIT binary patch literal 2816 zcmcIlQES^U5YB7-D-KhLoyLvRuI-wx>%*EtVGo67FqlX2Y^64&l9A8LXn401b&7*4JDF;2f5%W zeahh_6$y~%A0&=R476A-bIbE??>^6v?!$GKWY%~H_nZkPUNZv7rc%o?;ONrI2ysBKztVC}aqNAhuO7q*5BP~$2@)jT}B zwEpN7ykV4-4P1Xjch0`v&pyp>(V%;*riBFNgcHECrB=_GOx$X}dTPD)xTx_ToBU@; z-&1?4nRh@nwiA=>R5xpDvL+(w%Yr?-KKVP7YjPr6Q@!~z=NhnlWtxgGFsE1Cp`>vq6~el?wy8+E#JVEbvCA=@)H*|vI86Lj624z|>k LO<(SFBc1sdcMvfY literal 0 HcmV?d00001 diff --git a/ext/standard/tests/strings/chop_variation5.phpt b/ext/standard/tests/strings/chop_variation5.phpt new file mode 100644 index 0000000000..c8c363f00c --- /dev/null +++ b/ext/standard/tests/strings/chop_variation5.phpt @@ -0,0 +1,52 @@ +--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 + +--UEXPECTF-- +*** Testing chop() : with miscellaneous arguments *** +unicode(9) "chop test" +unicode(12) "chop test " +unicode(17) "chop test " +unicode(17) "chop test " +unicode(9) "chop test" +unicode(10) "chop test " +unicode(9) "chop test" +unicode(9) "chop test" +unicode(9) "chop test" +Done -- 2.40.0