X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=t%2F002_isis.t;h=e1163e555e4621a9bd557e27c95993ce7a9de616;hb=93653871b2f53e6f93524bc5ee4f761bfd6f678f;hp=fa8a70978f8123a0c89e79332d31138ee7e6a231;hpb=f9062f8281a06d7052bd162c203135bab5ef9728;p=Biblio-Isis diff --git a/t/002_isis.t b/t/002_isis.t index fa8a709..e1163e5 100755 --- a/t/002_isis.t +++ b/t/002_isis.t @@ -5,26 +5,29 @@ use blib; use Data::Dumper; -use Test::More tests => 108; +use Test::More tests => 110; -BEGIN { use_ok( 'IsisDB' ); } +BEGIN { use_ok( 'Biblio::Isis' ); } +my $debug = shift @ARGV; my $isis; sub test_data { my $args = {@_}; - isa_ok ($isis, 'IsisDB'); + isa_ok ($isis, 'Biblio::Isis'); - cmp_ok($isis->{maxmfn}, '==', 5, "maxmfn set to 5"); + cmp_ok($isis->count, '==', 5, "count is 5"); # test .CNT data SKIP: { skip "no CNT file for this database", 5 unless $isis->{cnt_file}; - $isis->read_cnt; + ok(my $isis_cnt = $isis->read_cnt, "read_cnt"); + + cmp_ok(scalar keys %{$isis_cnt}, '==', 2, "returns 2 elements"); my $cnt = { '1' => { @@ -53,7 +56,7 @@ sub test_data { foreach my $c (keys %{$cnt}) { foreach my $kn (keys %{$cnt->{$c}}) { - cmp_ok($isis->{cnt}->{$c}->{$kn}, '==', $cnt->{$c}->{$kn}, "cnt $c $kn same"); + cmp_ok($isis_cnt->{$c}->{$kn}, '==', $cnt->{$c}->{$kn}, "cnt $c $kn same"); } } } @@ -90,7 +93,7 @@ sub test_data { '200' => [ '1#^aPsychology^fCamille B. Wortman, Elizabeth F. Loftus, Mary E. Marshal' ], } ]; - foreach my $mfn (1 .. $isis->{'maxmfn'}) { + foreach my $mfn (1 .. $isis->count) { my $rec; ok($rec = $isis->fetch($mfn), "fetch $mfn"); @@ -111,7 +114,7 @@ sub test_data { skip "no Digest::MD5 module", 5 if ($@); - foreach my $mfn (1 .. $isis->{'maxmfn'}) { + foreach my $mfn (1 .. $isis->count) { my $md5 = md5_hex($isis->to_ascii($mfn)); cmp_ok($md5, 'eq', $args->{md5_ascii}[$mfn - 1], "md5 $mfn"); } @@ -119,9 +122,10 @@ sub test_data { } -$isis = IsisDB->new ( +$isis = Biblio::Isis->new ( isisdb => './data/winisis/BIBL', include_deleted => 1, + debug => $debug, ); print Dumper($isis); @@ -137,7 +141,7 @@ test_data( ) ], ); -$isis = IsisDB->new ( +$isis = Biblio::Isis->new ( isisdb => './data/isismarc/BIBL', include_deleted => 1, ); @@ -154,7 +158,7 @@ test_data( # check logically deleted -$isis = IsisDB->new ( +$isis = Biblio::Isis->new ( isisdb => './data/winisis/BIBL', include_deleted => 1, ); @@ -162,8 +166,9 @@ $isis = IsisDB->new ( ok($isis->fetch(3), "deleted found"); cmp_ok($isis->{deleted}, '==', 3, "MFN 3 is deleted"); -$isis = IsisDB->new ( +$isis = Biblio::Isis->new ( isisdb => './data/winisis/BIBL', + debug => $debug, ); ok(! $isis->fetch(3), "deleted not found");