Annotation of embedaddon/php/ext/mbstring/tests/mb_stripos_basic2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test mb_stripos() function : basic functionality
3: --SKIPIF--
4: <?php
5: extension_loaded('mbstring') or die('skip');
6: function_exists('mb_stripos') or die("skip mb_stripos() is not available in this build");
7: ?>
8: --FILE--
9: <?php
10: /* Prototype : int mb_stripos(string haystack, string needle [, int offset [, string encoding]])
11: * Description: Finds position of first 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_stripos with ASCII and multibyte characters
18: */
19:
20: echo "*** Testing mb_stripos() : 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_stripos($haystack, $needle));
60: var_dump(mb_stripos($haystack, $needle, 6));
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_stripos($haystack, $needle));
68: var_dump(mb_stripos($haystack, $needle, 4));
69: }
70: }
71:
72: echo "Done";
73: ?>
74: --EXPECTF--
75: *** Testing mb_stripos() : basic functionality***
76:
77: -- ASCII Strings --
78: int(4)
79: int(13)
80: int(4)
81: int(13)
82: int(4)
83: int(13)
84: int(4)
85: int(13)
86: int(4)
87: int(13)
88: int(4)
89: int(13)
90: int(4)
91: int(13)
92: int(4)
93: int(13)
94: int(4)
95: int(13)
96: int(4)
97: int(13)
98: int(4)
99: int(13)
100: int(4)
101: int(13)
102:
103: -- Greek Strings --
104: int(2)
105: int(11)
106: int(2)
107: int(11)
108: int(2)
109: int(11)
110: int(2)
111: int(11)
112: int(2)
113: int(11)
114: int(2)
115: int(11)
116: int(2)
117: int(11)
118: int(2)
119: int(11)
120: int(2)
121: int(11)
122: int(2)
123: int(11)
124: int(2)
125: int(11)
126: int(2)
127: int(11)
128: Done
129:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>