/[webpac2]/trunk/t/5-output-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

Diff of /trunk/t/5-output-excel.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1068 by dpavlin, Tue Nov 27 23:45:28 2007 UTC revision 1088 by dpavlin, Mon Jan 28 18:30:01 2008 UTC
# Line 3  Line 3 
3  use strict;  use strict;
4  use blib;  use blib;
5    
6  use Test::More tests => 14;  use Test::More tests => 22;
7    
8  BEGIN {  BEGIN {
9  use_ok( 'WebPAC::Test' );  use_ok( 'WebPAC::Test' );
10  use_ok( 'WebPAC::Output::Excel' );  use_ok( 'WebPAC::Output::Excel' );
11    use_ok( 'WebPAC::Input' );
12  }  }
13    
14  my $path = "$abs_path/out/test.xls";  my $path = "$abs_path/out/test.xls";
# Line 19  ok( $out->init, 'init' ); Line 20  ok( $out->init, 'init' );
20  throws_ok { $out->add( ) } qr/need id/, 'add without params';  throws_ok { $out->add( ) } qr/need id/, 'add without params';
21  throws_ok { $out->add( 42 ) } qr/need ds/, 'add without ds';  throws_ok { $out->add( 42 ) } qr/need ds/, 'add without ds';
22    
23    my @funny_chars = ( qw/è æ ¾ ¹ ð È Æ ® © Ð/ );
24    
25    my @expected;
26    
27  foreach my $line ( 1 .. 5 ) {  foreach my $line ( 1 .. 5 ) {
28          my $ds;          my $ds;
29            my $tmp;
30          foreach my $col ( 'A' .. 'Z' ) {          foreach my $col ( 'A' .. 'Z' ) {
31                  $ds->{ $col } = { csv => $line . $col };                  my $text = $line . $col;
32                    $text .= shift @funny_chars if @funny_chars;
33                    $ds->{ $col } = { csv => $text };
34                    $tmp->{$col} = $text;
35          }          }
36          ok( $out->add( $line, $ds ), "add $line" );          ok( $out->add( $line, $ds ), "add $line" );
37            push @expected, $tmp;
38  }  }
39    
40  ok( $out->finish );  ok( $out->finish );
# Line 33  ok( -e $out->path, "created $path" ); Line 43  ok( -e $out->path, "created $path" );
43    
44  cmp_ok( $out->path, 'eq', $path, 'path' );  cmp_ok( $out->path, 'eq', $path, 'path' );
45    
46    diag dump( @expected ) if $debug;
47    
48    ok(my $input = WebPAC::Input->new( module => 'WebPAC::Input::Excel', no_progress_bar => 1, %LOG ), 'new input' );
49    ok(my $db = $input->open( path => $path ), "input->open $path");
50    
51    cmp_ok( $input->size, '==', $#expected, "same size" );
52    
53    foreach my $mfn ( 1 ... $input->size ) {
54            my $ds = shift @expected;
55            my $rec = $input->fetch;
56            diag dump( $ds, $rec ) if $debug;
57            is_deeply( $ds, $rec, "$mfn same?" );
58    }

Legend:
Removed from v.1068  
changed lines
  Added in v.1088

  ViewVC Help
Powered by ViewVC 1.1.26