wharmby         Thu Jan 15 13:40:22 2009 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/standard/tests/strings strripos_variation3.phpt 
                                        strripos_variation4.phpt 
                                        strripos_variation1.phpt 
                                        strripos_basic1.phpt 
                                        strripos_variation5.phpt 
                                        strripos_variation2.phpt 
                                        strripos_error.phpt 
                                        strripos_basic2.phpt 
  Log:
  New test for strripos()  string function. All tests checked on Windows, Linux 
and Linux 64 bit. 
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strripos_variation3.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/strripos_variation3.phpt
+++ php-src/ext/standard/tests/strings/strripos_variation3.phpt
--TEST--
Test strripos() function : usage variations - multi line heredoc string for 
'haystack' argument
--FILE--
<?php
/* Prototype  : int strripos ( string $haystack, string $needle [, int $offset] 
);
 * Description: Find position of last occurrence of a case-insensitive 'needle' 
in a 'haystack'
 * Source code: ext/standard/string.c
*/

/* Test strripos() function by passing multi-line heredoc string for haystack 
and 
 *  with various needles & offsets
*/

echo "*** Testing strripos() function: with heredoc strings ***\n";
echo "-- With heredoc string containing multi lines --\n";
$multi_line_str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
EOD;

echo "\n-- Multi line strings with +ve offsets -- \n";
var_dump( strripos($multi_line_str, "iNg", 0) );
var_dump( strripos($multi_line_str, "inG", 15) );
var_dump( strripos($multi_line_str, "Ing", 22) );

echo "\n-- Multi line strings with +ve offsets -- \n";
var_dump( strripos($multi_line_str, "Ing", -1) );
var_dump( strripos($multi_line_str, "Ing", -17) );
var_dump( strripos($multi_line_str, "Ing", -50) );

echo "\n-- Multi line strings with no offset -- \n";
var_dump( strripos($multi_line_str, "spAn") );
var_dump( strripos($multi_line_str, "IPlE") );
var_dump( strripos($multi_line_str, "") );
var_dump( strripos($multi_line_str, " ") );

?>
===DONE===
--EXPECT--
*** Testing strripos() function: with heredoc strings ***
-- With heredoc string containing multi lines --

-- Multi line strings with +ve offsets -- 
int(44)
int(44)
int(44)

-- Multi line strings with +ve offsets -- 
int(44)
int(44)
bool(false)

-- Multi line strings with no offset -- 
int(18)
int(31)
bool(false)
int(55)
===DONE===

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strripos_variation4.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/strripos_variation4.phpt
+++ php-src/ext/standard/tests/strings/strripos_variation4.phpt
--TEST--
Test strripos() function : usage variations - heredoc string containing special 
chars for 'haystack' argument
--FILE--
<?php
/* Prototype  : int strripos ( string $haystack, string $needle [, int $offset] 
);
 * Description: Find position of last occurrence of a case-insensitive 'needle' 
in a 'haystack'
 * Source code: ext/standard/string.c
*/

/* Test strripos() function by passing heredoc string containing special chars 
for haystack
 *  and with various needles & offets 
*/

echo "*** Testing strripos() function: with heredoc strings ***\n";
echo "-- With heredoc string containing special chars --\n";
$special_chars_str = <<<EOD
Ex'ple of h'doc st'g, contains
$#%^*&*_("_")!#@@!$#$^^&$*(special)
chars.
EOD;
var_dump( strripos($special_chars_str, "Ex'pLE", 0) );
var_dump( strripos($special_chars_str, "!@@!", 23) );
var_dump( strripos($special_chars_str, '_') );
var_dump( strripos($special_chars_str, '("_")') );
var_dump( strripos($special_chars_str, "$*") );
var_dump( strripos($special_chars_str, "$*", 10) );
var_dump( strripos($special_chars_str, "(speCIal)") );

?>
===DONE===
--EXPECTF--
*** Testing strripos() function: with heredoc strings ***
-- With heredoc string containing special chars --
int(0)
bool(false)
int(41)
int(39)
int(55)
int(55)
int(57)
===DONE===

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strripos_variation1.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/strripos_variation1.phpt
+++ php-src/ext/standard/tests/strings/strripos_variation1.phpt
--TEST--
Test strripos() function : usage variations - double quoted strings for 
'haystack' & 'needle' arguments
--XFAIL--
This test will fail until bug #47102 fixed
--FILE--
<?php
/* Prototype  : int strripos ( string $haystack, string $needle [, int $offset] 
);
 * Description: Find position of last occurrence of a case-insensitive 'needle' 
in a 'haystack'
 * Source code: ext/standard/string.c
*/

