File: 50_sc.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 (58 lines) | stat: -rw-r--r-- 1,570 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl

use strict;
use warnings;

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

use     Spreadsheet::Read;
my $parser = Spreadsheet::Read::parses ("sc") or
    plan skip_all => "No SquirelCalc parser found";

print STDERR "# Parser: $parser-", $parser->VERSION, "\n";

{   my $ref;
    $ref = ReadData ("no_such_file.sc");
    ok (!defined $ref, "Nonexistent file");
    $ref = ReadData ("files/empty.sc");
    ok (!defined $ref, "Empty file");
    }

my $content;
{   local $/;
    open my $sc, "<", "files/test.sc" or die "files/test.sc: $!\n";
    binmode $sc;
    $content = <$sc>;
    close   $sc;
    isnt ($content, undef, "Content is defined");
    isnt ($content, "",    "Content is filled");
    }

foreach my $txt ("files/test.sc", $content) {
    foreach my $clip (0, 2) {
	my $sc;
	ok ($sc = ReadData ($txt, clip => $clip),
	    "Read/Parse sc file ".($clip?"clipped":"unclipped"));

	ok (1, "Base values");
	is (ref $sc,			"ARRAY",	"Return type");
	is ($sc->[0]{type},		"sc",		"Spreadsheet type");
	is ($sc->[0]{sheets},		1,		"Sheet count");
	is (ref $sc->[0]{sheet},	"HASH",		"Sheet list");
	is (scalar keys %{$sc->[0]{sheet}},
					1,		"Sheet list count");
	is ($sc->[0]{version}, $Spreadsheet::Read::VERSION, "Parser version");

	is ($sc->[1]{maxcol},		10 - $clip,	"Columns");
	is ($sc->[1]{maxrow},		28 - $clip,	"Rows");
	is ($sc->[1]{cell}[1][22],	"  Workspace",	"Just checking one cell");
	}
    }

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