6 use Test::More tests => 22;
9 use_ok( 'WebPAC::Test' );
10 use_ok( 'WebPAC::Output::Excel' );
11 use_ok( 'WebPAC::Input' );
14 my $path = "$abs_path/out/test.xls";
16 ok(my $out = new WebPAC::Output::Excel({ path => $path, %LOG }), "new");
18 ok( $out->init, 'init' );
20 throws_ok { $out->add( ) } qr/need id/, 'add without params';
21 throws_ok { $out->add( 42 ) } qr/need ds/, 'add without ds';
23 my @funny_chars = ( qw/è æ ¾ ¹ ð È Æ ® © Ð/ );
27 foreach my $line ( 1 .. 5 ) {
30 foreach my $col ( 'A' .. 'Z' ) {
31 my $text = $line . $col;
32 $text .= shift @funny_chars if @funny_chars;
33 $ds->{ $col } = { csv => $text };
36 ok( $out->add( $line, $ds ), "add $line" );
42 ok( -e $out->path, "created $path" );
44 cmp_ok( $out->path, 'eq', $path, 'path' );
46 diag dump( @expected ) if $debug;
48 ok(my $input = WebPAC::Input->new( module => 'WebPAC::Input::Excel', no_progress_bar => 1, encoding => 'utf-16', %LOG ), 'new input' );
49 ok(my $db = $input->open( path => $path ), "input->open $path");
51 cmp_ok( $input->size, '==', $#expected, "same size" );
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( $rec, $ds, "$mfn same?" );