kraghuba                Sat May 12 10:15:03 2007 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/standard/tests/strings trim1.phpt addcslashes.phpt 
                                        substr.phpt md5_file.phpt 

  Modified files:              
    /php-src/ext/standard/tests/strings strstr.phpt strpos.phpt 
                                        chr_ord.phpt implode1.phpt 
                                        str_replace.phpt 
                                        substr_count.phpt 
                                        str_repeat.phpt 
  Log:
  New version of addcslashes.phpt, md5_file.phpt, str_replace.phpt, 
substr.phpt, chr_ord.phpt, strpos.phpt, strstr.phpt, trim1.phpt, implode1.phpt, 
str_repeat.phpt, substr_count.phpt
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strstr.phpt?r1=1.2&r2=1.2.6.1&diff_format=u
Index: php-src/ext/standard/tests/strings/strstr.phpt
diff -u php-src/ext/standard/tests/strings/strstr.phpt:1.2 
php-src/ext/standard/tests/strings/strstr.phpt:1.2.6.1
--- php-src/ext/standard/tests/strings/strstr.phpt:1.2  Wed May 19 08:45:23 2004
+++ php-src/ext/standard/tests/strings/strstr.phpt      Sat May 12 10:15:02 2007
@@ -1,21 +1,181 @@
 --TEST--
-strstr() function
+Test strstr() function
 --FILE--
 <?php
-       var_dump(strstr("test string", "test"));
-       var_dump(strstr("test string", "string"));
-       var_dump(strstr("test string", "strin"));
-       var_dump(strstr("test string", "t s"));
-       var_dump(strstr("test string", "g"));
-       var_dump(md5(strstr("te".chr(0)."st", chr(0))));
-       var_dump(strstr("tEst", "test"));
-       var_dump(strstr("teSt", "test"));
-       var_dump(@strstr("", ""));
-       var_dump(@strstr("a", ""));
-       var_dump(@strstr("", "a"));
-       var_dump(md5(@strstr("\\\\a\\", "\\a")));
+/* Prototype: string strstr ( string $haystack, string $needle );
+   Description: Find first occurrence of a string 
+   and reurns the rest of the string from that string 
+*/
+
+echo "*** Testing basic functionality of strstr() ***\n";
+var_dump( strstr("test string", "test") );
+var_dump( strstr("test string", "string") );
+var_dump( strstr("test string", "strin") );
+var_dump( strstr("test string", "t s") );
+var_dump( strstr("test string", "g") );
+var_dump( md5(strstr("te".chr(0)."st", chr(0))) );
+var_dump( strstr("tEst", "test") );
+var_dump( strstr("teSt", "test") );
+var_dump( @strstr("", "") );
+var_dump( @strstr("a", "") );
+var_dump( @strstr("", "a") );
+
+
+echo "\n*** Testing strstr() with various needles ***";
+$string = 
+"Hello world,012033 -3.3445     NULL TRUE FALSE\0 abcd\xxyz \x000 octal\n 
+abcd$:Hello world";
+
+/* needles in an array to get the string starts with needle, in $string */
+$needles = array(
+  "Hello world",       
+  "WORLD", 
+  "\0", 
+  "\x00", 
+  "\x000", 
+  "abcd", 
+  "xyz", 
+  "octal", 
+  "-3", 
+  -3, 
+  "-3.344", 
+  -3.344, 
+  NULL, 
+  "NULL",
+  "0",
+  0, 
+  TRUE, 
+  "TRUE",
+  "1",
+  1,
+  FALSE,
+  "FALSE",
+  " ",
+  "     ",
+  'b',
+  '\n',
+  "\n",
+  "12",
+  "12twelve",
+  $string
+);
+
+/* loop through to get the string starts with "needle" in $string */
+for( $i = 0; $i < count($needles); $i++ ) {
+  echo "\n-- Iteration $i --\n";
+  var_dump( strstr($string, $needles[$i]) );
+}  
+
+       
+echo "\n*** Testing Miscelleneous input data ***\n";
+
+echo "-- Passing objects as string and needle --\n";
+/* we get "Catchable fatal error: saying Object of class needle could not be 
+converted to string" by default when an object is passed instead of string:
+The error can be  avoided by chosing the __toString magix method as follows: */
+
+class string 
+{
+  function __toString() {
+    return "Hello, world";
+  }
+}
+$obj_string = new string;
+
+class needle 
+{
+  function __toString() {
+    return "world";
+  }
+}
+$obj_needle = new needle;
+
+var_dump(strstr("$obj_string", "$obj_needle"));        
+
+
+echo "\n-- passing an array as string and needle --\n";
+$needles = array("hello", "?world", "!$%**()%**[][[[&@#~!");
+var_dump( strstr($needles, $needles) );  // won't work
+var_dump( strstr("hello?world,!$%**()%**[][[[&@#~!", "$needles[1]") );  // 
works
+var_dump( strstr("hello?world,!$%**()%**[][[[&@#~!", "$needles[2]") );  // 
works
+
+
+echo "\n-- passing Resources as string and needle --\n"; 
+$resource1 = fopen(__FILE__, "r");
+$resource2 = opendir(".");
+var_dump( strstr($resource1, $resource1) );
+var_dump( strstr($resource1, $resource2) );
+
+
+echo "\n-- Posiibilities with null --\n";
+var_dump( strstr("", NULL) );
+var_dump( strstr(NULL, NULL) );
+var_dump( strstr("a", NULL) );
+var_dump( strstr("/x0", "0") );  // Hexadecimal NUL
+
+echo "\n-- A longer and heredoc string --\n";
+$string = <<<EOD
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+EOD;
+var_dump( strstr($string, "abcd") );
+var_dump( strstr($string, "1234") );           
+
+echo "\n-- A heredoc null string --\n";
+$str = <<<EOD
+EOD;
+var_dump( strstr($str, "\0") );
+var_dump( strstr($str, NULL) );
+var_dump( strstr($str, "0") );
+
+
+echo "\n-- simple and complex syntax strings --\n";
+$needle = 'world';
+
+/* Simple syntax */
+var_dump( strstr("Hello, world", "$needle") );  // works 
+var_dump( strstr("Hello, world'S", "$needle'S") );  // works
+var_dump( strstr("Hello, worldS", "$needleS") );  // won't work 
+
+/* String with curly braces, complex syntax */
+var_dump( strstr("Hello, worldS", "${needle}S") );  // works
+var_dump( strstr("Hello, worldS", "{$needle}S") );  // works
+
+
+echo "\n-- complex strings containing other than 7-bit chars --\n";
+$str = chr(0).chr(128).chr(129).chr(234).chr(235).chr(254).chr(255);
+echo "- Positions of some chars in the string '$str' are as follows -\n";
+echo chr(128)." => "; 
+var_dump( strstr($str, chr(128)) );            
+echo chr(255)." => "; 
+var_dump( strstr($str, chr(255)) );
+echo chr(256)." => "; 
+var_dump( strstr($str, chr(256)) ); 
+
+echo "\n*** Testing error conditions ***";
+var_dump( strstr($string, ""));
+var_dump( strstr() );  // zero argument
+var_dump( strstr("") );  // null argument 
+var_dump( strstr($string) );  // without "needle"
+var_dump( strstr("a", "b", "c") );  // args > expected
+var_dump( strstr(NULL, "") );
+
+echo "\nDone";
+
+--CLEAN--
+fclose($resource1);
+closedir($resource2);
 ?>
