fixed some errors of mbstring in regression tests.

This commit is contained in:
Rui Hirokawa 2002-03-16 07:33:21 +00:00
parent fe976659fd
commit 9a735efbce
21 changed files with 70 additions and 53 deletions

View File

@ -2,7 +2,7 @@
// TODO:
//$debug = true;
ini_set('include_path','.');
include_once('common.inc');
include_once('common.php');
// EUC-JP
$r = mb_internal_encoding('EUC-JP');

View File

@ -2,7 +2,7 @@
// TODO: This is not a real test.... Need to change so that it does real testing
//$debug = true;
ini_set('include_path','.');
include_once('common.inc');
include_once('common.php');
$ini = ini_get('mbstring.http_input');

View File

@ -2,7 +2,7 @@
//TODO: Add more encoding. Wrong paramter type test.
//$debug = true;
ini_set('include_path','.');
include_once('common.inc');
include_once('common.php');
// Set HTTP output encoding to ASCII
$r = mb_http_output('ASCII');

View File

@ -1,7 +1,7 @@
<?php
//$debug = true;
ini_set('include_path','.');
include_once('common.inc');
include_once('common.php');
// Set order to "auto"

View File

@ -1,7 +1,7 @@
<?php
//$debug = true;
ini_set('include_path','.');
include_once('common.inc');
include_once('common.php');
// Note: It does not return TRUE/FALSE for setting char
@ -28,6 +28,5 @@ print mb_substitute_character() . "\n";
print "== INVALID PARAMETER ==\n";
$r = mb_substitute_character('BAD_NAME');
($r === FALSE) ? print "OK_BAD_NAME\n" : print("NG_BAD_NAME: ".gettype($r)." $r\n");
print mb_substitute_character() . "\n";
?>

View File

@ -14,6 +14,6 @@ long
OK_NONE
none
== INVALID PARAMETER ==
ERR:
ERR: Warning
OK_BAD_NAME

View File

@ -3,7 +3,7 @@
//$debug=true;
ini_set('include_path','.');
include_once('common.inc');
include_once('common.php');
$str = mb_preferred_mime_name('sjis-win');

View File

@ -3,7 +3,7 @@
//$debug=true;
ini_set('include_path','.');
include_once('common.inc');
include_once('common.php');
// restore detect_order to 'auto'
mb_detect_order('auto');
@ -33,6 +33,7 @@ print mb_strlen($sjis) . "\n";
// JIS
// Note: either convert_encoding or strlen has problem
echo "== JIS ==\n";
mb_internal_encoding('EUC-JP') or print("mb_internal_encoding() failed\n");
$jis = mb_convert_encoding($euc_jp, 'JIS');
print mb_strlen($jis,'JIS') . "\n";
mb_internal_encoding('JIS') or print("mb_internal_encoding() failed\n");
@ -41,6 +42,7 @@ print mb_strlen($jis) . "\n";
// UTF-8
// Note: either convert_encoding or strlen has problem
echo "== UTF-8 ==\n";
mb_internal_encoding('EUC-JP') or print("mb_internal_encoding() failed\n");
$utf8 = mb_convert_encoding($euc_jp, 'UTF-8');
print mb_strlen($utf8,'UTF-8') . "\n";
mb_internal_encoding('UTF-8') or print("mb_internal_encoding() failed\n");

View File

