[php-i18n-commits] cvs commit: php4/ext/mbstring/tests 021.inc 021.phpt 022.inc 022.phpt 023.inc 023.phpt 024.inc 024.phpt 026.phpt

Back to archive index

Moriyoshi Koizumi moriy****@users*****
2002年 10月 8日 (火) 05:54:31 JST


moriyoshi    02/10/08 05:54:31

  Added:       ext/mbstring/tests 021.inc 021.phpt 022.inc 022.phpt 023.inc
                        023.phpt 024.inc 024.phpt 026.phpt
  Log:
  Added test cases for mbregex
  
  Revision  Changes    Path
  1.1                  php4/ext/mbstring/tests/021.inc
  
  Index: 021.inc
  ===================================================================
  <?php
  	print mb_ereg_replace( ' ', '-', 'a b c d e' )."\n";
  	print mb_ereg_replace( '([a-z]+)','[\\1]', 'abc def ghi' );
  ?>
  
  
  
  1.1                  php4/ext/mbstring/tests/021.phpt
  
  Index: 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]
  
  
  
  
  1.1                  php4/ext/mbstring/tests/022.inc
  
  Index: 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 );
  	}
  ?>
  
  
  
  1.1                  php4/ext/mbstring/tests/022.phpt
  
  Index: 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
  
  
  
  1.1                  php4/ext/mbstring/tests/023.inc
  
  Index: 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 );
  	}
  ?>
  
  
  
  1.1                  php4/ext/mbstring/tests/023.phpt
  
  	<<Binary file>>
  
  
  1.1                  php4/ext/mbstring/tests/024.inc
  
  Index: 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' );
  	}
  ?>
  
  
  
  1.1                  php4/ext/mbstring/tests/024.phpt
  
  Index: 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
  
  
  
  1.1                  php4/ext/mbstring/tests/026.phpt
  
  Index: 026.phpt
  ===================================================================
  --TEST--
  SJIS with magic_quotes_gpc
  --SKIPIF--
  <?php 
  	ini_set('include_path','.'); 
  	include('skipif.inc'); 
  	if(php_sapi_name()!='cgi') {
  		die("skip\n");
  	}
  ?>
  --POST--
  test1=〓h〓〓〓~〓t〓@〓\〓〓〓V〓h〓\〓m〓\〓〓
  --INI--
  mbstring.output_handler=mb_output_handler
  mbstring.http_input=SJIS
  mbstring.internal_encoding=SJIS
  mbstring.http_output=EUC-JP
  mbstring.encoding_translation=On
  magic_quotes_gpc=1
  --FILE--
  <?php
  	echo $_REQUEST['test1']."\n";
  ?>
  --EXPECT--
  〓〓〓〓〓〓〓〓〓〓〓〓\〓〓〓〓〓〓〓〓\〓〓〓〓\〓〓
  
  
  



php-i18n-commits メーリングリストの案内
Back to archive index