---EXPECT--
+--EXPECTF--
+*** Testing basic functionality of strstr() ***
 string(11) "test string"
 string(6) "string"
 string(6) "string"
@@ -27,4 +187,226 @@
 bool(false)
 bool(false)
 bool(false)
-string(32) "6ec19f52f0766c463f3bb240f4396913"
+
+*** Testing strstr() with various needles ***
+-- Iteration 0 --
+string(86) "Hello world,012033 -3.3445     NULL TRUE FALSE+ 
+abcd$:Hello world"
+
+-- Iteration 1 --
+bool(false)
+
+-- Iteration 2 --
+string(40) "+ 
+abcd$:Hello world"
+
+-- Iteration 3 --
+string(40) "+ 
+abcd$:Hello world"
+
+-- Iteration 4 --
+string(28) "+ 
+abcd$:Hello world"
+
+-- Iteration 5 --
+string(38) "abcd\xxyz + 
+abcd$:Hello world"
+
+-- Iteration 6 --
+string(32) "xyz + 
+abcd$:Hello world"
+
+-- Iteration 7 --
+string(25) "octal
+ 
+abcd$:Hello world"
+
+-- Iteration 8 --
+string(67) "-3.3445     NULL TRUE FALSE+ 
+abcd$:Hello world"
+
+-- Iteration 9 --
+bool(false)
+
+-- Iteration 10 --
+string(67) "-3.3445     NULL TRUE FALSE+ 
+abcd$:Hello world"
+
+-- Iteration 11 --
+bool(false)
+
+-- Iteration 12 --
+string(40) "+ 
+abcd$:Hello world"
+
+-- Iteration 13 --
+string(55) "NULL TRUE FALSE+ 
+abcd$:Hello world"
+
+-- Iteration 14 --
+string(74) "012033 -3.3445     NULL TRUE FALSE+ 
+abcd$:Hello world"
+
+-- Iteration 15 --
+string(40) "+ 
+abcd$:Hello world"
+
+-- Iteration 16 --
+bool(false)
+
+-- Iteration 17 --
+string(50) "TRUE FALSE+ 
+abcd$:Hello world"
+
+-- Iteration 18 --
+string(73) "12033 -3.3445     NULL TRUE FALSE+ 
+abcd$:Hello world"
+
+-- Iteration 19 --
+bool(false)
+
+-- Iteration 20 --
+string(40) "+ 
+abcd$:Hello world"
+
+-- Iteration 21 --
+string(45) "FALSE+ 
+abcd$:Hello world"
+
+-- Iteration 22 --
+string(81) " world,012033 -3.3445     NULL TRUE FALSE+ 
+abcd$:Hello world"
+
+-- Iteration 23 --
+string(60) "     NULL TRUE FALSE+ 
+abcd$:Hello world"
+
+-- Iteration 24 --
+string(37) "bcd\xxyz + 
+abcd$:Hello world"
+
+-- Iteration 25 --
+bool(false)
+
+-- Iteration 26 --
+string(20) "
+ 
+abcd$:Hello world"
+
+-- Iteration 27 --
+string(73) "12033 -3.3445     NULL TRUE FALSE+ 
+abcd$:Hello world"
+
+-- Iteration 28 --
+bool(false)
+
+-- Iteration 29 --
+string(86) "Hello world,012033 -3.3445     NULL TRUE FALSE+ 
+abcd$:Hello world"
+
+*** Testing Miscelleneous input data ***
+-- Passing objects as string and needle --
+string(5) "world"
+
+-- passing an array as string and needle --
+
+Notice: Array to string conversion in %s on line %d
+bool(false)
+string(27) "?world,!$%**()%**[][[[&@#~!"
+string(20) "!$%**()%**[][[[&@#~!"
+
+-- passing Resources as string and needle --
+bool(false)
+bool(false)
+
+-- Posiibilities with null --
+bool(false)
+bool(false)
+bool(false)
+string(1) "0"
+
+-- A longer and heredoc string --
+string(729) 
"abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789"
+string(702) "123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789"
+
+-- A heredoc null string --
+bool(false)
+bool(false)
+bool(false)
+
+-- simple and complex syntax strings --
+string(5) "world"
+string(7) "world'S"
+
+Notice: Undefined variable: needleS in %s on line %d
+
+Warning: strstr(): Empty delimiter. in %s on line %d
+bool(false)
+string(6) "worldS"
+string(6) "worldS"
+
+-- complex strings containing other than 7-bit chars --
+- Positions of some chars in the string '+€ => string(6) "€êëþÿ"
+ÿ => string(1) "ÿ"
++
+*** Testing error conditions ***
+Warning: strstr(): Empty delimiter. in %s on line %d
+bool(false)
+
+Warning: Wrong parameter count for strstr() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for strstr() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for strstr() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for strstr() in %s on line %d
+NULL
+
+Warning: strstr(): Empty delimiter. in %s on line %d
+bool(false)
+
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strpos.phpt?r1=1.2&r2=1.2.6.1&diff_format=u
Index: php-src/ext/standard/tests/strings/strpos.phpt
diff -u php-src/ext/standard/tests/strings/strpos.phpt:1.2 
php-src/ext/standard/tests/strings/strpos.phpt:1.2.6.1
--- php-src/ext/standard/tests/strings/strpos.phpt:1.2  Wed May 19 08:45:23 2004
+++ php-src/ext/standard/tests/strings/strpos.phpt      Sat May 12 10:15:02 2007
@@ -1,21 +1,205 @@
 --TEST--
-strpos() function
+Test strpos() function
 --FILE--
 <?php
