1 |
dpavlin |
1068 |
#!/usr/bin/perl -w |
2 |
|
|
|
3 |
|
|
use strict; |
4 |
|
|
use blib; |
5 |
|
|
|
6 |
|
|
use Test::More tests => 14; |
7 |
|
|
|
8 |
|
|
BEGIN { |
9 |
|
|
use_ok( 'WebPAC::Test' ); |
10 |
|
|
use_ok( 'WebPAC::Output::Excel' ); |
11 |
|
|
} |
12 |
|
|
|
13 |
|
|
my $path = "$abs_path/out/test.xls"; |
14 |
|
|
|
15 |
|
|
ok(my $out = new WebPAC::Output::Excel({ path => $path, %LOG }), "new"); |
16 |
|
|
|
17 |
|
|
ok( $out->init, 'init' ); |
18 |
|
|
|
19 |
|
|
throws_ok { $out->add( ) } qr/need id/, 'add without params'; |
20 |
|
|
throws_ok { $out->add( 42 ) } qr/need ds/, 'add without ds'; |
21 |
|
|
|
22 |
|
|
foreach my $line ( 1 .. 5 ) { |
23 |
|
|
my $ds; |
24 |
|
|
foreach my $col ( 'A' .. 'Z' ) { |
25 |
|
|
$ds->{ $col } = { csv => $line . $col }; |
26 |
|
|
} |
27 |
|
|
ok( $out->add( $line, $ds ), "add $line" ); |
28 |
|
|
} |
29 |
|
|
|
30 |
|
|
ok( $out->finish ); |
31 |
|
|
|
32 |
|
|
ok( -e $out->path, "created $path" ); |
33 |
|
|
|
34 |
|
|
cmp_ok( $out->path, 'eq', $path, 'path' ); |
35 |
|
|
|