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

1.1       misho       1: --TEST--
                      2: Test mb_stristr() function : usage variation - multiple needles
                      3: --SKIPIF--
                      4: <?php
                      5: extension_loaded('mbstring') or die('skip');
                      6: function_exists('mb_stristr') or die("skip mb_stristr() is not available in this build");
                      7: ?>
                      8: --FILE--
                      9: <?php
                     10: /* Prototype  : string mb_stristr(string haystack, string needle[, bool part[, string encoding]])
                     11:  * Description: Finds first occurrence of a string within another, case insensitive 
                     12:  * Source code: ext/mbstring/mbstring.c
                     13:  * Alias to functions: 
                     14:  */
                     15: 
                     16: echo "*** Testing mb_stristr() : 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_stristr($string_ascii, $needle_ascii_upper, false)));
                     34: var_dump(bin2hex(mb_stristr($string_ascii, $needle_ascii_upper, true)));
                     35: var_dump(bin2hex(mb_stristr($string_ascii, $needle_ascii_lower, false)));
                     36: var_dump(bin2hex(mb_stristr($string_ascii, $needle_ascii_lower, true)));
                     37: var_dump(bin2hex(mb_stristr($string_ascii, $needle_ascii_mixed, false)));
                     38: var_dump(bin2hex(mb_stristr($string_ascii, $needle_ascii_mixed, true)));
                     39: 
                     40: 
                     41: echo "\n-- Multibyte string: needle exists --\n";
                     42: var_dump(bin2hex(mb_stristr($string_mb, $needle_mb_upper, false)));
                     43: var_dump(bin2hex(mb_stristr($string_mb, $needle_mb_upper, true)));
                     44: var_dump(bin2hex(mb_stristr($string_mb, $needle_mb_lower, false)));
                     45: var_dump(bin2hex(mb_stristr($string_mb, $needle_mb_lower, true)));
                     46: var_dump(bin2hex(mb_stristr($string_mb, $needle_mb_mixed, false)));
                     47: var_dump(bin2hex(mb_stristr($string_mb, $needle_mb_mixed, true)));
                     48: 
                     49: ?>
                     50: ===DONE===
                     51: --EXPECT--
                     52: *** Testing mb_stristr() : basic functionality ***
                     53: 
                     54: -- ASCII string: needle exists --
                     55: string(24) "6263446566207a4263447978"
                     56: string(2) "61"
                     57: string(24) "6263446566207a4263447978"
                     58: string(2) "61"
                     59: string(24) "6263446566207a4263447978"
                     60: string(2) "61"
                     61: 
                     62: -- Multibyte string: needle exists --
                     63: string(54) "cebccebdcebece9fcea0cea120cebacebbce9cce9dcebecebfcea0"
                     64: string(8) "cebacebb"
                     65: string(54) "cebccebdcebece9fcea0cea120cebacebbce9cce9dcebecebfcea0"
                     66: string(8) "cebacebb"
                     67: string(54) "cebccebdcebece9fcea0cea120cebacebbce9cce9dcebecebfcea0"
                     68: string(8) "cebacebb"
                     69: ===DONE===

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