/* Test strripos() function by passing double quoted strings for 'haystack' & 
'needle' arguments */

echo "*** Testing strripos() function: with double quoted strings ***\n";
$haystack = "Hello,\t\n\0\n  $&!#%()*<=>?...@hello123456he \x234 \101 ";
$needles = array(
                  //regular strings
/*1*/     "l",  
                  "L",
                  "HELLO",
                  "hEllo",
                
                  //escape characters
/*5*/     "\t",  
                  "\T",  //invalid input
                  "     ",
                  "\n",
                  "\N",  //invalid input
                  "
",  //new line
                
                  //nulls
/*11*/    "\0",  
                  NULL,
                  null,
                
                  //boolean false
/*14*/    FALSE,  
                  false,
                
                  //empty string
/*16*/    "",
                
                  //special chars
/*17*/    " ",  
                  "$",
                  " $",
                  "&",
                  "!#", 
                  "()",
                  "<=>", 
                  ">",  
                  "=>",
                  "?",
                  "@",
                  "@hEllo",
                
/*29*/    "12345", //decimal numeric string  
                  "\x23",  //hexadecimal numeric string
                  "#",  //respective ASCII char of \x23
                  "\101",  //octal numeric string
                  "A",  //respective ASCII char of \101
                  "456HEE",  //numerics + chars
                  $haystack  //haystack as needle  
);
 
/* loop through to get the position of the needle in haystack string */
$count = 1;
foreach ($needles as $needle) {
  echo "-- Iteration $count --\n";
  var_dump( strripos($haystack, $needle) );
  var_dump( strripos($haystack, $needle, 1) );
  var_dump( strripos($haystack, $needle, 20) );
  var_dump( strripos($haystack, $needle, -1) );
  $count++;
}
?>
===DONE===
--EXPECTF--
*** Testing strripos() function: with double quoted strings ***
-- Iteration 1 --
int(28)
int(28)
int(28)
int(28)
-- Iteration 2 --
int(28)
int(28)
int(28)
int(28)
-- Iteration 3 --
int(25)
int(25)
int(25)
int(25)
-- Iteration 4 --
int(25)
int(25)
int(25)
int(25)
-- Iteration 5 --
int(6)
int(6)
bool(false)
int(6)
-- Iteration 6 --
bool(false)
bool(false)
bool(false)
bool(false)
-- Iteration 7 --
bool(false)
bool(false)
bool(false)
bool(false)
-- Iteration 8 --
int(9)
int(9)
bool(false)
int(9)
-- Iteration 9 --
bool(false)
bool(false)
bool(false)
bool(false)
-- Iteration 10 --
int(9)
int(9)
bool(false)
int(9)
-- Iteration 11 --
int(8)
int(8)
bool(false)
int(8)
-- Iteration 12 --
int(8)
int(8)
bool(false)
int(8)
-- Iteration 13 --
int(8)
int(8)
bool(false)
int(8)
-- Iteration 14 --
int(8)
int(8)
bool(false)
int(8)
-- Iteration 15 --
int(8)
int(8)
bool(false)
int(8)
-- Iteration 16 --
bool(false)
bool(false)
bool(false)
bool(false)
-- Iteration 17 --
int(43)
int(43)
int(43)
int(43)
-- Iteration 18 --
int(12)
int(12)
bool(false)
int(12)
-- Iteration 19 --
int(11)
int(11)
bool(false)
int(11)
-- Iteration 20 --
int(13)
int(13)
bool(false)
int(13)
-- Iteration 21 --
int(14)
int(14)
bool(false)
int(14)
-- Iteration 22 --
int(17)
int(17)
bool(false)
int(17)
-- Iteration 23 --
int(20)
int(20)
int(20)
int(20)
-- Iteration 24 --
int(22)
int(22)
int(22)
int(22)
-- Iteration 25 --
int(21)
int(21)
int(21)
int(21)
-- Iteration 26 --
int(23)
int(23)
int(23)
int(23)
-- Iteration 27 --
int(24)
int(24)
int(24)
int(24)
-- Iteration 28 --
int(24)
int(24)
int(24)
int(24)
-- Iteration 29 --
int(30)
int(30)
int(30)
int(30)
-- Iteration 30 --
int(39)
int(39)
int(39)
int(39)
-- Iteration 31 --
int(39)
int(39)
int(39)
int(39)
-- Iteration 32 --
int(42)
int(42)
int(42)
int(42)
-- Iteration 33 --
int(42)
int(42)
int(42)
int(42)
-- Iteration 34 --
bool(false)
bool(false)
bool(false)
bool(false)
-- Iteration 35 --
int(0)
bool(false)
bool(false)
int(0)
===DONE===

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strripos_basic1.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/strripos_basic1.phpt
+++ php-src/ext/standard/tests/strings/strripos_basic1.phpt
--TEST--
Test strripos() function : basic functionality - with default arguments
--FILE--
<?php
/* Prototype  : int strripos ( string $haystack, string $needle [, int $offset] 
);
 * Description: Find position of last occurrence of a case-insensitive 'needle' 
in a 'haystack'
 * Source code: ext/standard/string.c
*/

