Annotation of embedaddon/php/ext/mbstring/tests/mb_strripos_basic2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test mb_strripos() function : basic functionality
3: --SKIPIF--
4: <?php
5: extension_loaded('mbstring') or die('skip');
6: function_exists('mb_strripos') or die("skip mb_strripos() is not available in this build");
7: ?>
8: --FILE--
9: <?php
10: /* Prototype : int mb_strripos(string haystack, string needle [, int offset [, string encoding]])
11: * Description: Finds position of last occurrence of a string within another, case insensitive
12: * Source code: ext/mbstring/mbstring.c
13: * Alias to functions:
14: */
15:
16: /*
17: * Test basic functionality of mb_strripos with ASCII and multibyte characters
18: */
19:
20: echo "*** Testing mb_strripos() : basic functionality***\n";
21:
22: mb_internal_encoding('UTF-8');
23:
24: //ascii strings
25: $ascii_haystacks = array(
26: b'abc defabc def',
27: b'ABC DEFABC DEF',
28: b'Abc dEFaBC Def',
29: );
30:
31: $ascii_needles = array(
32: // 4 good ones
33: b'DE',
34: b'de',
35: b'De',
36: b'dE',
37: );
38:
39: //greek strings in UTF-8
40: $greek_lower = base64_decode('zrrOu868zr3Ovs6/z4DPgSDOus67zrzOvc6+zr/PgA==');
41: $greek_upper = base64_decode('zprOm86czp3Ons6fzqDOoSDOms6bzpzOnc6ezp/OoA==');
42: $greek_mixed = base64_decode('zrrOu868zr3Ovs6fzqDOoSDOus67zpzOnc6+zr/OoA==');
43: $greek_haystacks = array($greek_lower, $greek_upper, $greek_mixed);
44:
45: $greek_nlower = base64_decode('zrzOvc6+zr8=');
46: $greek_nupper = base64_decode('zpzOnc6ezp8=');
47: $greek_nmixed1 = base64_decode('zpzOnc6+zr8=');
48: $greek_nmixed2 = base64_decode('zrzOvc6+zp8=');
49:
50: $greek_needles = array(
51: // 4 good ones
52: $greek_nlower, $greek_nupper, $greek_nmixed1, $greek_nmixed2,
53: );
54:
55: // try the basic options
56: echo "\n -- ASCII Strings --\n";
57: foreach ($ascii_needles as $needle) {
58: foreach ($ascii_haystacks as $haystack) {
59: var_dump(mb_strripos($haystack, $needle));
60: var_dump(mb_strripos($haystack, $needle, 14));
61: }
62: }
63:
64: echo "\n -- Greek Strings --\n";
65: foreach ($greek_needles as $needle) {
66: foreach ($greek_haystacks as $haystack) {
67: var_dump(mb_strripos($haystack, $needle));
68: var_dump(mb_strripos($haystack, $needle, 12));
69: }
70: }
71:
72: echo "Done";
73: ?>
74: --EXPECTF--
75: *** Testing mb_strripos() : basic functionality***
76:
77: -- ASCII Strings --
78: int(13)
79: bool(false)
80: int(13)
81: bool(false)
82: int(13)
83: bool(false)
84: int(13)
85: bool(false)
86: int(13)
87: bool(false)
88: int(13)
89: bool(false)
90: int(13)
91: bool(false)
92: int(13)
93: bool(false)
94: int(13)
95: bool(false)
96: int(13)
97: bool(false)
98: int(13)
99: bool(false)
100: int(13)
101: bool(false)
102:
103: -- Greek Strings --
104: int(11)
105: bool(false)
106: int(11)
107: bool(false)
108: int(11)
109: bool(false)
110: int(11)
111: bool(false)
112: int(11)
113: bool(false)
114: int(11)
115: bool(false)
116: int(11)
117: bool(false)
118: int(11)
119: bool(false)
120: int(11)
121: bool(false)
122: int(11)
123: bool(false)
124: int(11)
125: bool(false)
126: int(11)
127: bool(false)
128: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>