1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
|
|
|
use Test::More tests => 45; |
|
|
use Test::Exception; |
|
|
use Cwd qw/abs_path/; |
|
|
use blib; |
|
3 |
use strict; |
use strict; |
4 |
|
use blib; |
5 |
|
|
6 |
use Data::Dump qw/dump/; |
use Test::More tests => 12; |
|
|
|
|
my $debug = 1; |
|
7 |
|
|
8 |
BEGIN { |
BEGIN { |
9 |
|
use_ok( 'WebPAC::Test' ); |
10 |
use_ok( 'WebPAC::Input' ); |
use_ok( 'WebPAC::Input' ); |
11 |
} |
} |
12 |
|
|
|
ok(my $abs_path = abs_path($0), "abs_path"); |
|
|
$abs_path =~ s#/[^/]*$#/#; |
|
|
|
|
13 |
my $module = 'WebPAC::Input::ISI'; |
my $module = 'WebPAC::Input::ISI'; |
14 |
diag "testing with $module"; |
diag "testing with $module"; |
15 |
|
|
16 |
ok(my $input = new WebPAC::Input( |
ok(my $input = new WebPAC::Input( |
17 |
module => $module, |
module => $module, |
|
no_log => 0, |
|
18 |
no_progress_bar => 1, |
no_progress_bar => 1, |
19 |
debug => $debug, |
%LOG |
20 |
), "new"); |
), "new"); |
21 |
|
|
22 |
ok(my $db = $input->open( |
ok(my $db = $input->open( |
23 |
path => "$abs_path/data/recs.txt" |
path => "$abs_path/data/recs.txt" |
24 |
), "open"); |
), "open"); |
25 |
ok(my $size = $input->size, "size"); |
ok(my $size = $input->size, "size"); |
26 |
|
cmp_ok( $size, '==', 2, 'size ok' ); |
27 |
|
|
28 |
foreach my $mfn ( 1 ... $size ) { |
foreach my $mfn ( 1 ... $size ) { |
29 |
my $rec = $input->fetch; |
my $rec = $input->fetch; |
30 |
if ($mfn <= 10 || $mfn == 20) { |
if ($mfn <= 10 || $mfn == 20) { |
31 |
ok($rec, "fetch $mfn"); |
ok($rec, "fetch $mfn"); |
32 |
|
cmp_ok($rec->{'000'}->[0], '==', $mfn, 'has mfn'); |
33 |
} else { |
} else { |
34 |
ok(! $rec, "empty $mfn"); |
ok(! $rec, "empty $mfn"); |
35 |
} |
} |
36 |
|
|
37 |
cmp_ok($input->pos, '==', $mfn, "pos $mfn"); |
cmp_ok($input->pos, '==', $mfn, "pos $mfn"); |
38 |
|
|
39 |
diag "rec: ", dump($rec), "\n"; |
diag "rec: ", dump($rec), "\n" if $debug; |
40 |
} |
} |
41 |
|
|