1 2BEGIN { 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 10BEGIN { 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 19use Test; 20use strict; 21use warnings; 22BEGIN { plan tests => 35 }; 23use Unicode::Normalize qw(:all); 24ok(1); # If we made it this far, we're ok. 25 26sub _pack_U { Unicode::Normalize::pack_U(@_) } 27sub _unpack_U { Unicode::Normalize::unpack_U(@_) } 28sub answer { defined $_[0] ? $_[0] ? "YES" : "NO" : "MAYBE" } 29 30######################### 31 32ok(answer(checkFCD('')), 'YES'); 33ok(answer(checkFCD('A')), 'YES'); 34ok(answer(checkFCD("\x{030A}")), 'YES'); # 030A;COMBINING RING ABOVE 35ok(answer(checkFCD("\x{0327}")), 'YES'); # 0327;COMBINING CEDILLA 36ok(answer(checkFCD(_pack_U(0x00C5))), 'YES'); # A with ring above 37ok(answer(checkFCD(_pack_U(0x41, 0x30A))), 'YES'); # A+ring 38ok(answer(checkFCD(_pack_U(0x41, 0x327, 0x30A))), 'YES'); # A+cedilla+ring 39ok(answer(checkFCD(_pack_U(0x41, 0x30A, 0x327))), 'NO'); # A+ring+cedilla 40ok(answer(checkFCD(_pack_U(0xC5, 0x0327))), 'NO'); # A-ring+cedilla 41ok(answer(checkNFC(_pack_U(0xC5, 0x0327))), 'MAYBE'); # NFC: A-ring+cedilla 42ok(answer(check("FCD", _pack_U(0xC5, 0x0327))), 'NO'); 43ok(answer(check("NFC", _pack_U(0xC5, 0x0327))), 'MAYBE'); 44ok(answer(checkFCD("\x{AC01}\x{1100}\x{1161}")), 'YES'); # hangul 45ok(answer(checkFCD("\x{212B}\x{F900}")), 'YES'); # compat 46 47ok(FCD(''), ""); 48ok(FCC(''), ""); 49 50ok(FCD('A'), "A"); 51ok(FCC('A'), "A"); 52 53ok(answer(checkFCD(_pack_U(0x1EA7, 0x05AE, 0x0315, 0x0062))), "NO"); 54ok(answer(checkFCC(_pack_U(0x1EA7, 0x05AE, 0x0315, 0x0062))), "NO"); 55 56ok(FCC(_pack_U(0xC5, 0x327)), _pack_U(0x41, 0x327, 0x30A)); 57ok(FCC(_pack_U(0x45, 0x304, 0x300)), _pack_U(0x1E14)); 58ok(FCC("\x{1100}\x{1161}\x{1100}\x{1173}\x{11AF}"), "\x{AC00}\x{AE00}"); 59 60ok(answer(checkFCC('')), 'YES'); 61ok(answer(checkFCC('A')), 'YES'); 62ok(answer(checkFCC("\x{030A}")), 'MAYBE'); # 030A;COMBINING RING ABOVE 63ok(answer(checkFCC("\x{0327}")), 'MAYBE'); # 0327;COMBINING CEDILLA 64ok(answer(checkFCC(_pack_U(0x00C5))), 'YES'); # A with ring above 65ok(answer(checkFCC(_pack_U(0x41, 0x30A))), 'MAYBE'); # A+ring 66ok(answer(checkFCC(_pack_U(0x41, 0x327, 0x30A))), 'MAYBE'); # A+cedilla+ring 67ok(answer(checkFCC(_pack_U(0x41, 0x30A, 0x327))), 'NO'); # A+ring+cedilla 68ok(answer(checkFCC(_pack_U(0xC5, 0x0327))), 'NO'); # A-ring+cedilla 69ok(answer(checkFCC("\x{AC01}\x{1100}\x{1161}")), 'MAYBE'); # hangul 70ok(answer(checkFCC("\x{212B}\x{F900}")), 'NO'); # compat 71 72