echo "*** Testing strripos() function: basic functionality ***\n";
$heredoc_str = <<<EOD
Hello, World
EOD;

echo "\n-- regular string for haystack & needle --\n";
var_dump( strripos("Hello, World", "HeLLo") );
var_dump( strripos('Hello, World', "hello") );
var_dump( strripos("Hello, World", 'WoRLd') );
var_dump( strripos('Hello, World', 'WORLD') );
var_dump( strripos('Hello, World', 'foo') );

echo "\n-- single char for needle --\n";
var_dump( strripos("Hello, World", "O") );
var_dump( strripos("Hello, World", ",") );

echo "\n-- heredoc string for haystack & needle --\n"; 
var_dump( strripos($heredoc_str, "Hello, WoRLd") );
var_dump( strripos($heredoc_str, 'HelLO') );
var_dump( strripos($heredoc_str, $heredoc_str) );

?>
===DONE===
--EXPECT--
*** Testing strripos() function: basic functionality ***

-- regular string for haystack & needle --
int(0)
int(0)
int(7)
int(7)
bool(false)

-- single char for needle --
int(8)
int(5)

-- heredoc string for haystack & needle --
int(0)
int(0)
int(0)
===DONE===

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strripos_variation5.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/strripos_variation5.phpt
+++ php-src/ext/standard/tests/strings/strripos_variation5.phpt
--TEST--
Test strripos() function : usage variations - heredoc string containing escape 
chars for 'haystack' argument
--FILE--
<?php
/* Prototype  : int strripos ( string $haystack, string $needle [, int $offset] 
);
 * Description: Find position of last occurrence of a case-insensitive 'needle' 
in a 'haystack'
 * Source code: ext/standard/string.c
*/

/* Test strripos() function by passing heredoc string containing escape chars 
for haystack 
 *  and with various needles & offsets 
*/

echo "*** Testing strripos() function: with heredoc strings ***\n";
echo "-- With heredoc string containing escape characters --\n";
$control_char_str = <<<EOD
Hello, World\n
Hello\tWorld
EOD;
var_dump( strripos($control_char_str, "\n") );
var_dump( strripos($control_char_str, "\t") );
var_dump( strripos($control_char_str, "\n", 12) );
var_dump( strripos($control_char_str, "\t", 15) );

?>
===DONE===
--EXPECTF--
*** Testing strripos() function: with heredoc strings ***
-- With heredoc string containing escape characters --
int(13)
int(19)
int(13)
int(19)
===DONE===

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strripos_variation2.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/strripos_variation2.phpt
+++ php-src/ext/standard/tests/strings/strripos_variation2.phpt
--TEST--
Test strripos() function : usage variations - single quoted strings for 
'haystack' & 'needle' arguments
--XFAIL--
This test will fail until bug #47102 fixed
--FILE--
<?php
/* Prototype  : int strripos ( string $haystack, string $needle [, int $offset] 
);
 * Description: Find position of last occurrence of a case-insensitive 'needle' 
in a 'haystack'
 * Source code: ext/standard/string.c
*/

