A few tweaks to get Tk803 to work with Encode scheme.
[p5sagit/p5-mst-13.2.git] / t / lib / encode.t
CommitLineData
656753f8 1BEGIN {
2 chdir 't' if -d 't';
3 @INC = '../lib';
4}
5use Test;
6use Encode qw(from_to);
7use charnames qw(greek);
8my @encodings = grep(/iso8859/,Encode::encodings());
9my $n = 2;
10plan test => 13+$n*@encodings;
11my $str = join('',map(chr($_),0x20..0x7E));
12my $cpy = $str;
13ok(length($str),from_to($cpy,'iso8859-1','Unicode'),"Length Wrong");
14ok($cpy,$str,"ASCII mangled by translating from iso8859-1 to Unicode");
15$cpy = $str;
16ok(from_to($cpy,'Unicode','iso8859-1'),length($str),"Length wrong");
17ok($cpy,$str,"ASCII mangled by translating from Unicode to iso8859-1");
18
19$str = join('',map(chr($_),0xa0..0xff));
87714904 20$cpy = $str;
656753f8 21ok(length($str),from_to($cpy,'iso8859-1','Unicode'),"Length Wrong");
22
23my $sym = Encode->getEncoding('symbol');
24my $uni = $sym->toUnicode('a');
25ok("\N{alpha}",substr($uni,0,1),"alpha does not map so symbol 'a'");
26$str = $sym->fromUnicode("\N{Beta}");
27ok("B",substr($str,0,1),"Symbol 'B' does not map to Beta");
28
29foreach my $enc (qw(symbol dingbats ascii),@encodings)
30 {
31 my $tab = Encode->getEncoding($enc);
32 ok(1,defined($tab),"Could not load $enc");
33 $str = join('',map(chr($_),0x20..0x7E));
34 $uni = $tab->toUnicode($str);
35 $cpy = $tab->fromUnicode($uni);
36 ok($cpy,$str,"$enc mangled translating to Unicode and back");
37 }
38