Annotation of embedaddon/php/ext/mbstring/tests/mb_strrichr_basic.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test mb_strrichr() function : basic functionality 
                      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: $string_ascii = b'abcdef';
                     21: $needle_ascii_upper = b"BCD";
                     22: $needle_ascii_mixed = b"bCd";
                     23: $needle_ascii_lower = b"bcd";
                     24: 
                     25: //Greek string in lower case UTF-8
                     26: $string_mb = base64_decode('zrHOss6zzrTOtc62zrfOuM65zrrOu868zr3Ovs6/z4DPgc+Dz4TPhc+Gz4fPiM+J');
                     27: $needle_mb_upper = base64_decode('zpzOnc6ezp8=');
                     28: $needle_mb_lower = base64_decode('zrzOvc6+zr8=');
                     29: $needle_mb_mixed = base64_decode('zpzOnc6+zr8=');
                     30: 
                     31: echo "\n-- ASCII string: needle exists --\n";
                     32: var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_upper, false, 'ISO-8859-1')));
                     33: var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_lower)));
                     34: var_dump(bin2hex(mb_strrichr($string_ascii, $needle_ascii_mixed, true)));
                     35: 
                     36: 
                     37: echo "\n-- ASCII string: needle doesn't exist --\n";
                     38: var_dump(mb_strrichr($string_ascii, b'123'));
                     39: 
                     40: echo "\n-- Multibyte string: needle exists --\n";
                     41: var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_upper)));
                     42: var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_lower, false, 'utf-8')));
                     43: var_dump(bin2hex(mb_strrichr($string_mb, $needle_mb_mixed, true)));
                     44: 
                     45: 
                     46: echo "\n-- Multibyte string: needle doesn't exist --\n";
                     47: $needle2 = base64_decode('zrzOvs6/');
                     48: var_dump(mb_strrichr($string_mb, $needle2));
                     49: 
                     50: ?>
                     51: ===DONE===
                     52: --EXPECT--
                     53: *** Testing mb_strrichr() : basic functionality ***
                     54: 
                     55: -- ASCII string: needle exists --
                     56: string(10) "6263646566"
                     57: string(10) "6263646566"
                     58: string(2) "61"
                     59: 
                     60: -- ASCII string: needle doesn't exist --
                     61: bool(false)
                     62: 
                     63: -- Multibyte string: needle exists --
                     64: string(52) "cebccebdcebecebfcf80cf81cf83cf84cf85cf86cf87cf88cf89"
                     65: string(52) "cebccebdcebecebfcf80cf81cf83cf84cf85cf86cf87cf88cf89"
                     66: string(44) "ceb1ceb2ceb3ceb4ceb5ceb6ceb7ceb8ceb9cebacebb"
                     67: 
                     68: -- Multibyte string: needle doesn't exist --
                     69: bool(false)
                     70: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>