Upgrade to Unicode::Normalize 0.12.
[p5sagit/p5-mst-13.2.git] / ext / Unicode / Normalize / t / norm.t
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
6 use Test;
7 use strict;
8 use warnings;
9 BEGIN { plan tests => 18 };
10 use Unicode::Normalize qw(normalize);
11 ok(1); # If we made it this far, we're ok.
12
13 #########################
14
15 ok(normalize('C', ""), "");
16 ok(normalize('D', ""), "");
17
18 sub hexNFC {
19   join " ", map sprintf("%04X", $_),
20   unpack 'U*', normalize 'C', pack 'U*', map hex(), split ' ', shift;
21 }
22 sub hexNFD {
23   join " ", map sprintf("%04X", $_),
24   unpack 'U*', normalize 'NFD', pack 'U*', map hex(), split ' ', shift;
25 }
26
27 ok(hexNFC("0061 0315 0300 05AE 05C4 0062"), "00E0 05AE 05C4 0315 0062");
28 ok(hexNFC("00E0 05AE 05C4 0315 0062"),      "00E0 05AE 05C4 0315 0062");
29 ok(hexNFC("0061 05AE 0300 05C4 0315 0062"), "00E0 05AE 05C4 0315 0062");
30 ok(hexNFC("0045 0304 0300 AC00 11A8"), "1E14 AC01");
31 ok(hexNFC("1100 1161 1100 1173 11AF"), "AC00 AE00");
32 ok(hexNFC("1100 0300 1161 1173 11AF"), "1100 0300 1161 1173 11AF");
33
34 ok(hexNFD("0061 0315 0300 05AE 05C4 0062"), "0061 05AE 0300 05C4 0315 0062");
35 ok(hexNFD("00E0 05AE 05C4 0315 0062"),      "0061 05AE 0300 05C4 0315 0062");
36 ok(hexNFD("0061 05AE 0300 05C4 0315 0062"), "0061 05AE 0300 05C4 0315 0062");
37 ok(hexNFC("0061 05C4 0315 0300 05AE 0062"), "0061 05AE 05C4 0300 0315 0062");
38 ok(hexNFC("0061 05AE 05C4 0300 0315 0062"), "0061 05AE 05C4 0300 0315 0062");
39 ok(hexNFD("0061 05C4 0315 0300 05AE 0062"), "0061 05AE 05C4 0300 0315 0062");
40 ok(hexNFD("0061 05AE 05C4 0300 0315 0062"), "0061 05AE 05C4 0300 0315 0062");
41 ok(hexNFC("0000 0041 0000 0000"), "0000 0041 0000 0000");
42 ok(hexNFD("0000 0041 0000 0000"), "0000 0041 0000 0000");
43