Update to Digest::MD5 2.31
[p5sagit/p5-mst-13.2.git] / ext / Digest / MD5 / t / utf8.t
1 #!perl -w
2
3 BEGIN {
4     if ($] < 5.006) {
5         print "1..0 # Skipped: your perl don't know unicode\n";
6         exit;
7     }
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
25 my $exp = ord "A" == 193 ? # EBCDIC
26            "c307ec81deba65e9a222ca81cd8f6ccd" :
27            "503debffe559537231ed24f25651ec20"; # Latin 1
28
29 chop($str);  # only bytes left
30 print "not " unless md5_hex($str) eq $exp;
31 print "ok 2\n";
32
33 # reference
34 print "not " unless md5_hex("foo\xFF") eq $exp;
35 print "ok 3\n";