1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
|
|
3 |
use Test::More tests => 36; |
use Test::More tests => 48; |
4 |
use Test::Exception; |
use Test::Exception; |
5 |
use Cwd qw/abs_path/; |
use Cwd qw/abs_path/; |
6 |
use blib; |
use blib; |
13 |
ok(my $abs_path = abs_path($0), "abs_path"); |
ok(my $abs_path = abs_path($0), "abs_path"); |
14 |
$abs_path =~ s#/[^/]*$#/#; |
$abs_path =~ s#/[^/]*$#/#; |
15 |
|
|
16 |
ok(my $isis = new WebPAC::Input::ISIS(), "new"); |
ok(my $isis = new WebPAC::Input::ISIS( no_log => 1 ), "new"); |
17 |
ok(my $isis_lm = new WebPAC::Input::ISIS( low_mem => 1 ), "new"); |
ok(my $isis_lm = new WebPAC::Input::ISIS( low_mem => 1, no_log => 1 ), "new"); |
18 |
|
|
19 |
throws_ok { $isis->open() } qr/filename/, "need filename"; |
throws_ok { $isis->open( ) } qr/filename/, "need filename"; |
20 |
|
|
21 |
throws_ok { $isis->open( filename => '/dev/null' ) } qr/can't find database/ , "open"; |
throws_ok { $isis->open( filename => '/dev/null', ) } qr/can't find database/ , "open"; |
22 |
|
|
23 |
ok($isis->open( filename => "$abs_path/winisis/BIBL" ), "open"); |
ok($isis->open( filename => "$abs_path/winisis/BIBL" ), "open"); |
24 |
ok($isis_lm->open( filename => "$abs_path/winisis/BIBL", low_mem => 1 ), "open"); |
ok($isis_lm->open( filename => "$abs_path/winisis/BIBL", low_mem => 1 ), "open"); |
45 |
} |
} |
46 |
|
|
47 |
is_deeply(\@db1, \@db2, "seek working"); |
is_deeply(\@db1, \@db2, "seek working"); |
48 |
|
|
49 |
|
sub test_start_limit($$$) { |
50 |
|
my ($s,$l,$e) = @_; |
51 |
|
|
52 |
|
diag "start_mfn: $s, limit_mfn: $l, expected: $e"; |
53 |
|
|
54 |
|
ok($s = $isis->open( filename => "$abs_path/winisis/BIBL", start_mfn => $s, limit_mfn => $l, debug => 1 ), "open"); |
55 |
|
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 |
|
|