/[Biblio-Isis]/trunk/t/002_isis.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/t/002_isis.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 22 by dpavlin, Fri Dec 31 01:06:21 2004 UTC revision 36 by dpavlin, Thu Jan 6 20:48:07 2005 UTC
# Line 5  use blib; Line 5  use blib;
5    
6  use Data::Dumper;  use Data::Dumper;
7    
8  use Test::More tests => 104;  use Test::More tests => 110;
9    
10  BEGIN { use_ok( 'IsisDB' ); }  BEGIN { use_ok( 'Biblio::Isis' ); }
11    
12    my $debug = shift @ARGV;
13  my $isis;  my $isis;
14    
15  sub test_data {  sub test_data {
16    
17          my $args = {@_};          my $args = {@_};
18    
19          isa_ok ($isis, 'IsisDB');          isa_ok ($isis, 'Biblio::Isis');
20    
21          cmp_ok($isis->{maxmfn}, '==', 5, "maxmfn set to 5");          cmp_ok($isis->count, '==', 5, "count is 5");
22    
23          # test .CNT data          # test .CNT data
24    
25          SKIP: {          SKIP: {
26                  skip "no CNT file for this database", 5 unless $isis->{cnt_file};                  skip "no CNT file for this database", 5 unless $isis->{cnt_file};
27    
28                  $isis->read_cnt;                  ok(my $isis_cnt = $isis->read_cnt, "read_cnt");
29    
30                    cmp_ok(scalar keys %{$isis_cnt}, '==', 2, "returns 2 elements");
31    
32                  my $cnt = {                  my $cnt = {
33                          '1' => {                          '1' => {
# Line 53  sub test_data { Line 56  sub test_data {
56    
57                  foreach my $c (keys %{$cnt}) {                  foreach my $c (keys %{$cnt}) {
58                          foreach my $kn (keys %{$cnt->{$c}}) {                          foreach my $kn (keys %{$cnt->{$c}}) {
59                                  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");
60                          }                          }
61                  }                  }
62          }          }
# Line 90  sub test_data { Line 93  sub test_data {
93                  '200' => [ '1#^aPsychology^fCamille B. Wortman, Elizabeth F. Loftus, Mary E. Marshal' ],                  '200' => [ '1#^aPsychology^fCamille B. Wortman, Elizabeth F. Loftus, Mary E. Marshal' ],
94          } ];          } ];
95                                    
96          foreach my $mfn (1 .. $isis->{'maxmfn'}) {          foreach my $mfn (1 .. $isis->count) {
97                  my $rec;                  my $rec;
98                  ok($rec = $isis->fetch($mfn), "fetch $mfn");                  ok($rec = $isis->fetch($mfn), "fetch $mfn");
99    
# Line 98  sub test_data { Line 101  sub test_data {
101                          my $i = 0;                          my $i = 0;
102                          foreach my $v (@{$data->[$mfn-1]->{$f}}) {                          foreach my $v (@{$data->[$mfn-1]->{$f}}) {
103                                  $v =~ s/^[01# ][01# ]// if ($args->{no_ident});                                  $v =~ s/^[01# ][01# ]// if ($args->{no_ident});
104                                  cmp_ok($rec->{$f}->[$i], '==', $v, "MFN $mfn $f:$i $v");                                  cmp_ok($v, '==', $rec->{$f}->[$i], "MFN $mfn $f:$i $v");
105                                  $i++;                                  $i++;
106                          }                          }
107                  }                  }
# Line 111  sub test_data { Line 114  sub test_data {
114    
115                  skip "no Digest::MD5 module", 5 if ($@);                  skip "no Digest::MD5 module", 5 if ($@);
116    
117                  foreach my $mfn (1 .. $isis->{'maxmfn'}) {                  foreach my $mfn (1 .. $isis->count) {
118                          my $md5 = md5_hex($isis->to_ascii($mfn));                          my $md5 = md5_hex($isis->to_ascii($mfn));
119                          cmp_ok($args->{md5_ascii}[$mfn - 1], 'eq', $md5, "md5 $mfn");                          cmp_ok($md5, 'eq', $args->{md5_ascii}[$mfn - 1], "md5 $mfn");
120                  }                  }
121          }          }
122    
123  }  }
124    
125  $isis = IsisDB->new (  $isis = Biblio::Isis->new (
126          isisdb => './data/winisis/BIBL',          isisdb => './data/winisis/BIBL',
127            include_deleted => 1,
128            debug => $debug,
129  );  );
130    
131  print Dumper($isis);  print Dumper($isis);
# Line 130  test_data( Line 135  test_data(
135          md5_ascii => [ qw(          md5_ascii => [ qw(
136                  a369eff702307ba12eb81656ee0587fe                  a369eff702307ba12eb81656ee0587fe
137                  4fb38537a94f3f5954e40d9536b942b0                  4fb38537a94f3f5954e40d9536b942b0
138                  498cc16c9e7ab0fdc29182533cc35d11                  579a7c6901c654bdeac10547a98e5b71
139                  7d2adf1675c83283aa9b82bf343e3d85                  7d2adf1675c83283aa9b82bf343e3d85
140                  daf2cf86ca7e188e8360a185f3b43423                  daf2cf86ca7e188e8360a185f3b43423
141          ) ],          ) ],
142  );  );
143    
144  $isis = IsisDB->new (  $isis = Biblio::Isis->new (
145          isisdb => './data/isismarc/BIBL',          isisdb => './data/isismarc/BIBL',
146            include_deleted => 1,
147  );  );
148    
149  test_data(  test_data(
# Line 149  test_data( Line 155  test_data(
155                  843b9ebccf16a498fba623c78f21b6c0                  843b9ebccf16a498fba623c78f21b6c0
156          ) ],          ) ],
157  );  );
158    
159    # check logically deleted
160    
161    $isis = Biblio::Isis->new (
162            isisdb => './data/winisis/BIBL',
163            include_deleted => 1,
164    );
165    
166    ok($isis->fetch(3), "deleted found");
167    cmp_ok($isis->{deleted}, '==', 3, "MFN 3 is deleted");
168    
169    $isis = Biblio::Isis->new (
170            isisdb => './data/winisis/BIBL',
171            debug => $debug,
172    );
173    
174    ok(! $isis->fetch(3), "deleted not found");
175    cmp_ok($isis->{deleted}, '==', 3, "MFN 3 is deleted");
176    

Legend:
Removed from v.22  
changed lines
  Added in v.36

  ViewVC Help
Powered by ViewVC 1.1.26