Files
php-src/ext/mbstring/tests/mb_strpos_offset_errors.phpt

59 lines
1.8 KiB
PHP

--TEST--
Offset errors for various strpos functions
--EXTENSIONS--
mbstring
--FILE--
<?php
try {
var_dump(mb_strpos("f", "bar", 3));
} catch (\ValueError $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump(mb_strpos("f", "bar", -3));
} catch (\ValueError $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump(mb_strrpos("f", "bar", 3));
} catch (\ValueError $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump(mb_strrpos("f", "bar", -3));
} catch (\ValueError $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump(mb_stripos("f", "bar", 3));
} catch (\ValueError $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump(mb_stripos("f", "bar", -3));
} catch (\ValueError $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump(mb_strripos("f", "bar", 3));
} catch (\ValueError $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
var_dump(mb_strripos("f", "bar", -3));
} catch (\ValueError $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
ValueError: mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
ValueError: mb_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
ValueError: mb_strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
ValueError: mb_strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
ValueError: mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
ValueError: mb_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
ValueError: mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
ValueError: mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)