File: 62_fmt.t

package info (click to toggle)
libspreadsheet-read-perl 0.54-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 624 kB
  • ctags: 51
  • sloc: perl: 2,868; lisp: 293; makefile: 11; xml: 1
file content (64 lines) | stat: -rw-r--r-- 2,214 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/perl

use strict;
use warnings;

my     $tests = 40;
use     Test::More;
require Test::NoWarnings;

use     Spreadsheet::Read;
Spreadsheet::Read::parses ("xlsx") or
    plan skip_all => "No M\$-Excel parser found";

my $xls;
ok ($xls = ReadData ("files/attr.xlsx", attr => 1), "Excel Attributes testcase");

my $parser = $xls->[0]{parser};

SKIP: {
    ok (my $fmt = $xls->[$xls->[0]{sheet}{Format}],	"format");

    $fmt->{attr}[2][2]{merged} or
	skip "$parser $xls->[0]{version} does not reliably support attributes yet", 38;

    # The return value for the invisible part of merged cells differs for
    # the available parsers
    my $mcrv = $parser =~ m/::XLSX/ ? undef : "";

    is ($fmt->{B2},		"merged",	"Merged cell left    formatted");
    is ($fmt->{C2},		$mcrv,		"Merged cell right   formatted");
    is ($fmt->{cell}[2][2],	"merged",	"Merged cell left  unformatted");
    is ($fmt->{cell}[3][2],	$mcrv,		"Merged cell right unformatted");
    is ($fmt->{attr}[2][2]{merged}, 1,	"Merged cell left  merged");
    is ($fmt->{attr}[3][2]{merged}, 1,	"Merged cell right merged");

    is ($fmt->{B3},		"unlocked",	"Unlocked cell");
    is ($fmt->{attr}[2][3]{locked}, 0,	"Unlocked cell not locked");
    is ($fmt->{attr}[2][3]{merged}, 0,	"Unlocked cell not merged");
    is ($fmt->{attr}[2][3]{hidden}, 0,	"Unlocked cell not hidden");

    is ($fmt->{B4},		"hidden",	"Hidden cell");
    is ($fmt->{attr}[2][4]{hidden}, 1,	"Hidden cell hidden");
    is ($fmt->{attr}[2][4]{merged}, 0,	"Hidden cell not merged");

    foreach my $r (1 .. 12) {
	is ($fmt->{cell}[1][$r], 12345,	"Unformatted valued A$r");
	}
    is ($fmt->{attr}[1][1]{format}, undef,	"Default format");
    is ($fmt->{cell}[1][1],  $fmt->{A1},	"Formatted valued A1");
    is ($fmt->{cell}[1][10], $fmt->{A10},	"Formatted valued A10"); # String
    foreach my $r (2 .. 9, 11, 12) {
	isnt ($fmt->{cell}[1][$r], $fmt->{"A$r"},	"Unformatted valued A$r");
	}
    # Not yet. needs more digging
    #foreach my $r (2 .. 12) {
    #    ok (defined $fmt->{attr}[1][$r]{format},	"Defined format A$r");
    #    }
    }

unless ($ENV{AUTOMATED_TESTING}) {
    Test::NoWarnings::had_no_warnings ();
    $tests++;
    }
done_testing ($tests);