diff options
Diffstat (limited to 'ext/mbstring/tests')
-rw-r--r-- | ext/mbstring/tests/bug46806.phpt | 16 | ||||
-rw-r--r-- | ext/mbstring/tests/bug48645.phpt | 162 | ||||
-rw-r--r-- | ext/mbstring/tests/mb_convert_kana.phpt | 60 | ||||
-rw-r--r-- | ext/mbstring/tests/mb_decode_numericentity.phpt | 21 | ||||
-rw-r--r-- | ext/mbstring/tests/mb_encode_numericentity.phpt | 22 | ||||
-rw-r--r-- | ext/mbstring/tests/mb_ereg3.phpt | 44 | ||||
-rw-r--r-- | ext/mbstring/tests/mb_ereg4.phpt | 44 | ||||
-rwxr-xr-x | ext/mbstring/tests/mb_ereg_search.phpt | 39 | ||||
-rw-r--r-- | ext/mbstring/tests/mb_ereg_search_pos.phpt | 31 | ||||
-rw-r--r-- | ext/mbstring/tests/mb_ereg_search_regs.phpt | 28 | ||||
-rw-r--r-- | ext/mbstring/tests/mb_eregi.phpt | 20 | ||||
-rw-r--r-- | ext/mbstring/tests/mb_eregi_invalid_arguments.phpt | 20 | ||||
-rw-r--r-- | ext/mbstring/tests/mb_eregi_replace.phpt | 37 |
13 files changed, 544 insertions, 0 deletions
diff --git a/ext/mbstring/tests/bug46806.phpt b/ext/mbstring/tests/bug46806.phpt new file mode 100644 index 000000000..eec44b523 --- /dev/null +++ b/ext/mbstring/tests/bug46806.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #46806 (mb_wtrimwidth cutting to early) +--CREDITS-- +Sebastian Schürmann +sebs@php.net +Testfest 2009 +--SKIPIF-- +<?php if (!extension_loaded("mbstring")) die("skip mbstring is not available"); ?> +--FILE-- +<?php +echo mb_strimwidth('helloworld', 0, 5, '...', 'UTF-8') . "\n"; +echo mb_strimwidth('hello', 0, 5, '...', 'UTF-8'); +?> +--EXPECT-- +he... +hello diff --git a/ext/mbstring/tests/bug48645.phpt b/ext/mbstring/tests/bug48645.phpt new file mode 100644 index 000000000..6185442cc --- /dev/null +++ b/ext/mbstring/tests/bug48645.phpt @@ -0,0 +1,162 @@ +--TEST-- +Bug #48645 (mb_convert_encoding() doesn't understand hexadecimal html-entities) +--SKIPIF-- +<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?> +--FILE-- +<?php +var_dump(bin2hex(mb_convert_encoding("�", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("	", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("
", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("
", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("
", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("
", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("&#x/;", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("&#x:;", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("&#x@;", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("&#x`;", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("&#xG;", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("&#xg;", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("&#x;", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("�", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("	", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("
", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("
", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("
", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("
", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("&#X/;", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("&#X:;", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("&#X@;", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("&#X`;", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("&#XG;", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("&#Xg;", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("&#X;", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("�", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("	", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("&#/;", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("&#:;", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("&#;", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("�", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("�", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("", "UTF-8", "HTML-ENTITIES"))); +var_dump(bin2hex(mb_convert_encoding("�", "UTF-8", "HTML-ENTITIES"))); +?> +--EXPECT-- +string(2) "00" +string(2) "01" +string(2) "02" +string(2) "03" +string(2) "04" +string(2) "05" +string(2) "06" +string(2) "07" +string(2) "08" +string(2) "09" +string(2) "0a" +string(2) "0b" +string(2) "0c" +string(2) "0d" +string(2) "0e" +string(2) "0f" +string(2) "0a" +string(2) "0b" +string(2) "0c" +string(2) "0d" +string(2) "0e" +string(2) "0f" +string(10) "2623782f3b" +string(10) "2623783a3b" +string(10) "262378403b" +string(10) "262378603b" +string(10) "262378473b" +string(10) "262378673b" +string(8) "2623783b" +string(2) "00" +string(2) "01" +string(2) "02" +string(2) "03" +string(2) "04" +string(2) "05" +string(2) "06" +string(2) "07" +string(2) "08" +string(2) "09" +string(2) "0a" +string(2) "0b" +string(2) "0c" +string(2) "0d" +string(2) "0e" +string(2) "0f" +string(2) "0a" +string(2) "0b" +string(2) "0c" +string(2) "0d" +string(2) "0e" +string(2) "0f" +string(10) "2623582f3b" +string(10) "2623583a3b" +string(10) "262358403b" +string(10) "262358603b" +string(10) "262358473b" +string(10) "262358673b" +string(8) "2623583b" +string(2) "00" +string(2) "01" +string(2) "02" +string(2) "03" +string(2) "04" +string(2) "05" +string(2) "06" +string(2) "07" +string(2) "08" +string(2) "09" +string(8) "26232f3b" +string(8) "26233a3b" +string(6) "26233b" +string(8) "f48fbfbf" +string(20) "2623783131303030303b" +string(8) "f48fbfbf" +string(20) "2623583131303030303b" +string(8) "f48fbfbf" +string(20) "2623313131343131323b" diff --git a/ext/mbstring/tests/mb_convert_kana.phpt b/ext/mbstring/tests/mb_convert_kana.phpt new file mode 100644 index 000000000..b3bffb61d --- /dev/null +++ b/ext/mbstring/tests/mb_convert_kana.phpt @@ -0,0 +1,60 @@ +--TEST-- +Testing mb_convert_kana() function +--SKIPIF-- +<?php +if (!extension_loaded('mbstring')) die('skip mbstring not enabled'); +if (!function_exists("mb_convert_kana")) print "skip mb_convert_kana() not available"; +?> +--FILE-- +<?php +$zenKakuA = 'ァアィイゥウェエォオカガキギク'; +$zenKakuB = 'グケゲコゴサザシジスズセゼソゾタ'; +$zenKakuC = 'ダチヂッツヅテデトドナニヌネノハ'; +$zenKakuD = 'バパヒビピフブプヘベペホボポマミ'; +$zenKakuE = 'ムメモャヤュユョヨラリルレロヮワ'; +$zenKakuF = 'ヰヱヲンヴヵヶヷヸヹヺ・ーヽヾ'; + +$hanKakuA = '⦆。「」、・ヲァィゥェォャュョッ'; +$hanKakuB = 'ーアイウエオカキクケコサシスセソ'; +$hanKakuC = 'タチツテトナニヌネノハヒフヘホマ'; +$hanKakuD = 'ミムメモヤユヨラリルレロワン゙゚'; + + +echo $zenKakuA . ' => ' . mb_convert_kana($zenKakuA, 'AZKH', 'utf-8'); +echo "\n"; +echo $zenKakuB . ' => ' . mb_convert_kana($zenKakuB, 'azkh', 'utf-8'); +echo "\n"; +echo $zenKakuC . ' => ' . mb_convert_kana($zenKakuC, 'azkh', 'utf-8'); +echo "\n"; +echo $zenKakuD . ' => ' . mb_convert_kana($zenKakuD, 'azkh', 'utf-8'); +echo "\n"; +echo $zenKakuE . ' => ' . mb_convert_kana($zenKakuE, 'azkh', 'utf-8'); +echo "\n"; +echo $zenKakuF . ' => ' . mb_convert_kana($zenKakuF, 'azkh', 'utf-8'); +echo "\n"; +echo "\n"; +echo $hanKakuA . ' => ' . mb_convert_kana($hanKakuA, 'AZKH', 'utf-8'); +echo "\n"; +echo $hanKakuB . ' => ' . mb_convert_kana($hanKakuB, 'AZKH', 'utf-8'); +echo "\n"; +echo $hanKakuC . ' => ' . mb_convert_kana($hanKakuC, 'AZKH', 'utf-8'); +echo "\n"; +echo $hanKakuD . ' => ' . mb_convert_kana($hanKakuD, 'AZKH', 'utf-8'); +?> +--EXPECT-- +ァアィイゥウェエォオカガキギク => ァアィイゥウェエォオカガキギク +グケゲコゴサザシジスズセゼソゾタ => グケゲコゴサザシジスズセゼソゾタ +ダチヂッツヅテデトドナニヌネノハ => ダチヂッツヅテデトドナニヌネノハ +バパヒビピフブプヘベペホボポマミ => バパヒビピフブプヘベペホボポマミ +ムメモャヤュユョヨラリルレロヮワ => ムメモャヤュユョヨラリルレロワワ +ヰヱヲンヴヵヶヷヸヹヺ・ーヽヾ => イエヲンヴヵヶヷヸヹヺ・ーヽヾ + +⦆。「」、・ヲァィゥェォャュョッ => ⦆。「」、・ヲァィゥェォャュョッ +ーアイウエオカキクケコサシスセソ => ーアイウエオカキクケコサシスセソ +タチツテトナニヌネノハヒフヘホマ => タチツテトナニヌネノハヒフヘホマ +ミムメモヤユヨラリルレロワン゙゚ => ミムメモヤユヨラリルレロワン゛゜ + +--CREDITS-- +Jason Easter <easter@phpug-wuerzburg.de> +PHPUG Würzburg <phpug-wuerzburg.de> +Testfest 2009 2009-06-20 diff --git a/ext/mbstring/tests/mb_decode_numericentity.phpt b/ext/mbstring/tests/mb_decode_numericentity.phpt new file mode 100644 index 000000000..6008ef9a9 --- /dev/null +++ b/ext/mbstring/tests/mb_decode_numericentity.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test mb_decode_numericentity() function : Convert HTML-Entities to UTF-8 +--SKIPIF-- +<?php +if (!extension_loaded('mbstring')) die('skip mbstring not enabled'); +function_exists('mb_encode_mimeheader') or die("skip mb_encode_mimeheader() is not available in this build"); +?> +--FILE-- +<?php +$str1 = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'; +$str2 = 'ƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋〈〉◊♠♣♥♦'; +$str3 = 'aŒbœcŠdše€fg'; +$convmap = array(0x0, 0x2FFFF, 0, 0xFFFF); +echo mb_decode_numericentity($str1, $convmap, "UTF-8")."\n"; +echo mb_decode_numericentity($str2, $convmap, "UTF-8")."\n"; +echo mb_decode_numericentity($str3, $convmap, "UTF-8")."\n"; +?> +--EXPECT-- +¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ +ƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋〈〉◊♠♣♥♦ +aŒbœcŠdše€fg diff --git a/ext/mbstring/tests/mb_encode_numericentity.phpt b/ext/mbstring/tests/mb_encode_numericentity.phpt new file mode 100644 index 000000000..dffb41966 --- /dev/null +++ b/ext/mbstring/tests/mb_encode_numericentity.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test mb_encode_numericentity() function : Convert UTF-8 to HTML-Entities +--SKIPIF-- +<?php +if (!extension_loaded('mbstring')) die('skip mbstring not enabled'); +function_exists('mb_encode_mimeheader') or die("skip mb_encode_mimeheader() is not available in this build"); +?> +--FILE-- +<?php +$str1 = '¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ'; +$str2 = 'ƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋〈〉◊♠♣♥♦'; +$convmap = array(0x0, 0x2FFFF, 0, 0xFFFF); +echo mb_encode_numericentity($str1, $convmap, "UTF-8")."\n"; +echo mb_encode_numericentity($str2, $convmap, "UTF-8")."\n"; + +$convmap = array(0xFF, 0x2FFFF, 0, 0xFFFF); +echo mb_encode_numericentity('aŒbœcŠdše€fg', $convmap, "UTF-8")."\n"; +?> +--EXPECTF-- +¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ +ƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋〈〉◊♠♣♥♦ +aŒbœcŠdše€fg diff --git a/ext/mbstring/tests/mb_ereg3.phpt b/ext/mbstring/tests/mb_ereg3.phpt new file mode 100644 index 000000000..abec3e7ad --- /dev/null +++ b/ext/mbstring/tests/mb_ereg3.phpt @@ -0,0 +1,44 @@ +--TEST-- +mb_ereg() returning matches +--SKIPIF-- +<?php +if (!extension_loaded('mbstring')) die('skip mbstring not enabled'); +if (!function_exists("mb_ereg")) print "skip mb_ereg() not available"; +?> +--FILE-- +<?php + +$a = -1; $b = -1; $c = -1; +mbereg($a, $b, $c); +var_dump($a, $b, $c); + +mberegi($a, $b, $c); +var_dump($a, $b, $c); + +mbereg_search_init($a, $b, $c); +var_dump($a, $b, $c); + +echo "Done\n"; +?> +--EXPECTF-- +int(-1) +int(-1) +array(1) { + [0]=> + string(2) "-1" +} +int(-1) +int(-1) +array(1) { + [0]=> + string(2) "-1" +} + +Warning: mbereg_search_init() expects parameter 3 to be %binary_string_optional%, array given in %s on line %d +int(-1) +int(-1) +array(1) { + [0]=> + string(2) "-1" +} +Done diff --git a/ext/mbstring/tests/mb_ereg4.phpt b/ext/mbstring/tests/mb_ereg4.phpt new file mode 100644 index 000000000..8dca4358f --- /dev/null +++ b/ext/mbstring/tests/mb_ereg4.phpt @@ -0,0 +1,44 @@ +--TEST-- +mb_ereg() returning matches +--SKIPIF-- +<?php +if (!extension_loaded('mbstring')) die('skip mbstring not enabled'); +if (!function_exists("mb_ereg")) print "skip mb_ereg() not available"; +?> +--FILE-- +<?php + +$a = -1; $b = -1; $c = -1; +mbereg($a, $b, $c); +var_dump($a, $b, $c); + +mberegi($a, $b, $c); +var_dump($a, $b, $c); + +mbereg_search_init($a, $b, $c); +var_dump($a, $b, $c); + +echo "Done\n"; +?> +--EXPECTF-- +int(-1) +int(-1) +array(1) { + [0]=> + string(2) "-1" +} +int(-1) +int(-1) +array(1) { + [0]=> + string(2) "-1" +} + +Warning: mbereg_search_init() expects parameter 3 to be string, array given in %s on line %d +int(-1) +int(-1) +array(1) { + [0]=> + string(2) "-1" +} +Done diff --git a/ext/mbstring/tests/mb_ereg_search.phpt b/ext/mbstring/tests/mb_ereg_search.phpt new file mode 100755 index 000000000..4df54c482 --- /dev/null +++ b/ext/mbstring/tests/mb_ereg_search.phpt @@ -0,0 +1,39 @@ +--TEST-- +Testing mb_ereg_search() function +--SKIPIF-- +<?php +if (!extension_loaded('mbstring')) die('skip mbstring not enabled'); +function_exists('mb_ereg_search') or die("skip mb_ereg_search() is not available in this build"); +?> +--FILE-- +<?php + $str = "中国abc + abc ?!?!字符# china string"; + + $reg = "\w+"; + + mb_regex_encoding("UTF-8"); + + mb_ereg_search_init($str, $reg); + $r = mb_ereg_search(); + + if(!$r) + { + echo "null\n"; + } + else + { + $r = mb_ereg_search_getregs(); //get first result + do + { + var_dump($r[0]); + $r = mb_ereg_search_regs();//get next result + } + while($r); + } +?> +--EXPECT-- +string(9) "中国abc" +string(3) "abc" +string(6) "字符" +string(5) "china" +string(6) "string" diff --git a/ext/mbstring/tests/mb_ereg_search_pos.phpt b/ext/mbstring/tests/mb_ereg_search_pos.phpt new file mode 100644 index 000000000..fcd98e16c --- /dev/null +++ b/ext/mbstring/tests/mb_ereg_search_pos.phpt @@ -0,0 +1,31 @@ +--TEST-- +mb_ereg_search_pos() # a test for the basic function of mb_ereg_search_pos +--SKIPIF-- +<?php +if (!extension_loaded('mbstring')) die('skip mbstring not enabled'); +?> +--FILE-- +<?php + +$test_str = 'Itrntinliztin'; + +if(mb_ereg_search_init($test_str)) +{ + $val=mb_ereg_search_pos("ntin"); + + var_dump($val); + +} +else{ + var_dump("false"); +} +?> +--EXPECT-- +array(2) { + [0]=> + int(5) + [1]=> + int(6) +} + + diff --git a/ext/mbstring/tests/mb_ereg_search_regs.phpt b/ext/mbstring/tests/mb_ereg_search_regs.phpt new file mode 100644 index 000000000..2cc55a7bd --- /dev/null +++ b/ext/mbstring/tests/mb_ereg_search_regs.phpt @@ -0,0 +1,28 @@ +--TEST-- +Funktionstest mb_ereg_search_regs() +--SKIPIF-- +<?php +if (!extension_loaded('mbstring')) die('skip mbstring not enabled'); +function_exists('mb_ereg_search_regs') or die("skip mb_ereg_search_regs() not available"); +?> +--FILE-- +<?php + // homepage: + + //$mb_str = "Алексей Федорович Карамазов был Алексей Федорович Карамазов был kyrillischer string string"; + // = "Lorem ipsum dolor sit amet" + + mb_ereg_search_init("Алексей Федорович Карамазов был Алексей Федорович Карамазов был"); + + + + $match= mb_ereg_search_regs("ов"); + var_dump($match); + + +?> +--EXPECT-- +array(1) { + [0]=> + string(4) "ов" +} diff --git a/ext/mbstring/tests/mb_eregi.phpt b/ext/mbstring/tests/mb_eregi.phpt new file mode 100644 index 000000000..ced6fadcd --- /dev/null +++ b/ext/mbstring/tests/mb_eregi.phpt @@ -0,0 +1,20 @@ +--TEST-- +mb_eregi() and invalid arguments +--SKIPIF-- +<?php +if (!extension_loaded('mbstring')) die('skip mbstring not enabled'); +if (!function_exists("mb_eregi")) print "skip mb_eregi() not available"; +?> +--FILE-- +<?php + +mb_regex_encoding('utf-8'); + +var_dump(mb_eregi('z', 'XYZ')); +var_dump(mb_eregi('xyzp', 'XYZ')); +var_dump(mb_eregi('ö', 'Öäü')); +?> +--EXPECT-- +int(1) +bool(false) +int(1) diff --git a/ext/mbstring/tests/mb_eregi_invalid_arguments.phpt b/ext/mbstring/tests/mb_eregi_invalid_arguments.phpt new file mode 100644 index 000000000..ced6fadcd --- /dev/null +++ b/ext/mbstring/tests/mb_eregi_invalid_arguments.phpt @@ -0,0 +1,20 @@ +--TEST-- +mb_eregi() and invalid arguments +--SKIPIF-- +<?php +if (!extension_loaded('mbstring')) die('skip mbstring not enabled'); +if (!function_exists("mb_eregi")) print "skip mb_eregi() not available"; +?> +--FILE-- +<?php + +mb_regex_encoding('utf-8'); + +var_dump(mb_eregi('z', 'XYZ')); +var_dump(mb_eregi('xyzp', 'XYZ')); +var_dump(mb_eregi('ö', 'Öäü')); +?> +--EXPECT-- +int(1) +bool(false) +int(1) diff --git a/ext/mbstring/tests/mb_eregi_replace.phpt b/ext/mbstring/tests/mb_eregi_replace.phpt new file mode 100644 index 000000000..dd6162c25 --- /dev/null +++ b/ext/mbstring/tests/mb_eregi_replace.phpt @@ -0,0 +1,37 @@ +--TEST-- +Testing mb_eregi_replace() function +--SKIPIF-- +<?php +if (!extension_loaded('mbstring')) die('skip mbstring not enabled'); +function_exists('mb_eregi_replace') or die("skip mb_eregi_replace() is not available in this build"); +?> +--FILE-- +<?php +function do_translit($st) { + $replacement = array( + "й"=>"i","ц"=>"c","у"=>"u","к"=>"k","е"=>"e","н"=>"n", + "г"=>"g","ш"=>"sh","щ"=>"sh","з"=>"z","х"=>"x","ъ"=>"\'", + "ф"=>"f","ы"=>"i","в"=>"v","а"=>"a","п"=>"p","р"=>"r", + "о"=>"o","л"=>"l","д"=>"d","ж"=>"zh","э"=>"ie","ё"=>"e", + "я"=>"ya","ч"=>"ch","с"=>"c","м"=>"m","и"=>"i","т"=>"t", + "ь"=>"\'","б"=>"b","ю"=>"yu", + "Й"=>"I","Ц"=>"C","У"=>"U","К"=>"K","Е"=>"E","Н"=>"N", + "Г"=>"G","Ш"=>"SH","Щ"=>"SH","З"=>"Z","Х"=>"X","Ъ"=>"\'", + "Ф"=>"F","Ы"=>"I","В"=>"V","А"=>"A","П"=>"P","Р"=>"R", + "О"=>"O","Л"=>"L","Д"=>"D","Ж"=>"ZH","Э"=>"IE","Ё"=>"E", + "Я"=>"YA","Ч"=>"CH","С"=>"C","М"=>"M","И"=>"I","Т"=>"T", + "Ь"=>"\'","Б"=>"B","Ю"=>"YU", + ); + + foreach($replacement as $i=>$u) { + $st = mb_eregi_replace($i,$u,$st); + } + return $st; +} + +echo do_translit("Фуцк"); +?> +--EXPECT-- +Fuck +--CREDITS-- +Testfest Wuerzburg 2009-06-20 |