php-src/ext/mbstring/tests/mb_strripos_empty_needle.phpt
Nikita Popov a06d015e61 Remove unnecessary mbstring skipifs
These functions are always available (if the extension is available
at all).
2021-06-14 15:27:28 +02:00

92 lines
2.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

--TEST--
Test mb_strripos() function : with empty needle
--EXTENSIONS--
mbstring
--FILE--
<?php
mb_internal_encoding('UTF-8');
$string_ascii = 'abc def';
// Japanese string in UTF-8
$string_mb = "日本語テキストです。01234";
echo "\n-- ASCII string without offset --\n";
var_dump(mb_strripos($string_ascii, ''));
echo "\n-- ASCII string with in range positive offset --\n";
var_dump(mb_strripos($string_ascii, '', 2));
echo "\n-- ASCII string with in range negative offset --\n";
var_dump(mb_strripos($string_ascii, '', -2));
echo "\n-- ASCII string with out of bound positive offset --\n";
try {
var_dump(mb_strripos($string_ascii, '', 15));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
echo "\n-- ASCII string with out of bound negative offset --\n";
try {
var_dump(mb_strripos($string_ascii, '', -15));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
echo "\n-- Multi-byte string without offset --\n";
var_dump(mb_strripos($string_mb, ''));
echo "\n-- Multi-byte string with in range positive offset --\n";
var_dump(mb_strripos($string_mb, '', 2));
echo "\n-- Multi-byte string with in range negative offset --\n";
var_dump(mb_strripos($string_mb, '', -2));
echo "\n-- Multi-byte string with out of bound positive offset --\n";
try {
var_dump(mb_strripos($string_mb, '', 150));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
echo "\n-- Multi-byte string with out of bound negative offset --\n";
try {
var_dump(mb_strripos($string_mb, '', -150));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
?>
--EXPECT--
-- ASCII string without offset --
int(7)
-- ASCII string with in range positive offset --
int(7)
-- ASCII string with in range negative offset --
int(5)
-- ASCII string with out of bound positive offset --
mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- ASCII string with out of bound negative offset --
mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Multi-byte string without offset --
int(21)
-- Multi-byte string with in range positive offset --
int(21)
-- Multi-byte string with in range negative offset --
int(19)
-- Multi-byte string with out of bound positive offset --
mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)
-- Multi-byte string with out of bound negative offset --
mb_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack)