b46ebf2b67f517a583506127d59c4ef7c6a3e898
[webpac2] / t / 2-input-excel.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use blib;
5
6 use Test::More tests => 45;
7
8 BEGIN {
9 use_ok( 'WebPAC::Test' );
10 use_ok( 'WebPAC::Input' );
11 }
12
13 my $module = 'WebPAC::Input::Excel';
14 diag "testing with $module";
15
16 our ($input,$db,$size);
17
18 sub open_xls {
19
20         ok($input = new WebPAC::Input(
21                 module => $module,
22                 no_progress_bar => 1,
23                 %LOG,
24         ), "new $module");
25
26         my $path = shift;
27         $path = "$abs_path/data/$path";
28         ok(my $db = $input->open( path => $path ), "open $path");
29         ok($size = $input->size, "size $size");
30         return $db;
31 }
32
33
34 open_xls('excel_95.xls');
35
36 foreach my $mfn ( 1 ... $size ) {
37         my $rec = $input->fetch;
38         if ($mfn <= 10 || $mfn == 20) {
39                 ok($rec, "fetch $mfn");
40         } else {
41                 ok(! $rec, "empty $mfn");
42         }
43
44         cmp_ok($input->pos, '==', $mfn, "pos $mfn");
45
46         diag "rec: ", dump($rec), "\n" if $debug;
47 }
48
49 open_xls('stara-signatura.xls');
50
51 foreach my $mfn ( 20 .. 23 ) {
52         diag dump( $input->fetch( $mfn ) ) if $debug;
53 }