kraghuba                Wed Sep 26 14:42:15 2007 UTC

  Modified files:              
    /php-src/ext/standard/tests/strings strrev_variation1.phpt 
                                        strrev_basic.phpt 
                                        strrev_variation2.phpt 
                                        strrev_variation3.phpt 
                                        strrev_variation4.phpt 
                                        strrev_error.phpt 
  Log:
  new testcases for strrev() function
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strrev_variation1.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/strrev_variation1.phpt
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strrev_basic.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/strrev_basic.phpt
diff -u /dev/null php-src/ext/standard/tests/strings/strrev_basic.phpt:1.2
--- /dev/null   Wed Sep 26 14:42:15 2007
+++ php-src/ext/standard/tests/strings/strrev_basic.phpt        Wed Sep 26 
14:42:15 2007
@@ -0,0 +1,60 @@
+--TEST--
+Test strrev() function : basic functionality 
+--FILE--
+<?php
+/* Prototype  : string strrev(string $str);
+ * Description: Reverse a string 
+ * Source code: ext/standard/string.c
+*/
+
+echo "*** Testing strrev() : basic functionality ***\n";
+$heredoc = <<<EOD
+Hello, world
+EOD;
+
+//regular string
+var_dump( strrev("Hello, World") );
+var_dump( strrev('Hello, World') );
+
+//single character
+var_dump( strrev("H") );
+var_dump( strrev('H') );
+
+//string containing simalr chars
+var_dump( strrev("HHHHHH") );
+var_dump( strrev("HhhhhH") );
+
+//string containing escape char
+var_dump( strrev("Hello, World\n") );
+var_dump( strrev('Hello, World\n') );
+
+//heredoc string
+var_dump( strrev($heredoc) );
+echo "*** Done ***";
+?>
+--EXPECTF--
+*** Testing strrev() : basic functionality ***
+string(12) "dlroW ,olleH"
+string(12) "dlroW ,olleH"
+string(1) "H"
+string(1) "H"
+string(6) "HHHHHH"
+string(6) "HhhhhH"
+string(13) "
+dlroW ,olleH"
+string(14) "n\dlroW ,olleH"
+string(12) "dlrow ,olleH"
+*** Done ***
+--UEXPECTF--
+*** Testing strrev() : basic functionality ***
+unicode(12) "dlroW ,olleH"
+unicode(12) "dlroW ,olleH"
+unicode(1) "H"
+unicode(1) "H"
+unicode(6) "HHHHHH"
+unicode(6) "HhhhhH"
+unicode(13) "
+dlroW ,olleH"
+unicode(14) "n\dlroW ,olleH"
+unicode(12) "dlrow ,olleH"
+*** Done ***
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strrev_variation2.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/strrev_variation2.phpt
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strrev_variation3.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/strrev_variation3.phpt
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strrev_variation4.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/strrev_variation4.phpt
diff -u /dev/null php-src/ext/standard/tests/strings/strrev_variation4.phpt:1.2
--- /dev/null   Wed Sep 26 14:42:15 2007
+++ php-src/ext/standard/tests/strings/strrev_variation4.phpt   Wed Sep 26 
14:42:15 2007
@@ -0,0 +1,275 @@
+--TEST--
+Test strrev() function : usage variations - unexpected inputs 
+--FILE--
+<?php
+/* Prototype  : string strrev(string $str);
+ * Description: Reverse a string 
+ * Source code: ext/standard/string.c
+*/
+
+/* Testing strrev() function with unexpected inputs for 'str' */
+
+echo "*** Testing strrev() : unexpected inputs for 'str' ***\n";
+//class declaration
+class sample {
+  public function __toString(){
+    return "object";
+  }
+}
+
+//get the resource 
+$resource = fopen(__FILE__, "r");
+
+//get an unset variable
+$unset_var = 10;
+unset ($unset_var);
+
+//array of values to iterate over
+$values = array(
+
+  // int data
+  0,
+  1,
+  12345,
+  -2345,
+
+  // float data
+  10.5,
+   -10.5,
+  10.5e10,
+  10.6E-10,
+  .5,
+
+  // array data
+  array(),
+  array(0),
+  array(1),
+  array(1, 2),
+  array('color' => 'red', 'item' => 'pen'),
+
+  // null data
+  NULL,
+  null,
+
+  // boolean data
+  true,
+  false,
+  TRUE,
+  FALSE,
+
+  // empty data
+  "",
+  '',
+
+  // object data
+  new sample(),
+
+  // resource
+  $resource,
+
+  // undefined data
+  @$undefined_var,
+
+  // unset data
+  @$unset_var
+);
+
+// loop through each element of the array for str
+
+$count = 1;
+foreach($values as $value) {
+  echo "\n-- Iterator $count --\n";
+  var_dump( strrev($value) );
+  $count++;
+};
+
+fclose($resource);  //closing the file handle
+
+echo "*** Done ***";
+?>
+--EXPECTF--
+*** Testing strrev() : unexpected inputs for 'str' ***
+
+-- Iterator 1 --
+string(1) "0"
+
+-- Iterator 2 --
+string(1) "1"
+
+-- Iterator 3 --
+string(5) "54321"
+
+-- Iterator 4 --
+string(5) "5432-"
+
+-- Iterator 5 --
+string(4) "5.01"
+
+-- Iterator 6 --
+string(5) "5.01-"
+
+-- Iterator 7 --
+string(12) "000000000501"
+
+-- Iterator 8 --
+string(7) "9-E60.1"
+
+-- Iterator 9 --
+string(3) "5.0"
+
+-- Iterator 10 --
+
+Warning: strrev() expects parameter 1 to be string (Unicode or binary), array 
given in %s on line %d
+NULL
+
+-- Iterator 11 --
+
+Warning: strrev() expects parameter 1 to be string (Unicode or binary), array 
given in %s on line %d
+NULL
+
+-- Iterator 12 --
+
+Warning: strrev() expects parameter 1 to be string (Unicode or binary), array 
given in %s on line %d
+NULL
+
+-- Iterator 13 --
+
+Warning: strrev() expects parameter 1 to be string (Unicode or binary), array 
given in %s on line %d
+NULL
+
+-- Iterator 14 --
+
+Warning: strrev() expects parameter 1 to be string (Unicode or binary), array 
given in %s on line %d
+NULL
+
+-- Iterator 15 --
+string(0) ""
+
+-- Iterator 16 --
+string(0) ""
+
+-- Iterator 17 --
+string(1) "1"
+
+-- Iterator 18 --
+string(0) ""
+
+-- Iterator 19 --
+string(1) "1"
+
+-- Iterator 20 --
+string(0) ""
+
+-- Iterator 21 --
+string(0) ""
+
+-- Iterator 22 --
+string(0) ""
+
+-- Iterator 23 --
+string(6) "tcejbo"
+
+-- Iterator 24 --
+
+Warning: strrev() expects parameter 1 to be string (Unicode or binary), 
resource given in %s on line %d
+NULL
+
+-- Iterator 25 --
+string(0) ""
+
+-- Iterator 26 --
+string(0) ""
+*** Done ***
+--UEXPECTF--
+*** Testing strrev() : unexpected inputs for 'str' ***
+
+-- Iterator 1 --
+unicode(1) "0"
+
+-- Iterator 2 --
+unicode(1) "1"
+
+-- Iterator 3 --
+unicode(5) "54321"
+
+-- Iterator 4 --
+unicode(5) "5432-"
+
+-- Iterator 5 --
+unicode(4) "5.01"
+
+-- Iterator 6 --
+unicode(5) "5.01-"
+
+-- Iterator 7 --
+unicode(12) "000000000501"
+
+-- Iterator 8 --
+unicode(7) "9-E60.1"
+
+-- Iterator 9 --
+unicode(3) "5.0"
+
+-- Iterator 10 --
+
+Warning: strrev() expects parameter 1 to be string (Unicode or binary), array 
given in %s on line %d
+NULL
+
+-- Iterator 11 --
+
+Warning: strrev() expects parameter 1 to be string (Unicode or binary), array 
given in %s on line %d
+NULL
+
+-- Iterator 12 --
+
+Warning: strrev() expects parameter 1 to be string (Unicode or binary), array 
given in %s on line %d
+NULL
+
+-- Iterator 13 --
+
+Warning: strrev() expects parameter 1 to be string (Unicode or binary), array 
given in %s on line %d
+NULL
+
+-- Iterator 14 --
+
+Warning: strrev() expects parameter 1 to be string (Unicode or binary), array 
given in %s on line %d
+NULL
+
+-- Iterator 15 --
+unicode(0) ""
+
+-- Iterator 16 --
+unicode(0) ""
+
+-- Iterator 17 --
+unicode(1) "1"
+
+-- Iterator 18 --
+unicode(0) ""
+
+-- Iterator 19 --
+unicode(1) "1"
+
+-- Iterator 20 --
+unicode(0) ""
+
+-- Iterator 21 --
+unicode(0) ""
+
+-- Iterator 22 --
+unicode(0) ""
+
+-- Iterator 23 --
+unicode(6) "tcejbo"
+
+-- Iterator 24 --
+
+Warning: strrev() expects parameter 1 to be string (Unicode or binary), 
resource given in %s on line %d
+NULL
+
+-- Iterator 25 --
+unicode(0) ""
+
+-- Iterator 26 --
+unicode(0) ""
+*** Done ***
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strrev_error.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/strrev_error.phpt
diff -u /dev/null php-src/ext/standard/tests/strings/strrev_error.phpt:1.2
--- /dev/null   Wed Sep 26 14:42:15 2007
+++ php-src/ext/standard/tests/strings/strrev_error.phpt        Wed Sep 26 
14:42:15 2007
@@ -0,0 +1,37 @@
+--TEST--
+Test strrev() function : error conditions 
+--FILE--
+<?php
+/* Prototype  : string strrev(string $str);
+ * Description: Reverse a string 
+ * Source code: ext/standard/string.c
+*/
+
+echo "*** Testing strrev() : error conditions ***\n";
+echo "-- Testing strrev() function with Zero arguments --";
+var_dump( strrev() );
+
+echo "\n-- Testing strrev() function with more than expected no. of arguments 
--";
+var_dump( strrev("string", 'extra_arg') );
+echo "*** Done ***";
+?>
+--EXPECTF--
+*** Testing strrev() : error conditions ***
+-- Testing strrev() function with Zero arguments --
+Warning: strrev() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing strrev() function with more than expected no. of arguments --
+Warning: strrev() expects exactly 1 parameter, 2 given in %s on line %d
+NULL
+*** Done ***
+--UEXPECTF--
+*** Testing strrev() : error conditions ***
+-- Testing strrev() function with Zero arguments --
+Warning: strrev() expects exactly 1 parameter, 0 given in %s on line %d
+NULL
+
+-- Testing strrev() function with more than expected no. of arguments --
+Warning: strrev() expects exactly 1 parameter, 2 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