better utf8 test records
[webpac2] / t / 2-input-excel.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use blib;
5
6 use Test::More tests => 75;
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 ok(my $input = new WebPAC::Input(
17         module => $module,
18         no_progress_bar => 1,
19         %LOG,
20 ), "new");
21
22 our ($db,$size);
23
24 sub open_xls {
25         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 ) {
35         my $rec = $input->fetch;
36         if ($mfn <= 10 || $mfn == 20) {
37                 ok($rec, "fetch $mfn");
38         } else {
39                 ok(! $rec, "empty $mfn");
40         }
41
42         cmp_ok($input->pos, '==', $mfn, "pos $mfn");
43
44         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