-       var_dump(strpos("test string", "test"));
-       var_dump(strpos("test string", "string"));
-       var_dump(strpos("test string", "strin"));
-       var_dump(strpos("test string", "t s"));
-       var_dump(strpos("test string", "g"));
-       var_dump(strpos("te".chr(0)."st", chr(0)));
-       var_dump(strpos("tEst", "test"));
-       var_dump(strpos("teSt", "test"));
-       var_dump(@strpos("", ""));
-       var_dump(@strpos("a", ""));
-       var_dump(@strpos("", "a"));
-       var_dump(@strpos("\\\\a", "\\a"));
+/* Prototype: int strpos ( string $haystack, mixed $needle [, int $offset] );
+   Description: Find position of first occurrence of a string
+*/
+
+echo "*** Testing basic functionality of strpos() ***\n";
+var_dump( strpos("test string", "test") );
+var_dump( strpos("test string", "string") );
+var_dump( strpos("test string", "strin") );
+var_dump( strpos("test string", "t s") );
+var_dump( strpos("test string", "g") );
+var_dump( strpos("te".chr(0)."st", chr(0)) );
+var_dump( strpos("tEst", "test") );
+var_dump( strpos("teSt", "test") );
+var_dump( @strpos("", "") );
+var_dump( @strpos("a", "") );
+var_dump( @strpos("", "a") );
+var_dump( @strpos("\\\\a", "\\a") );
+
+
+echo "\n*** Testing stropos() to find various needles and a long string ***\n";
+$string = 
+"Hello world,012033 -3.3445     NULL TRUE FALSE\0 abcd\xxyz \x000 octal\n
+abcd$:Hello world";
+
+/* needles in an array to get the position of needle in $string */
+$needles = array(
+  "Hello world",       
+  "WORLD", 
+  "\0", 
+  "\x00", 
+  "\x000", 
+  "abcd", 
+  "xyz", 
+  "octal", 
+  "-3", 
+  -3, 
+  "-3.344", 
+  -3.344, 
+  NULL, 
+  "NULL",
+  "0",
+  0, 
+  TRUE, 
+  "TRUE",
+  "1",
+  1,
+  FALSE,
+  "FALSE",
+  " ",
+  "     ",
+  'b',
+  '\n',
+  "\n",
+  "12",
+  "12twelve",
+  $string
+);
+
+/* loop through to get the "needle" position in $string */
+for( $i = 0; $i < count($needles); $i++ ) {
+  echo "Position of '$needles[$i]' is => ";
+  var_dump( strpos($string, $needles[$i]) );
+}  
+
+
+echo "\n*** Testing strpos() with possible variations in offset ***\n";
+$offset_values = array (
+  1,  // offset = 1
+  "string",  // offset as string, converts to zero
+  NULL,  // offset as string, converts to zero
+  "",  // offset as string, converts to zero
+  "12string",  // mixed string with int and chars
+  "0",
+  TRUE,
+  NULL,
+  FALSE,
+  "string12",
+  "12.3string",  // mixed string with float and chars
+);
+
+/* loop through to get the "needle" position in $string */
+for( $i = 0; $i < count( $offset_values ); $i++ ) {
+  echo "Position of 'Hello' with offset '$offset_values[$i]' is => ";
+  var_dump( strpos($string, "Hello", $offset_values[$i]) );
+}
+
+
+echo "\n*** Testing Miscelleneous input data ***\n";
+
+echo "-- Passing objects as string and needle --\n";
+/* we get "Catchable fatal error: saying Object of class needle could not be
+ converted to string" by default when an object is passed instead of string:
+ The error can be avoided by chosing the __toString magix method as follows: */
+
+class string 
+{
+  function __toString() {
+    return "Hello, world";
+  }
+}
+$obj_string = new string;
+
+class needle 
+{
+  function __toString() {
+    return "world";
+  }
+}
+$obj_needle = new needle;
+
+var_dump( strpos("$obj_string", "$obj_needle") );
+
+echo "\n-- Passing an array as string and needle --\n";
+$needles = array("hello", "?world", "!$%**()%**[][[[&@#~!");
+var_dump( strpos($needles, $needles) );         // won't work
+var_dump( strpos("hello?world,!$%**()%**[][[[&@#~!", "$needles[1]") ); // works
+var_dump( strpos("hello?world,!$%**()%**[][[[&@#~!", "$needles[2]") ); // works
+
+
+echo "\n-- Passing Resources as string and needle --\n"; 
+$resource1 = fopen(__FILE__, "r");
+$resource2 = opendir(".");
+var_dump( strpos($resource1, $resource1) );
+var_dump( strpos($resource1, $resource2) );
+
+echo "\n-- Posiibilities with null --\n";
+var_dump( strpos("", NULL) );
+var_dump( strpos(NULL, NULL) );
+var_dump( strpos("a", NULL) );
+var_dump( strpos("/x0", "0") );         // Hexadecimal NUL
+
+echo "\n-- A longer and heredoc string --\n";
+$string = <<<EOD
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+EOD;
+var_dump( strpos($string, "abcd") );
+var_dump( strpos($string, "abcd", 72) );  // 72 -> "\n" in the first line
+var_dump( strpos($string, "abcd", 73) );  // 73 -> "abcd" in the second line
+var_dump( strpos($string, "9", (strlen($string)-1)) );
+
+echo "\n-- A heredoc null string --\n";
+$str = <<<EOD
+EOD;
+var_dump( strpos($str, "\0") );
+var_dump( strpos($str, NULL) );
+var_dump( strpos($str, "0") );
+
+
+echo "\n-- simple and complex syntax strings --\n";
+$needle = 'world';
+
+/* Simple syntax */
+var_dump( strpos("Hello, world", "$needle") );  // works 
+var_dump( strpos("Hello, world'S", "$needle'S") );  // works
+var_dump( strpos("Hello, worldS", "$needleS") );  // won't work 
+
+/* String with curly braces, complex syntax */
+var_dump( strpos("Hello, worldS", "${needle}S") );  // works
+var_dump( strpos("Hello, worldS", "{$needle}S") );  // works
+
+
+echo "\n-- complex strings containing other than 7-bit chars --\n";
+$str = chr(0).chr(128).chr(129).chr(234).chr(235).chr(254).chr(255);
+echo "-- Positions of some chars in the string '$str' are as follows --\n";
+echo chr(128)." => "; 
+var_dump( strpos($str, chr(128)) );            
+echo chr(255)." => "; 
+var_dump( strpos($str, chr(255), 3) );
+echo chr(256)." => "; 
+var_dump( strpos($str, chr(256)) );
+
+echo "\n*** Testing error conditions ***";
+var_dump( strpos($string, "") );
+var_dump( strpos() );  // zero argument
+var_dump( strpos("") );  // null argument 
+var_dump( strpos($string) );  // without "needle"
+var_dump( strpos("a", "b", "c", "d") );  // args > expected
+var_dump( strpos($string, "test", strlen($string)+1) );  // offset > strlen()
+var_dump( strpos($string, "test", -1) );  // offset < 0
+var_dump( strpos(NULL, "") );
+
+echo "\nDone";
+
+--CLEAN--
+fclose($resource1); 
+closedir($resource2);
 ?>
---EXPECT--
+--EXPECTF--
+*** Testing basic functionality of strpos() ***
 int(0)
 int(5)
 int(5)
@@ -28,3 +212,127 @@
 bool(false)
 bool(false)
 int(1)
