Now that binmode(FH) does implicit ":bytes" revisit
[p5sagit/p5-mst-13.2.git] / ext / Digest / MD5 / t / utf8.t
1 #!perl -w
2
3 if ($] < 5.006) {
4     print "1..0\n";
5     exit;
6 }
7
8 print "1..3\n";
9
10 use strict;
11 use Digest::MD5 qw(md5_hex);
12
13 my $str;
14 $str = "foo\xFF\x{100}";
15
16 eval {
17     print md5_hex($str);
18     print "not ok 1\n";  # should not run
19 };
20 print "not " unless $@ && $@ =~ /^(Big byte|Wide character)/;
21 print "ok 1\n";
22
23 my $exp = ord "A" == 193 ? # EBCDIC
24            "c307ec81deba65e9a222ca81cd8f6ccd" :
25            "503debffe559537231ed24f25651ec20"; # Latin 1
26
27 chop($str);  # only bytes left
28 print "not " unless md5_hex($str) eq $exp;
29 print "ok 2\n";
30
31 # reference
32 print "not " unless md5_hex("foo\xFF") eq $exp;
33 print "ok 3\n";