diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-10-09 10:34:04 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-10-09 10:34:04 -0400 |
commit | 9be18dff1973f9701b9a7fab33d7be48d5bbdf7d (patch) | |
tree | df4fe3fe931cd4d9a199807409f3c8f571c91ef8 /t | |
parent | 2f2f03f915eaaf9300dcf3587961f43733b7ded7 (diff) | |
download | spreadsheet-parsexlsx-9be18dff1973f9701b9a7fab33d7be48d5bbdf7d.tar.gz spreadsheet-parsexlsx-9be18dff1973f9701b9a7fab33d7be48d5bbdf7d.zip |
test for merged cells (#10)
Diffstat (limited to 't')
-rw-r--r-- | t/bug-10.t | 99 | ||||
-rw-r--r-- | t/data/bug-10.xlsx | bin | 0 -> 9323 bytes |
2 files changed, 99 insertions, 0 deletions
diff --git a/t/bug-10.t b/t/bug-10.t new file mode 100644 index 0000000..5dd6737 --- /dev/null +++ b/t/bug-10.t @@ -0,0 +1,99 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +use Spreadsheet::ParseXLSX; + +my $wb = Spreadsheet::ParseXLSX->new->parse('t/data/bug-10.xlsx'); +is($wb->worksheet_count, 4); + +{ + my @contents = ( + [ ['Foo01', 0], ['Bar01', 0] ], + [ ['Foo02', 0], ['Bar02', 0] ], + [ ['Foo03', 0], ['Bar03', 0] ], + [ ['Foo04', 0], ['Bar04', 0] ], + ); + my $ws = $wb->worksheet(0); + for my $row (0..$#contents) { + for my $col (0..$#{ $contents[$row] }) { + my $cell = $ws->get_cell($row, $col); + is($cell->value, $contents[$row][$col][0]); + is(!!$cell->is_merged, !!$contents[$row][$col][1]); + } + } + is($ws->get_merged_areas, undef); +} + +{ + my @contents = ( + [ ['Foo01', 0], ['Bar01', 0] ], + [ ['Foo02', 0], ['Bar02', 0] ], + [ ['Foo03', 0], ['Bar03', 0] ], + [ ['Foo04', 1], ['', 1] ], + ); + my $ws = $wb->worksheet(1); + for my $row (0..$#contents) { + for my $col (0..$#{ $contents[$row] }) { + my $cell = $ws->get_cell($row, $col); + is($cell->value, $contents[$row][$col][0]); + is(!!$cell->is_merged, !!$contents[$row][$col][1]); + } + } + is_deeply( + $ws->get_merged_areas, + [ [ 3, 0, 3, 1 ] ], + ); +} + +{ + my @contents = ( + [ ['Foo01', 0], ['Bar01', 0] ], + [ ['Foo02', 0], ['Bar02', 0] ], + [ ['Foo03', 0], ['Bar03', 1] ], + [ ['Foo04', 0], ['', 1] ], + ); + my $ws = $wb->worksheet(2); + for my $row (0..$#contents) { + for my $col (0..$#{ $contents[$row] }) { + my $cell = $ws->get_cell($row, $col); + is($cell->value, $contents[$row][$col][0]); + is(!!$cell->is_merged, !!$contents[$row][$col][1]); + } + } + is_deeply( + $ws->get_merged_areas, + [ [ 2, 1, 3, 1 ] ], + ); +} + +{ + my @contents = ( + [ ['Foo01', 0], ['Bar01', 0] ], + [ ['Foo02', 0], ['Bar02', 0] ], + [ ['Foo03', 1], ['', 1] ], + [ ['', 1], ['', 1] ], + [ ['Foo04', 0], ['Bar04', 1] ], + [ ['Foo05', 0], ['', 1] ], + [ ['Foo06', 1], ['', 1] ], + ); + my $ws = $wb->worksheet(3); + for my $row (0..$#contents) { + for my $col (0..$#{ $contents[$row] }) { + my $cell = $ws->get_cell($row, $col); + is($cell->value, $contents[$row][$col][0]); + is(!!$cell->is_merged, !!$contents[$row][$col][1]); + } + } + is_deeply( + $ws->get_merged_areas, + [ + [ 2, 0, 3, 1 ], + [ 4, 1, 5, 1 ], + [ 6, 0, 6, 1 ], + ], + ); +} + +done_testing; diff --git a/t/data/bug-10.xlsx b/t/data/bug-10.xlsx Binary files differnew file mode 100644 index 0000000..6e89a8c --- /dev/null +++ b/t/data/bug-10.xlsx |