@ -3,7 +3,7 @@
//$debug=true;
ini_set('include_path','.');
include_once('common.inc');
include_once('common.php');
// Test string
@ -26,24 +26,32 @@ print mb_strpos($euc_jp, 0, 15, 'EUC-JP') . "\n";
// Note: PHP Warning - offset is negative.
// Note: For offset(-15). It does not return position of latter string. (ie the same result as -50)
echo "== NEGATIVE OFFSET ==\n";
print mb_strpos($euc_jp,'ÆüËܸì', -15, 'EUC-JP') . "\n";
print mb_strpos($euc_jp, '0', -15, 'EUC-JP') . "\n";
print mb_strpos($euc_jp, 3, -15, 'EUC-JP') . "\n";
print mb_strpos($euc_jp, 0, -15, 'EUC-JP') . "\n";
print mb_strpos($euc_jp,'ÆüËܸì', -50, 'EUC-JP') . "\n";
print mb_strpos($euc_jp, '0', -50, 'EUC-JP') . "\n";
print mb_strpos($euc_jp, 3, -50, 'EUC-JP') . "\n";
print mb_strpos($euc_jp, 0, -50, 'EUC-JP') . "\n";
$r = mb_strpos($euc_jp,'ÆüËܸì', -15, 'EUC-JP');
($r === FALSE) ? print "OK_NEGATIVE_OFFSET\n" : print "NG_NEGATIVE_OFFSET\n";
$r = mb_strpos($euc_jp, '0', -15, 'EUC-JP');
($r === FALSE) ? print "OK_NEGATIVE_OFFSET\n" : print "NG_NEGATIVE_OFFSET\n";
$r = mb_strpos($euc_jp, 3, -15, 'EUC-JP');
($r === FALSE) ? print "OK_NEGATIVE_OFFSET\n" : print "NG_NEGATIVE_OFFSET\n";
$r = mb_strpos($euc_jp, 0, -15, 'EUC-JP');
($r === FALSE) ? print "OK_NEGATIVE_OFFSET\n" : print "NG_NEGATIVE_OFFSET\n";
$r = mb_strpos($euc_jp,'ÆüËܸì', -50, 'EUC-JP');
($r === FALSE) ? print "OK_NEGATIVE_OFFSET\n" : print "NG_NEGATIVE_OFFSET\n";
$r = mb_strpos($euc_jp, '0', -50, 'EUC-JP');
($r === FALSE) ? print "OK_NEGATIVE_OFFSET\n" : print "NG_NEGATIVE_OFFSET\n";
$r = mb_strpos($euc_jp, 3, -50, 'EUC-JP');
($r === FALSE) ? print "OK_NEGATIVE_OFFSET\n" : print "NG_NEGATIVE_OFFSET\n";
$r = mb_strpos($euc_jp, 0, -50, 'EUC-JP');
($r === FALSE) ? print "OK_NEGATIVE_OFFSET\n" : print "NG_NEGATIVE_OFFSET\n";
// Out of range - should return false
print ("== OUT OF RANGE ==\n");
$r = mb_strpos($euc_jp,'ÆüËܸì', 40, 'EUC-JP') . "\n";
$r = mb_strpos($euc_jp,'ÆüËܸì', 40, 'EUC-JP');
($r === FALSE) ? print "OK_OUT_RANGE\n" : print "NG_OUT_RANGE\n";
$r = mb_strpos($euc_jp, '0', 40, 'EUC-JP') . "\n";
$r = mb_strpos($euc_jp, '0', 40, 'EUC-JP');
($r === FALSE) ? print "OK_OUT_RANGE\n" : print "NG_OUT_RANGE\n";
$r = mb_strpos($euc_jp, 3, 40, 'EUC-JP') . "\n";
$r = mb_strpos($euc_jp, 3, 40, 'EUC-JP');
($r === FALSE) ? print "OK_OUT_RANGE\n" : print "NG_OUT_RANGE\n";
$r = mb_strpos($euc_jp, 0, 40, 'EUC-JP') . "\n";
$r = mb_strpos($euc_jp, 0, 40, 'EUC-JP');
($r === FALSE) ? print "OK_OUT_RANGE\n" : print "NG_OUT_RANGE\n";
// Note: Returned NULL string
// echo gettype($r). ' val '. $r ."\n";

View File

@ -17,14 +17,22 @@ mb_strpos()
33
30
== NEGATIVE OFFSET ==
34
30
33
30
10
0
3
0
ERR: Warning
OK_NEGATIVE_OFFSET
ERR: Warning
OK_NEGATIVE_OFFSET
ERR: Warning
OK_NEGATIVE_OFFSET
ERR: Warning
OK_NEGATIVE_OFFSET
ERR: Warning
OK_NEGATIVE_OFFSET
ERR: Warning
OK_NEGATIVE_OFFSET
ERR: Warning
OK_NEGATIVE_OFFSET
ERR: Warning
OK_NEGATIVE_OFFSET
== OUT OF RANGE ==
OK_OUT_RANGE
OK_OUT_RANGE

View File

@ -3,7 +3,7 @@
//$debug=true;
ini_set('include_path','.');
include_once('common.inc');
include_once('common.php');
// Test string

View File

@ -1,7 +1,7 @@
<?php
// TODO: Add more encodings
ini_set('include_path','.');
include_once('common.inc');
include_once('common.php');
// EUC-JP
$euc_jp = '0123この文字列は日本語です。EUC-JPを使っています。日本語は面倒臭い。';

View File

@ -1,7 +1,7 @@
<?php
// TODO: Add more encodings
ini_set('include_path','.');
include_once('common.inc');
include_once('common.php');
// EUC-JP
$euc_jp = '0123この文字列は日本語です。EUC-JPを使っています。日本語は面倒臭い。';

View File

