Commit | Line | Data |
82e740b6 |
1 | |
2 | BEGIN { |
3 | unless ("A" eq pack('U', 0x41)) { |
4 | print "1..0 # Unicode::Normalize " . |
5 | "cannot stringify a Unicode code point\n"; |
6 | exit 0; |
7 | } |
8 | } |
9 | |
10 | BEGIN { |
11 | if ($ENV{PERL_CORE}) { |
12 | chdir('t') if -d 't'; |
13 | @INC = $^O eq 'MacOS' ? qw(::lib) : qw(../lib); |
14 | } |
15 | } |
16 | |
17 | ######################### |
18 | |
19 | use Test; |
20 | use strict; |
21 | use warnings; |
22 | BEGIN { plan tests => 35 }; |
23 | use Unicode::Normalize qw(:all); |
24 | ok(1); # If we made it this far, we're ok. |
25 | |
26 | sub _pack_U { Unicode::Normalize::pack_U(@_) } |
27 | sub _unpack_U { Unicode::Normalize::unpack_U(@_) } |
28 | sub answer { defined $_[0] ? $_[0] ? "YES" : "NO" : "MAYBE" } |
29 | |
30 | ######################### |
31 | |
32 | ok(answer(checkFCD('')), 'YES'); |
33 | ok(answer(checkFCD('A')), 'YES'); |
34 | ok(answer(checkFCD("\x{030A}")), 'YES'); # 030A;COMBINING RING ABOVE |
35 | ok(answer(checkFCD("\x{0327}")), 'YES'); # 0327;COMBINING CEDILLA |
36 | ok(answer(checkFCD(_pack_U(0x00C5))), 'YES'); # A with ring above |
37 | ok(answer(checkFCD(_pack_U(0x41, 0x30A))), 'YES'); # A+ring |
38 | ok(answer(checkFCD(_pack_U(0x41, 0x327, 0x30A))), 'YES'); # A+cedilla+ring |
39 | ok(answer(checkFCD(_pack_U(0x41, 0x30A, 0x327))), 'NO'); # A+ring+cedilla |
40 | ok(answer(checkFCD(_pack_U(0xC5, 0x0327))), 'NO'); # A-ring+cedilla |
41 | ok(answer(checkNFC(_pack_U(0xC5, 0x0327))), 'MAYBE'); # NFC: A-ring+cedilla |
42 | ok(answer(check("FCD", _pack_U(0xC5, 0x0327))), 'NO'); |
43 | ok(answer(check("NFC", _pack_U(0xC5, 0x0327))), 'MAYBE'); |
44 | ok(answer(checkFCD("\x{AC01}\x{1100}\x{1161}")), 'YES'); # hangul |
45 | ok(answer(checkFCD("\x{212B}\x{F900}")), 'YES'); # compat |
46 | |
47 | ok(FCD(''), ""); |
48 | ok(FCC(''), ""); |
49 | |
50 | ok(FCD('A'), "A"); |
51 | ok(FCC('A'), "A"); |
52 | |
53 | ok(answer(checkFCD(_pack_U(0x1EA7, 0x05AE, 0x0315, 0x0062))), "NO"); |
54 | ok(answer(checkFCC(_pack_U(0x1EA7, 0x05AE, 0x0315, 0x0062))), "NO"); |
55 | |
56 | ok(FCC(_pack_U(0xC5, 0x327)), _pack_U(0x41, 0x327, 0x30A)); |
57 | ok(FCC(_pack_U(0x45, 0x304, 0x300)), _pack_U(0x1E14)); |
58 | ok(FCC("\x{1100}\x{1161}\x{1100}\x{1173}\x{11AF}"), "\x{AC00}\x{AE00}"); |
59 | |
60 | ok(answer(checkFCC('')), 'YES'); |
61 | ok(answer(checkFCC('A')), 'YES'); |
62 | ok(answer(checkFCC("\x{030A}")), 'MAYBE'); # 030A;COMBINING RING ABOVE |
63 | ok(answer(checkFCC("\x{0327}")), 'MAYBE'); # 0327;COMBINING CEDILLA |
64 | ok(answer(checkFCC(_pack_U(0x00C5))), 'YES'); # A with ring above |
65 | ok(answer(checkFCC(_pack_U(0x41, 0x30A))), 'MAYBE'); # A+ring |
66 | ok(answer(checkFCC(_pack_U(0x41, 0x327, 0x30A))), 'MAYBE'); # A+cedilla+ring |
67 | ok(answer(checkFCC(_pack_U(0x41, 0x30A, 0x327))), 'NO'); # A+ring+cedilla |
68 | ok(answer(checkFCC(_pack_U(0xC5, 0x0327))), 'NO'); # A-ring+cedilla |
69 | ok(answer(checkFCC("\x{AC01}\x{1100}\x{1161}")), 'MAYBE'); # hangul |
70 | ok(answer(checkFCC("\x{212B}\x{F900}")), 'NO'); # compat |
71 | |