diff options
Diffstat (limited to 'ext/standard/tests/strings')
-rw-r--r-- | ext/standard/tests/strings/bug40754.phpt | 6 | ||||
-rw-r--r-- | ext/standard/tests/strings/bug53021.phpt | 6 | ||||
-rw-r--r-- | ext/standard/tests/strings/bug55871.phpt | 2 | ||||
-rw-r--r-- | ext/standard/tests/strings/html_entity_decode3.phpt | 45 | ||||
-rw-r--r-- | ext/standard/tests/strings/stripos_basic2.phpt | 20 | ||||
-rw-r--r-- | ext/standard/tests/strings/stripos_error.phpt | 15 | ||||
-rw-r--r-- | ext/standard/tests/strings/stripos_variation14.phpt | 6 | ||||
-rw-r--r-- | ext/standard/tests/strings/strpos.phpt | bin | 9999 -> 10239 bytes | |||
-rw-r--r-- | ext/standard/tests/strings/substr_count_basic.phpt | 8 | ||||
-rw-r--r-- | ext/standard/tests/strings/substr_count_error.phpt | 40 | ||||
-rw-r--r-- | ext/standard/tests/strings/unpack_error.phpt | 6 | ||||
-rw-r--r-- | ext/standard/tests/strings/unpack_offset.phpt | 17 | ||||
-rw-r--r-- | ext/standard/tests/strings/url_t.phpt | 34 |
13 files changed, 138 insertions, 67 deletions
diff --git a/ext/standard/tests/strings/bug40754.phpt b/ext/standard/tests/strings/bug40754.phpt index 6cfe47056b..84e4337463 100644 --- a/ext/standard/tests/strings/bug40754.phpt +++ b/ext/standard/tests/strings/bug40754.phpt @@ -32,7 +32,7 @@ var_dump(substr("abcde", $v, $v)); bool(false) bool(false) -Warning: substr_count(): Offset value 2147483647 exceeds string length in %s on line %d +Warning: substr_count(): Offset not contained in string in %s on line %d bool(false) Warning: substr_compare(): The start position cannot exceed initial string length in %s on line %d @@ -41,10 +41,10 @@ bool(false) Warning: stripos(): Offset not contained in string in %s on line %d bool(false) -Warning: substr_count(): Offset value 2147483647 exceeds string length in %s on line %d +Warning: substr_count(): Offset not contained in string in %s on line %d bool(false) -Warning: substr_count(): Length value 2147483647 exceeds string length in %s on line %d +Warning: substr_count(): Invalid length value in %s on line %d bool(false) Warning: strpos(): Offset not contained in string in %s on line %d diff --git a/ext/standard/tests/strings/bug53021.phpt b/ext/standard/tests/strings/bug53021.phpt index 4a8fbe4f76..38d904761d 100644 --- a/ext/standard/tests/strings/bug53021.phpt +++ b/ext/standard/tests/strings/bug53021.phpt @@ -10,11 +10,14 @@ echo html_entity_decode(""", ENT_QUOTES, 'UTF-8'), "\n"; echo html_entity_decode(""", ENT_QUOTES, 'UTF-8'), "\n";
echo html_entity_decode(""", ENT_COMPAT, 'UTF-8'), "\n";
echo html_entity_decode(""", ENT_COMPAT, 'UTF-8'), "\n";
+echo html_entity_decode("""), "\n";
+echo html_entity_decode("""), "\n";
echo "\nsingle quotes variations:", "\n";
echo html_entity_decode("'", ENT_NOQUOTES, 'UTF-8'), "\n";
echo html_entity_decode("'", ENT_QUOTES, 'UTF-8'), "\n";
echo html_entity_decode("'", ENT_COMPAT, 'UTF-8'), "\n";
+echo html_entity_decode("'"), "\n";
--EXPECT--
array(1) {
[1]=>
@@ -27,8 +30,11 @@ double quotes variations: "
"
"
+"
+"
single quotes variations:
'
'
'
+'
diff --git a/ext/standard/tests/strings/bug55871.phpt b/ext/standard/tests/strings/bug55871.phpt index 249d1bd3a3..0044f50ce7 100644 --- a/ext/standard/tests/strings/bug55871.phpt +++ b/ext/standard/tests/strings/bug55871.phpt @@ -41,6 +41,8 @@ array(1) { [0]=> string(0) "" } + +Warning: A non-numeric value encountered in %s on line %d array(1) { [0]=> string(40) "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" diff --git a/ext/standard/tests/strings/html_entity_decode3.phpt b/ext/standard/tests/strings/html_entity_decode3.phpt index fcf2710679..48cff17bda 100644 --- a/ext/standard/tests/strings/html_entity_decode3.phpt +++ b/ext/standard/tests/strings/html_entity_decode3.phpt @@ -14,6 +14,7 @@ $tests = array( "", "", " ", //allowed always + "'", //single quote, depends on flags "", //DEL "€", //C1 "Ÿ", @@ -76,6 +77,17 @@ foreach ($tests as $t) { } } +echo "\n*** Default options ***\n"; + +foreach ($tests as $t) { + $dec = html_entity_decode($t); + if ($t == $dec) { + echo "$t\tNOT DECODED\n"; + } else { + echo "$t\tDECODED\n"; + } +} + echo "\nDone.\n"; --EXPECT-- *** HTML 4.01 *** @@ -89,6 +101,7 @@ echo "\nDone.\n";  NOT DECODED  NOT DECODED   DECODED +' DECODED  NOT DECODED € NOT DECODED Ÿ NOT DECODED @@ -117,6 +130,7 @@ echo "\nDone.\n";  NOT DECODED  NOT DECODED   DECODED +' DECODED  DECODED € DECODED Ÿ DECODED @@ -145,6 +159,7 @@ echo "\nDone.\n";  NOT DECODED  NOT DECODED   DECODED +' DECODED  NOT DECODED € NOT DECODED Ÿ NOT DECODED @@ -173,6 +188,7 @@ echo "\nDone.\n";  NOT DECODED  NOT DECODED   DECODED +' DECODED  DECODED € DECODED Ÿ DECODED @@ -190,4 +206,33 @@ echo "\nDone.\n";  DECODED  DECODED +*** Default options *** +� NOT DECODED + NOT DECODED +	 DECODED +
 DECODED + NOT DECODED + NOT DECODED +
 DECODED + NOT DECODED + NOT DECODED +  DECODED +' NOT DECODED + NOT DECODED +€ NOT DECODED +Ÿ NOT DECODED +  DECODED +퟿ DECODED +� NOT DECODED +� NOT DECODED + DECODED + DECODED + DECODED +﷏ DECODED + DECODED + DECODED +ﷰ DECODED + DECODED + DECODED + Done. diff --git a/ext/standard/tests/strings/stripos_basic2.phpt b/ext/standard/tests/strings/stripos_basic2.phpt index 3022bae168..226d3f61d2 100644 --- a/ext/standard/tests/strings/stripos_basic2.phpt +++ b/ext/standard/tests/strings/stripos_basic2.phpt @@ -18,6 +18,9 @@ var_dump( stripos("Hello, World", "Hello", 0) ); var_dump( stripos("Hello, World", 'Hello', 1) ); var_dump( stripos('Hello, World', 'WORLD', 1) ); var_dump( stripos('Hello, World', "WoRld", 5) ); +var_dump( stripos('Hello, World', "WoRld", -6) ); +var_dump( stripos('Hello, World', "WoRld", -3) ); +var_dump( stripos('Hello, World', "WoRld", -12) ); //heredoc string for haystack & needle, with various offsets var_dump( stripos($heredoc_str, "Hello, World", 0) ); @@ -25,12 +28,19 @@ var_dump( stripos($heredoc_str, 'Hello', 0) ); var_dump( stripos($heredoc_str, 'Hello', 1) ); var_dump( stripos($heredoc_str, $heredoc_str, 0) ); var_dump( stripos($heredoc_str, $heredoc_str, 1) ); +var_dump( stripos($heredoc_str, $heredoc_str, -strlen($heredoc_str)) ); +var_dump( stripos($heredoc_str, $heredoc_str, -strlen($heredoc_str)+1) ); //various offsets var_dump( stripos("Hello, World", "o", 3) ); var_dump( stripos("Hello, World", "O", 5) ); var_dump( stripos("Hello, World", "o", 6) ); var_dump( stripos("Hello, World", "o", 10) ); +var_dump( stripos("Hello, World", "o", -7) ); +var_dump( stripos("Hello, World", "o", -8) ); +var_dump( stripos("Hello, World", "o", -10) ); +var_dump( stripos("Hello, World", "o", -4) ); +var_dump( stripos("Hello, World", "o", -3) ); echo "*** Done ***"; ?> --EXPECTF-- @@ -40,13 +50,23 @@ int(0) bool(false) int(7) int(7) +int(7) +bool(false) +int(7) int(0) int(0) bool(false) int(0) bool(false) +int(0) +bool(false) int(4) int(8) int(8) bool(false) +int(8) +int(4) +int(4) +int(8) +bool(false) *** Done *** diff --git a/ext/standard/tests/strings/stripos_error.phpt b/ext/standard/tests/strings/stripos_error.phpt index ef6ad9e6ec..c59473046d 100644 --- a/ext/standard/tests/strings/stripos_error.phpt +++ b/ext/standard/tests/strings/stripos_error.phpt @@ -16,6 +16,13 @@ var_dump( stripos("String") ); echo "\n-- With more than expected number of arguments --"; var_dump( stripos("string", "String", 1, 'extra_arg') ); + +echo "\n-- Offset beyond the end of the string --"; +var_dump( stripos("Hello World", "o", 12) ); + +echo "\n-- Offset before the start of the string --"; +var_dump( stripos("Hello World", "o", -12) ); + echo "*** Done ***"; ?> --EXPECTF-- @@ -32,4 +39,12 @@ NULL -- With more than expected number of arguments -- Warning: stripos() expects at most 3 parameters, 4 given in %s on line %d NULL + +-- Offset beyond the end of the string -- +Warning: stripos(): Offset not contained in string in %s on line %d +bool(false) + +-- Offset before the start of the string -- +Warning: stripos(): Offset not contained in string in %s on line %d +bool(false) *** Done *** diff --git a/ext/standard/tests/strings/stripos_variation14.phpt b/ext/standard/tests/strings/stripos_variation14.phpt index aabf0e62ea..3339e2f27e 100644 --- a/ext/standard/tests/strings/stripos_variation14.phpt +++ b/ext/standard/tests/strings/stripos_variation14.phpt @@ -1,7 +1,5 @@ --TEST-- Test stripos() function : usage variations - unexpected inputs for 'offset' argument ---SKIPIF-- -<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64-bit only"); --FILE-- <?php /* Prototype : int stripos ( string $haystack, string $needle [, int $offset] ); @@ -37,7 +35,7 @@ $offsets = array ( // float values 1.5, -1.5, - 1.5e10, + 1.5e6, 1.6E-10, .5, @@ -91,8 +89,6 @@ echo "*** Done ***"; -- Iteration 1 -- int(6) -- Iteration 2 -- - -Warning: stripos(): Offset not contained in string in %s on line %d bool(false) -- Iteration 3 -- diff --git a/ext/standard/tests/strings/strpos.phpt b/ext/standard/tests/strings/strpos.phpt Binary files differindex 36854d1b37..f5d60a69b5 100644 --- a/ext/standard/tests/strings/strpos.phpt +++ b/ext/standard/tests/strings/strpos.phpt diff --git a/ext/standard/tests/strings/substr_count_basic.phpt b/ext/standard/tests/strings/substr_count_basic.phpt index f880e9481e..c7c96fd55b 100644 --- a/ext/standard/tests/strings/substr_count_basic.phpt +++ b/ext/standard/tests/strings/substr_count_basic.phpt @@ -9,12 +9,17 @@ 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)); +var_dump(substr_count($a, "bca", -200)); +var_dump(substr_count($a, "bca", -200, 50)); +var_dump(substr_count($a, "bca", -200, -50)); echo "Done\n"; @@ -30,4 +35,7 @@ int(100) int(200) int(160) int(10) +int(40) +int(10) +int(30) Done diff --git a/ext/standard/tests/strings/substr_count_error.phpt b/ext/standard/tests/strings/substr_count_error.phpt index f6924217b9..881da391e6 100644 --- a/ext/standard/tests/strings/substr_count_error.phpt +++ b/ext/standard/tests/strings/substr_count_error.phpt @@ -4,27 +4,31 @@ Test substr_count() function (error conditions) <?php echo "\n*** Testing error conditions ***\n"; +$str = 'abcdefghik'; + /* Zero argument */ var_dump( substr_count() ); /* more than expected no. of args */ var_dump( substr_count($str, "t", 0, 15, 30) ); -/* offset as negative value */ -var_dump(substr_count($str, "t", -5)); +/* offset before start */ +var_dump(substr_count($str, "t", -20)); /* 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) ); +var_dump( substr_count($str, "i", 5, 7) ); -/* length as Null */ -var_dump( substr_count($str, "t", "", "") ); -var_dump( substr_count($str, "i", NULL, NULL) ); - -echo "Done\n"; +/* Invalid offset argument */ +var_dump( substr_count($str, "t", "") ); + +/* length too small */ +var_dump( substr_count($str, "t", 2, -20) ); + +echo "Done\n"; ?> --EXPECTF-- @@ -33,33 +37,21 @@ echo "Done\n"; Warning: substr_count() expects at least 2 parameters, 0 given in %s on line %d NULL -Notice: Undefined variable: str in %s on line %d - Warning: substr_count() expects at most 4 parameters, 5 given in %s on line %d NULL -Notice: Undefined variable: str in %s on line %d - -Warning: substr_count(): Offset should be greater than or equal to 0 in %s on line %d +Warning: substr_count(): Offset not contained in string in %s on line %d bool(false) -Notice: Undefined variable: str in %s on line %d - -Warning: substr_count(): Offset value 25 exceeds string length in %s on line %d +Warning: substr_count(): Offset not contained in string in %s on line %d bool(false) -Notice: Undefined variable: str in %s on line %d - -Warning: substr_count(): Offset value 5 exceeds string length in %s on line %d +Warning: substr_count(): Invalid length value in %s on line %d bool(false) -Notice: Undefined variable: str in %s on line %d - Warning: substr_count() expects parameter 3 to be integer, string given in %s on line %d NULL -Notice: Undefined variable: str in %s on line %d - -Warning: substr_count(): Length should be greater than 0 in %s on line %d +Warning: substr_count(): Invalid length value in %s on line %d bool(false) Done diff --git a/ext/standard/tests/strings/unpack_error.phpt b/ext/standard/tests/strings/unpack_error.phpt index 1ef97ccbaf..3a4f334c3b 100644 --- a/ext/standard/tests/strings/unpack_error.phpt +++ b/ext/standard/tests/strings/unpack_error.phpt @@ -15,7 +15,7 @@ var_dump( unpack() ); echo "\n-- Testing unpack() function with more than expected no. of arguments --\n"; $extra_arg = 10; -var_dump(unpack("I", pack("I", 65534), $extra_arg)); +var_dump(unpack("I", pack("I", 65534), 0, $extra_arg)); echo "\n-- Testing unpack() function with invalid format character --\n"; $extra_arg = 10; @@ -27,12 +27,12 @@ var_dump(unpack("G", pack("I", 65534))); -- Testing unpack() function with no arguments -- -Warning: unpack() expects exactly 2 parameters, 0 given in %s on line %d +Warning: unpack() expects at least 2 parameters, 0 given in %s on line %d NULL -- Testing unpack() function with more than expected no. of arguments -- -Warning: unpack() expects exactly 2 parameters, 3 given in %s on line %d +Warning: unpack() expects at most 3 parameters, 4 given in %s on line %d NULL -- Testing unpack() function with invalid format character -- diff --git a/ext/standard/tests/strings/unpack_offset.phpt b/ext/standard/tests/strings/unpack_offset.phpt new file mode 100644 index 0000000000..c8c08e74f2 --- /dev/null +++ b/ext/standard/tests/strings/unpack_offset.phpt @@ -0,0 +1,17 @@ +--TEST-- +unpack() with offset +--FILE-- +<?php +$data = "pad" . pack("ll", 0x01020304, 0x05060708); + +$a = unpack("l2", $data, 3); +printf("0x%08x 0x%08x\n", $a[1], $a[2]); + +printf("0x%08x 0x%08x\n", + unpack("l", $data, 3)[1], + unpack("@4/l", $data, 3)[1]); +?> +--EXPECT-- +0x01020304 0x05060708 +0x01020304 0x05060708 + diff --git a/ext/standard/tests/strings/url_t.phpt b/ext/standard/tests/strings/url_t.phpt index e172061ec2..8fdddcb9f5 100644 --- a/ext/standard/tests/strings/url_t.phpt +++ b/ext/standard/tests/strings/url_t.phpt @@ -575,22 +575,7 @@ $sample_urls = array ( string(16) "some_page_ref123" } ---> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) { - ["scheme"]=> - string(4) "http" - ["host"]=> - string(11) "www.php.net" - ["port"]=> - int(80) - ["user"]=> - string(14) "secret@hideout" - ["path"]=> - string(10) "/index.php" - ["query"]=> - string(31) "test=1&test2=char&test3=mixesCI" - ["fragment"]=> - string(16) "some_page_ref123" -} +--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: bool(false) --> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(8) { ["scheme"]=> @@ -759,22 +744,7 @@ $sample_urls = array ( string(7) "9130731" } ---> http://user:@pass@host/path?argument?value#etc: array(7) { - ["scheme"]=> - string(4) "http" - ["host"]=> - string(4) "host" - ["user"]=> - string(4) "user" - ["pass"]=> - string(5) "@pass" - ["path"]=> - string(5) "/path" - ["query"]=> - string(14) "argument?value" - ["fragment"]=> - string(3) "etc" -} +--> http://user:@pass@host/path?argument?value#etc: bool(false) string(4) "http" string(11) "www.php.net" int(80) |