diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/mbstring/tests/mb_strpos_basic.phpt | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/mbstring/tests/mb_strpos_basic.phpt')
-rw-r--r-- | ext/mbstring/tests/mb_strpos_basic.phpt | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/ext/mbstring/tests/mb_strpos_basic.phpt b/ext/mbstring/tests/mb_strpos_basic.phpt new file mode 100644 index 0000000..36641b1 --- /dev/null +++ b/ext/mbstring/tests/mb_strpos_basic.phpt @@ -0,0 +1,57 @@ +--TEST-- +Test mb_strpos() function : basic functionality +--SKIPIF-- +<?php +extension_loaded('mbstring') or die('skip'); +function_exists('mb_strpos') or die("skip mb_strpos() is not available in this build"); +?> +--FILE-- +<?php +/* Prototype : int mb_strpos(string $haystack, string $needle [, int $offset [, string $encoding]]) + * Description: Find position of first occurrence of a string within another + * Source code: ext/mbstring/mbstring.c + */ + +/* + * Test basic functionality of mb_strpos with ASCII and multibyte characters + */ + +echo "*** Testing mb_strpos() : basic functionality***\n"; + +mb_internal_encoding('UTF-8'); + +$string_ascii = b'abc def'; +//Japanese string in UTF-8 +$string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII='); + +echo "\n-- ASCII string 1 --\n"; +var_dump(mb_strpos($string_ascii, b'd', 2, 'ISO-8859-1')); + +echo "\n-- ASCII string 2 --\n"; +var_dump(mb_strpos($string_ascii, '123')); + +echo "\n-- Multibyte string 1 --\n"; +$needle1 = base64_decode('5pel5pys6Kqe'); +var_dump(mb_strpos($string_mb, $needle1)); + +echo "\n-- Multibyte string 2 --\n"; +$needle2 = base64_decode("44GT44KT44Gr44Gh44Gv44CB5LiW55WM"); +var_dump(mb_strpos($string_mb, $needle2)); + +echo "Done"; +?> +--EXPECT-- +*** Testing mb_strpos() : basic functionality*** + +-- ASCII string 1 -- +int(4) + +-- ASCII string 2 -- +bool(false) + +-- Multibyte string 1 -- +int(0) + +-- Multibyte string 2 -- +bool(false) +Done
\ No newline at end of file |