1 2BEGIN { 3 if ($ENV{PERL_CORE}) { 4 chdir('t') if -d 't'; 5 @INC = $^O eq 'MacOS' ? qw(::lib) : qw(../lib); 6 } 7} 8 9######################### 10 11use strict; 12use warnings; 13BEGIN { $| = 1; print "1..70\n"; } 14my $count = 0; 15sub ok { Unicode::Normalize::ok(\$count, @_) } 16 17use Unicode::Normalize qw(:all); 18 19ok(1); 20 21sub _pack_U { Unicode::Normalize::dot_t_pack_U(@_) } 22sub hexU { _pack_U map hex, split ' ', shift } 23sub answer { defined $_[0] ? $_[0] ? "YES" : "NO" : "MAYBE" } 24 25######################### 26 27ok(FCD(''), ""); 28ok(FCC(''), ""); 29ok(FCD('A'), "A"); 30ok(FCC('A'), "A"); 31 32ok(normalize('FCD', ""), ""); 33ok(normalize('FCC', ""), ""); 34ok(normalize('FCC', "A"), "A"); 35ok(normalize('FCD', "A"), "A"); 36 37# 9 38 39# if checkFCD is YES, the return value from FCD should be same as the original 40ok(FCD(hexU("00C5")), hexU("00C5")); # A with ring above 41ok(FCD(hexU("0041 030A")), hexU("0041 030A")); # A+ring 42ok(FCD(hexU("0041 0327 030A")), hexU("0041 0327 030A")); # A+cedilla+ring 43ok(FCD(hexU("AC01 1100 1161")), hexU("AC01 1100 1161")); # hangul 44ok(FCD(hexU("212B F900")), hexU("212B F900")); # compat 45 46ok(normalize('FCD', hexU("00C5")), hexU("00C5")); 47ok(normalize('FCD', hexU("0041 030A")), hexU("0041 030A")); 48ok(normalize('FCD', hexU("0041 0327 030A")), hexU("0041 0327 030A")); 49ok(normalize('FCD', hexU("AC01 1100 1161")), hexU("AC01 1100 1161")); 50ok(normalize('FCD', hexU("212B F900")), hexU("212B F900")); 51 52# 19 53 54# if checkFCD is MAYBE or NO, FCD returns NFD (this behavior isn't documented) 55ok(FCD(hexU("00C5 0327")), hexU("0041 0327 030A")); 56ok(FCD(hexU("0041 030A 0327")), hexU("0041 0327 030A")); 57ok(FCD(hexU("00C5 0327")), NFD(hexU("00C5 0327"))); 58ok(FCD(hexU("0041 030A 0327")), NFD(hexU("0041 030A 0327"))); 59 60ok(normalize('FCD', hexU("00C5 0327")), hexU("0041 0327 030A")); 61ok(normalize('FCD', hexU("0041 030A 0327")), hexU("0041 0327 030A")); 62ok(normalize('FCD', hexU("00C5 0327")), NFD(hexU("00C5 0327"))); 63ok(normalize('FCD', hexU("0041 030A 0327")), NFD(hexU("0041 030A 0327"))); 64 65# 27 66 67ok(answer(checkFCD('')), 'YES'); 68ok(answer(checkFCD('A')), 'YES'); 69ok(answer(checkFCD("\x{030A}")), 'YES'); # 030A;COMBINING RING ABOVE 70ok(answer(checkFCD("\x{0327}")), 'YES'); # 0327;COMBINING CEDILLA 71ok(answer(checkFCD(_pack_U(0x00C5))), 'YES'); # A with ring above 72ok(answer(checkFCD(hexU("0041 030A"))), 'YES'); # A+ring 73ok(answer(checkFCD(hexU("0041 0327 030A"))), 'YES'); # A+cedilla+ring 74ok(answer(checkFCD(hexU("0041 030A 0327"))), 'NO'); # A+ring+cedilla 75ok(answer(checkFCD(hexU("00C5 0327"))), 'NO'); # A-ring+cedilla 76ok(answer(checkNFC(hexU("00C5 0327"))), 'MAYBE'); # NFC: A-ring+cedilla 77ok(answer(check("FCD", hexU("00C5 0327"))), 'NO'); 78ok(answer(check("NFC", hexU("00C5 0327"))), 'MAYBE'); 79ok(answer(checkFCD("\x{AC01}\x{1100}\x{1161}")), 'YES'); # hangul 80ok(answer(checkFCD("\x{212B}\x{F900}")), 'YES'); # compat 81 82ok(answer(checkFCD(hexU("1EA7 05AE 0315 0062"))), "NO"); 83ok(answer(checkFCC(hexU("1EA7 05AE 0315 0062"))), "NO"); 84ok(answer(check('FCD', hexU("1EA7 05AE 0315 0062"))), "NO"); 85ok(answer(check('FCC', hexU("1EA7 05AE 0315 0062"))), "NO"); 86 87# 45 88 89ok(FCC(hexU("00C5 0327")), hexU("0041 0327 030A")); 90ok(FCC(hexU("0045 0304 0300")), "\x{1E14}"); 91ok(FCC("\x{1100}\x{1161}\x{1100}\x{1173}\x{11AF}"), "\x{AC00}\x{AE00}"); 92ok(normalize('FCC', hexU("00C5 0327")), hexU("0041 0327 030A")); 93ok(normalize('FCC', hexU("0045 0304 0300")), "\x{1E14}"); 94ok(normalize('FCC', hexU("1100 1161 1100 1173 11AF")), "\x{AC00}\x{AE00}"); 95 96ok(FCC("\x{0B47}\x{0300}\x{0B3E}"), "\x{0B47}\x{0300}\x{0B3E}"); 97ok(FCC("\x{1100}\x{0300}\x{1161}"), "\x{1100}\x{0300}\x{1161}"); 98ok(FCC("\x{0B47}\x{0B3E}\x{0300}"), "\x{0B4B}\x{0300}"); 99ok(FCC("\x{1100}\x{1161}\x{0300}"), "\x{AC00}\x{0300}"); 100ok(FCC("\x{0B47}\x{300}\x{0B3E}\x{327}"), "\x{0B47}\x{300}\x{0B3E}\x{327}"); 101ok(FCC("\x{1100}\x{300}\x{1161}\x{327}"), "\x{1100}\x{300}\x{1161}\x{327}"); 102 103# 57 104 105ok(answer(checkFCC('')), 'YES'); 106ok(answer(checkFCC('A')), 'YES'); 107ok(answer(checkFCC("\x{030A}")), 'MAYBE'); # 030A;COMBINING RING ABOVE 108ok(answer(checkFCC("\x{0327}")), 'MAYBE'); # 0327;COMBINING CEDILLA 109ok(answer(checkFCC(hexU("00C5"))), 'YES'); # A with ring above 110ok(answer(checkFCC(hexU("0041 030A"))), 'MAYBE'); # A+ring 111ok(answer(checkFCC(hexU("0041 0327 030A"))), 'MAYBE'); # A+cedilla+ring 112ok(answer(checkFCC(hexU("0041 030A 0327"))), 'NO'); # A+ring+cedilla 113ok(answer(checkFCC(hexU("00C5 0327"))), 'NO'); # A-ring+cedilla 114ok(answer(checkFCC("\x{AC01}\x{1100}\x{1161}")), 'MAYBE'); # hangul 115ok(answer(checkFCC("\x{212B}\x{F900}")), 'NO'); # compat 116ok(answer(checkFCC("\x{212B}\x{0327}")), 'NO'); # compat 117ok(answer(checkFCC("\x{0327}\x{212B}")), 'NO'); # compat 118 119# 70 120 121