test excell file
[webpac2] / t / 2-input-excel.t
index 9b091d3..962f48c 100755 (executable)
@@ -1,36 +1,36 @@
 #!/usr/bin/perl -w
 
-use Test::More tests => 45;
-use Test::Exception;
-use Cwd qw/abs_path/;
-use blib;
 use strict;
+use blib;
 
-use Data::Dump qw/dump/;
-
-my $debug = 1;
+use Test::More tests => 49;
 
 BEGIN {
+use_ok( 'WebPAC::Test' );
 use_ok( 'WebPAC::Input' );
 }
 
-ok(my $abs_path = abs_path($0), "abs_path");
-$abs_path =~ s#/[^/]*$#/#;
-
 my $module = 'WebPAC::Input::Excel';
 diag "testing with $module";
 
 ok(my $input = new WebPAC::Input(
        module => $module,
-       no_log => 0,
        no_progress_bar => 1,
-       debug => $debug,
+       %LOG,
 ), "new");
 
-ok(my $db = $input->open(
-       path => "$abs_path/data/excel_95.xls"
-), "open");
-ok(my $size = $input->size, "size");
+our ($db,$size);
+
+sub open_xls {
+       my $args = shift;
+
+       $args->{path} = "$abs_path/data/" . $args->{path} || die "no path?";
+       ok(my $db = $input->open( %$args ), "open " . dump( $args ));
+       ok($size = $input->size, "size $size");
+       return $db;
+}
+
+open_xls({ path => 'excel_95.xls' });
 
 foreach my $mfn ( 1 ... $size ) {
        my $rec = $input->fetch;
@@ -42,6 +42,10 @@ foreach my $mfn ( 1 ... $size ) {
 
        cmp_ok($input->pos, '==', $mfn, "pos $mfn");
 
-       diag "rec: ", dump($rec), "\n";
+       diag "rec: ", dump($rec), "\n" if $debug;
 }
 
+open_xls({ path => 'stara-signatura.xls', input_encoding => 'utf-16' });
+ok( $input->seek( 790 ), 'seek 790');
+ok( my $rec = $input->fetch, 'fetch' );
+diag dump( $rec );