Annotation of embedaddon/php/ext/mbstring/tests/mb_strrichr_variation5.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test mb_strrichr() function : usage variation - multiple needles
3: --SKIPIF--
4: <?php
5: extension_loaded('mbstring') or die('skip');
6: function_exists('mb_strrichr') or die("skip mb_strrichr() is not available in this build");
7: ?>
8: --FILE--
9: <?php
10: /* Prototype : string mb_strrichr(string haystack, string needle[, bool part[, string encoding]])
11: * Description: Finds the last occurrence of a character in a string within another, case insensitive
12: * Source code: ext/mbstring/mbstring.c
13: * Alias to functions:
14: */
15:
16: echo "*** Testing mb_strrichr() : basic functionality ***\n";
17:
18: mb_internal_encoding('UTF-8');
19:
20: //ascii mixed case, multiple needles
21: $string_ascii = b'abcDef zBcDyx';
22: $needle_ascii_upper = b"BCD";
23: $needle_ascii_mixed = b"bCd";
24: $needle_ascii_lower = b"bcd";
25:
26: //Greek string in mixed case UTF-8 with multiple needles
27: $string_mb = base64_decode('zrrOu868zr3Ovs6fzqDOoSDOus67zpzOnc6+zr/OoA==');
28: $needle_mb_upper = base64_decode('zpzOnc6ezp8=');
29: $needle_mb_lower = base64_decode('zrzOvc6+zr8=');
30: $needle_mb_mixed = base64_decode('zpzOnc6+zr8=');
31:
32: echo "\n-- ASCII string: needle exists --\n";
33: var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_upper, false)));
34: var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_upper, true)));
35: var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_lower, false)));
36: var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_lower, true)));
37: var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_mixed, false)));
38: var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_mixed, true)));
39:
40:
41: echo "\n-- Multibyte string: needle exists --\n";
42: var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_upper, false)));
43: var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_upper, true)));
44: var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_lower, false)));
45: var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_lower, true)));
46: var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_mixed, false)));
47: var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_mixed, true)));
48:
49: ?>
50: ===DONE===
51: --EXPECT--
52: *** Testing mb_strrichr() : basic functionality ***
53:
54: -- ASCII string: needle exists --
55: string(10) "4263447978"
56: string(16) "616263446566207a"
57: string(10) "4263447978"
58: string(16) "616263446566207a"
59: string(10) "4263447978"
60: string(16) "616263446566207a"
61:
62: -- Multibyte string: needle exists --
63: string(20) "ce9cce9dcebecebfcea0"
64: string(42) "cebacebbcebccebdcebece9fcea0cea120cebacebb"
65: string(20) "ce9cce9dcebecebfcea0"
66: string(42) "cebacebbcebccebdcebece9fcea0cea120cebacebb"
67: string(20) "ce9cce9dcebecebfcea0"
68: string(42) "cebacebbcebccebdcebece9fcea0cea120cebacebb"
69: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>