+
+*** Testing stropos() to find various needles and a long string ***
+Position of 'Hello world' is => int(0)
+Position of 'WORLD' is => bool(false)
+Position of '+Position of '+Position of '+Position of 'abcd' is => int(48)
+Position of 'xyz' is => int(54)
+Position of 'octal' is => int(61)
+Position of '-3' is => int(19)
+Position of '-3' is => bool(false)
+Position of '-3.344' is => int(19)
+Position of '-3.344' is => bool(false)
+Position of '' is => int(46)
+Position of 'NULL' is => int(31)
+Position of '0' is => int(12)
+Position of '0' is => int(46)
+Position of '1' is => bool(false)
+Position of 'TRUE' is => int(36)
+Position of '1' is => int(13)
+Position of '1' is => bool(false)
+Position of '' is => int(46)
+Position of 'FALSE' is => int(41)
+Position of ' ' is => int(5)
+Position of '     ' is => int(26)
+Position of 'b' is => int(49)
+Position of '\n' is => bool(false)
+Position of '
+' is => int(66)
+Position of '12' is => int(13)
+Position of '12twelve' is => bool(false)
+Position of 'Hello world,012033 -3.3445     NULL TRUE FALSE+
+abcd$:Hello world' is => int(0)
+
+*** Testing strpos() with possible variations in offset ***
+Position of 'Hello' with offset '1' is => int(74)
+Position of 'Hello' with offset 'string' is => int(0)
+Position of 'Hello' with offset '' is => int(0)
+Position of 'Hello' with offset '' is => int(0)
+Position of 'Hello' with offset '12string' is => int(74)
+Position of 'Hello' with offset '0' is => int(0)
+Position of 'Hello' with offset '1' is => int(74)
+Position of 'Hello' with offset '' is => int(0)
+Position of 'Hello' with offset '' is => int(0)
+Position of 'Hello' with offset 'string12' is => int(0)
+Position of 'Hello' with offset '12.3string' is => int(74)
+
+*** Testing Miscelleneous input data ***
+-- Passing objects as string and needle --
+int(7)
+
+-- Passing an array as string and needle --
+
+Notice: Array to string conversion in %s on line %d
+bool(false)
+int(5)
+int(12)
+
+-- Passing Resources as string and needle --
+bool(false)
+bool(false)
+
+-- Posiibilities with null --
+bool(false)
+bool(false)
+bool(false)
+int(2)
+
+-- A longer and heredoc string --
+int(0)
+int(73)
+int(73)
+int(728)
+
+-- A heredoc null string --
+bool(false)
+bool(false)
+bool(false)
+
+-- simple and complex syntax strings --
+int(7)
+int(7)
+
+Notice: Undefined variable: needleS in %s on line %d
+
+Warning: strpos(): Empty delimiter. in %s on line %d
+bool(false)
+int(7)
+int(7)
+
+-- complex strings containing other than 7-bit chars --
+-- Positions of some chars in the string '+€ => int(1)
+ÿ => int(6)
++
+*** Testing error conditions ***
+Warning: strpos(): Empty delimiter. in %s on line %d
+bool(false)
+
+Warning: Wrong parameter count for strpos() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for strpos() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for strpos() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for strpos() in %s on line %d
+NULL
+
+Warning: strpos(): Offset not contained in string. in %s on line %d
+bool(false)
+
+Warning: strpos(): Offset not contained in string. in %s on line %d
+bool(false)
+
+Warning: strpos(): Empty delimiter. in %s on line %d
+bool(false)
+
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/chr_ord.phpt?r1=1.2&r2=1.2.6.1&diff_format=u
Index: php-src/ext/standard/tests/strings/chr_ord.phpt
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/implode1.phpt?r1=1.1.2.2&r2=1.1.2.3&diff_format=u
Index: php-src/ext/standard/tests/strings/implode1.phpt
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/str_replace.phpt?r1=1.1.2.4&r2=1.1.2.5&diff_format=u
Index: php-src/ext/standard/tests/strings/str_replace.phpt
diff -u php-src/ext/standard/tests/strings/str_replace.phpt:1.1.2.4 
php-src/ext/standard/tests/strings/str_replace.phpt:1.1.2.5
--- php-src/ext/standard/tests/strings/str_replace.phpt:1.1.2.4 Fri Oct  6 
14:50:46 2006
+++ php-src/ext/standard/tests/strings/str_replace.phpt Sat May 12 10:15:02 2007
@@ -1,40 +1,168 @@
 --TEST--
-str_replace() tests
+Test str_replace() function
 --FILE--
 <?php
+/* 
+  Prototype: mixed str_replace(mixed $search, mixed $replace, 
+                               mixed $subject [, int &$count]);
+  Description: Replace all occurrences of the search string with 
+               the replacement string
+*/
+
+echo "\n*** Testing str_replace() on basic operations ***\n";
+
+var_dump( str_replace("", "", "") );
+
+var_dump( str_replace("e", "b", "test") );
+
+var_dump( str_replace("", "", "", $count) );
+var_dump( $count );
+
+var_dump( str_replace("q", "q", "q", $count) );
+var_dump( $count );
+
+var_dump( str_replace("long string here", "", "", $count) );
+var_dump( $count );
+
+$fp = fopen( __FILE__, "r" );
+var_dump( str_replace($fp, $fp, $fp, $fp) );
+var_dump( $fp );
+
+echo "\n*** Testing str_replace() with various search values ***";
+$search_arr = array( TRUE, FALSE, 1, 0, -1, "1", "0", "-1",  NULL, 
+                     array(), "php", "");
+
+$i = 0;
+/* loop through to replace the matched elements in the array */
+foreach( $search_arr as $value ) {
+  echo "\n-- Iteration $i --\n";
+  /* replace the string in array */
+  var_dump( str_replace($value, "FOUND", $search_arr, $count) ); 
+  var_dump( $count );
+  $i++;
+}
 
-var_dump(str_replace("", "", ""));
-
-var_dump(str_replace("e", "b", "test"));
+echo "\n*** Testing str_replace() with various subjects ***";
+$subject = "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE\000
+           \x000\xABCD\0abcd \xXYZ\tabcd [EMAIL PROTECTED]&*!~,.:;?: !!Hello, 
World 
+           ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)";
+
+/* needles in an array to be compared in the string $string */
+$search_str = array ( 
+  "Hello, World",
+  'Hello, World',
+  '!!Hello, World',
+  "??Hello, World",
+  "[EMAIL PROTECTED]&*!~,.:;?",
+  "123",
+  123,
+  "-1.2345",
+  -1.2344,
+  "abcd",
+  'XYZ',
+  NULL,
+  "NULL",
+  "0",
+  0,
+  "",
+  " ",
+  "\0",
+  "\x000",
+  "\xABC",
+  "\0000",
+  ".3",
+  TRUE,
+  "TRUE",
+  "1",
+  1,
+  FALSE,
+  "FALSE",
+  " ",
+  "          ",
+  'b',
+  '\t',
+  "\t",
+  chr(128).chr(234).chr(65).chr(255).chr(256),
+  $subject
+);
+
+/* loop through to get the  $string */
+for( $i = 0; $i < count($search_str); $i++ ) {
+  echo "\n--- Iteration $i ---";
+  echo "\n-- String after replacing the search value is => --\n";
+  var_dump( str_replace($search_str[$i], "FOUND", $subject, $count) );
+  echo "-- search string has found '$count' times\n";
+}
+  
 
