From efc32bacaac35d5de812cb04f0447e880a7b9b88 Mon Sep 17 00:00:00 2001 From: Raghubansh Kumar Date: Sat, 29 Sep 2007 16:56:46 +0000 Subject: [PATCH] New testcases for stripos() function --- .../tests/strings/stripos_basic1.phpt | 48 ++++ .../tests/strings/stripos_basic2.phpt | 52 ++++ ext/standard/tests/strings/stripos_error.phpt | 35 +++ .../tests/strings/stripos_variation1.phpt | 226 +++++++++++++++++ .../tests/strings/stripos_variation10.phpt | 196 +++++++++++++++ .../tests/strings/stripos_variation11.phpt | 215 ++++++++++++++++ .../tests/strings/stripos_variation12.phpt | 47 ++++ .../tests/strings/stripos_variation13.phpt | 49 ++++ .../tests/strings/stripos_variation14.phpt | 155 ++++++++++++ .../tests/strings/stripos_variation15.phpt | 171 +++++++++++++ .../tests/strings/stripos_variation2.phpt | 234 ++++++++++++++++++ .../tests/strings/stripos_variation3.phpt | 37 +++ .../tests/strings/stripos_variation4.phpt | 41 +++ .../tests/strings/stripos_variation5.phpt | 34 +++ .../tests/strings/stripos_variation6.phpt | 35 +++ .../tests/strings/stripos_variation7.phpt | 34 +++ .../tests/strings/stripos_variation8.phpt | 216 ++++++++++++++++ .../tests/strings/stripos_variation9.phpt | 184 ++++++++++++++ 18 files changed, 2009 insertions(+) create mode 100644 ext/standard/tests/strings/stripos_basic1.phpt create mode 100644 ext/standard/tests/strings/stripos_basic2.phpt create mode 100644 ext/standard/tests/strings/stripos_error.phpt create mode 100644 ext/standard/tests/strings/stripos_variation1.phpt create mode 100644 ext/standard/tests/strings/stripos_variation10.phpt create mode 100644 ext/standard/tests/strings/stripos_variation11.phpt create mode 100644 ext/standard/tests/strings/stripos_variation12.phpt create mode 100644 ext/standard/tests/strings/stripos_variation13.phpt create mode 100644 ext/standard/tests/strings/stripos_variation14.phpt create mode 100644 ext/standard/tests/strings/stripos_variation15.phpt create mode 100644 ext/standard/tests/strings/stripos_variation2.phpt create mode 100644 ext/standard/tests/strings/stripos_variation3.phpt create mode 100644 ext/standard/tests/strings/stripos_variation4.phpt create mode 100644 ext/standard/tests/strings/stripos_variation5.phpt create mode 100644 ext/standard/tests/strings/stripos_variation6.phpt create mode 100644 ext/standard/tests/strings/stripos_variation7.phpt create mode 100644 ext/standard/tests/strings/stripos_variation8.phpt create mode 100644 ext/standard/tests/strings/stripos_variation9.phpt diff --git a/ext/standard/tests/strings/stripos_basic1.phpt b/ext/standard/tests/strings/stripos_basic1.phpt new file mode 100644 index 00000000000..cffbdba1b59 --- /dev/null +++ b/ext/standard/tests/strings/stripos_basic1.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test stripos() function : basic functionality - with default arguments +--FILE-- + +--EXPECTF-- +*** Testing stripos() function: basic functionality *** +-- With default arguments -- +int(0) +int(0) +int(7) +int(7) +int(4) +int(5) +int(0) +int(0) +int(0) +bool(false) +*** Done *** diff --git a/ext/standard/tests/strings/stripos_basic2.phpt b/ext/standard/tests/strings/stripos_basic2.phpt new file mode 100644 index 00000000000..3022bae1680 --- /dev/null +++ b/ext/standard/tests/strings/stripos_basic2.phpt @@ -0,0 +1,52 @@ +--TEST-- +Test stripos() function : basic functionality - with all arguments +--FILE-- + +--EXPECTF-- +*** Testing stripos() function: basic functionality *** +-- With all arguments -- +int(0) +bool(false) +int(7) +int(7) +int(0) +int(0) +bool(false) +int(0) +bool(false) +int(4) +int(8) +int(8) +bool(false) +*** Done *** diff --git a/ext/standard/tests/strings/stripos_error.phpt b/ext/standard/tests/strings/stripos_error.phpt new file mode 100644 index 00000000000..ef6ad9e6ec2 --- /dev/null +++ b/ext/standard/tests/strings/stripos_error.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test stripos() function : error conditions +--FILE-- + +--EXPECTF-- +*** Testing stripos() function: error conditions *** + +-- With Zero arguments -- +Warning: stripos() expects at least 2 parameters, 0 given in %s on line %d +NULL + +-- With less than expected number of arguments -- +Warning: stripos() expects at least 2 parameters, 1 given in %s on line %d +NULL + +-- With more than expected number of arguments -- +Warning: stripos() expects at most 3 parameters, 4 given in %s on line %d +NULL +*** Done *** diff --git a/ext/standard/tests/strings/stripos_variation1.phpt b/ext/standard/tests/strings/stripos_variation1.phpt new file mode 100644 index 00000000000..38d2578d956 --- /dev/null +++ b/ext/standard/tests/strings/stripos_variation1.phpt @@ -0,0 +1,226 @@ +--TEST-- +Test stripos() function : usage variations - double quoted strings for 'haystack' & 'needle' arguments +--FILE-- +?@hello123456he \x234 \101 "; +$needle = array( + //regular strings + "l", + "L", + "HELLO", + "hEllo", + + //escape characters + "\t", + "\T", //invalid input + " ", + "\n", + "\N", //invalid input + " +", //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 + "#", //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; +for($index=0; $index +--EXPECTF-- +*** Testing stripos() function: with double quoted strings *** +-- Iteration 1 -- +int(2) +int(2) +-- Iteration 2 -- +int(2) +int(2) +-- Iteration 3 -- +int(0) +int(34) +-- Iteration 4 -- +int(0) +int(34) +-- Iteration 5 -- +int(6) +int(6) +-- Iteration 6 -- +bool(false) +bool(false) +-- Iteration 7 -- +bool(false) +bool(false) +-- Iteration 8 -- +int(7) +int(7) +-- Iteration 9 -- +bool(false) +bool(false) +-- Iteration 10 -- +int(7) +int(9) +-- Iteration 11 -- +int(8) +bool(false) +-- Iteration 12 -- + +Warning: stripos(): needle is not a string or an integer. in %s on line %d +bool(false) + +Warning: stripos(): needle is not a string or an integer. in %s on line %d +bool(false) +-- Iteration 13 -- + +Warning: stripos(): needle is not a string or an integer. in %s on line %d +bool(false) + +Warning: stripos(): needle is not a string or an integer. in %s on line %d +bool(false) +-- Iteration 14 -- +int(8) +bool(false) +-- Iteration 15 -- +int(8) +bool(false) +-- Iteration 16 -- +bool(false) +bool(false) +-- Iteration 17 -- +int(10) +int(47) +-- Iteration 18 -- +int(12) +bool(false) +-- Iteration 19 -- +int(11) +bool(false) +-- Iteration 20 -- +int(13) +bool(false) +-- Iteration 21 -- +int(14) +bool(false) +-- Iteration 22 -- +int(16) +bool(false) +-- Iteration 23 -- +int(17) +bool(false) +-- Iteration 24 -- +int(20) +bool(false) +-- Iteration 25 -- +int(22) +bool(false) +-- Iteration 26 -- +int(23) +bool(false) +-- Iteration 27 -- +int(24) +bool(false) +-- Iteration 28 -- +int(25) +bool(false) +-- Iteration 29 -- +bool(false) +bool(false) +-- Iteration 30 -- +int(27) +bool(false) +-- Iteration 31 -- +int(28) +bool(false) +-- Iteration 32 -- +int(29) +bool(false) +-- Iteration 33 -- +int(31) +bool(false) +-- Iteration 34 -- +int(30) +bool(false) +-- Iteration 35 -- +int(32) +bool(false) +-- Iteration 36 -- +int(33) +bool(false) +-- Iteration 37 -- +int(33) +bool(false) +-- Iteration 38 -- +int(39) +int(39) +-- Iteration 39 -- +int(15) +int(48) +-- Iteration 40 -- +int(15) +int(48) +-- Iteration 41 -- +int(51) +int(51) +-- Iteration 42 -- +int(51) +int(51) +-- Iteration 43 -- +bool(false) +bool(false) +-- Iteration 44 -- +int(0) +bool(false) +*** Done *** diff --git a/ext/standard/tests/strings/stripos_variation10.phpt b/ext/standard/tests/strings/stripos_variation10.phpt new file mode 100644 index 00000000000..5b79b99e322 --- /dev/null +++ b/ext/standard/tests/strings/stripos_variation10.phpt @@ -0,0 +1,196 @@ +--TEST-- +Test stripos() function : usage variations - unexpected inputs for 'needle' argument +--FILE-- + '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 'needle' array to check the working of stripos() +$counter = 1; +for($index = 0; $index < count($needles); $index ++) { + echo "\n-- Iteration $counter --\n"; + var_dump( stripos($haystack, $needles[$index]) ); + $counter ++; +} + +fclose($file_handle); //closing the file handle + +echo "*** Done ***"; +?> +--EXPECTF-- +*** Testing stripos() function with unexpected values 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 -- + +Warning: stripos(): needle is not a string or an integer. in %s on line %d +bool(false) + +-- Iteration 11 -- + +Warning: stripos(): needle is not a string or an integer. in %s on line %d +bool(false) + +-- Iteration 12 -- + +Warning: stripos(): needle is not a string or an integer. in %s on line %d +bool(false) + +-- Iteration 13 -- + +Warning: stripos(): needle is not a string or an integer. in %s on line %d +bool(false) + +-- Iteration 14 -- + +Warning: stripos(): needle is not a string or an integer. 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 -- + +Warning: stripos(): needle is not a string or an integer. in %s on line %d +bool(false) + +-- Iteration 20 -- +bool(false) + +-- Iteration 21 -- +bool(false) + +-- Iteration 22 -- + +Warning: stripos(): needle is not a string or an integer. in %s on line %d +bool(false) + +-- Iteration 23 -- + +Warning: stripos(): needle is not a string or an integer. in %s on line %d +bool(false) + +-- Iteration 24 -- + +Warning: stripos(): needle is not a string or an integer. in %s on line %d +bool(false) + +-- Iteration 25 -- + +Warning: stripos(): needle is not a string or an integer. in %s on line %d +bool(false) + +-- Iteration 26 -- + +Warning: stripos(): needle is not a string or an integer. in %s on line %d +bool(false) +*** Done *** diff --git a/ext/standard/tests/strings/stripos_variation11.phpt b/ext/standard/tests/strings/stripos_variation11.phpt new file mode 100644 index 00000000000..b29b1a87e67 --- /dev/null +++ b/ext/standard/tests/strings/stripos_variation11.phpt @@ -0,0 +1,215 @@ +--TEST-- +Test stripos() function : usage variations - unexpected inputs for 'haystack' and 'needle' arguments +--FILE-- + '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 stripos() +$counter = 1; +for($index = 0; $index < count($values); $index ++) { + echo "-- Iteration $counter --\n"; + $haystack = $values[$index]; + var_dump( stripos($values[$index], $values[$index]) ); + var_dump( stripos($values[$index], $values[$index], 1) ); + $counter ++; +} + +echo "*** Done ***"; +?> +--EXPECTF-- +*** Testing stripos() function with unexpected values for haystack and needle *** +-- Iteration 1 -- +bool(false) +bool(false) +-- Iteration 2 -- +bool(false) +bool(false) +-- Iteration 3 -- +bool(false) +bool(false) +-- Iteration 4 -- +bool(false) +bool(false) +-- Iteration 5 -- +bool(false) +bool(false) +-- Iteration 6 -- +bool(false) +bool(false) +-- Iteration 7 -- +bool(false) +bool(false) +-- Iteration 8 -- +bool(false) +bool(false) +-- Iteration 9 -- +bool(false) +bool(false) +-- Iteration 10 -- + +Warning: stripos() expects parameter 1 to be string, array given in %s on line %d +NULL + +Warning: stripos() expects parameter 1 to be string, array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: stripos() expects parameter 1 to be string, array given in %s on line %d +NULL + +Warning: stripos() expects parameter 1 to be string, array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: stripos() expects parameter 1 to be string, array given in %s on line %d +NULL + +Warning: stripos() expects parameter 1 to be string, array given in %s on line %d +NULL +-- Iteration 13 -- + +Warning: stripos() expects parameter 1 to be string, array given in %s on line %d +NULL + +Warning: stripos() expects parameter 1 to be string, array given in %s on line %d +NULL +-- Iteration 14 -- + +Warning: stripos() expects parameter 1 to be string, array given in %s on line %d +NULL + +Warning: stripos() expects parameter 1 to be string, array given in %s on line %d +NULL +-- Iteration 15 -- +bool(false) +bool(false) +-- Iteration 16 -- +bool(false) + +Warning: stripos(): Offset not contained in string. in %s on line %d +bool(false) +-- Iteration 17 -- +bool(false) +bool(false) +-- Iteration 18 -- +bool(false) + +Warning: stripos(): Offset not contained in string. in %s on line %d +bool(false) +-- Iteration 19 -- + +Warning: stripos(): needle is not a string or an integer. in %s on line %d +bool(false) + +Warning: stripos(): needle is not a string or an integer. in %s on line %d +bool(false) +-- Iteration 20 -- +bool(false) + +Warning: stripos(): Offset not contained in string. in %s on line %d +bool(false) +-- Iteration 21 -- +bool(false) + +Warning: stripos(): Offset not contained in string. in %s on line %d +bool(false) +-- Iteration 22 -- +bool(false) + +Warning: stripos(): Offset not contained in string. in %s on line %d +bool(false) +-- Iteration 23 -- +bool(false) + +Warning: stripos(): Offset not contained in string. in %s on line %d +bool(false) +-- Iteration 24 -- + +Warning: stripos() expects parameter 1 to be string, resource given in %s on line %d +NULL + +Warning: stripos() expects parameter 1 to be string, resource given in %s on line %d +NULL +-- Iteration 25 -- +bool(false) + +Warning: stripos(): Offset not contained in string. in %s on line %d +bool(false) +-- Iteration 26 -- +bool(false) + +Warning: stripos(): Offset not contained in string. in %s on line %d +bool(false) +*** Done *** diff --git a/ext/standard/tests/strings/stripos_variation12.phpt b/ext/standard/tests/strings/stripos_variation12.phpt new file mode 100644 index 00000000000..bd0d8aeb8f1 --- /dev/null +++ b/ext/standard/tests/strings/stripos_variation12.phpt @@ -0,0 +1,47 @@ +--TEST-- +Test stripos() function : usage variations - null terminated strings for 'haystack' argument +--FILE-- + +--EXPECTF-- +*** Test stripos() function: binary safe *** +int(5) +int(5) +int(0) +bool(false) +int(11) +int(11) +int(0) +bool(false) +int(5) +int(5) +int(0) +bool(false) +int(5) +bool(false) +*** Done *** diff --git a/ext/standard/tests/strings/stripos_variation13.phpt b/ext/standard/tests/strings/stripos_variation13.phpt new file mode 100644 index 00000000000..3c4508f0837 --- /dev/null +++ b/ext/standard/tests/strings/stripos_variation13.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test stripos() function : usage variations - null terminated strings for 'needle' argument +--FILE-- + +--EXPECTF-- +*** Test stripos() function: binary safe *** +int(1) +int(1) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +bool(false) +int(1) +bool(false) +int(0) +bool(false) +int(1) +bool(false) +*** Done *** diff --git a/ext/standard/tests/strings/stripos_variation14.phpt b/ext/standard/tests/strings/stripos_variation14.phpt new file mode 100644 index 00000000000..4cd2e75bcf5 --- /dev/null +++ b/ext/standard/tests/strings/stripos_variation14.phpt @@ -0,0 +1,155 @@ +--TEST-- +Test stripos() function : usage variations - unexpected inputs for 'offset' argument +--FILE-- + '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 stripos() +$counter = 1; +for($index = 0; $index < count($offsets); $index ++) { + echo "-- Iteration $counter --\n"; + var_dump( stripos($haystack, $needle, $offsets[$index]) ); + $counter ++; +} + +echo "*** Done ***"; +?> +--EXPECTF-- +*** Testing stripos() function with unexpected values for offset *** +-- Iteration 1 -- +int(6) +-- Iteration 2 -- + +Warning: stripos(): Offset not contained in string. in %s on line %d +bool(false) +-- Iteration 3 -- + +Warning: stripos(): Offset not contained in string. in %s on line %d +bool(false) +-- Iteration 4 -- +int(6) +-- Iteration 5 -- +int(6) +-- Iteration 6 -- + +Warning: stripos() expects parameter 3 to be long, array given in %s on line %d +NULL +-- Iteration 7 -- + +Warning: stripos() expects parameter 3 to be long, array given in %s on line %d +NULL +-- Iteration 8 -- + +Warning: stripos() expects parameter 3 to be long, array given in %s on line %d +NULL +-- Iteration 9 -- + +Warning: stripos() expects parameter 3 to be long, array given in %s on line %d +NULL +-- Iteration 10 -- + +Warning: stripos() expects parameter 3 to be long, array given in %s on line %d +NULL +-- Iteration 11 -- +int(6) +-- Iteration 12 -- +int(6) +-- Iteration 13 -- +int(6) +-- Iteration 14 -- +int(6) +-- Iteration 15 -- + +Warning: stripos() expects parameter 3 to be long, object given in %s on line %d +NULL +-- Iteration 16 -- + +Warning: stripos() expects parameter 3 to be long, string given in %s on line %d +NULL +-- Iteration 17 -- + +Warning: stripos() expects parameter 3 to be long, string given in %s on line %d +NULL +-- Iteration 18 -- +int(6) +-- Iteration 19 -- +int(6) +-- Iteration 20 -- + +Warning: stripos() expects parameter 3 to be long, resource given in %s on line %d +NULL +-- Iteration 21 -- +int(6) +-- Iteration 22 -- +int(6) +*** Done *** diff --git a/ext/standard/tests/strings/stripos_variation15.phpt b/ext/standard/tests/strings/stripos_variation15.phpt new file mode 100644 index 00000000000..59ac83f7011 --- /dev/null +++ b/ext/standard/tests/strings/stripos_variation15.phpt @@ -0,0 +1,171 @@ +--TEST-- +Test stripos() function : usage variations - unexpected inputs for 'haystack', 'needle' & 'offset' arguments +--FILE-- + '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 stripos() +$counter = 1; +for($index = 0; $index < count($values); $index ++) { + echo "-- Iteration $counter --\n"; + var_dump( stripos($values[$index], $values[$index], $values[$index]) ); + $counter ++; +} + +echo "*** Done ***"; +?> +--EXPECTF-- +*** Testing stripos() function with unexpected values for haystack, needle & offset *** +-- Iteration 1 -- +bool(false) +-- Iteration 2 -- +bool(false) +-- Iteration 3 -- + +Warning: stripos(): Offset not contained in string. in %s on line %d +bool(false) +-- Iteration 4 -- + +Warning: stripos(): Offset not contained in string. in %s on line %d +bool(false) +-- Iteration 5 -- + +Warning: stripos(): Offset not contained in string. in %s on line %d +bool(false) +-- Iteration 6 -- + +Warning: stripos(): Offset not contained in string. in %s on line %d +bool(false) +-- Iteration 7 -- + +Warning: stripos(): Offset not contained in string. in %s on line %d +bool(false) +-- Iteration 8 -- +bool(false) +-- Iteration 9 -- +bool(false) +-- Iteration 10 -- + +Warning: stripos() expects parameter 1 to be string, array given in %s on line %d +NULL +-- Iteration 11 -- + +Warning: stripos() expects parameter 1 to be string, array given in %s on line %d +NULL +-- Iteration 12 -- + +Warning: stripos() expects parameter 1 to be string, array given in %s on line %d +NULL +-- Iteration 13 -- + +Warning: stripos() expects parameter 1 to be string, array given in %s on line %d +NULL +-- Iteration 14 -- + +Warning: stripos() expects parameter 1 to be string, array given in %s on line %d +NULL +-- Iteration 15 -- +bool(false) +-- Iteration 16 -- +bool(false) +-- Iteration 17 -- +bool(false) +-- Iteration 18 -- +bool(false) +-- Iteration 19 -- + +Warning: stripos() expects parameter 3 to be long, object given in %s on line %d +NULL +-- Iteration 20 -- + +Warning: stripos() expects parameter 3 to be long, string given in %s on line %d +NULL +-- Iteration 21 -- + +Warning: stripos() expects parameter 3 to be long, string given in %s on line %d +NULL +-- Iteration 22 -- +bool(false) +-- Iteration 23 -- +bool(false) +-- Iteration 24 -- + +Warning: stripos() expects parameter 1 to be string, resource given in %s on line %d +NULL +-- Iteration 25 -- +bool(false) +-- Iteration 26 -- +bool(false) +*** Done *** diff --git a/ext/standard/tests/strings/stripos_variation2.phpt b/ext/standard/tests/strings/stripos_variation2.phpt new file mode 100644 index 00000000000..2f02b0e51ac --- /dev/null +++ b/ext/standard/tests/strings/stripos_variation2.phpt @@ -0,0 +1,234 @@ +--TEST-- +Test stripos() function : usage variations - single quoted strings for 'haystack' & 'needle' arguments +--FILE-- +?@hello123456he \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 +--EXPECTF-- +*** Testing stripos() function: with single quoted strings *** +-- Iteration 1 -- +int(2) +int(2) +-- Iteration 2 -- +int(2) +int(2) +-- Iteration 3 -- +int(0) +int(38) +-- Iteration 4 -- +int(0) +int(38) +-- Iteration 5 -- +int(6) +int(6) +-- Iteration 6 -- +int(6) +int(6) +-- Iteration 7 -- +bool(false) +bool(false) +-- Iteration 8 -- +int(8) +int(8) +-- Iteration 9 -- +int(8) +int(8) +-- Iteration 10 -- +bool(false) +bool(false) +-- Iteration 11 -- +int(10) +int(10) +-- Iteration 12 -- + +Warning: stripos(): needle is not a string or an integer. in %s on line %d +bool(false) + +Warning: stripos(): needle is not a string or an integer. in %s on line %d +bool(false) +-- Iteration 13 -- + +Warning: stripos(): needle is not a string or an integer. in %s on line %d +bool(false) + +Warning: stripos(): needle is not a string or an integer. in %s on line %d +bool(false) +-- Iteration 14 -- +bool(false) +bool(false) +-- Iteration 15 -- +bool(false) +bool(false) +-- Iteration 16 -- +bool(false) +bool(false) +-- Iteration 17 -- +int(14) +int(51) +-- Iteration 18 -- +int(16) +bool(false) +-- Iteration 19 -- +int(15) +bool(false) +-- Iteration 20 -- +int(17) +bool(false) +-- Iteration 21 -- +int(18) +bool(false) +-- Iteration 22 -- +int(20) +bool(false) +-- Iteration 23 -- +int(21) +bool(false) +-- Iteration 24 -- +int(24) +int(24) +-- Iteration 25 -- +int(26) +int(26) +-- Iteration 26 -- +int(27) +int(27) +-- Iteration 27 -- +int(28) +int(28) +-- Iteration 28 -- +int(29) +int(29) +-- Iteration 29 -- +bool(false) +bool(false) +-- Iteration 30 -- +bool(false) +bool(false) +-- Iteration 31 -- +int(31) +int(31) +-- Iteration 32 -- +int(32) +int(32) +-- Iteration 33 -- +int(33) +int(33) +-- Iteration 34 -- +int(35) +int(35) +-- Iteration 35 -- +int(34) +int(34) +-- Iteration 36 -- +int(36) +int(36) +-- Iteration 37 -- +int(37) +int(37) +-- Iteration 38 -- +int(37) +int(37) +-- Iteration 39 -- +int(43) +int(43) +-- Iteration 40 -- +int(52) +int(52) +-- Iteration 41 -- +int(19) +bool(false) +-- Iteration 42 -- +int(58) +int(58) +-- Iteration 43 -- +bool(false) +bool(false) +-- Iteration 44 -- +bool(false) +bool(false) +-- Iteration 45 -- +int(26) +bool(false) +-- Iteration 46 -- +int(0) +bool(false) +*** Done *** diff --git a/ext/standard/tests/strings/stripos_variation3.phpt b/ext/standard/tests/strings/stripos_variation3.phpt new file mode 100644 index 00000000000..40cdea48fe8 --- /dev/null +++ b/ext/standard/tests/strings/stripos_variation3.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test stripos() function : usage variations - multi line heredoc string for 'haystack' argument +--FILE-- + +--EXPECTF-- +*** Testing stripos() function: with heredoc strings *** +-- With heredoc string containing multi lines -- +int(14) +int(23) +int(23) +bool(false) +int(7) +*** Done *** diff --git a/ext/standard/tests/strings/stripos_variation4.phpt b/ext/standard/tests/strings/stripos_variation4.phpt new file mode 100644 index 00000000000..8249ef0f608 --- /dev/null +++ b/ext/standard/tests/strings/stripos_variation4.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test stripos() function : usage variations - heredoc string containing special chars for 'haystack' argument +--FILE-- + +--EXPECTF-- +*** Testing stripos() function: with heredoc strings *** +-- With heredoc string containing special chars -- +int(0) +bool(false) +int(38) +int(39) +int(55) +int(55) +int(57) +*** Done *** diff --git a/ext/standard/tests/strings/stripos_variation5.phpt b/ext/standard/tests/strings/stripos_variation5.phpt new file mode 100644 index 00000000000..900fe04bb7e --- /dev/null +++ b/ext/standard/tests/strings/stripos_variation5.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test stripos() function : usage variations - heredoc string containing escape chars for 'haystack' argument +--FILE-- + +--EXPECTF-- +*** Testing stripos() function: with heredoc strings *** +-- With heredoc string containing escape characters -- +int(12) +int(19) +int(12) +int(19) +*** Done *** diff --git a/ext/standard/tests/strings/stripos_variation6.phpt b/ext/standard/tests/strings/stripos_variation6.phpt new file mode 100644 index 00000000000..c69ee174d19 --- /dev/null +++ b/ext/standard/tests/strings/stripos_variation6.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test stripos() function : usage variations - heredoc string containing quotes for 'haystack' argument +--FILE-- + +--EXPECTF-- +*** Testing stripos() function: with heredoc strings *** +-- With heredoc string containing quote & slash chars -- +int(88) +int(34) +int(34) +int(34) +*** Done *** diff --git a/ext/standard/tests/strings/stripos_variation7.phpt b/ext/standard/tests/strings/stripos_variation7.phpt new file mode 100644 index 00000000000..75d0ddfb848 --- /dev/null +++ b/ext/standard/tests/strings/stripos_variation7.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test stripos() function : usage variations - empty heredoc string for 'haystack' argument +--FILE-- + +--EXPECTF-- +*** Testing stripos() function: with heredoc strings *** +-- With empty heredoc string -- +bool(false) + +Warning: stripos(): Offset not contained in string. in %s on line %d +bool(false) +bool(false) +bool(false) +*** Done *** diff --git a/ext/standard/tests/strings/stripos_variation8.phpt b/ext/standard/tests/strings/stripos_variation8.phpt new file mode 100644 index 00000000000..cbf96bf12a3 --- /dev/null +++ b/ext/standard/tests/strings/stripos_variation8.phpt @@ -0,0 +1,216 @@ +--TEST-- +Test stripos() function : usage variations - repetitive chars for 'haystack' argument +--FILE-- + +--EXPECTF-- +*** Testing stripos() function: strings repetitive chars *** + +-- Iteration 1 -- +int(0) +int(2) +int(2) +int(4) +int(4) +int(6) +int(6) +int(8) +int(8) +int(10) +int(10) +int(12) +int(12) +int(14) +int(14) +int(16) +int(16) +bool(false) +bool(false) +bool(false) + +-- Iteration 2 -- +int(0) +int(2) +int(2) +int(4) +int(4) +int(6) +int(6) +int(8) +int(8) +int(10) +int(10) +int(12) +int(12) +int(14) +int(14) +int(16) +int(16) +bool(false) +bool(false) +bool(false) + +-- Iteration 3 -- +int(0) +int(2) +int(2) +int(4) +int(4) +int(6) +int(6) +int(8) +int(8) +int(10) +int(10) +int(12) +int(12) +int(14) +int(14) +int(16) +int(16) +bool(false) +bool(false) +bool(false) + +-- Iteration 4 -- +int(0) +int(2) +int(2) +int(4) +int(4) +int(6) +int(6) +int(8) +int(8) +int(10) +int(10) +int(12) +int(12) +int(14) +int(14) +int(16) +int(16) +bool(false) +bool(false) +bool(false) + +-- Iteration 5 -- +int(1) +int(1) +int(3) +int(3) +int(5) +int(5) +int(7) +int(7) +int(9) +int(9) +int(11) +int(11) +int(13) +int(13) +int(15) +int(15) +bool(false) +bool(false) +bool(false) +bool(false) + +-- Iteration 6 -- +int(1) +int(1) +int(3) +int(3) +int(5) +int(5) +int(7) +int(7) +int(9) +int(9) +int(11) +int(11) +int(13) +int(13) +int(15) +int(15) +bool(false) +bool(false) +bool(false) +bool(false) + +-- Iteration 7 -- +int(1) +int(1) +int(3) +int(3) +int(5) +int(5) +int(7) +int(7) +int(9) +int(9) +int(11) +int(11) +int(13) +int(13) +int(15) +int(15) +bool(false) +bool(false) +bool(false) +bool(false) + +-- Iteration 8 -- +int(1) +int(1) +int(3) +int(3) +int(5) +int(5) +int(7) +int(7) +int(9) +int(9) +int(11) +int(11) +int(13) +int(13) +int(15) +int(15) +bool(false) +bool(false) +bool(false) +bool(false) +*** Done *** diff --git a/ext/standard/tests/strings/stripos_variation9.phpt b/ext/standard/tests/strings/stripos_variation9.phpt new file mode 100644 index 00000000000..1401dcfae8f --- /dev/null +++ b/ext/standard/tests/strings/stripos_variation9.phpt @@ -0,0 +1,184 @@ +--TEST-- +Test stripos() function : usage variations - unexpected inputs for 'haystack' argument +--FILE-- + '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 +); + +$needle = "heredoc 0 1 2 -2 10.5 -10.5 10.5e10 10.6E-10 .5 array true false object \"\" null Resource"; + +// loop through each element of the array and check the working of stripos() +$counter = 1; +for($index = 0; $index < count($haystacks); $index ++) { + echo "\n-- Iteration $counter --\n"; + var_dump( stripos($haystacks[$index], $needle) ); + $counter ++; +} + +fclose($file_handle); //closing the file handle + +echo "*** Done ***"; +?> +--EXPECTF-- +*** Testing stripos() function with unexpected values for haystack *** + +-- 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 -- + +Warning: stripos() expects parameter 1 to be string, array given in %s on line %d +NULL + +-- Iteration 11 -- + +Warning: stripos() expects parameter 1 to be string, array given in %s on line %d +NULL + +-- Iteration 12 -- + +Warning: stripos() expects parameter 1 to be string, array given in %s on line %d +NULL + +-- Iteration 13 -- + +Warning: stripos() expects parameter 1 to be string, array given in %s on line %d +NULL + +-- Iteration 14 -- + +Warning: stripos() expects parameter 1 to be string, array given in %s on line %d +NULL + +-- 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 -- +bool(false) + +-- Iteration 22 -- +bool(false) + +-- Iteration 23 -- +bool(false) + +-- Iteration 24 -- + +Warning: stripos() expects parameter 1 to be string, resource given in %s on line %d +NULL + +-- Iteration 25 -- +bool(false) + +-- Iteration 26 -- +bool(false) +*** Done ***