kraghuba Sat Sep 29 09:24:27 2007 UTC Modified files: /php-src/ext/standard/tests/strings strrchr_variation1.phpt strrchr_variation2.phpt strrchr_variation3.phpt strrchr_variation4.phpt strrchr_variation5.phpt strrchr_variation6.phpt strrchr_variation7.phpt strrchr_variation8.phpt strrchr_variation9.phpt strrchr_error.phpt strrchr_basic.phpt strrchr_variation10.phpt strrchr_variation11.phpt strrchr_variation12.phpt Log: New testcases for strrchr() function
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strrchr_variation1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/strrchr_variation1.phpt http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strrchr_variation2.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/strrchr_variation2.phpt diff -u /dev/null php-src/ext/standard/tests/strings/strrchr_variation2.phpt:1.2 --- /dev/null Sat Sep 29 09:24:27 2007 +++ php-src/ext/standard/tests/strings/strrchr_variation2.phpt Sat Sep 29 09:24:27 2007 @@ -0,0 +1,357 @@ +--TEST-- +Test strrchr() function : usage variations - single quoted strings +--FILE-- +<?php +/* Prototype : string strrchr(string $haystack, string $needle); + * Description: Finds the last occurrence of a character in a string. + * Source code: ext/standard/string.c +*/ + +/* Test strrchr() function by passing various single quoted strings to 'haystack' & 'needle' */ + +echo "*** Testing strrchr() function: with various single quoted strings ***"; +$haystack = 'Hello,\t\n\0\n $&!#%\o,()*+-./:;<=>[EMAIL PROTECTED] \x234 \101 '; +$needle = array( + //regular strings + 'l', + 'L', + 'HELLO', + 'hEllo', + + //escape characters + '\t', + '\T', + ' ', + '\n', + '\N', + ' +', //new line + + //nulls + '\0', + NULL, + null, + + //boolean false + FALSE, + false, + + //empty string + '', + + //special chars + ' ', + '$', + ' $', + '&', + '!#', + '%\o', + '\o,', + '()', + '*+', + '+', + '-', + '.', + '.;', + ':;', + ';', + '<=>', + '>', + '=>', + '?', + '@', + '@hEllo', + + '12345', //decimal numeric string + '\x23', //hexadecimal numeric string + '#', //hexadecimal numeric string + '\101', //octal numeric string + 'A', + '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; +for($index=0; $index<count($needle); $index++) { + echo "\n-- Iteration $count --\n"; + var_dump( strrchr($haystack, $needle[$index]) ); + $count ++; +} +echo "*** Done ***"; +?> +--EXPECTF-- +*** Testing strrchr() function: with various single quoted strings *** +-- Iteration 1 -- +string(22) "lo123456he \x234 \101 " + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +string(63) "Hello,\t\n\0\n $&!#%\o,()*+-./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 4 -- +string(14) "he \x234 \101 " + +-- Iteration 5 -- +string(5) "\101 " + +-- Iteration 6 -- +string(5) "\101 " + +-- Iteration 7 -- +string(1) " " + +-- Iteration 8 -- +string(5) "\101 " + +-- Iteration 9 -- +string(5) "\101 " + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +string(5) "\101 " + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +string(1) " " + +-- Iteration 18 -- +string(47) "$&!#%\o,()*+-./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 19 -- +string(1) " " + +-- Iteration 20 -- +string(46) "&!#%\o,()*+-./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 21 -- +string(45) "!#%\o,()*+-./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 22 -- +string(43) "%\o,()*+-./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 23 -- +string(5) "\101 " + +-- Iteration 24 -- +string(39) "()*+-./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 25 -- +string(37) "*+-./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 26 -- +string(36) "+-./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 27 -- +string(35) "-./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 28 -- +string(34) "./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 29 -- +string(34) "./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 30 -- +string(32) ":;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 31 -- +string(31) ";<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 32 -- +string(30) "<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 33 -- +string(28) ">[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 34 -- +string(29) "=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 35 -- +string(27) "[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 36 -- +string(26) "@hello123456he \x234 \101 " + +-- Iteration 37 -- +string(26) "@hello123456he \x234 \101 " + +-- Iteration 38 -- +string(2) "1 " + +-- Iteration 39 -- +string(5) "\101 " + +-- Iteration 40 -- +string(44) "#%\o,()*+-./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 41 -- +string(5) "\101 " + +-- Iteration 42 -- +bool(false) + +-- Iteration 43 -- +string(7) "4 \101 " + +-- Iteration 44 -- +string(37) "*+-./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 45 -- +string(63) "Hello,\t\n\0\n $&!#%\o,()*+-./:;<=>[EMAIL PROTECTED] \x234 \101 " +*** Done *** +--UEXPECTF-- +*** Testing strrchr() function: with various single quoted strings *** +-- Iteration 1 -- +unicode(22) "lo123456he \x234 \101 " + +-- Iteration 2 -- +bool(false) + +-- Iteration 3 -- +unicode(63) "Hello,\t\n\0\n $&!#%\o,()*+-./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 4 -- +unicode(14) "he \x234 \101 " + +-- Iteration 5 -- +unicode(5) "\101 " + +-- Iteration 6 -- +unicode(5) "\101 " + +-- Iteration 7 -- +unicode(1) " " + +-- Iteration 8 -- +unicode(5) "\101 " + +-- Iteration 9 -- +unicode(5) "\101 " + +-- Iteration 10 -- +bool(false) + +-- Iteration 11 -- +unicode(5) "\101 " + +-- Iteration 12 -- +bool(false) + +-- Iteration 13 -- +bool(false) + +-- Iteration 14 -- +bool(false) + +-- Iteration 15 -- +bool(false) + +-- Iteration 16 -- +bool(false) + +-- Iteration 17 -- +unicode(1) " " + +-- Iteration 18 -- +unicode(47) "$&!#%\o,()*+-./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 19 -- +unicode(1) " " + +-- Iteration 20 -- +unicode(46) "&!#%\o,()*+-./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 21 -- +unicode(45) "!#%\o,()*+-./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 22 -- +unicode(43) "%\o,()*+-./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 23 -- +unicode(5) "\101 " + +-- Iteration 24 -- +unicode(39) "()*+-./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 25 -- +unicode(37) "*+-./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 26 -- +unicode(36) "+-./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 27 -- +unicode(35) "-./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 28 -- +unicode(34) "./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 29 -- +unicode(34) "./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 30 -- +unicode(32) ":;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 31 -- +unicode(31) ";<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 32 -- +unicode(30) "<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 33 -- +unicode(28) ">[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 34 -- +unicode(29) "=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 35 -- +unicode(27) "[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 36 -- +unicode(26) "@hello123456he \x234 \101 " + +-- Iteration 37 -- +unicode(26) "@hello123456he \x234 \101 " + +-- Iteration 38 -- +unicode(2) "1 " + +-- Iteration 39 -- +unicode(5) "\101 " + +-- Iteration 40 -- +unicode(44) "#%\o,()*+-./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 41 -- +unicode(5) "\101 " + +-- Iteration 42 -- +bool(false) + +-- Iteration 43 -- +unicode(7) "4 \101 " + +-- Iteration 44 -- +unicode(37) "*+-./:;<=>[EMAIL PROTECTED] \x234 \101 " + +-- Iteration 45 -- +unicode(63) "Hello,\t\n\0\n $&!#%\o,()*+-./:;<=>[EMAIL PROTECTED] \x234 \101 " +*** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strrchr_variation3.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/strrchr_variation3.phpt diff -u /dev/null php-src/ext/standard/tests/strings/strrchr_variation3.phpt:1.2 --- /dev/null Sat Sep 29 09:24:27 2007 +++ php-src/ext/standard/tests/strings/strrchr_variation3.phpt Sat Sep 29 09:24:27 2007 @@ -0,0 +1,52 @@ +--TEST-- +Test strrchr() function : usage variations - multi line heredoc string for 'haystack' +--FILE-- +<?php +/* Prototype : string strrchr(string $haystack, string $needle); + * Description: Finds the last occurrence of a character in a string. + * Source code: ext/standard/string.c +*/ + +/* Test strrchr() function by passing multi-line heredoc string for haystack and + * with various needles +*/ + +echo "*** Testing strrchr() function: with heredoc strings ***\n"; +$multi_line_str = <<<EOD +Example of string +spanning multiple lines +using heredoc syntax. +EOD; + +$needles = array( + "ing", + "", + " ", + $multi_line_str //needle as heredoc string +); + +//loop through to test strrchr() with each needle +foreach($needles as $needle) { + var_dump( strrchr($multi_line_str, $needle) ); +} + +echo "*** Done ***"; +?> +--EXPECTF-- +*** Testing strrchr() function: with heredoc strings *** +string(19) "ing heredoc syntax." +bool(false) +string(8) " syntax." +string(63) "Example of string +spanning multiple lines +using heredoc syntax." +*** Done *** +--UEXPECTF-- +*** Testing strrchr() function: with heredoc strings *** +unicode(19) "ing heredoc syntax." +bool(false) +unicode(8) " syntax." +unicode(63) "Example of string +spanning multiple lines +using heredoc syntax." +*** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strrchr_variation4.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/strrchr_variation4.phpt diff -u /dev/null php-src/ext/standard/tests/strings/strrchr_variation4.phpt:1.2 --- /dev/null Sat Sep 29 09:24:27 2007 +++ php-src/ext/standard/tests/strings/strrchr_variation4.phpt Sat Sep 29 09:24:27 2007 @@ -0,0 +1,76 @@ +--TEST-- +Test strrchr() function : usage variations - heredoc string containing special chars for 'haystack' +--FILE-- +<?php +/* Prototype : string strrchr(string $haystack, string $needle); + * Description: Finds the last occurrence of a character in a string. + * Source code: ext/standard/string.c +*/ + +/* Test strrchr() function by passing heredoc string containing special chars for haystack + * and with various needles +*/ + +echo "*** Testing strrchr() function: with heredoc strings ***\n"; +$special_chars_str = <<<EOD +Example of heredoc string contains +$#%^*&*_("_")!#@@!$#$^^&*(special) +chars. +EOD; + +$heredoc_needle = <<<EOD +^^&*( +EOD; + +$needles = array( + "!@@!", + '_', + '("_")', + "$*", + "(special)", + $heredoc_needle, //needle as heredoc string + $special_chars_str //needle as haystack +); + +//loop through to test strrchr() with each needle +foreach($needles as $needle) { + var_dump( strrchr($special_chars_str, $needle) ); +} +echo "*** Done ***"; +?> +--EXPECTF-- +*** Testing strrchr() function: with heredoc strings *** +string(24) "!$#$^^&*(special) +chars." +string(31) "_")!#@@!$#$^^&*(special) +chars." +string(16) "(special) +chars." +string(21) "$^^&*(special) +chars." +string(16) "(special) +chars." +string(19) "^&*(special) +chars." +string(76) "Example of heredoc string contains +$#%^*&*_("_")!#@@!$#$^^&*(special) +chars." +*** Done *** +--UEXPECTF-- +*** Testing strrchr() function: with heredoc strings *** +unicode(24) "!$#$^^&*(special) +chars." +unicode(31) "_")!#@@!$#$^^&*(special) +chars." +unicode(16) "(special) +chars." +unicode(21) "$^^&*(special) +chars." +unicode(16) "(special) +chars." +unicode(19) "^&*(special) +chars." +unicode(76) "Example of heredoc string contains +$#%^*&*_("_")!#@@!$#$^^&*(special) +chars." +*** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strrchr_variation5.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/strrchr_variation5.phpt diff -u /dev/null php-src/ext/standard/tests/strings/strrchr_variation5.phpt:1.2 --- /dev/null Sat Sep 29 09:24:27 2007 +++ php-src/ext/standard/tests/strings/strrchr_variation5.phpt Sat Sep 29 09:24:27 2007 @@ -0,0 +1,75 @@ +--TEST-- +Test strrchr() function : usage variations - heredoc string containing escape sequences for 'haystack' +--FILE-- +<?php +/* Prototype : string strrchr(string $haystack, string $needle); + * Description: Finds the last occurrence of a character in a string. + * Source code: ext/standard/string.c +*/ + +/* Test strrchr() function by passing heredoc string containing + * escape sequences for haystack and with various needles +*/ + +echo "*** Testing strrchr() function: with heredoc strings ***\n"; +$escape_char_str = <<<EOD +\tes\t st\r\rch\r using +\escape \\seque\nce +EOD; + +$heredoc_needle = <<<EOD +\n +EOD; + +$needles = array( + "\t", + '\n', + "\r", + "\\", + $heredoc_needle, //needle as heredoc string + $escape_char_str //needle as haystack +); + +//loop through to test strrchr() with each needle +foreach($needles as $needle) { + var_dump( strrchr($escape_char_str, $needle) ); +} + +echo "*** Done ***"; +?> +--EXPECTF-- +*** Testing strrchr() function: with heredoc strings *** +string(33) " stch using +\escape \seque +ce" +string(9) "\seque +ce" +string(25) " using +\escape \seque +ce" +string(9) "\seque +ce" +string(3) " +ce" +string(33) " stch using +\escape \seque +ce" +*** Done *** +--UEXPECTF-- +*** Testing strrchr() function: with heredoc strings *** +unicode(33) " stch using +\escape \seque +ce" +unicode(9) "\seque +ce" +unicode(25) " using +\escape \seque +ce" +unicode(9) "\seque +ce" +unicode(3) " +ce" +unicode(33) " stch using +\escape \seque +ce" +*** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strrchr_variation6.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/strrchr_variation6.phpt diff -u /dev/null php-src/ext/standard/tests/strings/strrchr_variation6.phpt:1.2 --- /dev/null Sat Sep 29 09:24:27 2007 +++ php-src/ext/standard/tests/strings/strrchr_variation6.phpt Sat Sep 29 09:24:27 2007 @@ -0,0 +1,63 @@ +--TEST-- +Test strrchr() function : usage variations - heredoc string containing quote chars for 'haystack' +--FILE-- +<?php +/* Prototype : string strrchr(string $haystack, string $needle); + * Description: Finds the last occurrence of a character in a string. + * Source code: ext/standard/string.c +*/ + +/* Test strrchr() function by passing heredoc string containing quote chars for haystack + * and with various needles +*/ + +echo "*** Testing strrchr() function: with heredoc strings ***\n"; +$quote_char_str = <<<EOD +"things" "in" "double" "quote" +'things' 'in' 'single' 'quote' +EOD; + +$heredoc_needle = <<<EOD +quote +EOD; + +$needles = array( + "things", + "\"things\"", + "\'things\'", + "in", + "quote", + $heredoc_needle, //needle as heredoc string + $quote_char_str //needle as haystack +); + +//loop through to test strrchr() with each needle +foreach($needles as $needle) { + var_dump( strrchr($quote_char_str, $needle) ); +} +echo "*** Done ***"; +?> +--EXPECTF-- +*** Testing strrchr() function: with heredoc strings *** +string(3) "te'" +string(32) "" +'things' 'in' 'single' 'quote'" +bool(false) +string(14) "ingle' 'quote'" +string(6) "quote'" +string(6) "quote'" +string(32) "" +'things' 'in' 'single' 'quote'" +*** Done *** +--UEXPECTF-- +*** Testing strrchr() function: with heredoc strings *** +unicode(3) "te'" +unicode(32) "" +'things' 'in' 'single' 'quote'" +bool(false) +unicode(14) "ingle' 'quote'" +unicode(6) "quote'" +unicode(6) "quote'" +unicode(32) "" +'things' 'in' 'single' 'quote'" +*** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strrchr_variation7.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/strrchr_variation7.phpt diff -u /dev/null php-src/ext/standard/tests/strings/strrchr_variation7.phpt:1.2 --- /dev/null Sat Sep 29 09:24:27 2007 +++ php-src/ext/standard/tests/strings/strrchr_variation7.phpt Sat Sep 29 09:24:27 2007 @@ -0,0 +1,61 @@ +--TEST-- +Test strrchr() function : usage variations - heredoc string containing blank line for 'haystack' +--FILE-- +<?php +/* Prototype : string strrchr(string $haystack, string $needle); + * Description: Finds the last occurrence of a character in a string. + * Source code: ext/standard/string.c +*/ + +/* Test strrchr() function by passing heredoc string containing + * blank-line for haystack and with various needles +*/ + +echo "*** Testing strrchr() function: with heredoc strings ***\n"; +$blank_line = <<<EOD + +EOD; + +$needles = array( + "\n", + '\n', + "\r", + "\r\n", + " ", + "\t", + "", + $blank_line //needle as haystack +); + +//loop through to test strrchr() with each needle +foreach($needles as $needle) { + var_dump( strrchr($blank_line, $needle) ); +} +echo "*** Done ***"; +?> +--EXPECTF-- +*** Testing strrchr() function: with heredoc strings *** +string(1) " +" +bool(false) +bool(false) +string(1) " +" +bool(false) +bool(false) +string(1) " +" +*** Done *** +--UEXPECTF-- +*** Testing strrchr() function: with heredoc strings *** +string(1) " +" +bool(false) +bool(false) +string(1) " +" +bool(false) +bool(false) +string(1) " +" +*** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strrchr_variation8.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/strrchr_variation8.phpt diff -u /dev/null php-src/ext/standard/tests/strings/strrchr_variation8.phpt:1.2 --- /dev/null Sat Sep 29 09:24:27 2007 +++ php-src/ext/standard/tests/strings/strrchr_variation8.phpt Sat Sep 29 09:24:27 2007 @@ -0,0 +1,47 @@ +--TEST-- +Test strrchr() function : usage variations - empty heredoc string for 'haystack' +--FILE-- +<?php +/* Prototype : string strrchr(string $haystack, string $needle); + * Description: Finds the last occurrence of a character in a string. + * Source code: ext/standard/string.c +*/ + +/* Test strrchr() function by passing empty heredoc string for haystack + * and with various needles +*/ + +echo "*** Testing strrchr() function: with heredoc strings ***\n"; +$empty_str = <<<EOD +EOD; + +$needles = array( + "", //needle as empty string + FALSE, + NULL, + "\0", + $empty_str //needle as haystack +); + +//loop through to test strrchr() with each needle +foreach($needles as $needle) { + var_dump( strrchr($empty_str, $needle) ); +} +echo "*** Done ***"; +?> +--EXPECTF-- +*** Testing strrchr() function: with heredoc strings *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +*** Done *** +--UEXPECTF-- +*** Testing strrchr() function: with heredoc strings *** +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +*** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strrchr_variation9.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/strrchr_variation9.phpt diff -u /dev/null php-src/ext/standard/tests/strings/strrchr_variation9.phpt:1.2 --- /dev/null Sat Sep 29 09:24:27 2007 +++ php-src/ext/standard/tests/strings/strrchr_variation9.phpt Sat Sep 29 09:24:27 2007 @@ -0,0 +1,261 @@ +--TEST-- +Test strrchr() function : usage variations - unexpected inputs for haystack +--FILE-- +<?php +/* Prototype : string strrchr(string $haystack, string $needle); + * Description: Finds the last occurrence of a character in a string. + * Source code: ext/standard/string.c +*/ + +/* Test strrchr() function with unexpected inputs for haystack + * and expected type for 'needle' +*/ + +echo "*** Testing strrchr() function: with unexpected inputs for haystack ***\n"; + +// get an unset variable +$unset_var = 'string_val'; +unset($unset_var); + +// declaring a class +class sample { + public function __toString() { + return "object"; + } +} + +//getting the resource +$file_handle = fopen(__FILE__, "r"); + +// array with different values +$haystacks = 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, + + // null vlaues + NULL, + null, + + // objects + new sample(), + + // empty string + "", + '', + + // resource + $file_handle, + + // undefined variable + @$undefined_var, + + // unset variable + @$unset_var +); + +$needles = array ( + //integer numeric strings + "0", + "1", + "2", + "-2", + + //float numeric strings + "10.5", + "-10.5", + "10.5e10", + "10.6E-10", + ".5", + + //regular strings + "array", + "a", + "r", + "y", + "ay", + "true", + "false", + "TRUE", + "FALSE", + "NULL", + "null", + "object", + + //empty string + "", + '', + + //resource variable in string form + "$file_handle", + + //undefined variable in string form + @"$undefined_var", + @"$unset_var" +); + +// loop through each element of the array and check the working of strrchr() +$count = 1; +for($index = 0; $index < count($haystacks); $index++) { + echo "-- Iteration $count --\n"; + var_dump( strrchr($haystacks[$index], $needles[$index]) ); + $count ++; +} + +fclose($file_handle); //closing the file handle + +echo "*** Done ***"; +?> +--EXPECTF-- +*** Testing strrchr() function: with unexpected inputs for haystack *** +-- Iteration 1 -- +string(1) "0" +-- Iteration 2 -- +string(1) "1" +-- Iteration 3 -- +string(4) "2345" +-- Iteration 4 -- +string(5) "-2345" +-- Iteration 5 -- +string(4) "10.5" +-- Iteration 6 -- +string(5) "-10.5" +-- Iteration 7 -- +string(12) "105000000000" +-- Iteration 8 -- +string(7) "1.06E-9" +-- Iteration 9 -- +string(2) ".5" +-- Iteration 10 -- + +Notice: Array to string conversion in %s on line %d%d +string(2) "ay" +-- Iteration 11 -- + +Notice: Array to string conversion in %s on line %d%d +string(2) "ay" +-- Iteration 12 -- + +Notice: Array to string conversion in %s on line %d%d +string(3) "ray" +-- Iteration 13 -- + +Notice: Array to string conversion in %s on line %d%d +string(1) "y" +-- Iteration 14 -- + +Notice: Array to string conversion in %s on line %d%d +string(2) "ay" +-- Iteration 15 -- +bool(false) +-- Iteration 16 -- +bool(false) +-- Iteration 17 -- +bool(false) +-- Iteration 18 -- +bool(false) +-- Iteration 19 -- +bool(false) +-- Iteration 20 -- +bool(false) +-- Iteration 21 -- +string(6) "object" +-- Iteration 22 -- +bool(false) +-- Iteration 23 -- +bool(false) +-- Iteration 24 -- +string(14) "Resource id #5" +-- Iteration 25 -- +bool(false) +-- Iteration 26 -- +bool(false) +*** Done *** +--UEXPECTF-- +*** Testing strrchr() function: with unexpected inputs for haystack *** +-- Iteration 1 -- +unicode(1) "0" +-- Iteration 2 -- +unicode(1) "1" +-- Iteration 3 -- +unicode(4) "2345" +-- Iteration 4 -- +unicode(5) "-2345" +-- Iteration 5 -- +unicode(4) "10.5" +-- Iteration 6 -- +unicode(5) "-10.5" +-- Iteration 7 -- +unicode(12) "105000000000" +-- Iteration 8 -- +unicode(7) "1.06E-9" +-- Iteration 9 -- +unicode(2) ".5" +-- Iteration 10 -- + +Notice: Array to string conversion in %s on line %d +unicode(2) "ay" +-- Iteration 11 -- + +Notice: Array to string conversion in %s on line %d +unicode(2) "ay" +-- Iteration 12 -- + +Notice: Array to string conversion in %s on line %d +unicode(3) "ray" +-- Iteration 13 -- + +Notice: Array to string conversion in %s on line %d +unicode(1) "y" +-- Iteration 14 -- + +Notice: Array to string conversion in %s on line %d +unicode(2) "ay" +-- Iteration 15 -- +bool(false) +-- Iteration 16 -- +bool(false) +-- Iteration 17 -- +bool(false) +-- Iteration 18 -- +bool(false) +-- Iteration 19 -- +bool(false) +-- Iteration 20 -- +bool(false) +-- Iteration 21 -- +unicode(6) "object" +-- Iteration 22 -- +bool(false) +-- Iteration 23 -- +bool(false) +-- Iteration 24 -- +unicode(14) "Resource id #5" +-- Iteration 25 -- +bool(false) +-- Iteration 26 -- +bool(false) +*** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strrchr_error.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/strrchr_error.phpt diff -u /dev/null php-src/ext/standard/tests/strings/strrchr_error.phpt:1.2 --- /dev/null Sat Sep 29 09:24:27 2007 +++ php-src/ext/standard/tests/strings/strrchr_error.phpt Sat Sep 29 09:24:27 2007 @@ -0,0 +1,55 @@ +--TEST-- +Test strrchr() function : error conditions +--FILE-- +<?php +/* Prototype : string strrchr(string $haystack, string $needle); + * Description: Finds the last occurrence of a character in a string. + * Source code: ext/standard/string.c +*/ + +echo "*** Testing strrchr() function: error conditions ***\n"; +$haystack = "Hello"; +$needle = "Hello"; +$extra_arg = "Hello"; + +echo "\n-- Testing strrchr() function with Zero arguments --"; +var_dump( strrchr() ); + +echo "\n-- Testing strrchr() function with less than expected no. of arguments --"; +var_dump( strrchr($haystack) ); + +echo "\n-- Testing strrchr() function with more than expected no. of arguments --"; +var_dump( strrchr($haystack, $needle, $extra_arg) ); + +echo "*** Done ***"; +?> +--EXPECTF-- +*** Testing strrchr() function: error conditions *** + +-- Testing strrchr() function with Zero arguments -- +Warning: strrchr() expects exactly 2 parameters, 0 given in %s on line %d +NULL + +-- Testing strrchr() function with less than expected no. of arguments -- +Warning: strrchr() expects exactly 2 parameters, 1 given in %s on line %d +NULL + +-- Testing strrchr() function with more than expected no. of arguments -- +Warning: strrchr() expects exactly 2 parameters, 3 given in %s on line %d +NULL +*** Done *** +--UEXPECTF-- +*** Testing strrchr() function: error conditions *** + +-- Testing strrchr() function with Zero arguments -- +Warning: strrchr() expects exactly 2 parameters, 0 given in %s on line %d +NULL + +-- Testing strrchr() function with less than expected no. of arguments -- +Warning: strrchr() expects exactly 2 parameters, 1 given in %s on line %d +NULL + +-- Testing strrchr() function with more than expected no. of arguments -- +Warning: strrchr() expects exactly 2 parameters, 3 given in %s on line %d +NULL +*** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strrchr_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/strrchr_basic.phpt diff -u /dev/null php-src/ext/standard/tests/strings/strrchr_basic.phpt:1.2 --- /dev/null Sat Sep 29 09:24:27 2007 +++ php-src/ext/standard/tests/strings/strrchr_basic.phpt Sat Sep 29 09:24:27 2007 @@ -0,0 +1,75 @@ +--TEST-- +Test strrchr() function : basic functionality +--FILE-- +<?php +/* Prototype : string strrchr(string $haystack, string $needle); + * Description: Finds the last occurrence of a character in a string. + * Source code: ext/standard/string.c +*/ + +echo "*** Testing strrchr() function: basic functionality ***\n"; +var_dump( strrchr("Hello, World", "H") ); //needle as single char +var_dump( strrchr("Hello, World", "Hello") ); //needle as a first word of haystack +var_dump( strrchr('Hello, World', 'H') ); +var_dump( strrchr('Hello, World', 'Hello') ); + +//considering case +var_dump( strrchr("Hello, World", "h") ); +var_dump( strrchr("Hello, World", "hello") ); + +//needle as second word of haystack +var_dump( strrchr("Hello, World", "World") ); +var_dump( strrchr('Hello, World', 'World') ); + +//needle as special char +var_dump( strrchr("Hello, World", ",") ); +var_dump( strrchr('Hello, World', ',') ); + +var_dump( strrchr("Hello, World", "Hello, World") ); //needle as haystack + +//needle string containing one existing and one non-existing char +var_dump( strrchr("Hello, World", "Hi") ); + +//multiple existance of needle in haystack +var_dump( strrchr("Hello, World", "o") ); +var_dump( strrchr("Hello, World", "ooo") ); + +var_dump( strrchr("Hello, World", "Zzzz") ); //non-existant needle in haystack +echo "*** Done ***"; +?> +--EXPECTF-- +*** Testing strrchr() function: basic functionality *** +string(12) "Hello, World" +string(12) "Hello, World" +string(12) "Hello, World" +string(12) "Hello, World" +bool(false) +bool(false) +string(5) "World" +string(5) "World" +string(7) ", World" +string(7) ", World" +string(12) "Hello, World" +string(12) "Hello, World" +string(4) "orld" +string(4) "orld" +bool(false) +*** Done *** +--UEXPECTF-- +*** Testing strrchr() function: basic functionality *** +unicode(12) "Hello, World" +unicode(12) "Hello, World" +unicode(12) "Hello, World" +unicode(12) "Hello, World" +bool(false) +bool(false) +unicode(5) "World" +unicode(5) "World" +unicode(7) ", World" +unicode(7) ", World" +unicode(12) "Hello, World" +unicode(12) "Hello, World" +unicode(4) "orld" +unicode(4) "orld" +bool(false) +*** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strrchr_variation10.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/strrchr_variation10.phpt diff -u /dev/null php-src/ext/standard/tests/strings/strrchr_variation10.phpt:1.2 --- /dev/null Sat Sep 29 09:24:27 2007 +++ php-src/ext/standard/tests/strings/strrchr_variation10.phpt Sat Sep 29 09:24:27 2007 @@ -0,0 +1,251 @@ +--TEST-- +Test strrchr() function : usage variations - unexpected inputs for needle +--FILE-- +<?php +/* Prototype : string strrchr(string $haystack, string $needle); + * Description: Finds the last occurrence of a character in a string. + * Source code: ext/standard/string.c +*/ + +/* Test strrchr() function: with unexpected inputs for needle + * and expected type for haystack +*/ + +echo "*** Testing strrchr() function with unexpected inputs for needle ***\n"; + +// get an unset variable +$unset_var = 'string_val'; +unset($unset_var); + +// declaring a class +class sample { + public function __toString() { + return "object"; + } +} + +//getting the resource +$file_handle = fopen(__FILE__, "r"); + +$haystacks = array ( + //integer numeric strings + "0", + "1", + "2", + "-2", + + //float numeric strings + "10.5", + "-10.5", + "10.5e10", + "10.6E-10", + ".5", + + //regular strings + "array", + "a", + "r", + "y", + "ay", + "true", + "false", + "TRUE", + "FALSE", + "NULL", + "null", + "object", + + //empty string + "", + '', + + //resource variable in string form + "$file_handle", + + //undefined variable in string form + @"$undefined_var", + @"$unset_var" +); + +// array with different values +$needles = 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, + + // null vlaues + NULL, + null, + + // objects + new sample(), + + // empty string + "", + '', + + // resource + $file_handle, + + // undefined variable + @$undefined_var, + + // unset variable + @$unset_var +); + +// loop through each element of the array and check the working of strrchr() +$count = 1; +for($index = 0; $index < count($haystacks); $index++) { + echo "-- Iteration $count --\n"; + var_dump( strrchr($haystacks[$index], $needles[$index]) ); + $count ++; +} + +fclose($file_handle); //closing the file handle + +echo "*** Done ***"; +?> +--EXPECTF-- +*** Testing strrchr() function with unexpected inputs for needle *** +-- Iteration 1 -- +bool(false) +-- Iteration 2 -- +bool(false) +-- Iteration 3 -- +bool(false) +-- Iteration 4 -- +bool(false) +-- Iteration 5 -- +bool(false) +-- Iteration 6 -- +bool(false) +-- Iteration 7 -- +bool(false) +-- Iteration 8 -- +bool(false) +-- Iteration 9 -- +bool(false) +-- Iteration 10 -- +bool(false) +-- Iteration 11 -- +bool(false) +-- Iteration 12 -- +bool(false) +-- Iteration 13 -- +bool(false) +-- Iteration 14 -- +bool(false) +-- Iteration 15 -- +bool(false) +-- Iteration 16 -- +bool(false) +-- Iteration 17 -- +bool(false) +-- Iteration 18 -- +bool(false) +-- Iteration 19 -- +bool(false) +-- Iteration 20 -- +bool(false) +-- Iteration 21 -- + +Notice: Object of class sample could not be converted to int in %s on line %d%d +bool(false) +-- Iteration 22 -- +bool(false) +-- Iteration 23 -- +bool(false) +-- Iteration 24 -- +bool(false) +-- Iteration 25 -- +bool(false) +-- Iteration 26 -- +bool(false) +*** Done *** +--UEXPECTF-- +*** Testing strrchr() function with unexpected inputs for needle *** +-- Iteration 1 -- +bool(false) +-- Iteration 2 -- +bool(false) +-- Iteration 3 -- +bool(false) +-- Iteration 4 -- + +Warning: Needle argument codepoint value out of range (0 - 0x10FFFF) in %s on line %d +bool(false) +-- Iteration 5 -- +bool(false) +-- Iteration 6 -- + +Warning: Needle argument codepoint value out of range (0 - 0x10FFFF) in %s on line %d +bool(false) +-- Iteration 7 -- + +Warning: Needle argument codepoint value out of range (0 - 0x10FFFF) in %s on line %d +bool(false) +-- Iteration 8 -- +bool(false) +-- Iteration 9 -- +bool(false) +-- Iteration 10 -- +bool(false) +-- Iteration 11 -- +bool(false) +-- Iteration 12 -- +bool(false) +-- Iteration 13 -- +bool(false) +-- Iteration 14 -- +bool(false) +-- Iteration 15 -- +bool(false) +-- Iteration 16 -- +bool(false) +-- Iteration 17 -- +bool(false) +-- Iteration 18 -- +bool(false) +-- Iteration 19 -- +bool(false) +-- Iteration 20 -- +bool(false) +-- Iteration 21 -- + +Notice: Object of class sample could not be converted to int in %s on line %d +bool(false) +-- Iteration 22 -- +bool(false) +-- Iteration 23 -- +bool(false) +-- Iteration 24 -- +bool(false) +-- Iteration 25 -- +bool(false) +-- Iteration 26 -- +bool(false) +*** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strrchr_variation11.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/strrchr_variation11.phpt diff -u /dev/null php-src/ext/standard/tests/strings/strrchr_variation11.phpt:1.2 --- /dev/null Sat Sep 29 09:24:27 2007 +++ php-src/ext/standard/tests/strings/strrchr_variation11.phpt Sat Sep 29 09:24:27 2007 @@ -0,0 +1,232 @@ +--TEST-- +Test strrchr() function : usage variations - unexpected inputs for haystack and needle +--FILE-- +<?php +/* Prototype : string strrchr(string $haystack, string $needle); + * Description: Finds the last occurrence of a character in a string. + * Source code: ext/standard/string.c +*/ + +/* Test strrchr() function with unexpected inputs for haystack and needle */ + +echo "*** Testing strrchr() function: with unexpected inputs for haystack and needle ***\n"; + +// get an unset variable +$unset_var = 'string_val'; +unset($unset_var); + +// declaring a class +class sample { + public function __toString() { + return "object"; + } +} + +//getting the 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 strrchr() +$counter = 1; +for($index = 0; $index < count($values); $index ++) { + echo "-- Iteration $counter --\n"; + $haystack = $values[$index]; + + var_dump( strrchr($values[$index], $values[$index]) ); + $counter ++; +} + +fclose($file_handle); //closing the file handle + +echo "*** Done ***"; +?> +--EXPECTF-- +*** Testing strrchr() function: with unexpected inputs for haystack and needle *** +-- Iteration 1 -- +bool(false) +-- Iteration 2 -- +bool(false) +-- Iteration 3 -- +bool(false) +-- Iteration 4 -- +bool(false) +-- Iteration 5 -- +bool(false) +-- Iteration 6 -- +bool(false) +-- Iteration 7 -- +bool(false) +-- Iteration 8 -- +bool(false) +-- Iteration 9 -- +bool(false) +-- Iteration 10 -- + +Notice: Array to string conversion in %s on line %d%d +bool(false) +-- Iteration 11 -- + +Notice: Array to string conversion in %s on line %d%d +bool(false) +-- Iteration 12 -- + +Notice: Array to string conversion in %s on line %d%d +bool(false) +-- Iteration 13 -- + +Notice: Array to string conversion in %s on line %d%d +bool(false) +-- Iteration 14 -- + +Notice: Array to string conversion in %s on line %d%d +bool(false) +-- Iteration 15 -- +bool(false) +-- Iteration 16 -- +bool(false) +-- Iteration 17 -- +bool(false) +-- Iteration 18 -- +bool(false) +-- Iteration 19 -- + +Notice: Object of class sample could not be converted to int in %s on line %d%d +bool(false) +-- Iteration 20 -- +bool(false) +-- Iteration 21 -- +bool(false) +-- Iteration 22 -- +bool(false) +-- Iteration 23 -- +bool(false) +-- Iteration 24 -- +bool(false) +-- Iteration 25 -- +bool(false) +-- Iteration 26 -- +bool(false) +*** Done *** +--UEXPECTF-- +*** Testing strrchr() function: with unexpected inputs for haystack and needle *** +-- Iteration 1 -- +bool(false) +-- Iteration 2 -- +bool(false) +-- Iteration 3 -- +bool(false) +-- Iteration 4 -- + +Warning: Needle argument codepoint value out of range (0 - 0x10FFFF) in %s on line %d +bool(false) +-- Iteration 5 -- +bool(false) +-- Iteration 6 -- + +Warning: Needle argument codepoint value out of range (0 - 0x10FFFF) in %s on line %d +bool(false) +-- Iteration 7 -- + +Warning: Needle argument codepoint value out of range (0 - 0x10FFFF) in %s on line %d +bool(false) +-- Iteration 8 -- +bool(false) +-- Iteration 9 -- +bool(false) +-- Iteration 10 -- + +Notice: Array to string conversion in %s on line %d +bool(false) +-- Iteration 11 -- + +Notice: Array to string conversion in %s on line %d +bool(false) +-- Iteration 12 -- + +Notice: Array to string conversion in %s on line %d +bool(false) +-- Iteration 13 -- + +Notice: Array to string conversion in %s on line %d +bool(false) +-- Iteration 14 -- + +Notice: Array to string conversion in %s on line %d +bool(false) +-- Iteration 15 -- +bool(false) +-- Iteration 16 -- +bool(false) +-- Iteration 17 -- +bool(false) +-- Iteration 18 -- +bool(false) +-- Iteration 19 -- + +Notice: Object of class sample could not be converted to int in %s on line %d +bool(false) +-- Iteration 20 -- +bool(false) +-- Iteration 21 -- +bool(false) +-- Iteration 22 -- +bool(false) +-- Iteration 23 -- +bool(false) +-- Iteration 24 -- +bool(false) +-- Iteration 25 -- +bool(false) +-- Iteration 26 -- +bool(false) +*** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/strrchr_variation12.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/strings/strrchr_variation12.phpt
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php