r1699@llin: dpavlin | 2008-01-11 19:51:52 +0100
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 28 Jan 2008 18:30:01 +0000 (18:30 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 28 Jan 2008 18:30:01 +0000 (18:30 +0000)
 test round-trip of excel encoding to report bug

git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@1088 07558da8-63fa-0310-ba24-9fe276d99e06

t/5-output-excel.t

index d588645..490fc17 100755 (executable)
@@ -3,11 +3,12 @@
 use strict;
 use blib;
 
-use Test::More tests => 14;
+use Test::More tests => 22;
 
 BEGIN {
 use_ok( 'WebPAC::Test' );
 use_ok( 'WebPAC::Output::Excel' );
+use_ok( 'WebPAC::Input' );
 }
 
 my $path = "$abs_path/out/test.xls";
@@ -19,12 +20,21 @@ ok( $out->init, 'init' );
 throws_ok { $out->add( ) } qr/need id/, 'add without params';
 throws_ok { $out->add( 42 ) } qr/need ds/, 'add without ds';
 
+my @funny_chars = ( qw/è æ ¾ ¹ ð È Æ ® © Ð/ );
+
+my @expected;
+
 foreach my $line ( 1 .. 5 ) {
        my $ds;
+       my $tmp;
        foreach my $col ( 'A' .. 'Z' ) {
-               $ds->{ $col } = { csv => $line . $col };
+               my $text = $line . $col;
+               $text .= shift @funny_chars if @funny_chars;
+               $ds->{ $col } = { csv => $text };
+               $tmp->{$col} = $text;
        }
        ok( $out->add( $line, $ds ), "add $line" );
+       push @expected, $tmp;
 }
 
 ok( $out->finish );
@@ -33,3 +43,16 @@ ok( -e $out->path, "created $path" );
 
 cmp_ok( $out->path, 'eq', $path, 'path' );
 
+diag dump( @expected ) if $debug;
+
+ok(my $input = WebPAC::Input->new( module => 'WebPAC::Input::Excel', no_progress_bar => 1, %LOG ), 'new input' );
+ok(my $db = $input->open( path => $path ), "input->open $path");
+
+cmp_ok( $input->size, '==', $#expected, "same size" );
+
+foreach my $mfn ( 1 ... $input->size ) {
+       my $ds = shift @expected;
+       my $rec = $input->fetch;
+       diag dump( $ds, $rec ) if $debug;
+       is_deeply( $ds, $rec, "$mfn same?" );
+}