xref: /PHP-5.3/ext/mbstring/tests/bug45923.phpt (revision 9d7250d4)
1--TEST--
2Bug #45923 (mb_st[r]ripos() offset not handled correctly)
3--SKIPIF--
4<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
5--INI--
6mbstring.internal_encoding=UTF-8
7--FILE--
8<?php
9var_dump(strpos("abc abc abc", "abc", 0));
10var_dump(strpos("abc abc abc", "abc", 3));
11var_dump(strpos("abc abc abc", "abc", 6));
12var_dump(strpos("abc abc abc", "abc", 9));
13var_dump(strpos("abc abc abc", "abc", 11));
14var_dump(strpos("abc abc abc", "abc", 12));
15var_dump(strpos("abc abc abc", "abc", -1));
16var_dump(strpos("abc abc abc", "abc", -3));
17var_dump(strpos("abc abc abc", "abc", -6));
18
19var_dump(mb_strpos("●○◆ ●○◆ ●○◆", "●○◆", 0));
20var_dump(mb_strpos("●○◆ ●○◆ ●○◆", "●○◆", 3));
21var_dump(mb_strpos("●○◆ ●○◆ ●○◆", "●○◆", 6));
22var_dump(mb_strpos("●○◆ ●○◆ ●○◆", "●○◆", 9));
23var_dump(mb_strpos("●○◆ ●○◆ ●○◆", "●○◆", 11));
24var_dump(mb_strpos("●○◆ ●○◆ ●○◆", "●○◆", 12));
25var_dump(mb_strpos("●○◆ ●○◆ ●○◆", "●○◆", -1));
26var_dump(mb_strpos("●○◆ ●○◆ ●○◆", "●○◆", -3));
27var_dump(mb_strpos("●○◆ ●○◆ ●○◆", "●○◆", -6));
28
29var_dump(stripos("abc abc abc", "abc", 0));
30var_dump(stripos("abc abc abc", "abc", 3));
31var_dump(stripos("abc abc abc", "abc", 6));
32var_dump(stripos("abc abc abc", "abc", 9));
33var_dump(stripos("abc abc abc", "abc", 11));
34var_dump(stripos("abc abc abc", "abc", 12));
35var_dump(stripos("abc abc abc", "abc", -1));
36var_dump(stripos("abc abc abc", "abc", -3));
37var_dump(stripos("abc abc abc", "abc", -6));
38
39var_dump(mb_stripos("●○◆ ●○◆ ●○◆", "●○◆", 0));
40var_dump(mb_stripos("●○◆ ●○◆ ●○◆", "●○◆", 3));
41var_dump(mb_stripos("●○◆ ●○◆ ●○◆", "●○◆", 6));
42var_dump(mb_stripos("●○◆ ●○◆ ●○◆", "●○◆", 9));
43var_dump(mb_stripos("●○◆ ●○◆ ●○◆", "●○◆", 11));
44var_dump(mb_stripos("●○◆ ●○◆ ●○◆", "●○◆", 12));
45var_dump(mb_stripos("●○◆ ●○◆ ●○◆", "●○◆", -1));
46var_dump(mb_stripos("●○◆ ●○◆ ●○◆", "●○◆", -3));
47var_dump(mb_stripos("●○◆ ●○◆ ●○◆", "●○◆", -6));
48
49var_dump(strrpos("abc abc abc", "abc", 0));
50var_dump(strrpos("abc abc abc", "abc", 3));
51var_dump(strrpos("abc abc abc", "abc", 6));
52var_dump(strrpos("abc abc abc", "abc", 9));
53var_dump(strrpos("abc abc abc", "abc", 11));
54var_dump(strrpos("abc abc abc", "abc", 12));
55var_dump(strrpos("abc abc abc", "abc", -1));
56var_dump(strrpos("abc abc abc", "abc", -3));
57var_dump(strrpos("abc abc abc", "abc", -6));
58
59var_dump(mb_strrpos("●○◆ ●○◆ ●○◆", "●○◆", 0));
60var_dump(mb_strrpos("●○◆ ●○◆ ●○◆", "●○◆", 3));
61var_dump(mb_strrpos("●○◆ ●○◆ ●○◆", "●○◆", 6));
62var_dump(mb_strrpos("●○◆ ●○◆ ●○◆", "●○◆", 9));
63var_dump(mb_strrpos("●○◆ ●○◆ ●○◆", "●○◆", 11));
64var_dump(mb_strrpos("●○◆ ●○◆ ●○◆", "●○◆", 12));
65var_dump(mb_strrpos("●○◆ ●○◆ ●○◆", "●○◆", -1));
66var_dump(mb_strrpos("●○◆ ●○◆ ●○◆", "●○◆", -3));
67var_dump(mb_strrpos("●○◆ ●○◆ ●○◆", "●○◆", -6));
68
69var_dump(strripos("abc abc abc", "abc", 0));
70var_dump(strripos("abc abc abc", "abc", 3));
71var_dump(strripos("abc abc abc", "abc", 6));
72var_dump(strripos("abc abc abc", "abc", 9));
73var_dump(strripos("abc abc abc", "abc", 11));
74var_dump(strripos("abc abc abc", "abc", 12));
75var_dump(strripos("abc abc abc", "abc", -1));
76var_dump(strripos("abc abc abc", "abc", -3));
77var_dump(strripos("abc abc abc", "abc", -6));
78
79var_dump(mb_strripos("●○◆ ●○◆ ●○◆", "●○◆", 0));
80var_dump(mb_strripos("●○◆ ●○◆ ●○◆", "●○◆", 3));
81var_dump(mb_strripos("●○◆ ●○◆ ●○◆", "●○◆", 6));
82var_dump(mb_strripos("●○◆ ●○◆ ●○◆", "●○◆", 9));
83var_dump(mb_strripos("●○◆ ●○◆ ●○◆", "●○◆", 11));
84var_dump(mb_strripos("●○◆ ●○◆ ●○◆", "●○◆", 12));
85var_dump(mb_strripos("●○◆ ●○◆ ●○◆", "●○◆", -1));
86var_dump(mb_strripos("●○◆ ●○◆ ●○◆", "●○◆", -3));
87var_dump(mb_strripos("●○◆ ●○◆ ●○◆", "●○◆", -6));
88
89?>
90--EXPECTF--
91int(0)
92int(4)
93int(8)
94bool(false)
95bool(false)
96
97Warning: strpos(): Offset not contained in string in %s on line %d
98bool(false)
99
100Warning: strpos(): Offset not contained in string in %s on line %d
101bool(false)
102
103Warning: strpos(): Offset not contained in string in %s on line %d
104bool(false)
105
106Warning: strpos(): Offset not contained in string in %s on line %d
107bool(false)
108int(0)
109int(4)
110int(8)
111bool(false)
112bool(false)
113
114Warning: mb_strpos(): Offset not contained in string in %s on line %d
115bool(false)
116
117Warning: mb_strpos(): Offset not contained in string in %s on line %d
118bool(false)
119
120Warning: mb_strpos(): Offset not contained in string in %s on line %d
121bool(false)
122
123Warning: mb_strpos(): Offset not contained in string in %s on line %d
124bool(false)
125int(0)
126int(4)
127int(8)
128bool(false)
129bool(false)
130
131Warning: stripos(): Offset not contained in string in %s on line %d
132bool(false)
133
134Warning: stripos(): Offset not contained in string in %s on line %d
135bool(false)
136
137Warning: stripos(): Offset not contained in string in %s on line %d
138bool(false)
139
140Warning: stripos(): Offset not contained in string in %s on line %d
141bool(false)
142int(0)
143int(4)
144int(8)
145bool(false)
146bool(false)
147
148Warning: mb_stripos(): Offset not contained in string in %s on line %d
149bool(false)
150
151Warning: mb_stripos(): Offset not contained in string in %s on line %d
152bool(false)
153
154Warning: mb_stripos(): Offset not contained in string in %s on line %d
155bool(false)
156
157Warning: mb_stripos(): Offset not contained in string in %s on line %d
158bool(false)
159int(8)
160int(8)
161int(8)
162bool(false)
163bool(false)
164
165Warning: strrpos(): Offset is greater than the length of haystack string in %s on line %d
166bool(false)
167int(8)
168int(8)
169int(4)
170int(8)
171int(8)
172int(8)
173bool(false)
174bool(false)
175
176Warning: mb_strrpos(): Offset is greater than the length of haystack string in %s on line %d
177bool(false)
178int(8)
179int(8)
180int(4)
181int(8)
182int(8)
183int(8)
184bool(false)
185bool(false)
186
187Warning: strripos(): Offset is greater than the length of haystack string in %s on line %d
188bool(false)
189int(8)
190int(8)
191int(4)
192int(8)
193int(8)
194int(8)
195bool(false)
196bool(false)
197
198Warning: mb_strripos(): Offset is greater than the length of haystack string in %s on line %d
199bool(false)
200int(8)
201int(8)
202int(4)
203