/* Test strripos() function by passing single quoted strings to 'haystack' & 
'needle' arguments */

echo "*** Testing strripos() function: with single quoted strings ***\n";
$haystack = 'Hello,\t\n\0\n  $&!#%()*<=>?...@hello123456he \x234 \101 ';
$needles = array(
                  //regular strings
/*1*/     'l',  
                  'L',
                  'HELLO',
                  'hEllo',
                
                  //escape characters
/*5*/     '\t',  
                  '\T',
                  '     ',
                  '\n',
                  '\N',
                  '
                ',  //new line
                
                  //nulls
/*11*/    '\0',  
                  NULL,
                  null,
                
                  //boolean false
/*14*/    FALSE,  
                  false,
                
                  //empty string
/*16*/    '',
                
                  //special chars
/*17*/    ' ',  
                  '$',
                  ' $',
                  '&',
                  '!#',
                  '()',
                  '<=>',  
                  '>',
                  '=>',
                  '?',
                  '@',
                  '@hEllo',
                
/*29*/    '12345',      //decimal numeric string  
                  '\x23',       //hexadecimal numeric string
                  '#',          //respective ASCII char of \x23
                  '\101',       //octal numeric string
                  'A',          // respective ASCII char for \101
                  '456HEE', //numerics + chars
                  42,           //needle as int(ASCII value of '*')
                  $haystack  //haystack as needle  
);

/* loop through to get the position of the needle in haystack string */
$count = 1;
foreach ($needles as $needle) {
  echo "-- Iteration $count --\n";
  var_dump( strripos($haystack, $needle) );
  var_dump( strripos($haystack, $needle, 1) );
  var_dump( strripos($haystack, $needle, 20) );
  var_dump( strripos($haystack, $needle, -1) );
  $count++;
}
?>
===DONE===
--EXPECT--
*** Testing strripos() function: with single quoted strings ***
-- Iteration 1 --
int(32)
int(32)
int(32)
int(32)
-- Iteration 2 --
int(32)
int(32)
int(32)
int(32)
-- Iteration 3 --
int(29)
int(29)
int(29)
int(29)
-- Iteration 4 --
int(29)
int(29)
int(29)
int(29)
-- Iteration 5 --
int(6)
int(6)
bool(false)
int(6)
-- Iteration 6 --
int(6)
int(6)
bool(false)
int(6)
-- Iteration 7 --
bool(false)
bool(false)
bool(false)
bool(false)
-- Iteration 8 --
int(12)
int(12)
bool(false)
int(12)
-- Iteration 9 --
int(12)
int(12)
bool(false)
int(12)
-- Iteration 10 --
bool(false)
bool(false)
bool(false)
bool(false)
-- Iteration 11 --
int(10)
int(10)
bool(false)
int(10)
-- Iteration 12 --
bool(false)
bool(false)
bool(false)
bool(false)
-- Iteration 13 --
bool(false)
bool(false)
bool(false)
bool(false)
-- Iteration 14 --
bool(false)
bool(false)
bool(false)
bool(false)
-- Iteration 15 --
bool(false)
bool(false)
bool(false)
bool(false)
-- Iteration 16 --
bool(false)
bool(false)
bool(false)
bool(false)
-- Iteration 17 --
int(53)
int(53)
int(53)
int(53)
-- Iteration 18 --
int(16)
int(16)
bool(false)
int(16)
-- Iteration 19 --
int(15)
int(15)
bool(false)
int(15)
-- Iteration 20 --
int(17)
int(17)
bool(false)
int(17)
-- Iteration 21 --
int(18)
int(18)
bool(false)
int(18)
-- Iteration 22 --
int(21)
int(21)
int(21)
int(21)
-- Iteration 23 --
int(24)
int(24)
int(24)
int(24)
-- Iteration 24 --
int(26)
int(26)
int(26)
int(26)
-- Iteration 25 --
int(25)
int(25)
int(25)
int(25)
-- Iteration 26 --
int(27)
int(27)
int(27)
int(27)
-- Iteration 27 --
int(28)
int(28)
int(28)
int(28)
-- Iteration 28 --
int(28)
int(28)
int(28)
int(28)
-- Iteration 29 --
int(34)
int(34)
int(34)
int(34)
-- Iteration 30 --
int(43)
int(43)
int(43)
int(43)
-- Iteration 31 --
int(19)
int(19)
bool(false)
int(19)
-- Iteration 32 --
int(49)
int(49)
int(49)
int(49)
-- Iteration 33 --
bool(false)
bool(false)
bool(false)
bool(false)
-- Iteration 34 --
bool(false)
bool(false)
bool(false)
bool(false)
-- Iteration 35 --
int(23)
int(23)
int(23)
int(23)
-- Iteration 36 --
int(0)
bool(false)
bool(false)
int(0)
===DONE===

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strripos_error.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/strripos_error.phpt
+++ php-src/ext/standard/tests/strings/strripos_error.phpt
--TEST--
Test strripos() function : error conditions 
--FILE--
<?php
/* Prototype  : int strripos ( string $haystack, string $needle [, int $offset] 
);
 * Description: Find position of last occurrence of a case-insensitive 'needle' 
in a 'haystack'
 * Source code: ext/standard/string.c
*/