@ -2,7 +2,7 @@
// TODO: Add more encoding
//$debug = true;
ini_set('include_path','.');
include_once('common.inc');
include_once('common.php');
// EUC-JP
$euc_jp = '0123この文字列は日本語です。EUC-JPを使っています。日本語は面倒臭い。';
@ -11,12 +11,13 @@ print "1: ". mb_strimwidth($euc_jp, 0, 15,'...','EUC-JP') . "\n";
print "2: ". mb_strimwidth($euc_jp, 0, 100,'...','EUC-JP') . "\n";
print "3: ". mb_strimwidth($euc_jp, 15, 100,'...','EUC-JP') . "\n";
// Note: Did not start form -22 offset. Staring from 0.
print "4: ". mb_strimwidth($euc_jp,-22, 100,'...','EUC-JP') . "\n";
$str = mb_strimwidth($euc_jp,-22, 100,'...','EUC-JP');
($str === FALSE) ? print "4 OK\n" : print "NG: $str\n";
$str = mb_strimwidth($euc_jp, 100, -10,'...','EUC-JP');
($str === "") ? print "5 OK\n" : print "NG: $str\n";
($str === FALSE) ? print "5 OK\n" : print "NG: $str\n";
$str = mb_strimwidth($euc_jp, -100, 10,'...','EUC-JP');
($str !== "") ? print "6 OK: $str\n" : print "NG: $str\n";
($str === FALSE) ? print "6 OK\n" : print "NG: $str\n";
?>

View File

@ -10,8 +10,11 @@ mb_strimwidth()
1: 0123この文字...
2: 0123この文字列は日本語です。EUC-JPを使っています。日本語は面倒臭い。
3: 。EUC-JPを使っています。日本語は面倒臭い。
4: EUC-JPを使っています。日本語は面倒臭い。
ERR: Warning
4 OK
ERR: Warning
5 OK
6 OK: 0123こ...
ERR: Warning
6 OK

View File

@ -2,7 +2,7 @@
// TODO: Add more tests
//$debug = true; // Uncomment this line to view error/warning/notice message in *.out file
ini_set('include_path','.');
include_once('common.inc');
include_once('common.php');
// SJIS string (BASE64 encoded)
$sjis = base64_decode('k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg==');

View File

@ -2,7 +2,7 @@
// TODO: Add more tests
//$debug = true; // Uncomment this line to view error/warning/notice message in *.out file
ini_set('include_path','.');
include_once('common.inc');
include_once('common.php');
// SJIS string (BASE64 encoded)
$sjis = base64_decode('k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg==');
@ -35,8 +35,7 @@ print("JIS: ".base64_encode($s)."\n"); // JIS
// Using Encoding List Array
echo "== ARRAY ENCODING LIST ==\n";
$a = array(0=>'UTF-8',1=>'EUC-JP', 2=>'SJIS', 3=>'JIS');
$a = array(0=>'JIS', 1=>'UTF-8', 2=>'EUC-JP', 3=>'SJIS');
$s = $jis;
$s = mb_convert_encoding($s, 'EUC-JP', $a);
print("EUC-JP: $s\n"); // EUC-JP
@ -53,19 +52,16 @@ print("JIS: ".base64_encode($s)."\n"); // JIS
// Using Detect Order
echo "== DETECT ORDER ==\n";
mb_detect_order('auto');
$s = $jis;
$s = mb_convert_encoding($s, 'EUC-JP');
$s = mb_convert_encoding($s, 'EUC-JP', 'auto');
print("EUC-JP: $s\n"); // EUC-JP
$s = $euc_jp;
$s = mb_convert_encoding($s, 'SJIS');
$s = mb_convert_encoding($s, 'SJIS', 'auto');
print("SJIS: ".base64_encode($s)."\n"); // SJIS
$s = $euc_jp;
$s = mb_convert_encoding($s, 'JIS');
$s = mb_convert_encoding($s, 'JIS', 'auto');
print("JIS: ".base64_encode($s)."\n"); // JIS

View File

@ -2,7 +2,7 @@
// TODO: Add more tests
//$debug = true; // Uncomment this line to view error/warning/notice message in *.out file
ini_set('include_path','.');
include_once('common.inc');
include_once('common.php');
// SJIS string (BASE64 encoded)
$sjis = base64_decode('k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg==');

View File

@ -2,7 +2,7 @@
// TODO: Add more encoding, strings.....
//$debug = true;
ini_set('include_path','.');
include_once('common.inc');
include_once('common.php');
// EUC-JP
$euc_jp = '0123この文字列は日本語です。EUC-JPを使っています。日本語は面倒臭い。';

View File

@ -3,7 +3,7 @@
//$debug=true;
ini_set('include_path','.');
include_once('common.inc');
include_once('common.php');
// restore detect_order to 'auto'
mb_detect_order('auto');

View File

@ -1,5 +1,5 @@
--TEST--
mb_strlen()
strlen()
--SKIPIF--
<?php include('skipif.inc'); ?>
--POST--