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; |
fe067ad9 |
22 | BEGIN { plan tests => 68 }; |
82e740b6 |
23 | use Unicode::Normalize qw(:all); |
24 | ok(1); # If we made it this far, we're ok. |
25 | |
fe067ad9 |
26 | sub _pack_U { Unicode::Normalize::pack_U(@_) } |
27 | sub hexU { _pack_U map hex, split ' ', shift } |
82e740b6 |
28 | sub answer { defined $_[0] ? $_[0] ? "YES" : "NO" : "MAYBE" } |
29 | |
30 | ######################### |
31 | |
fe067ad9 |
32 | ok(FCD(''), ""); |
33 | ok(FCC(''), ""); |
34 | ok(FCD('A'), "A"); |
35 | ok(FCC('A'), "A"); |
36 | |
37 | ok(normalize('FCD', ""), ""); |
38 | ok(normalize('FCC', ""), ""); |
39 | ok(normalize('FCC', "A"), "A"); |
40 | ok(normalize('FCD', "A"), "A"); |
41 | |
42 | # if checkFCD is YES, the return value from FCD should be same as the original |
43 | ok(FCD(hexU("00C5")), hexU("00C5")); # A with ring above |
44 | ok(FCD(hexU("0041 030A")), hexU("0041 030A")); # A+ring |
45 | ok(FCD(hexU("0041 0327 030A")), hexU("0041 0327 030A")); # A+cedilla+ring |
46 | ok(FCD(hexU("AC01 1100 1161")), hexU("AC01 1100 1161")); # hangul |
47 | ok(FCD(hexU("212B F900")), hexU("212B F900")); # compat |
48 | |
49 | ok(normalize('FCD', hexU("00C5")), hexU("00C5")); |
50 | ok(normalize('FCD', hexU("0041 030A")), hexU("0041 030A")); |
51 | ok(normalize('FCD', hexU("0041 0327 030A")), hexU("0041 0327 030A")); |
52 | ok(normalize('FCD', hexU("AC01 1100 1161")), hexU("AC01 1100 1161")); |
53 | ok(normalize('FCD', hexU("212B F900")), hexU("212B F900")); |
54 | |
55 | # if checkFCD is MAYBE or NO, FCD returns NFD (this behavior isn't documented) |
56 | ok(FCD(hexU("00C5 0327")), hexU("0041 0327 030A")); |
57 | ok(FCD(hexU("0041 030A 0327")), hexU("0041 0327 030A")); |
58 | ok(FCD(hexU("00C5 0327")), NFD(hexU("00C5 0327"))); |
59 | ok(FCD(hexU("0041 030A 0327")), NFD(hexU("0041 030A 0327"))); |
60 | |
61 | ok(normalize('FCD', hexU("00C5 0327")), hexU("0041 0327 030A")); |
62 | ok(normalize('FCD', hexU("0041 030A 0327")), hexU("0041 0327 030A")); |
63 | ok(normalize('FCD', hexU("00C5 0327")), NFD(hexU("00C5 0327"))); |
64 | ok(normalize('FCD', hexU("0041 030A 0327")), NFD(hexU("0041 030A 0327"))); |
65 | |
82e740b6 |
66 | ok(answer(checkFCD('')), 'YES'); |
67 | ok(answer(checkFCD('A')), 'YES'); |
68 | ok(answer(checkFCD("\x{030A}")), 'YES'); # 030A;COMBINING RING ABOVE |
fe067ad9 |
69 | ok(answer(checkFCD("\x{0327}")), 'YES'); # 0327;COMBINING CEDILLA |
82e740b6 |
70 | ok(answer(checkFCD(_pack_U(0x00C5))), 'YES'); # A with ring above |
fe067ad9 |
71 | ok(answer(checkFCD(hexU("0041 030A"))), 'YES'); # A+ring |
72 | ok(answer(checkFCD(hexU("0041 0327 030A"))), 'YES'); # A+cedilla+ring |
73 | ok(answer(checkFCD(hexU("0041 030A 0327"))), 'NO'); # A+ring+cedilla |
74 | ok(answer(checkFCD(hexU("00C5 0327"))), 'NO'); # A-ring+cedilla |
75 | ok(answer(checkNFC(hexU("00C5 0327"))), 'MAYBE'); # NFC: A-ring+cedilla |
76 | ok(answer(check("FCD", hexU("00C5 0327"))), 'NO'); |
77 | ok(answer(check("NFC", hexU("00C5 0327"))), 'MAYBE'); |
82e740b6 |
78 | ok(answer(checkFCD("\x{AC01}\x{1100}\x{1161}")), 'YES'); # hangul |
79 | ok(answer(checkFCD("\x{212B}\x{F900}")), 'YES'); # compat |
80 | |
fe067ad9 |
81 | ok(answer(checkFCD(hexU("1EA7 05AE 0315 0062"))), "NO"); |
82 | ok(answer(checkFCC(hexU("1EA7 05AE 0315 0062"))), "NO"); |
83 | ok(answer(check('FCD', hexU("1EA7 05AE 0315 0062"))), "NO"); |
84 | ok(answer(check('FCC', hexU("1EA7 05AE 0315 0062"))), "NO"); |
82e740b6 |
85 | |
fe067ad9 |
86 | ok(FCC(hexU("00C5 0327")), hexU("0041 0327 030A")); |
87 | ok(FCC(hexU("0045 0304 0300")), "\x{1E14}"); |
82e740b6 |
88 | ok(FCC("\x{1100}\x{1161}\x{1100}\x{1173}\x{11AF}"), "\x{AC00}\x{AE00}"); |
fe067ad9 |
89 | ok(normalize('FCC', hexU("00C5 0327")), hexU("0041 0327 030A")); |
90 | ok(normalize('FCC', hexU("0045 0304 0300")), "\x{1E14}"); |
91 | ok(normalize('FCC', hexU("1100 1161 1100 1173 11AF")), "\x{AC00}\x{AE00}"); |
92 | |
93 | ok(FCC("\x{0B47}\x{0300}\x{0B3E}"), "\x{0B47}\x{0300}\x{0B3E}"); |
94 | ok(FCC("\x{1100}\x{0300}\x{1161}"), "\x{1100}\x{0300}\x{1161}"); |
95 | ok(FCC("\x{0B47}\x{0B3E}\x{0300}"), "\x{0B4B}\x{0300}"); |
96 | ok(FCC("\x{1100}\x{1161}\x{0300}"), "\x{AC00}\x{0300}"); |
97 | ok(FCC("\x{0B47}\x{300}\x{0B3E}\x{327}"), "\x{0B47}\x{300}\x{0B3E}\x{327}"); |
98 | ok(FCC("\x{1100}\x{300}\x{1161}\x{327}"), "\x{1100}\x{300}\x{1161}\x{327}"); |
82e740b6 |
99 | |
100 | ok(answer(checkFCC('')), 'YES'); |
101 | ok(answer(checkFCC('A')), 'YES'); |
102 | ok(answer(checkFCC("\x{030A}")), 'MAYBE'); # 030A;COMBINING RING ABOVE |
103 | ok(answer(checkFCC("\x{0327}")), 'MAYBE'); # 0327;COMBINING CEDILLA |
fe067ad9 |
104 | ok(answer(checkFCC(hexU("00C5"))), 'YES'); # A with ring above |
105 | ok(answer(checkFCC(hexU("0041 030A"))), 'MAYBE'); # A+ring |
106 | ok(answer(checkFCC(hexU("0041 0327 030A"))), 'MAYBE'); # A+cedilla+ring |
107 | ok(answer(checkFCC(hexU("0041 030A 0327"))), 'NO'); # A+ring+cedilla |
108 | ok(answer(checkFCC(hexU("00C5 0327"))), 'NO'); # A-ring+cedilla |
82e740b6 |
109 | ok(answer(checkFCC("\x{AC01}\x{1100}\x{1161}")), 'MAYBE'); # hangul |
110 | ok(answer(checkFCC("\x{212B}\x{F900}")), 'NO'); # compat |
111 | |