Upgrade to Unicode::Normalize 0.12.
[p5sagit/p5-mst-13.2.git] / ext / Unicode / Normalize / t / test.t
CommitLineData
45394607 1# Before `make install' is performed this script should be runnable with
2# `make test'. After `make install' it should work as `perl test.pl'
3
4#########################
5
6use Test;
7use strict;
8use warnings;
2a204b45 9BEGIN { plan tests => 20 };
45394607 10use Unicode::Normalize;
11ok(1); # If we made it this far, we're ok.
12
13#########################
14
15ok(NFC(""), "");
16ok(NFD(""), "");
17
18sub hexNFC {
19 join " ", map sprintf("%04X", $_),
20 unpack 'U*', NFC pack 'U*', map hex(), split ' ', shift;
21}
22sub hexNFD {
23 join " ", map sprintf("%04X", $_),
24 unpack 'U*', NFD pack 'U*', map hex(), split ' ', shift;
25}
26
27ok(hexNFC("0061 0315 0300 05AE 05C4 0062"), "00E0 05AE 05C4 0315 0062");
28ok(hexNFC("00E0 05AE 05C4 0315 0062"), "00E0 05AE 05C4 0315 0062");
29ok(hexNFC("0061 05AE 0300 05C4 0315 0062"), "00E0 05AE 05C4 0315 0062");
ac5ea531 30ok(hexNFC("0045 0304 0300 AC00 11A8"), "1E14 AC01");
31ok(hexNFC("1100 1161 1100 1173 11AF"), "AC00 AE00");
32ok(hexNFC("1100 0300 1161 1173 11AF"), "1100 0300 1161 1173 11AF");
45394607 33
34ok(hexNFD("0061 0315 0300 05AE 05C4 0062"), "0061 05AE 0300 05C4 0315 0062");
35ok(hexNFD("00E0 05AE 05C4 0315 0062"), "0061 05AE 0300 05C4 0315 0062");
36ok(hexNFD("0061 05AE 0300 05C4 0315 0062"), "0061 05AE 0300 05C4 0315 0062");
45394607 37ok(hexNFC("0061 05C4 0315 0300 05AE 0062"), "0061 05AE 05C4 0300 0315 0062");
38ok(hexNFC("0061 05AE 05C4 0300 0315 0062"), "0061 05AE 05C4 0300 0315 0062");
39ok(hexNFD("0061 05C4 0315 0300 05AE 0062"), "0061 05AE 05C4 0300 0315 0062");
40ok(hexNFD("0061 05AE 05C4 0300 0315 0062"), "0061 05AE 05C4 0300 0315 0062");
45394607 41ok(hexNFC("0000 0041 0000 0000"), "0000 0041 0000 0000");
42ok(hexNFD("0000 0041 0000 0000"), "0000 0041 0000 0000");
43
2a204b45 44# should be unary.
45ok(NFC "\x{41}\x{0302}\x{0301}\x62" eq "\x{1EA4}\x62");
46ok(NFD "\x{E0}\x{AC00}" eq "\x{61}\x{0300}\x{1100}\x{1161}");