summaryrefslogtreecommitdiff
path: root/cpan/dist/Jcode/t
diff options
context:
space:
mode:
Diffstat (limited to 'cpan/dist/Jcode/t')
-rw-r--r--cpan/dist/Jcode/t/mime.t28
-rw-r--r--cpan/dist/Jcode/t/unibench.pl19
2 files changed, 32 insertions, 15 deletions
diff --git a/cpan/dist/Jcode/t/mime.t b/cpan/dist/Jcode/t/mime.t
index 236e8985..f00931b3 100644
--- a/cpan/dist/Jcode/t/mime.t
+++ b/cpan/dist/Jcode/t/mime.t
@@ -31,12 +31,12 @@ my $file;
my %mime =
(
- "テストtestです" =>
- "=?ISO-2022-JP?B?GyRCJUYlOSVIGyhCdGVzdBskQiRHJDkbKEI=?=",
+ "漢字、カタカナ、ひらがな" =>
+ "=?ISO-2022-JP?B?GyRCNEE7eiEiJSslPyUrJUohIiRSJGkkLCRKGyhC?=",
"foo bar" =>
"foo bar",
- "01234567890123456789012345678901234567890123456789" =>
- "=?ISO-2022-JP?B?GyRCIzAjMSMyIzMjNCM1IzYjNyM4IzkjMCMxIzIjMyM0IzUjNiM3GyhC?=\n =?ISO-2022-JP?B?GyRCIzgjOSMwIzEjMiMzIzQjNSM2IzcjOCM5IzAjMSMyIzMjNCM1GyhC?=\n =?ISO-2022-JP?B?GyRCIzYjNyM4IzkjMCMxIzIjMyM0IzUjNiM3IzgjORsoQg==?=",
+ "漢字、カタカナ、ひらがなの混じったSubject Header." =>
+ "=?ISO-2022-JP?B?GyRCNEE7eiEiJSslPyUrJUohIiRSJGkkLCRKJE46LiQ4JEMkPxsoQlN1?=\n =?ISO-2022-JP?B?YmplY3Q=?= Header.",
);
for my $k (keys %mime){
@@ -45,12 +45,17 @@ for my $k (keys %mime){
for my $decoded (sort keys %mime){
my ($ok, $out);
+
my $encoded = $mime{$decoded};
my $encoded_i = $encoded; $encoded_i =~ s/^(=\?ISO-2022-JP\?B\?)/lc($1)/eo;
+
my $t_encoded = jcode($decoded)->mime_encode;
my $t_decoded = jcode($encoded)->mime_decode;
my $t_decoded_i = jcode($encoded_i)->mime_decode;
+ my $decoded_h = jcode($decoded)->h2z->euc;
+ my $t_encoded_h = jcode($decoded_h)->mime_encode;
+
if ($t_decoded eq $decoded){
$ok = "ok";
}else{
@@ -66,7 +71,7 @@ EOF
if ($t_decoded_i eq $decoded){
$ok = "ok";
- print $encoded_i, "\n";
+ #print $encoded_i, "\n";
}else{
$ok = "not ok";
print <<"EOF";
@@ -88,6 +93,19 @@ EOF
}
profile(sprintf("MIME encode: %s -> %s %s %d\n",
$decoded, $encoded, $ok, ++$n ));
+
+ if ($t_encoded_h eq $encoded){
+ $ok = "ok";
+ }else{
+ $ok = "not ok";
+ print <<"EOF";
+E>$decoded_h<
+E>$t_encoded_h<
+EOF
+ }
+ profile(sprintf("MIME encode: %s -> %s %s %d\n",
+ $decoded_h, $t_encoded_h, $ok, ++$n ));
+
}
diff --git a/cpan/dist/Jcode/t/unibench.pl b/cpan/dist/Jcode/t/unibench.pl
index 6a7e084c..d9ac7a42 100644
--- a/cpan/dist/Jcode/t/unibench.pl
+++ b/cpan/dist/Jcode/t/unibench.pl
@@ -2,16 +2,16 @@
use ExtUtils::testlib;
use Benchmark;
+use strict;
+use lib qw(.);
$| = 1;
-
-print "Jcode Loading...\n";
require Jcode;
$Jcode::DEBUG = 1;
+$Jcode::NOXS = $ARGV[0];
print "done.\n";
-
-$file = "t/table.euc";
+my $file = "t/table.euc";
open F, $file or die "$file:$!";
my $euc;
read F, $euc, -s $file;
@@ -19,16 +19,14 @@ read F, $euc, -s $file;
my $ucs2 = Jcode->new($euc)->ucs2;
my $utf8 = Jcode->new($euc)->utf8;
-my $count = $ARGV[0] || 16;
+my $count = $ARGV[1] || 16;
timethese($count, {
"utf8->ucs2" => \&utf8_ucs2,
"ucs2->utf8" => \&ucs2_utf8,
- "euc->ucs2" => \&euc_ucs2,
- "ucs2->euc" => \&ucs2_euc,
- }
- );
-
+ "ucs2->euc" => \&ucs2_euc,
+ "ucs2->utf8" => \&ucs2_utf8,
+});
sub utf8_ucs2{
&Jcode::utf8_ucs2($utf8);
@@ -45,3 +43,4 @@ sub euc_ucs2{
sub ucs2_euc{
&Jcode::ucs2_euc($ucs2);
}
+