/[webpac2]/trunk/t/2-input-excel.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/t/2-input-excel.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1100 - (hide annotations)
Sat Aug 2 23:46:41 2008 UTC (15 years, 9 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1005 byte(s)
Make cleanup of encodings, moving webpac closer to having
internal utf-8 representation.

This will break current code, but is really neceserry
step toward checking input encoding for validity

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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26