added real test (beginning of...) and changed some confesses to croak
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 30 Dec 2004 23:16:20 +0000 (23:16 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 30 Dec 2004 23:16:20 +0000 (23:16 +0000)
git-svn-id: file:///home/dpavlin/svn/Biblio-Isis/trunk@19 4670fa4d-42ec-0310-ab5b-a66af6943492

IsisDB.pm
t/001_load.t
t/002_isis.t [new file with mode: 0755]

index c30e0ad..d8919d2 100644 (file)
--- a/IsisDB.pm
+++ b/IsisDB.pm
@@ -148,7 +148,7 @@ sub new {
        push @must_exist, "fdt" if ($self->{read_fdt});
 
        foreach my $ext (@must_exist) {
        push @must_exist, "fdt" if ($self->{read_fdt});
 
        foreach my $ext (@must_exist) {
-               confess "missing ",uc($ext)," file in ",$self->{isisdb} unless ($self->{$ext."_file"});
+               croak "missing ",uc($ext)," file in ",$self->{isisdb} unless ($self->{$ext."_file"});
        }
 
        print STDERR "## using files: ",join(" ",@isis_files),"\n" if ($self->{debug});
        }
 
        print STDERR "## using files: ",join(" ",@isis_files),"\n" if ($self->{debug});
@@ -224,7 +224,7 @@ about your index (if debugging it for example).
 sub read_cnt  {
        my $self = shift;
 
 sub read_cnt  {
        my $self = shift;
 
-       confess "missing CNT file in ",$self->{isisdb} unless ($self->{cnt_file});
+       croak "missing CNT file in ",$self->{isisdb} unless ($self->{cnt_file});
 
        # Get the index information from $db.CNT
    
 
        # Get the index information from $db.CNT
    
index 0d1c9a9..39eb2ff 100755 (executable)
@@ -8,7 +8,7 @@ use Test::More tests => 2;
 BEGIN { use_ok( 'IsisDB' ); }
 
 my $object = IsisDB->new (
 BEGIN { use_ok( 'IsisDB' ); }
 
 my $object = IsisDB->new (
-       isisdb => '/data/isis_data/ps/LIBRI/LIBRI',
+       isisdb => './data/winisis/BIBL',
 );
 
 isa_ok ($object, 'IsisDB');
 );
 
 isa_ok ($object, 'IsisDB');
diff --git a/t/002_isis.t b/t/002_isis.t
new file mode 100755 (executable)
index 0000000..4290505
--- /dev/null
@@ -0,0 +1,73 @@
+#!/usr/bin/perl -w
+
+use strict;
+use blib;
+
+use Data::Dumper;
+
+use Test::More tests => 28;
+
+BEGIN { use_ok( 'IsisDB' ); }
+
+my $isis;
+
+sub test_data {
+
+       isa_ok ($isis, 'IsisDB');
+
+       cmp_ok($isis->{maxmfn}, '==', 5, "maxmfn set to 5");
+
+       # test .CNT data
+
+       SKIP: {
+               skip "no CNT file for this database", 5 unless $isis->{cnt_file};
+
+               $isis->read_cnt;
+
+               my $cnt = {
+                       '1' => {
+                               'N' => 15,
+                               'K' => 5,
+                               'FMAXPOS' => 8,
+                               'POSRX' => 1,
+                               'ABNORMAL' => 1,
+                               'ORDN' => 5,
+                               'LIV' => 0,
+                               'ORDF' => 5,
+                               'NMAXPOS' => 1
+                               },
+                       '2' => {
+                               'N' => 15,
+                               'K' => 5,
+                               'FMAXPOS' => 4,
+                               'POSRX' => 1,
+                               'ABNORMAL' => 0,
+                               'ORDN' => 5,
+                               'LIV' => 0,
+                               'ORDF' => 5,
+                               'NMAXPOS' => 1
+                               }
+               };
+
+               foreach my $c (keys %{$cnt}) {
+                       foreach my $kn (keys %{$cnt->{$c}}) {
+                               cmp_ok($isis->{cnt}->{$c}->{$kn}, '==', $cnt->{$c}->{$kn}, "cnt $c $kn same");
+                       }
+               }
+       }
+
+}
+
+$isis = IsisDB->new (
+       isisdb => './data/winisis/BIBL',
+);
+
+print Dumper($isis);
+
+test_data;
+
+$isis = IsisDB->new (
+       isisdb => './data/isismarc/BIBL',
+);
+
+test_data;