/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1088 - (show annotations)
Mon Jan 28 18:30:01 2008 UTC (16 years, 3 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1333 byte(s)
 r1699@llin:  dpavlin | 2008-01-11 19:51:52 +0100
 test round-trip of excel encoding to report bug

1 #!/usr/bin/perl -w
2
3 use strict;
4 use blib;
5
6 use Test::More tests => 22;
7
8 BEGIN {
9 use_ok( 'WebPAC::Test' );
10 use_ok( 'WebPAC::Output::Excel' );
11 use_ok( 'WebPAC::Input' );
12 }
13
14 my $path = "$abs_path/out/test.xls";
15
16 ok(my $out = new WebPAC::Output::Excel({ path => $path, %LOG }), "new");
17
18 ok( $out->init, 'init' );
19
20 throws_ok { $out->add( ) } qr/need id/, 'add without params';
21 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 ) {
28 my $ds;
29 my $tmp;
30 foreach my $col ( 'A' .. 'Z' ) {
31 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" );
37 push @expected, $tmp;
38 }
39
40 ok( $out->finish );
41
42 ok( -e $out->path, "created $path" );
43
44 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 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26