From 95225e1a4cf7032a79c0020e027fb04f7de545ca Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Thu, 30 Dec 2004 23:16:20 +0000 Subject: [PATCH 1/1] added real test (beginning of...) and changed some confesses to croak git-svn-id: file:///home/dpavlin/svn/Biblio-Isis/trunk@19 4670fa4d-42ec-0310-ab5b-a66af6943492 --- IsisDB.pm | 4 +-- t/001_load.t | 2 +- t/002_isis.t | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 3 deletions(-) create mode 100755 t/002_isis.t diff --git a/IsisDB.pm b/IsisDB.pm index c30e0ad..d8919d2 100644 --- 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) { - 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}); @@ -224,7 +224,7 @@ about your index (if debugging it for example). 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 diff --git a/t/001_load.t b/t/001_load.t index 0d1c9a9..39eb2ff 100755 --- a/t/001_load.t +++ b/t/001_load.t @@ -8,7 +8,7 @@ use Test::More tests => 2; BEGIN { use_ok( 'IsisDB' ); } my $object = IsisDB->new ( - isisdb => '/data/isis_data/ps/LIBRI/LIBRI', + isisdb => './data/winisis/BIBL', ); isa_ok ($object, 'IsisDB'); diff --git a/t/002_isis.t b/t/002_isis.t new file mode 100755 index 0000000..4290505 --- /dev/null +++ b/t/002_isis.t @@ -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; -- 2.20.1