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::Dumper; |
use Test::More tests => 75; |
|
|
|
|
my $debug = 1; |
|
7 |
|
|
8 |
BEGIN { |
BEGIN { |
9 |
use_ok( 'WebPAC::Input::Excel' ); |
use_ok( 'WebPAC::Test' ); |
10 |
|
use_ok( 'WebPAC::Input' ); |
11 |
} |
} |
12 |
|
|
|
ok(my $abs_path = abs_path($0), "abs_path"); |
|
|
$abs_path =~ s#/[^/]*$#/#; |
|
|
|
|
13 |
my $module = 'WebPAC::Input::Excel'; |
my $module = 'WebPAC::Input::Excel'; |
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( |
our ($db,$size); |
23 |
path => "$abs_path/data/excel_95.xls" |
|
24 |
), "open"); |
sub open_xls { |
25 |
ok(my $size = $input->size, "size"); |
my $path = shift || die "no path?"; |
26 |
|
$path = "$abs_path/data/$path"; |
27 |
|
ok(my $db = $input->open( path => $path ), "open $path"); |
28 |
|
ok($size = $input->size, "size $size"); |
29 |
|
return $db; |
30 |
|
} |
31 |
|
|
32 |
|
open_xls('excel_95.xls'); |
33 |
|
|
34 |
foreach my $mfn ( 1 ... $size ) { |
foreach my $mfn ( 1 ... $size ) { |
35 |
my $rec = $input->fetch; |
my $rec = $input->fetch; |
41 |
|
|
42 |
cmp_ok($input->pos, '==', $mfn, "pos $mfn"); |
cmp_ok($input->pos, '==', $mfn, "pos $mfn"); |
43 |
|
|
44 |
diag "rec: ", Dumper($rec), "\n"; |
diag "rec: ", dump($rec), "\n" if $debug; |
45 |
|
} |
46 |
|
|
47 |
|
open_xls('stara-signatura.xls'); |
48 |
|
for ( 1 .. 14 ) { |
49 |
|
ok( $input->seek( $_ ), "seek $_"); |
50 |
|
ok( my $rec = $input->fetch, "fetch $_" ); |
51 |
|
diag dump( $rec ) if $debug; |
52 |
} |
} |
53 |
|
|