/[webpac2]/trunk/t/2-input-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

Annotation of /trunk/t/2-input-isis.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (hide annotations)
Sun Jul 24 15:03:11 2005 UTC (18 years, 9 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1572 byte(s)
re-worked logging, added no_log option to disable logging

1 dpavlin 8 #!/usr/bin/perl -w
2    
3 dpavlin 21 use Test::More tests => 48;
4 dpavlin 8 use Test::Exception;
5 dpavlin 9 use Cwd qw/abs_path/;
6 dpavlin 8 use blib;
7     use strict;
8    
9     BEGIN {
10     use_ok( 'WebPAC::Input::ISIS' );
11     }
12    
13 dpavlin 9 ok(my $abs_path = abs_path($0), "abs_path");
14     $abs_path =~ s#/[^/]*$#/#;
15    
16 dpavlin 31 ok(my $isis = new WebPAC::Input::ISIS( no_log => 1 ), "new");
17     ok(my $isis_lm = new WebPAC::Input::ISIS( low_mem => 1, no_log => 1 ), "new");
18 dpavlin 8
19 dpavlin 31 throws_ok { $isis->open( ) } qr/filename/, "need filename";
20 dpavlin 8
21 dpavlin 31 throws_ok { $isis->open( filename => '/dev/null', ) } qr/can't find database/ , "open";
22 dpavlin 9
23     ok($isis->open( filename => "$abs_path/winisis/BIBL" ), "open");
24 dpavlin 10 ok($isis_lm->open( filename => "$abs_path/winisis/BIBL", low_mem => 1 ), "open");
25    
26     cmp_ok($isis->pos, '==', -1, "mfn");
27    
28     ok(my $size = $isis->size, "size");
29    
30     my @db1;
31    
32     foreach my $mfn ( 1 ... $size ) {
33     ok(my $rec = $isis->fetch, "fetch");
34     cmp_ok($isis->pos, '==', $mfn, "rec $mfn");
35     push @db1, $rec;
36     }
37    
38     my @db2;
39    
40     foreach my $mfn ( 1 ... $size ) {
41     ok($isis_lm->seek($mfn), "seek");
42     ok(my $rec = $isis_lm->fetch, "fetch");
43     cmp_ok($isis_lm->pos, '==', $mfn, "rec $mfn");
44     push @db2, $rec;
45     }
46    
47     is_deeply(\@db1, \@db2, "seek working");
48 dpavlin 21
49     sub test_start_limit($$$) {
50     my ($s,$l,$e) = @_;
51    
52     diag "start_mfn: $s, limit_mfn: $l, expected: $e";
53    
54 dpavlin 31 ok($s = $isis->open( filename => "$abs_path/winisis/BIBL", start_mfn => $s, limit_mfn => $l, debug => 1 ), "open");
55 dpavlin 21 cmp_ok($s, '==', $size, "db size from open");
56     cmp_ok($isis->size, '==', $e, "size");
57     }
58    
59     test_start_limit(1, 3, 3);
60     test_start_limit($size, 3, 0);
61     test_start_limit(3, $size, $size - 2);
62     test_start_limit(1, $size + 2, $size);
63    

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26