-var_dump(str_replace("", "", "", $count));
+echo "\n*** Testing Miscelleneous input data ***\n";
+/*  If replace has fewer values than search, then an empty 
+    string is used for the rest of replacement values */
+var_dump( str_replace(array("a", "a", "b"), 
+                     array("q", "q"), 
+                     "aaabb", $count
+                    )
+       );
+var_dump($count);
+var_dump( str_replace(array("a", "a", "b"), 
+                      array("q", "q"), 
+                      array("aaa", "bbb", "ccc"), 
+                      $count
+                     )
+        );
 var_dump($count);
 
-var_dump(str_replace("q", "q", "q", $count));
-var_dump($count);
 
-var_dump(str_replace("long string here", "", "", $count));
-var_dump($count);
+echo "\n-- Testing objects --\n";
+/* we get "Catchable fatal error: saying Object of class could not be converted
+        to string" by default, when an object is passed instead of string:
+The error can be  avoided by chosing the __toString magix method as follows: */
+
+class subject 
+{
+  function __toString() {
+    return "Hello, world";
+  }
+}
+$obj_subject = new subject;
 
-var_dump(str_replace(chr(0), "a", "", $count));
-var_dump($count);
+class search 
+{
+  function __toString() {
+    return "Hello, world";
+  }
+}
+$obj_search = new search;
 
-var_dump(str_replace(chr(0), "a", chr(0), $count));
-var_dump($count);
+class replace 
+{
+  function __toString() {
+    return "Hello, world";
+  }
+}
+$obj_replace = new replace;
 
-var_dump(str_replace("multi", "a", "aaa", $count));
+var_dump(str_replace("$obj_search", "$obj_replace", "$obj_subject", $count));
 var_dump($count);
 
-var_dump(str_replace("a", "multi", "aaa", $count));
-var_dump($count);
 
+echo "\n-- Testing arrays --\n";
 var_dump(str_replace(array("a", "a", "b"), "multi", "aaa", $count));
 var_dump($count);
 
-var_dump(str_replace(array("a", "a", "b"), array("q", "q", "c"), "aaa", 
$count));
+var_dump(str_replace( array("a", "a", "b"),
+                      array("q", "q", "c"), 
+                      "aaa", $count
+                    )
+);
 var_dump($count);
 
-var_dump(str_replace(array("a", "a", "b"), array("q", "q", "c"), array("aaa", 
"bbb"), $count));
+var_dump(str_replace( array("a", "a", "b"),
+                      array("q", "q", "c"), 
+                      array("aaa", "bbb"), 
+                      $count
+                    )
+);
 var_dump($count);
 
 var_dump(str_replace("a", array("q", "q", "c"), array("aaa", "bbb"), $count));
@@ -46,13 +174,70 @@
 var_dump(str_replace(1, 3, array("aaa1", "2bbb"), $count));
 var_dump($count);
 
