kraghuba                Fri Sep 14 19:14:52 2007 UTC

  Modified files:              
    /php-src/ext/standard/tests/strings chop_variation2.phpt 
                                        chop_variation3.phpt 
                                        chop_error.phpt 
                                        chop_variation4.phpt 
                                        chop_variation5.phpt 
                                        chop_basic.phpt 
                                        chop_variation1.phpt 
  Log:
  New testcases for chop()
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/chop_variation2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/chop_variation2.phpt
diff -u /dev/null php-src/ext/standard/tests/strings/chop_variation2.phpt:1.2
--- /dev/null   Fri Sep 14 19:14:52 2007
+++ php-src/ext/standard/tests/strings/chop_variation2.phpt     Fri Sep 14 
19:14:52 2007
@@ -0,0 +1,248 @@
+--TEST--
+Test chop() function : usage variations  - unexpected values for charlist 
argument
+--FILE--
+<?php
+/* Prototype  : string chop ( string $str [, string $charlist] )
+ * Description: Strip whitespace (or other characters) from the end of a string
+ * Source code: ext/standard/string.c
+*/
+
+/*
+ * Testing chop() : with different unexpected values of charlist argument 
passed tot he function
+*/
+
+echo "*** Testing chop() : with unexpected values of charlist argument passed 
to the function ***\n";
+// initialize all required variables
+$str = 'hello world12345 ';
+
+// get an unset variable
+$unset_var = 'string_val';
+unset($unset_var);
+
+// declaring class
+class sample  {
+  public function __toString()  {
+  return "@# $%12345";
+  }
+}
+
+// defining a resource
+$file_handle = fopen(__FILE__, 'r');
+
+// array with different values
+$values =  array (
+
+  // integer values
+  0,
+  1,
+  12345,
+  -2345,
+
+  // float values
+  10.5,
+  -10.5,
+  10.5e10,
+  10.6E-10,
+  .5,
+
+  // array values
+  array(),
+  array(0),
+  array(1),
+  array(1, 2),
+  array('color' => '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
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/chop_variation3.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/chop_variation3.phpt
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/chop_error.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/chop_error.phpt
diff -u /dev/null php-src/ext/standard/tests/strings/chop_error.phpt:1.2
--- /dev/null   Fri Sep 14 19:14:52 2007
+++ php-src/ext/standard/tests/strings/chop_error.phpt  Fri Sep 14 19:14:52 2007
@@ -0,0 +1,59 @@
+--TEST--
+Test chop() function : error conditions 
+--FILE--
+<?php
+/* Prototype  : string chop ( string $str [, string $charlist] )
+ * Description: Strip whitespace (or other characters) from the end of a string
+ * Source code: ext/standard/string.c
+*/
+
+/*
+ * Testing chop() : error conditions
+*/
+
+echo "*** Testing chop() : error conditions ***\n";
+
+// Zero argument
+echo "\n-- Testing chop() function with Zero arguments --\n";
+var_dump( chop() );
+
+// More than expected number of arguments
+echo "\n-- Testing chop() function with more than expected no. of arguments 
--\n";
+$str = 'string_val ';
+$charlist = 'string_val';
+$extra_arg = 10;
+
+var_dump( chop($str, $charlist, $extra_arg) );
+var_dump( $str );
+
+echo "Done\n";
+?>
+--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
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/chop_variation4.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/chop_variation4.phpt
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/chop_variation5.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/chop_variation5.phpt
diff -u /dev/null php-src/ext/standard/tests/strings/chop_variation5.phpt:1.2
--- /dev/null   Fri Sep 14 19:14:52 2007
+++ php-src/ext/standard/tests/strings/chop_variation5.phpt     Fri Sep 14 
19:14:52 2007
@@ -0,0 +1,52 @@
+--TEST--
+Test chop() function : usage variations - miscellaneous arguments
+--FILE--
+<?php
+/* Prototype  : string chop ( string $str [, string $charlist] )
+ * Description: Strip whitespace (or other characters) from the end of a string
+ * Source code: ext/standard/string.c
+*/
+
+/*
+ * Testing chop() : with miscellaneous arguments
+*/
+
+echo "*** Testing chop() : with miscellaneous arguments ***\n";
+
+ var_dump ( chop("chop test   \t\0 ") );                       /* without 
second Argument */
+ var_dump ( chop("chop test   " , "") );                       /* no 
characters in second Argument */
+ var_dump ( chop("chop test        ", NULL) );                 /* with NULL as 
second Argument */
+ var_dump ( chop("chop test        ", true) );                 /* with boolean 
value as second Argument */
+ var_dump ( chop("chop test        ", " ") );                  /* with single 
space as second Argument */
+ var_dump ( chop("chop test \t\n\r\0\x0B", "\t\n\r\0\x0B") );  /* with 
multiple escape sequences as second Argument */
+ var_dump ( chop("chop testABCXYZ", "A..Z") );                 /* with 
characters range as second Argument */
+ var_dump ( chop("chop test0123456789", "0..9") );             /* with numbers 
range as second Argument */
+ var_dump ( chop("chop test$#@", "[EMAIL PROTECTED]") );                     
/* with some special characters as second Argument */
+
+echo "Done\n";
+?>
+--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
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/chop_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/chop_basic.phpt
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/chop_variation1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/chop_variation1.phpt
diff -u /dev/null php-src/ext/standard/tests/strings/chop_variation1.phpt:1.2
--- /dev/null   Fri Sep 14 19:14:52 2007
+++ php-src/ext/standard/tests/strings/chop_variation1.phpt     Fri Sep 14 
19:14:52 2007
@@ -0,0 +1,326 @@
+--TEST--
+Test chop() function : usage variations  - unexpected values for str argument 
+--FILE--
+<?php
+/* Prototype  : string chop ( string $str [, string $charlist] )
+ * Description: Strip whitespace (or other characters) from the end of a string
+ * Source code: ext/standard/string.c
+*/
+
+/*
+ * Testing chop() : with different unexpected values for str argument passed 
to the function 
+*/
+
+echo "*** Testing chop() : with unexpected values for str argument passed to 
the function ***\n";
+// initialize all required variables
+
+$charlist = " @#$%1234567890";
+// get an unset variable
+$unset_var = 'string_val';
+unset($unset_var);
+
+// declaring class
+class sample  {
+  public function __toString() {
+    return " @#$%Object @#$%";
+  }
+}
+$sample_obj = new sample;
+
+// creating a file resource
+$file_handle = fopen(__FILE__, 'r');
+
+// array with different values
+$values =  array (
+
+  // integer values
+  0,
+  1,
+  12345,
+  -2345,
+
+  // float values
+  10.5,
+  -10.5,
+  10.5e10,
+  10.6E-10,
+  .5,
+
+  // array values
+  array(),
+  array(0),
+  array(1),
+  array(1, 2),
+  array('color' => '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

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to