summaryrefslogtreecommitdiff
path: root/ext/mbstring/tests/mb_strripos_empty_needle.phpt
blob: ebc5e540600354326c02984c58d2f0f66b875e78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
--TEST--
Test mb_strripos() function : with empty needle
--SKIPIF--
<?php
extension_loaded('mbstring') or die('skip');
function_exists('mb_strripos') or die("skip mb_strripos() is not available in this build");
?>
--FILE--
<?php

mb_internal_encoding('UTF-8');

$string_ascii = 'abc def';
// Japanese string in UTF-8
$string_mb = "日本語テキストです。0123456789。";

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)