-$fp = fopen(__FILE__, "r");
-var_dump(str_replace($fp, $fp, $fp, $fp));
-var_dump($fp);
+
+echo "\n-- Testing Resources --\n";
+$resource1 = fopen( __FILE__, "r" );
+$resource2 = opendir( "." );
+var_dump(str_replace("stream", "FOUND", $resource1, $count)); 
+var_dump($count);
+var_dump(str_replace("stream", "FOUND", $resource2, $count));
+var_dump($count);
+
+
+echo "\n-- Testing a longer and heredoc string --\n";
+$string = <<<EOD
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
[EMAIL PROTECTED]&**&[EMAIL PROTECTED]:())))((((&&&**%$###@@@[EMAIL PROTECTED]&*
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+EOD;
+
+var_dump( str_replace("abcdef", "FOUND", $string, $count) );
+var_dump( $count );
+
+echo "\n-- Testing a heredoc null string --\n";
+$str = <<<EOD
+EOD;
+var_dump( str_replace("", "FOUND", $str, $count) );
+var_dump( $count );
+
+
+echo "\n-- Testing simple and complex syntax strings --\n";
+$str = 'world';
+
+/* Simple syntax */
+var_dump( str_replace("world", "FOUND", "$str") );
+var_dump( str_replace("world'S", "FOUND", "$str'S") );
+var_dump( str_replace("worldS", "FOUND", "$strS") );
+
+/* String with curly braces, complex syntax */
+var_dump( str_replace("worldS", "FOUND", "${str}S") );
+var_dump( str_replace("worldS", "FOUND", "{$str}S") );
+
+
+echo "\n*** Testing error conditions ***";
+/* Invalid arguments */
+var_dump( str_replace() );
+var_dump( str_replace("") );
+var_dump( str_replace(NULL) );
+var_dump( str_replace(1, 2) );
+var_dump( str_replace(1,2,3,$var,5) );
 
 echo "Done\n";
+
+--CLEAN--
+fclose($fp);
+fclose($resource1);
+closedir($resource2);
+
 ?>
 --EXPECTF--    
+*** Testing str_replace() on basic operations ***
 string(0) ""
 string(4) "tbst"
 string(0) ""
@@ -61,14 +246,632 @@
 int(1)
 string(0) ""
 int(0)
-string(0) ""
+string(14) "Resource id #5"
+int(1)
+
+*** Testing str_replace() with various search values ***
+-- Iteration 0 --
+array(12) {
+  [0]=>
+  string(5) "FOUND"
+  [1]=>
+  string(0) ""
+  [2]=>
+  string(5) "FOUND"
+  [3]=>
+  string(1) "0"
+  [4]=>
+  string(6) "-FOUND"
+  [5]=>
+  string(5) "FOUND"
+  [6]=>
+  string(1) "0"
+  [7]=>
+  string(6) "-FOUND"
+  [8]=>
+  string(0) ""
+  [9]=>
+  array(0) {
+  }
+  [10]=>
+  string(3) "php"
+  [11]=>
+  string(0) ""
+}
+int(5)
+
+-- Iteration 1 --
+array(12) {
+  [0]=>
+  string(1) "1"
+  [1]=>
+  string(0) ""
+  [2]=>
+  string(1) "1"
+  [3]=>
+  string(1) "0"
+  [4]=>
+  string(2) "-1"
+  [5]=>
+  string(1) "1"
+  [6]=>
+  string(1) "0"
+  [7]=>
+  string(2) "-1"
+  [8]=>
+  string(0) ""
+  [9]=>
+  array(0) {
+  }
+  [10]=>
+  string(3) "php"
+  [11]=>
+  string(0) ""
+}
 int(0)
-string(1) "a"
+
+-- Iteration 2 --
+array(12) {
+  [0]=>
+  string(5) "FOUND"
+  [1]=>
+  string(0) ""
+  [2]=>
+  string(5) "FOUND"
+  [3]=>
+  string(1) "0"
+  [4]=>
+  string(6) "-FOUND"
+  [5]=>
+  string(5) "FOUND"
+  [6]=>
+  string(1) "0"
+  [7]=>
+  string(6) "-FOUND"
+  [8]=>
+  string(0) ""
+  [9]=>
+  array(0) {
+  }
+  [10]=>
+  string(3) "php"
+  [11]=>
+  string(0) ""
+}
+int(5)
+
+-- Iteration 3 --
+array(12) {
+  [0]=>
+  string(1) "1"
+  [1]=>
+  string(0) ""
+  [2]=>
+  string(1) "1"
+  [3]=>
+  string(5) "FOUND"
+  [4]=>
+  string(2) "-1"
+  [5]=>
+  string(1) "1"
+  [6]=>
+  string(5) "FOUND"
+  [7]=>
+  string(2) "-1"
+  [8]=>
+  string(0) ""
+  [9]=>
+  array(0) {
+  }
+  [10]=>
+  string(3) "php"
+  [11]=>
+  string(0) ""
+}
+int(2)
+
+-- Iteration 4 --
+array(12) {
+  [0]=>
+  string(1) "1"
+  [1]=>
+  string(0) ""
+  [2]=>
+  string(1) "1"
+  [3]=>
+  string(1) "0"
+  [4]=>
+  string(5) "FOUND"
+  [5]=>
+  string(1) "1"
+  [6]=>
+  string(1) "0"
+  [7]=>
+  string(5) "FOUND"
+  [8]=>
+  string(0) ""
+  [9]=>
+  array(0) {
+  }
+  [10]=>
+  string(3) "php"
+  [11]=>
+  string(0) ""
+}
+int(2)
+
+-- Iteration 5 --
+array(12) {
+  [0]=>
+  string(5) "FOUND"
+  [1]=>
+  string(0) ""
+  [2]=>
+  string(5) "FOUND"
+  [3]=>
+  string(1) "0"
+  [4]=>
+  string(6) "-FOUND"
+  [5]=>
+  string(5) "FOUND"
+  [6]=>
+  string(1) "0"
+  [7]=>
+  string(6) "-FOUND"
+  [8]=>
+  string(0) ""
+  [9]=>
+  array(0) {
+  }
+  [10]=>
+  string(3) "php"
+  [11]=>
+  string(0) ""
+}
+int(5)
+
+-- Iteration 6 --
+array(12) {
+  [0]=>
+  string(1) "1"
+  [1]=>
+  string(0) ""
+  [2]=>
+  string(1) "1"
+  [3]=>
+  string(5) "FOUND"
+  [4]=>
+  string(2) "-1"
+  [5]=>
+  string(1) "1"
+  [6]=>
+  string(5) "FOUND"
+  [7]=>
+  string(2) "-1"
+  [8]=>
+  string(0) ""
+  [9]=>
+  array(0) {
+  }
+  [10]=>
+  string(3) "php"
+  [11]=>
+  string(0) ""
+}
+int(2)
+
+-- Iteration 7 --
+array(12) {
+  [0]=>
+  string(1) "1"
+  [1]=>
+  string(0) ""
+  [2]=>
+  string(1) "1"
+  [3]=>
+  string(1) "0"
+  [4]=>
+  string(5) "FOUND"
+  [5]=>
+  string(1) "1"
+  [6]=>
+  string(1) "0"
+  [7]=>
+  string(5) "FOUND"
+  [8]=>
+  string(0) ""
+  [9]=>
+  array(0) {
+  }
+  [10]=>
+  string(3) "php"
+  [11]=>
+  string(0) ""
+}
+int(2)
+
+-- Iteration 8 --
+array(12) {
+  [0]=>
+  string(1) "1"
+  [1]=>
+  string(0) ""
+  [2]=>
+  string(1) "1"
+  [3]=>
+  string(1) "0"
+  [4]=>
+  string(2) "-1"
+  [5]=>
+  string(1) "1"
+  [6]=>
+  string(1) "0"
+  [7]=>
+  string(2) "-1"
+  [8]=>
+  string(0) ""
+  [9]=>
+  array(0) {
+  }
+  [10]=>
+  string(3) "php"
+  [11]=>
+  string(0) ""
+}
+int(0)
+
+-- Iteration 9 --
+array(12) {
+  [0]=>
+  string(1) "1"
+  [1]=>
+  string(0) ""
+  [2]=>
+  string(1) "1"
+  [3]=>
+  string(1) "0"
+  [4]=>
+  string(2) "-1"
+  [5]=>
+  string(1) "1"
+  [6]=>
+  string(1) "0"
+  [7]=>
+  string(2) "-1"
+  [8]=>
+  string(0) ""
+  [9]=>
+  array(0) {
+  }
+  [10]=>
+  string(3) "php"
+  [11]=>
+  string(0) ""
+}
+int(0)
+
+-- Iteration 10 --
+array(12) {
+  [0]=>
+  string(1) "1"
+  [1]=>
+  string(0) ""
+  [2]=>
+  string(1) "1"
+  [3]=>
+  string(1) "0"
+  [4]=>
+  string(2) "-1"
+  [5]=>
+  string(1) "1"
+  [6]=>
+  string(1) "0"
+  [7]=>
+  string(2) "-1"
+  [8]=>
+  string(0) ""
+  [9]=>
+  array(0) {
+  }
+  [10]=>
+  string(5) "FOUND"
+  [11]=>
+  string(0) ""
+}
 int(1)
-string(3) "aaa"
+
+-- Iteration 11 --
+array(12) {
+  [0]=>
+  string(1) "1"
+  [1]=>
+  string(0) ""
+  [2]=>
+  string(1) "1"
+  [3]=>
+  string(1) "0"
+  [4]=>
+  string(2) "-1"
+  [5]=>
+  string(1) "1"
+  [6]=>
+  string(1) "0"
+  [7]=>
+  string(2) "-1"
+  [8]=>
+  string(0) ""
+  [9]=>
+  array(0) {
+  }
+  [10]=>
+  string(3) "php"
+  [11]=>
+  string(0) ""
+}
 int(0)
-string(15) "multimultimulti"
-int(3)
+
+*** Testing str_replace() with various subjects ***
+--- Iteration 0 ---
+-- String after replacing the search value is => --
+string(177) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE+      
    +       ?FOUND chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '2' times
+
+--- Iteration 1 ---
+-- String after replacing the search value is => --
+string(177) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE+      
    +       ?FOUND chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '2' times
+
+--- Iteration 2 ---
+-- String after replacing the search value is => --
+string(182) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE+      
    +       ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '1' times
+
+--- Iteration 3 ---
+-- String after replacing the search value is => --
+string(191) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE+      
    +       ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '0' times
+
+--- Iteration 4 ---
+-- String after replacing the search value is => --
+string(182) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE+      
    +       ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '1' times
+
+--- Iteration 5 ---
+-- String after replacing the search value is => --
+string(191) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE+      
    +       ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '0' times
+
+--- Iteration 6 ---
+-- String after replacing the search value is => --
+string(191) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE+      
    +       ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '0' times
+
+--- Iteration 7 ---
+-- String after replacing the search value is => --
+string(189) "Hello, world,0120333.3445FOUND67          NULL TRUE FALSE+        
    +       ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '1' times
+
+--- Iteration 8 ---
+-- String after replacing the search value is => --
+string(191) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE+      
    +       ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '0' times
+
+--- Iteration 9 ---
+-- String after replacing the search value is => --
+string(193) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE+      
    +       ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '2' times
+
+--- Iteration 10 ---
+-- String after replacing the search value is => --
+string(193) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE+      
    +       ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '1' times
+
+--- Iteration 11 ---
+-- String after replacing the search value is => --
+string(191) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE+      
    +       ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '0' times
+
+--- Iteration 12 ---
+-- String after replacing the search value is => --
+string(192) "Hello, world,0120333.3445-1.234567          FOUND TRUE FALSE+     
    +       ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '1' times
+
+--- Iteration 13 ---
+-- String after replacing the search value is => --
+string(207) "Hello, world,FOUND12FOUND333.3445-1.234567          NULL TRUE 
FALSE+          +       ?Hello, World 
chr(FOUND).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '4' times
+
+--- Iteration 14 ---
+-- String after replacing the search value is => --
+string(207) "Hello, world,FOUND12FOUND333.3445-1.234567          NULL TRUE 
FALSE+          +       ?Hello, World 
chr(FOUND).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '4' times
+
+--- Iteration 15 ---
+-- String after replacing the search value is => --
+string(191) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE+      
    +       ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '0' times
+
+--- Iteration 16 ---
+-- String after replacing the search value is => --
+string(307) 
"Hello,FOUNDworld,0120333.3445-1.234567FOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDNULLFOUNDTRUEFOUNDFALSE+FOUND
     FOUNDFOUNDFOUNDFOUND+   
FOUNDFOUNDFOUNDFOUND?Hello,FOUNDWorldFOUNDchr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '29' times
+
+--- Iteration 17 ---
+-- String after replacing the search value is => --
+string(203) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSEFOUND
+           FOUND0«CDFOUNDabcd \xXYZ    abcd [EMAIL PROTECTED]&*!~,.:;?: 
!!Hello, World 
+           ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '3' times
+
+--- Iteration 18 ---
+-- String after replacing the search value is => --
+string(194) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE+      
    FOUND«CD+       ?Hello, World 
chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '1' times
+
+--- Iteration 19 ---
+-- String after replacing the search value is => --
+string(194) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE+      
    +       ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '1' times
+
+--- Iteration 20 ---
+-- String after replacing the search value is => --
+string(194) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE+      
    FOUND«CD+       ?Hello, World 
chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '1' times
+
+--- Iteration 21 ---
+-- String after replacing the search value is => --
+string(194) "Hello, world,0120333FOUND445-1.234567          NULL TRUE FALSE+   
    +       ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '1' times
+
+--- Iteration 22 ---
+-- String after replacing the search value is => --
+string(203) "Hello, world,0FOUND20333.3445-FOUND.234567          NULL TRUE 
FALSE+          +       ?Hello, World 
chr(0).chr(FOUND28).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '3' times
+
+--- Iteration 23 ---
+-- String after replacing the search value is => --
+string(192) "Hello, world,0120333.3445-1.234567          NULL FOUND FALSE+     
    +       ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '1' times
+
+--- Iteration 24 ---
+-- String after replacing the search value is => --
+string(203) "Hello, world,0FOUND20333.3445-FOUND.234567          NULL TRUE 
FALSE+          +       ?Hello, World 
chr(0).chr(FOUND28).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '3' times
+
+--- Iteration 25 ---
+-- String after replacing the search value is => --
+string(203) "Hello, world,0FOUND20333.3445-FOUND.234567          NULL TRUE 
FALSE+          +       ?Hello, World 
chr(0).chr(FOUND28).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '3' times
+
+--- Iteration 26 ---
+-- String after replacing the search value is => --
+string(191) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE+      
    +       ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '0' times
+
+--- Iteration 27 ---
+-- String after replacing the search value is => --
+string(191) "Hello, world,0120333.3445-1.234567          NULL TRUE FOUND+      
    +       ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '1' times
+
+--- Iteration 28 ---
+-- String after replacing the search value is => --
+string(307) 
"Hello,FOUNDworld,0120333.3445-1.234567FOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDFOUNDNULLFOUNDTRUEFOUNDFALSE+FOUND
     FOUNDFOUNDFOUNDFOUND+   
FOUNDFOUNDFOUNDFOUND?Hello,FOUNDWorldFOUNDchr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '29' times
+
+--- Iteration 29 ---
+-- String after replacing the search value is => --
+string(186) "Hello, world,0120333.3445-1.234567FOUNDNULL TRUE FALSE+       +   
    ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '1' times
+
+--- Iteration 30 ---
+-- String after replacing the search value is => --
+string(199) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE+      
    +       ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '2' times
+
+--- Iteration 31 ---
+-- String after replacing the search value is => --
+string(191) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE+      
    +       ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '0' times
+
+--- Iteration 32 ---
+-- String after replacing the search value is => --
+string(203) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE+ 
FOUND    +FOUND    ?Hello, World 
chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '3' times
+
+--- Iteration 33 ---
+-- String after replacing the search value is => --
+string(191) "Hello, world,0120333.3445-1.234567          NULL TRUE FALSE+      
    +       ?Hello, World chr(0).chr(128).chr(234).chr(65).chr(255).chr(256)"
+-- search string has found '0' times
+
+--- Iteration 34 ---
+-- String after replacing the search value is => --
+string(5) "FOUND"
+-- search string has found '1' times
+
+*** Testing Miscelleneous input data ***
+string(3) "qqq"
+int(5)
+array(3) {
+  [0]=>
+  string(3) "qqq"
+  [1]=>
+  string(0) ""
+  [2]=>
+  string(3) "ccc"
+}
+int(6)
+
+-- Testing objects --
+string(12) "Hello, world"
+int(1)
+
+-- Testing arrays --
 string(15) "multimultimulti"
 int(3)
 string(3) "qqq"
@@ -103,6 +906,51 @@
   string(4) "2bbb"
 }
 int(1)
-string(%d) "Resource id #%d"
-int(1)
+
+-- Testing Resources --
+string(14) "Resource id #6"
+int(0)
+string(14) "Resource id #7"
+int(0)
+
+-- Testing a longer and heredoc string --
+string(623) 
"FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789
+FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789
+FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789
+FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789
+FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789
+FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789
+FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789
[EMAIL PROTECTED]&**&[EMAIL PROTECTED]:())))((((&&&**%$###@@@[EMAIL PROTECTED]&*
+FOUNDghijklmnopqrstuvwxyz0123456789FOUNDghijklmnopqrstuvwxyz0123456789"
+int(16)
+
+-- Testing a heredoc null string --
+string(0) ""
+int(0)
+
+-- Testing simple and complex syntax strings --
+string(5) "FOUND"
+string(5) "FOUND"
+
+Notice: Undefined variable: strS in %s on line %d
+string(0) ""
+string(5) "FOUND"
+string(5) "FOUND"
+
+*** Testing error conditions ***
+Warning: Wrong parameter count for str_replace() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for str_replace() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for str_replace() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for str_replace() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for str_replace() in %s on line %d
+NULL
 Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/substr_count.phpt?r1=1.3&r2=1.3.4.1&diff_format=u
Index: php-src/ext/standard/tests/strings/substr_count.phpt
diff -u php-src/ext/standard/tests/strings/substr_count.phpt:1.3 
php-src/ext/standard/tests/strings/substr_count.phpt:1.3.4.1
--- php-src/ext/standard/tests/strings/substr_count.phpt:1.3    Sat Jun 18 
18:23:12 2005
+++ php-src/ext/standard/tests/strings/substr_count.phpt        Sat May 12 
10:15:02 2007
@@ -1,23 +1,99 @@
 --TEST--
-substr_count() function
+Test substr_count() function
 --FILE--
 <?php
-       var_dump(@substr_count("", ""));
-       var_dump(@substr_count("a", ""));
-       var_dump(@substr_count("", "a"));
-       var_dump(@substr_count("", "a"));
-       var_dump(@substr_count("", chr(0)));
+/* Prototype: int substr_count ( string $haystack, string $needle [, int 
$offset [, int $length]] );
+ * Description: substr_count() returns the number of times the needle 
substring occurs in the 
+ *               haystack string. Please note that needle is case sensitive
+ */
+
+/* Count the number of substring occurrences */
+echo "***Testing basic operations ***\n";
+var_dump(@substr_count("", ""));
+var_dump(@substr_count("a", ""));
+var_dump(@substr_count("", "a"));
+var_dump(@substr_count("", "a"));
+var_dump(@substr_count("", chr(0)));
+$a = str_repeat("abcacba", 100);
+var_dump(@substr_count($a, "bca"));
+$a = str_repeat("abcacbabca", 100);
+var_dump(@substr_count($a, "bca"));
+var_dump(substr_count($a, "bca", 200));
+var_dump(substr_count($a, "bca", 200, 50));
+
+echo "\n*** Testing possible variations ***\n";
+echo "-- 3rd or 4th arg as string --\n";
+$str = "this is a string";
+var_dump( substr_count($str, "t", "5") );
+var_dump( substr_count($str, "t", "5", "10") );
+var_dump( substr_count($str, "i", "5t") );
+var_dump( substr_count($str, "i", "5t", "10t") );
+
+echo "\n-- 3rd or 4th arg as NULL --\n";
+var_dump( substr_count($str, "t", "") );
+var_dump( substr_count($str, "T", "") );
+var_dump( substr_count($str, "t", "", 15) );
+var_dump( substr_count($str, "I", NULL) );
+var_dump( substr_count($str, "i", NULL, 10) );
+
+echo "\n-- overlapped substrings --\n";
+var_dump( substr_count("abcabcabcabcabc", "abca") ); 
+var_dump( substr_count("abcabcabcabcabc", "abca", 2) ); 
+
+echo "\n-- complex strings containing other than 7-bit chars --\n";
+$str = chr(128).chr(129).chr(128).chr(256).chr(255).chr(254).chr(255);
+var_dump(substr_count($str, chr(128)));
+var_dump(substr_count($str, chr(255)));
+var_dump(substr_count($str, chr(256)));
+
+echo "\n-- heredoc string --\n";
+$string = <<<EOD
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+acdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+acdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456789
+EOD;
+var_dump(substr_count($string, "abcd"));
+var_dump(substr_count($string, "1234"));
+
+echo "\n-- heredoc null string --\n";
+$str = <<<EOD
+EOD;
+var_dump(substr_count($str, "\0"));
+var_dump(substr_count($str, "\x000"));
+var_dump(substr_count($str, "0"));
+
+
+echo "\n*** Testing error conditions ***\n";
+/* Zero argument */
+var_dump( substr_count() );
+
+/* more than expected no. of args */
+var_dump( substr_count($str, "t", 0, 15, 30) );
        
-       $a = str_repeat("abcacba", 100);
-       var_dump(@substr_count($a, "bca"));
+/* offset as negative value */
+var_dump(substr_count($str, "t", -5));
+
+/* offset > size of the string */
+var_dump(substr_count($str, "t", 25));
+
+/* Using offset and length to go beyond the size of the string: 
+   Warning message expected, as length+offset > length of string */
+var_dump( substr_count($str, "i", 5, 15) );
+
+/* length as Null */
+var_dump( substr_count($str, "t", "", "") );
+var_dump( substr_count($str, "i", NULL, NULL) );
        
-       $a = str_repeat("abcacbabca", 100);
-       var_dump(@substr_count($a, "bca"));
+echo "Done\n"; 
 
-       var_dump(substr_count($a, "bca", 200));
-       var_dump(substr_count($a, "bca", 200, 50));
 ?>
---EXPECT--
+--EXPECTF--
+***Testing basic operations ***
 bool(false)
 bool(false)
 int(0)
@@ -27,3 +103,59 @@
 int(200)
 int(160)
 int(10)
+
+*** Testing possible variations ***
+-- 3rd or 4th arg as string --
+int(1)
+int(1)
+int(2)
+int(2)
+
+-- 3rd or 4th arg as NULL --
+int(2)
+int(0)
+int(2)
+int(0)
+int(2)
+
+-- overlapped substrings --
+int(2)
+int(2)
+
+-- complex strings containing other than 7-bit chars --
+int(2)
+int(2)
+int(1)
+
+-- heredoc string --
+int(14)
+int(16)
+
+-- heredoc null string --
+int(0)
+int(0)
+int(0)
+
+*** Testing error conditions ***
+
+Warning: Wrong parameter count for substr_count() in %s on line %d
+NULL
+
+Warning: Wrong parameter count for substr_count() in %s on line %d
+NULL
+
+Warning: substr_count(): Offset should be greater than or equal to 0. in %s on 
line %d
+bool(false)
+
+Warning: substr_count(): Offset value 25 exceeds string length. in %s on line 
%d
+bool(false)
+
+Warning: substr_count(): Offset value 5 exceeds string length. in %s on line %d
+bool(false)
+
+Warning: substr_count(): Length should be greater than 0. in %s on line %d
+bool(false)
+
+Warning: substr_count(): Length should be greater than 0. in %s on line %d
+bool(false)
+Done
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/str_repeat.phpt?r1=1.2&r2=1.2.6.1&diff_format=u
Index: php-src/ext/standard/tests/strings/str_repeat.phpt

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/trim1.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/trim1.phpt
+++ php-src/ext/standard/tests/strings/trim1.phpt

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/addcslashes.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/addcslashes.phpt
+++ php-src/ext/standard/tests/strings/addcslashes.phpt

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/substr.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/substr.phpt
+++ php-src/ext/standard/tests/strings/substr.phpt

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/md5_file.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/md5_file.phpt
+++ php-src/ext/standard/tests/strings/md5_file.phpt

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

Reply via email to