echo "*** Testing strripos() function: error conditions ***";
echo "\n-- With Zero arguments --";
var_dump( strripos() );

echo "\n-- With less than expected number of arguments --";
var_dump( strripos("String") );

echo "\n-- With more than expected number of arguments --";
var_dump( strripos("string", "String", 1, 'extra_arg') );
?>
===DONE===
--EXPECTF--
*** Testing strripos() function: error conditions ***
-- With Zero arguments --
Warning: strripos() expects at least 2 parameters, 0 given in %s on line %d
bool(false)

-- With less than expected number of arguments --
Warning: strripos() expects at least 2 parameters, 1 given in %s on line %d
bool(false)

-- With more than expected number of arguments --
Warning: strripos() expects at most 3 parameters, 4 given in %s on line %d
bool(false)
===DONE===

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strripos_basic2.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/strripos_basic2.phpt
+++ php-src/ext/standard/tests/strings/strripos_basic2.phpt
--TEST--
Test strripos() function : basic functionality - with all arguments
--XFAIL--
This test will fail until bug #47102 fixed
--FILE--
<?php
/* Prototype  : int strripos ( string $haystack, string $needle [, int $offset] 
);
 * Description: Find position of last occurrence of a case-insensitive 'needle' 
in a 'haystack'
 * Source code: ext/standard/string.c
*/

echo "*** Testing strripos() function: basic functionality ***\n";
$heredoc_str = <<<EOD
Hello, World
EOD;

echo "\n-- regular string for haystack & needle, with various offsets --\n"; 
var_dump( strripos("Hello, World", "HeLLo", 0) );
var_dump( strripos("Hello, World", 'Hello', 1) );
var_dump( strripos('Hello, World', 'world', 1) );
var_dump( strripos('Hello, World', "WorLD", 5) );

echo "\n-- heredoc string for haystack & needle, with various offsets --\n"; 
var_dump( strripos($heredoc_str, "Hello, WORLD", 0) );
var_dump( strripos($heredoc_str, 'HelLo', 0) );
var_dump( strripos($heredoc_str, 'HeLLo', 1) );
var_dump( strripos($heredoc_str, $heredoc_str, 0) );
var_dump( strripos($heredoc_str, $heredoc_str, 1) );

echo "\n-- various +ve offsets --\n"; 
var_dump( strripos("Hello, World", "O", 3) );
var_dump( strripos("Hello, World", "O", 6) );
var_dump( strripos("Hello, World", "O", 10) );

echo "\n-- various -ve offsets --\n"; 
var_dump( strripos("Hello, World", "O", -1) );
var_dump( strripos("Hello, World", "O", -5) );
var_dump( strripos("Hello, World", "O",  -9) );
?>
===DONE===
--EXPECT--
*** Testing strripos() function: basic functionality ***

-- regular string for haystack & needle, with various offsets --
int(0)
bool(false)
int(7)
int(7)

-- heredoc string for haystack & needle, with various offsets --
int(0)
int(0)
bool(false)
int(0)
bool(false)

-- various +ve offsets --
int(8)
int(8)
bool(false)

-- various -ve offsets --
int(8)
int(4)
bool(false)
===DONE===

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

Reply via email to