summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-03-25 04:03:50 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-03-25 04:03:50 +0000
commit4d5cc3322517048132902b777d962f6cf57559f1 (patch)
tree79ef92e9bb2e1bddc5834b476f6a43fb4f185336 /t
parent6fba102dfb9a79b0f5fd8d5e2b811acf44919bf1 (diff)
downloadperl-4d5cc3322517048132902b777d962f6cf57559f1.tar.gz
Put back the MD5-Base64 tests now that we have MIME::Base64.
p4raw-id: //depot/perl@9335
Diffstat (limited to 't')
-rw-r--r--t/lib/md5-file.t28
1 files changed, 27 insertions, 1 deletions
diff --git a/t/lib/md5-file.t b/t/lib/md5-file.t
index a5b726bcdd..b9c51e035d 100644
--- a/t/lib/md5-file.t
+++ b/t/lib/md5-file.t
@@ -6,7 +6,7 @@ BEGIN {
print "1..2\n";
use strict;
-use Digest::MD5 qw(md5 md5_hex);
+use Digest::MD5 qw(md5 md5_hex md5_base64);
#
# This is the output of: 'md5sum MD5.pm MD5.xs'
@@ -25,6 +25,14 @@ $EXPECT = <<EOT;
EOT
}
+my $B64 = 1;
+eval { require MIME::Base64; };
+if ($@) {
+ print $@;
+ print "# Will not test base64 methods\n";
+ $B64 = 0;
+}
+
my $testno = 0;
use File::Spec;
@@ -39,6 +47,11 @@ for (split /^/, $EXPECT) {
}
$file = File::Spec->catfile($path, $last);
my $md5bin = pack("H*", $md5hex);
+ my $md5b64;
+ if ($B64) {
+ $md5b64 = MIME::Base64::encode($md5bin, "");
+ chop($md5b64); chop($md5b64); # remove padding
+ }
my $failed;
if (digest_file($file, 'digest') ne $md5bin) {
@@ -51,6 +64,11 @@ for (split /^/, $EXPECT) {
$failed++;
}
+ if ($B64 && digest_file($file, 'b64digest') ne $md5b64) {
+ print "$file: Bad b64digest\n";
+ $failed++;
+ }
+
my $data = cat_file($file);
if (md5($data) ne $md5bin) {
print "$file: md5() failed\n";
@@ -60,6 +78,10 @@ for (split /^/, $EXPECT) {
print "$file: md5_hex() failed\n";
$failed++;
}
+ if ($B64 && md5_base64($data) ne $md5b64) {
+ print "$file: md5_base64() failed\n";
+ $failed++;
+ }
if (Digest::MD5->new->add($data)->digest ne $md5bin) {
print "$file: MD5->new->add(...)->digest failed\n";
@@ -69,6 +91,10 @@ for (split /^/, $EXPECT) {
print "$file: MD5->new->add(...)->hexdigest failed\n";
$failed++;
}
+ if ($B64 && Digest::MD5->new->add($data)->b64digest ne $md5b64) {
+ print "$file: MD5->new->add(...)->b64digest failed\n";
+ $failed++;
+ }
my @data = split //, $data;
if (md5(@data) ne $md5bin) {