Rename ext/Digest/SHA to ext/Digest-SHA
[perl.git] / ext / Digest-SHA / t / base64.t
1 use strict;
2
3 my $MODULE;
4
5 BEGIN {
6         $MODULE = ($ENV{PERL_CORE} || -d "src") ? "Digest::SHA" : "Digest::SHA::PurePerl";
7         eval "require $MODULE" || die $@;
8         $MODULE->import(qw(sha1_base64 sha224_base64 sha256_base64
9                 sha384_base64 sha512_base64));
10 }
11
12 BEGIN {
13         if ($ENV{PERL_CORE}) {
14                 chdir 't' if -d 't';
15                 @INC = '../lib';
16         }
17 }
18
19 my $in = "abc";
20 my @out = map { eval } <DATA>;
21 my @fcn = (\&sha1_base64, \&sha224_base64, \&sha256_base64,
22         \&sha384_base64, \&sha512_base64);
23
24 print "1..", scalar @out, "\n";
25
26 my $testnum = 1;
27 while (@out) {
28         my $fcn = shift @fcn;
29         my $rsp = shift @out;
30         my $skip = &$fcn("") ? 0 : 1;
31         unless ($skip) {
32                 print "not " unless &$fcn($in) eq $rsp;
33         }
34         print "ok ", $testnum++, $skip ? " # skip: no 64 bit" : "", "\n";
35 }
36
37 __DATA__
38 "qZk+NkcGgWq6PiVxeFDCbJzQ2J0"
39 "Iwl9IjQF2CKGQqR3vaJVsyqtvOS9oLP342ydpw"
40 "ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0"
41 "ywB1P0WjXou1oD1pmsZQBycsMqsO3tFjGotgWkP/W+2AhgcroefMI1i67KE0yCWn"
42 "3a81oZNherrMQXNJriBBMRLm+k6JqX6iCp7u5ktV05ohkpkqJ0/BqDa6PCOj/uu9RU1EI2Q86A4qmslPpUyknw"
43