6 use Test::More tests => 6;
8 use Hash::Normalize qw<normalize>;
10 my $cafe_nfc = "caf\x{e9}";
11 my $cafe_nfd = "cafe\x{301}";
13 my %h1 = (cafe => 1, $cafe_nfc => 2);
15 is_deeply [ sort keys %h1 ], [ 'cafe', $cafe_nfc ], 'new hash';
19 is_deeply [ sort keys %h2 ], [ 'cafe', $cafe_nfc ], 'idempotent renormalization';
23 is_deeply [ sort keys %h3 ], [ 'cafe', $cafe_nfd ], 'true renormalization';
25 my %h4 = (cafe => 1, $cafe_nfc => 2, $cafe_nfd => 3);
26 my $keys = join ' ', sort keys %h4;
27 is scalar(keys %h4), 3, 'plain hash contains 3 keys';
28 eval { normalize %h4 };
29 like $@, qr/^Key collision after normalization /, 'normalizations collide';
30 is join(' ', sort keys %h4), $keys, 'collision happened but hash was untouched'