Commit | Line | Data |
2e60967a |
1 | #!perl -w |
2 | |
8be5f608 |
3 | BEGIN { |
4 | if ($] < 5.006) { |
5 | print "1..0 # Skipped: your perl don't know unicode\n"; |
6 | exit; |
7 | } |
2e60967a |
8 | } |
9 | |
10 | print "1..3\n"; |
11 | |
12 | use strict; |
13 | use Digest::MD5 qw(md5_hex); |
14 | |
15 | my $str; |
16 | $str = "foo\xFF\x{100}"; |
17 | |
18 | eval { |
19 | print md5_hex($str); |
20 | print "not ok 1\n"; # should not run |
21 | }; |
22 | print "not " unless $@ && $@ =~ /^(Big byte|Wide character)/; |
23 | print "ok 1\n"; |
24 | |
bf32f79f |
25 | my $exp = ord "A" == 193 ? # EBCDIC |
26 | "c307ec81deba65e9a222ca81cd8f6ccd" : |
27 | "503debffe559537231ed24f25651ec20"; # Latin 1 |
28 | |
2e60967a |
29 | chop($str); # only bytes left |
bf32f79f |
30 | print "not " unless md5_hex($str) eq $exp; |
2e60967a |
31 | print "ok 2\n"; |
32 | |
33 | # reference |
bf32f79f |
34 | print "not " unless md5_hex("foo\xFF") eq $exp; |
2e60967a |
35 | print "ok 3\n"; |