test to_ascii
[Biblio-Isis] / t / 002_isis.t
index 7fc00c7..078f5b0 100755 (executable)
@@ -5,7 +5,7 @@ use blib;
 
 use Data::Dumper;
 
-use Test::More tests => 94;
+use Test::More tests => 104;
 
 BEGIN { use_ok( 'IsisDB' ); }
 
@@ -90,7 +90,7 @@ sub test_data {
                '200' => [ '1#^aPsychology^fCamille B. Wortman, Elizabeth F. Loftus, Mary E. Marshal' ],
        } ];
                
-       for (my $mfn = 1; $mfn <= $isis->{'maxmfn'}; $mfn++) {
+       foreach my $mfn (1 .. $isis->{'maxmfn'}) {
                my $rec;
                ok($rec = $isis->fetch($mfn), "fetch $mfn");
 
@@ -102,7 +102,19 @@ sub test_data {
                                $i++;
                        }
                }
-#              print Dumper($rec);
+       }
+
+       # test to_ascii
+
+       SKIP: {
+               eval "use Digest::MD5 qw(md5_hex)";
+
+               skip "no Digest::MD5 module", 5 if ($@);
+
+               foreach my $mfn (1 .. $isis->{'maxmfn'}) {
+                       my $md5 = md5_hex($isis->to_ascii($mfn));
+                       cmp_ok($args->{md5_ascii}[$mfn - 1], 'eq', $md5, "md5 $mfn");
+               }
        }
 
 }
@@ -113,10 +125,27 @@ $isis = IsisDB->new (
 
 print Dumper($isis);
 
-test_data( no_ident => 1 );
+test_data(
+       no_ident => 1,
+       md5_ascii => [ qw(
+               a369eff702307ba12eb81656ee0587fe
+               4fb38537a94f3f5954e40d9536b942b0
+               498cc16c9e7ab0fdc29182533cc35d11
+               7d2adf1675c83283aa9b82bf343e3d85
+               daf2cf86ca7e188e8360a185f3b43423
+       ) ],
+);
 
 $isis = IsisDB->new (
        isisdb => './data/isismarc/BIBL',
 );
 
-test_data();
+test_data(
+       md5_ascii => [ qw(
+               f5587d9bcaa54257a98fe27d3c17a0b6
+               3be9a049f686f2a36af93a856dcae0f2
+               3961be5e3ba8fb274c89c08d18df4bcc
+               5f73ec00d08af044a2c4105f7d889e24
+               843b9ebccf16a498fba623c78f21b6c0
+       ) ],
+);