moriyoshi Mon Oct 7 14:02:05 2002 EDT
Added files:
/php4/ext/mbstring/tests 021.inc 021.phpt 022.inc 022.phpt 023.inc
023.phpt 024.inc 024.phpt
Log:
Added test cases for mbregex
Index: php4/ext/mbstring/tests/021.inc
+++ php4/ext/mbstring/tests/021.inc
<?php
print mb_ereg_replace( ' ', '-', 'a b c d e' )."\n";
print mb_ereg_replace( '([a-z]+)','[\\1]', 'abc def ghi' );
?>
Index: php4/ext/mbstring/tests/021.phpt
+++ php4/ext/mbstring/tests/021.phpt
--TEST--
mb_ereg_replace()
--SKIPIF--
<?php include('skipif.inc'); ?>
function_exists('mb_ereg_replace') or die("SKIP");
--POST--
--GET--
--FILE--
<?php include('021.inc'); ?>
--EXPECT--
a-b-c-d-e
[abc] [def] [ghi]
Index: php4/ext/mbstring/tests/022.inc
+++ php4/ext/mbstring/tests/022.inc
<?php
mb_regex_encoding( 'EUC-JP' );
function verify_split( $spliton, $str, $count = 0 )
{
$result1 = mb_split( $spliton, $str, $count );
$result2 = split( $spliton, $str, $count );
if ( $result1 == $result2 ) {
print "ok\n";
} else {
print count($result1).'-'.count($result2)."\n";
}
}
var_dump( mb_split( " ", "a b c d e f g" )
== mb_split( "[[:space:]]", "a\nb\tc\nd e f g" ) );
for ( $i = 0; $i < 5; ++$i ) {
verify_split( " ", "a\tb\tc\td e\tf g", $i );
}
for ( $i = 1; $i < 5; ++$i ) {
verify_split( "\xa1\xa1+",
"\xa1\xa1\xa1\xa2\xa2\xa1\xa1\xa1\xa1\xa1\xa1\xa2\xa2\xa1\xa1\xa1", $i );
}
?>
Index: php4/ext/mbstring/tests/022.phpt
+++ php4/ext/mbstring/tests/022.phpt
--TEST--
mb_split()
--SKIPIF--
<?php include('skipif.inc'); ?>
function_exists('mb_split') or die("SKIP");
--POST--
--GET--
--FILE--
<?php include('022.inc'); ?>
--EXPECT--
bool(true)
ok
ok
ok
ok
ok
ok
2-2
3-3
4-4
Index: php4/ext/mbstring/tests/023.inc
+++ php4/ext/mbstring/tests/023.inc
<?php
$encs = array( 'EUC-JP', 'Shift_JIS', 'SJIS', 'UTF-8' );
function test_ereg( $test_enc, $pat, $str, $in_enc = 'EUC-JP' ) {
mb_regex_encoding( $test_enc );
$pat = mb_convert_encoding( $pat, $test_enc, $in_enc );
$str = mb_convert_encoding( $str, $test_enc, $in_enc );
printf( "(%d)%s\n", mb_ereg( $pat, $str, $reg ), ( is_array( $reg )?
mb_convert_encoding( implode( ' ', $reg ), $in_enc, $test_enc ) : '' ) );
}
function do_tests( $enc ) {
test_ereg( $enc, 'abc ([a-z]+) ([a-z]+) ([a-z]+)$', "abc def ghi jkl"
);
$pat = '([��-��]+) ([ ��-��]+)([��-��]+) ([��-��]+)$';
test_ereg( $enc, $pat, '���� ������ ������ ����' );
test_ereg( $enc, $pat, '��������� ������ ���� ���' );
}
foreach( $encs as $enc ) {
do_tests( $enc );
}
?>
Index: php4/ext/mbstring/tests/023.phpt
+++ php4/ext/mbstring/tests/023.phpt
--TEST--
mb_ereg()
--SKIPIF--
<?php include('skipif.inc'); ?>
function_exists('mb_ereg') or die("SKIP");
--POST--
--GET--
--FILE--
<?php include('023.inc'); ?>
--EXPECT--
(15)abc def ghi jkl def ghi jkl
(27)���� ������ ������ ���� ���� ������ �� ���� ����
(27)��������� ������ ���� ��� ��������� ������ ���� ���
(15)abc def ghi jkl def ghi jkl
(27)���� ������ ������ ���� ���� ������ �� ���� ����
(27)��������� ������ ���� ��� ��������� ������ ���� ���
(15)abc def ghi jkl def ghi jkl
(27)���� ������ ������ ���� ���� ������ �� ���� ����
(27)��������� ������ ���� ��� ��������� ������ ���� ���
(15)abc def ghi jkl def ghi jkl
(39)���� ������ ������ ���� ���� ������ �� ���� ����
(39)��������� ������ ���� ��� ��������� ������ ���� ���
Index: php4/ext/mbstring/tests/024.inc
+++ php4/ext/mbstring/tests/024.inc
<?php
$encs = array( 'EUC-JP', 'Shift_JIS', 'SJIS', 'UTF-8' );
function test_search( $test_enc, $str, $look_for, $opt, $in_enc = 'EUC-JP' ) {
mb_regex_encoding( $test_enc );
$str = mb_convert_encoding( $str, $test_enc, $in_enc );
$look_for = mb_convert_encoding( $look_for, $test_enc, $in_enc );
mb_ereg_search_init( $str, $look_for, $opt );
while ( mb_ereg_search_pos() ) {
$regs = mb_ereg_search_getregs();
array_shift( $regs );
printf( "(%s) (%d) %s\n", $test_enc, mb_ereg_search_getpos(),
mb_convert_encoding( ( is_array( $regs ) ? implode( '-', $regs ): '' ), $in_enc,
$test_enc ) );
}
}
function do_tests( $enc, $opt ) {
test_search( $enc, "�ϡ� ����\n", ' (��?�ϡ�?)[[:space:]]', $opt );
test_search( $enc, 'abcde abdeabcf anvfabc odu abcd ', '(ab[a-z]+)',
$opt );
}
foreach( $encs as $enc ) {
do_tests( $enc, '' );
do_tests( $enc, 'x' );
}
?>
Index: php4/ext/mbstring/tests/024.phpt
+++ php4/ext/mbstring/tests/024.phpt
--TEST--
mb_ereg_search() stuff
--SKIPIF--
<?php include('skipif.inc'); ?>
function_exists('mb_ereg_search') or die("SKIP");
--POST--
--GET--
--FILE--
<?php include('024.inc'); ?>
--EXPECT--
(EUC-JP) (10) ����
(EUC-JP) (5) abcde
(EUC-JP) (14) abdeabcf
(EUC-JP) (22) abc
(EUC-JP) (31) abcd
(EUC-JP) (5) �ϡ�
(EUC-JP) (10) ����
(EUC-JP) (5) abcde
(EUC-JP) (14) abdeabcf
(EUC-JP) (22) abc
(EUC-JP) (31) abcd
(Shift_JIS) (10) ����
(Shift_JIS) (5) abcde
(Shift_JIS) (14) abdeabcf
(Shift_JIS) (22) abc
(Shift_JIS) (31) abcd
(Shift_JIS) (5) �ϡ�
(Shift_JIS) (10) ����
(Shift_JIS) (5) abcde
(Shift_JIS) (14) abdeabcf
(Shift_JIS) (22) abc
(Shift_JIS) (31) abcd
(SJIS) (10) ����
(SJIS) (5) abcde
(SJIS) (14) abdeabcf
(SJIS) (22) abc
(SJIS) (31) abcd
(SJIS) (5) �ϡ�
(SJIS) (10) ����
(SJIS) (5) abcde
(SJIS) (14) abdeabcf
(SJIS) (22) abc
(SJIS) (31) abcd
(UTF-8) (14) ����
(UTF-8) (5) abcde
(UTF-8) (14) abdeabcf
(UTF-8) (22) abc
(UTF-8) (31) abcd
(UTF-8) (7) �ϡ�
(UTF-8) (14) ����
(UTF-8) (5) abcde
(UTF-8) (14) abdeabcf
(UTF-8) (22) abc
(UTF-8) (31) abcd
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php