2 # -----------------------------------------------------------------------------
5 use lib
($0 =~ m
|^(.*/)| ?
$1 : ".");
9 &message
("Check ssconvert split");
13 # -----------------------------------------------------------------------------
14 # Create reliable file to split
17 for my $i (1 ... $N) {
18 my $fn = "t9006-file$i.csv";
19 &GnumericTest
::junkfile
($fn);
20 push @little_files, $fn;
21 my $f = new IO
::File
($fn, "w");
22 die "$0: Failed to write $fn: $!\n" unless $f;
23 print $f "File $i,$i,=$i+1\nLine 2,$i,=$i-1\n";
26 my $combined = "t9006-combined.gnumeric";
27 &GnumericTest
::junkfile
($combined);
29 &test_command
("$ssconvert --merge-to=$combined " . join (" ", @little_files),
32 &GnumericTest
::removejunk
($_) foreach @little_files;
35 # -----------------------------------------------------------------------------
39 my $f = new IO
::File
($fn, "r");
40 die "$0: Failed to read $fn: $!\n" unless $f;
47 my ($ext,$args,$post,$pexpected) = @_;
48 my $template = 't9006-out-%n.' . $ext;
50 &test_command
("$ssconvert --export-file-per-sheet $args $combined '$template'",
53 for my $i (1 ... $N) {
58 my $expected = $pexpected->[$i - 1];
59 my $data = &read_whole_file
($fn);
67 if ($data ne $expected) {
68 print STDERR
"Difference for format $ext, sheet number $i\n";
69 print STDERR
"Observed:\n";
70 &GnumericTest
::dump_indented
($data);
71 print STDERR
"Expected:\n";
72 &GnumericTest
::dump_indented
($expected);
80 # -----------------------------------------------------------------------------
82 if (&subtest
("txt")) {
83 &message
("Check splitting info text files.");
85 for my $sep (",", "::") {
87 for my $i (1 ... $N) {
90 push @expected, "\"File $i\"$sep$i$sep$ip1\n\"Line 2\"$sep$i$sep$im1\n";
93 &common_test
('txt', "-O 'separator=$sep'", undef, \
@expected);
97 if (&subtest
("csv")) {
98 &message
("Check splitting info csv files.");
101 for my $i (1 ... $N) {
104 push @expected, "\"File $i\",$i,$ip1\n\"Line 2\",$i,$im1\n";
107 &common_test
('csv', '', undef, \
@expected);
110 if (&subtest
("tex")) {
111 &message
("Check splitting info latex files.");
114 for my $i (1 ... $N) {
117 push @expected, "File $i\t&$i\t&$ip1\\\\\nLine 2\t&$i\t&$im1\\\\\n";
120 &common_test
('tex', '-T Gnumeric_html:latex_table',
121 sub { s/(\%.*$)\n//mg; },
125 if (&subtest
("pdf")) {
126 &message
("Check splitting info pdf files.");
128 # We check only that the files are generated
129 my @expected = ('') x
$N;
130 &common_test
('pdf', '', sub { $_ = ''; }, \
@expected);