Assorted 2.15 fixes.
[p5sagit/p5-mst-13.2.git] / ext / Encode / t / gsm0338.t
1 BEGIN {
2     if ($ENV{'PERL_CORE'}){
3         chdir 't';
4         unshift @INC, '../lib';
5     }
6     require Config; import Config;
7     if ($Config{'extensions'} !~ /\bEncode\b/) {
8       print "1..0 # Skip: Encode was not built\n";
9       exit 0;
10     }
11     $| = 1;
12 }
13
14 use strict;
15 use Test::More tests => 21;
16 use Encode;
17
18 # The specification of GSM 03.38 is not awfully clear.
19 # (http://www.unicode.org/Public/MAPPINGS/ETSI/GSM0338.TXT)
20 # The various combinations of 0x00 and 0x1B as leading bytes
21 # are unclear, as is the semantics of those bytes as standalone
22 # or as final single bytes.
23
24 sub t { is(decode("gsm0338", my $t = $_[0]), $_[1]) }
25
26 # t("\x00",     "\x00"); # ???
27
28 # "Round-trip".
29 t("\x41",     "\x41");
30
31 t("\x01",     "\xA3");
32 t("\x02",     "\x24");
33 t("\x03",     "\xA5");
34 t("\x09",     "\xE7");
35
36 t("\x00\x00", "\x00\x00"); # Maybe?
37 t("\x00\x1B", "\x40\xA0"); # Maybe?
38 t("\x00\x41", "\x40\x41");
39
40 # t("\x1B",     "\x1B"); # ???
41
42 # Escape with no special second byte is just a NBSP.
43 t("\x1B\x41", "\xA0\x41");
44
45 t("\x1B\x00", "\xA0\x40"); # Maybe?
46
47 # Special escape characters.
48 t("\x1B\x0A", "\x0C");
49 t("\x1B\x14", "\x5E");
50 t("\x1B\x28", "\x7B");
51 t("\x1B\x29", "\x7D");
52 t("\x1B\x2F", "\x5C");
53 t("\x1B\x3C", "\x5B");
54 t("\x1B\x3D", "\x7E");
55 t("\x1B\x3E", "\x5D");
56 t("\x1B\x40", "\x7C");
57 t("\x1B\x40", "\x7C");
58 t("\x1B\x65", "\x{20AC}");
59
60
61
62