cvs: php-src /ext/mbstring/tests mb_stristr_basic.phpt

From: Date: Fri, 05 Dec 2008 14:02:53 +0000
Subject: cvs: php-src /ext/mbstring/tests mb_stristr_basic.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-54706@lists.php.net to get a copy of this message
ant Fri Dec 5 14:02:53 2008 UTC Modified files: /php-src/ext/mbstring/tests mb_stristr_basic.phpt Log: MBString tests: checked on PHP 5.2.6, 5.3 and 6.0 (Windows, Linux and Linux 64 bit). http://cvs.php.net/viewvc.cgi/php-src/ext/mbstring/tests/mb_stristr_basic.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/mbstring/tests/mb_stristr_basic.phpt diff -u /dev/null php-src/ext/mbstring/tests/mb_stristr_basic.phpt:1.2 --- /dev/null Fri Dec 5 14:02:53 2008 +++ php-src/ext/mbstring/tests/mb_stristr_basic.phpt Fri Dec 5 14:02:53 2008 @@ -0,0 +1,72 @@ +--TEST-- +Test mb_stristr() function : basic functionality +--XFAIL-- +Bug #46763 stristr() wrong output when needle does not exist +--SKIPIF-- +<?php +extension_loaded('mbstring') or die('skip'); +function_exists('mb_stristr') or die("skip mb_stristr() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : string mb_stristr(string haystack, string needle[, bool part[, string encoding]]) + * Description: Finds first occurrence of a string within another, case insensitive + * Source code: ext/mbstring/mbstring.c + * Alias to functions: + */ + +echo "*** Testing mb_stristr() : basic functionality ***\n"; + +mb_internal_encoding('UTF-8'); + +$string_ascii = b'abcdef'; +$needle_ascii_upper = b"BCD"; +$needle_ascii_mixed = b"bCd"; +$needle_ascii_lower = b"bcd"; + +//Greek string in lower case UTF-8 +$string_mb = base64_decode('zrHOss6zzrTOtc62zrfOuM65zrrOu868zr3Ovs6/z4DPgc+Dz4TPhc+Gz4fPiM+J'); +$needle_mb_upper = base64_decode('zpzOnc6ezp8='); +$needle_mb_lower = base64_decode('zrzOvc6+zr8='); +$needle_mb_mixed = base64_decode('zpzOnc6+zr8='); + +echo "\n-- ASCII string: needle exists --\n"; +var_dump(bin2hex(mb_stristr($string_ascii, $needle_ascii_upper, false, 'ISO-8859-1'))); +var_dump(bin2hex(mb_stristr($string_ascii, $needle_ascii_lower))); +var_dump(bin2hex(mb_stristr($string_ascii, $needle_ascii_mixed, true))); + + +echo "\n-- ASCII string: needle doesn't exist --\n"; +var_dump(mb_stristr($string_ascii, '123')); + +echo "\n-- Multibyte string: needle exists --\n"; +var_dump(bin2hex(mb_stristr($string_mb, $needle_mb_upper))); +var_dump(bin2hex(mb_stristr($string_mb, $needle_mb_lower, false, 'utf-8'))); +var_dump(bin2hex(mb_stristr($string_mb, $needle_mb_mixed, true))); + + +echo "\n-- Multibyte string: needle doesn't exist --\n"; +$needle2 = base64_decode("zrzOvs6/"); +var_dump(mb_stristr($string_mb, $needle2)); + +?> +===DONE=== +--EXPECT-- +*** Testing mb_stristr() : basic functionality *** + +-- ASCII string: needle exists -- +unicode(10) "6263646566" +unicode(10) "6263646566" +unicode(2) "61" + +-- ASCII string: needle doesn't exist -- +bool(false) + +-- Multibyte string: needle exists -- +unicode(52) "cebccebdcebecebfcf80cf81cf83cf84cf85cf86cf87cf88cf89" +unicode(52) "cebccebdcebecebfcf80cf81cf83cf84cf85cf86cf87cf88cf89" +unicode(44) "ceb1ceb2ceb3ceb4ceb5ceb6ceb7ceb8ceb9cebacebb" + +-- Multibyte string: needle doesn't exist -- +bool(false) +===DONE===

« previous php.cvs (#54706) next »