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