5a39bb8a576dd0171e5717cfd56d1c90449043c8
[perl.git] / ext / Unicode-Collate / t / cjkrange.t
1
2 BEGIN {
3     unless ("A" eq pack('U', 0x41)) {
4         print "1..0 # Unicode::Collate " .
5             "cannot stringify a Unicode code point\n";
6         exit 0;
7     }
8     if ($ENV{PERL_CORE}) {
9         chdir('t') if -d 't';
10         @INC = $^O eq 'MacOS' ? qw(::lib) : qw(../lib);
11     }
12 }
13
14 use Test;
15 BEGIN { plan tests => 51 };
16
17 use strict;
18 use warnings;
19 use Unicode::Collate;
20
21 ok(1);
22
23 my $Collator = Unicode::Collate->new(
24   table => 'keys.txt',
25   normalization => undef,
26 );
27
28 # U+9FA6..U+9FBB are CJK UI since Unicode 4.1.0.
29 # U+3400 is CJK UI ExtA, then greater than any CJK UI.
30
31 ##### 2..11
32 ok($Collator->lt("\x{9FA5}", "\x{3400}")); # UI < ExtA
33 ok($Collator->lt("\x{9FA6}", "\x{3400}")); # new UI < ExtA
34 ok($Collator->lt("\x{9FBB}", "\x{3400}")); # new UI < ExtA
35 ok($Collator->gt("\x{9FBC}", "\x{3400}")); # Unassigned > ExtA
36 ok($Collator->gt("\x{9FFF}", "\x{3400}")); # Unassigned > ExtA
37 ok($Collator->lt("\x{9FA6}", "\x{9FBB}")); # new UI > new UI
38 ok($Collator->lt("\x{3400}","\x{20000}")); # ExtA < ExtB
39 ok($Collator->lt("\x{3400}","\x{2A6D6}")); # ExtA < ExtB
40 ok($Collator->gt("\x{9FFF}","\x{20000}")); # Unassigned > ExtB
41 ok($Collator->gt("\x{9FFF}","\x{2A6D6}")); # Unassigned > ExtB
42
43 ##### 12..21
44 $Collator->change(UCA_Version => 11);
45 ok($Collator->lt("\x{9FA5}", "\x{3400}")); # UI < ExtA
46 ok($Collator->gt("\x{9FA6}", "\x{3400}")); # Unassigned > ExtA
47 ok($Collator->gt("\x{9FBB}", "\x{3400}")); # Unassigned > ExtA
48 ok($Collator->gt("\x{9FBC}", "\x{3400}")); # Unassigned > ExtA
49 ok($Collator->gt("\x{9FFF}", "\x{3400}")); # Unassigned > ExtA
50 ok($Collator->lt("\x{9FA6}", "\x{9FBB}")); # Unassigned > Unassigned
51 ok($Collator->lt("\x{3400}","\x{20000}")); # ExtA < ExtB
52 ok($Collator->lt("\x{3400}","\x{2A6D6}")); # ExtA < ExtB
53 ok($Collator->gt("\x{9FFF}","\x{20000}")); # Unassigned > ExtB
54 ok($Collator->gt("\x{9FFF}","\x{2A6D6}")); # Unassigned > ExtB
55
56 ##### 22..31
57 $Collator->change(UCA_Version => 9);
58 ok($Collator->lt("\x{9FA5}", "\x{3400}")); # UI < ExtA
59 ok($Collator->gt("\x{9FA6}", "\x{3400}")); # Unassigned > ExtA
60 ok($Collator->gt("\x{9FBB}", "\x{3400}")); # Unassigned > ExtA
61 ok($Collator->gt("\x{9FBC}", "\x{3400}")); # Unassigned > ExtA
62 ok($Collator->gt("\x{9FFF}", "\x{3400}")); # Unassigned > ExtA
63 ok($Collator->lt("\x{9FA6}", "\x{9FBB}")); # Unassigned > Unassigned
64 ok($Collator->lt("\x{3400}","\x{20000}")); # ExtA < ExtB
65 ok($Collator->lt("\x{3400}","\x{2A6D6}")); # ExtA < ExtB
66 ok($Collator->gt("\x{9FFF}","\x{20000}")); # Unassigned > ExtB
67 ok($Collator->gt("\x{9FFF}","\x{2A6D6}")); # Unassigned > ExtB
68
69 ##### 32..41
70 $Collator->change(UCA_Version => 8);
71 ok($Collator->gt("\x{9FA5}", "\x{3400}")); # UI > ExtA
72 ok($Collator->gt("\x{9FA6}", "\x{3400}")); # Unassigned > ExtA
73 ok($Collator->gt("\x{9FBB}", "\x{3400}")); # Unassigned > ExtA
74 ok($Collator->gt("\x{9FBC}", "\x{3400}")); # Unassigned > ExtA
75 ok($Collator->gt("\x{9FFF}", "\x{3400}")); # Unassigned > ExtA
76 ok($Collator->lt("\x{9FA6}", "\x{9FBB}")); # new UI > new UI
77 ok($Collator->lt("\x{3400}","\x{20000}")); # ExtA < Unassigned(ExtB)
78 ok($Collator->lt("\x{3400}","\x{2A6D6}")); # ExtA < Unassigned(ExtB)
79 ok($Collator->lt("\x{9FFF}","\x{20000}")); # Unassigned < Unassigned(ExtB)
80 ok($Collator->lt("\x{9FFF}","\x{2A6D6}")); # Unassigned < Unassigned(ExtB)
81
82 ##### 42..51
83 $Collator->change(UCA_Version => 14);
84 ok($Collator->lt("\x{9FA5}", "\x{3400}")); # UI < ExtA
85 ok($Collator->lt("\x{9FA6}", "\x{3400}")); # new UI < ExtA
86 ok($Collator->lt("\x{9FBB}", "\x{3400}")); # new UI < ExtA
87 ok($Collator->gt("\x{9FBC}", "\x{3400}")); # Unassigned > ExtA
88 ok($Collator->gt("\x{9FFF}", "\x{3400}")); # Unassigned > ExtA
89 ok($Collator->lt("\x{9FA6}", "\x{9FBB}")); # new UI > new UI
90 ok($Collator->lt("\x{3400}","\x{20000}")); # ExtA < ExtB
91 ok($Collator->lt("\x{3400}","\x{2A6D6}")); # ExtA < ExtB
92 ok($Collator->gt("\x{9FFF}","\x{20000}")); # Unassigned > ExtB
93 ok($Collator->gt("\x{9FFF}","\x{2A6D6}")); # Unassigned > ExtB
94