This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add a simple Unicode character database interface, Unicode::UCD.
[perl5.git] / lib / Unicode / UCD.t
CommitLineData
561c79ed
JH
1use Unicode::UCD 3.1.0;
2
3use Test;
4use strict;
5
6BEGIN { plan tests => 81 };
7
8use Unicode::UCD 'charinfo';
9
10my %charinfo;
11
12%charinfo = charinfo(0x41);
13
14ok($charinfo{code}, '0041');
15ok($charinfo{name}, 'LATIN CAPITAL LETTER A');
16ok($charinfo{category}, 'Lu');
17ok($charinfo{combining}, '0');
18ok($charinfo{bidi}, 'L');
19ok($charinfo{decomposition}, '');
20ok($charinfo{decimal}, '');
21ok($charinfo{digit}, '');
22ok($charinfo{numeric}, '');
23ok($charinfo{mirrored}, 'N');
24ok($charinfo{unicode10}, '');
25ok($charinfo{comment}, '');
26ok($charinfo{upper}, '');
27ok($charinfo{lower}, '0061');
28ok($charinfo{title}, '');
29ok($charinfo{block}, 'Basic Latin');
30
31%charinfo = charinfo(0x100);
32
33ok($charinfo{code}, '0100');
34ok($charinfo{name}, 'LATIN CAPITAL LETTER A WITH MACRON');
35ok($charinfo{category}, 'Lu');
36ok($charinfo{combining}, '0');
37ok($charinfo{bidi}, 'L');
38ok($charinfo{decomposition}, '0041 0304');
39ok($charinfo{decimal}, '');
40ok($charinfo{digit}, '');
41ok($charinfo{numeric}, '');
42ok($charinfo{mirrored}, 'N');
43ok($charinfo{unicode10}, 'LATIN CAPITAL LETTER A MACRON');
44ok($charinfo{comment}, '');
45ok($charinfo{upper}, '');
46ok($charinfo{lower}, '0101');
47ok($charinfo{title}, '');
48ok($charinfo{block}, 'Latin Extended-A');
49
50%charinfo = charinfo(0x590);
51
52ok($charinfo{code}, undef);
53ok($charinfo{name}, undef);
54ok($charinfo{category}, undef);
55ok($charinfo{combining}, undef);
56ok($charinfo{bidi}, undef);
57ok($charinfo{decomposition}, undef);
58ok($charinfo{decimal}, undef);
59ok($charinfo{digit}, undef);
60ok($charinfo{numeric}, undef);
61ok($charinfo{mirrored}, undef);
62ok($charinfo{unicode10}, undef);
63ok($charinfo{comment}, undef);
64ok($charinfo{upper}, undef);
65ok($charinfo{lower}, undef);
66ok($charinfo{title}, undef);
67ok($charinfo{block}, undef);
68
69%charinfo = charinfo(0x5d0);
70
71ok($charinfo{code}, '05D0');
72ok($charinfo{name}, 'HEBREW LETTER ALEF');
73ok($charinfo{category}, 'Lo');
74ok($charinfo{combining}, '0');
75ok($charinfo{bidi}, 'R');
76ok($charinfo{decomposition}, '');
77ok($charinfo{decimal}, '');
78ok($charinfo{digit}, '');
79ok($charinfo{numeric}, '');
80ok($charinfo{mirrored}, 'N');
81ok($charinfo{unicode10}, '');
82ok($charinfo{comment}, '');
83ok($charinfo{upper}, '');
84ok($charinfo{lower}, '');
85ok($charinfo{title}, '');
86ok($charinfo{block}, 'Hebrew');
87
88use Unicode::UCD 'charblock';
89
90ok(charblock(0x590), 'Hebrew');
91
92%charinfo = charinfo(0xbe);
93
94ok($charinfo{code}, '00BE');
95ok($charinfo{name}, 'VULGAR FRACTION THREE QUARTERS');
96ok($charinfo{category}, 'No');
97ok($charinfo{combining}, '0');
98ok($charinfo{bidi}, 'ON');
99ok($charinfo{decomposition}, '<fraction> 0033 2044 0034');
100ok($charinfo{decimal}, '');
101ok($charinfo{digit}, '');
102ok($charinfo{numeric}, '3/4');
103ok($charinfo{mirrored}, 'N');
104ok($charinfo{unicode10}, 'FRACTION THREE QUARTERS');
105ok($charinfo{comment}, '');
106ok($charinfo{upper}, '');
107ok($charinfo{lower}, '');
108ok($charinfo{title}, '');
109ok($charinfo{block}, 'Latin-1 Supplement');
110