[gnumeric] Test: string round trip testing.



commit b278fe7eef0d75744b1c32d021a0274ac0899b57
Author: Morten Welinder <terra gnome org>
Date:   Sun Feb 16 09:52:54 2014 -0500

    Test: string round trip testing.

 samples/string-tests.gnumeric |  Bin 0 -> 3358 bytes
 test/GnumericTest.pm          |   42 ++++++++++++++++++++++++++++++++++++++++-
 test/Makefile.am              |    1 +
 test/t6500-strings.pl         |   20 +++++++++++++++++++
 4 files changed, 62 insertions(+), 1 deletions(-)
---
diff --git a/samples/string-tests.gnumeric b/samples/string-tests.gnumeric
new file mode 100644
index 0000000..e1a2cd7
Binary files /dev/null and b/samples/string-tests.gnumeric differ
diff --git a/test/GnumericTest.pm b/test/GnumericTest.pm
index a689a81..305d985 100644
--- a/test/GnumericTest.pm
+++ b/test/GnumericTest.pm
@@ -7,7 +7,7 @@ use XML::Parser;
 
 @GnumericTest::ISA = qw (Exporter);
 @GnumericTest::EXPORT = qw(test_sheet_calc test_valgrind
-                           test_importer test_exporter
+                           test_importer test_exporter test_roundtrip
                           test_ssindex sstest test_command message
                           $ssconvert $sstest $topsrc $top_builddir
                           $samples $PERL);
@@ -354,6 +354,46 @@ sub test_exporter {
 
 # -----------------------------------------------------------------------------
 
+sub test_roundtrip {
+    my ($file,$format,$newext) = @_;
+
+    &report_skip ("file $file does not exist") unless -r $file;
+
+    my $tmp = fileparse ($file);
+    $tmp =~ s/\.([a-zA-Z0-9]+)$// or die "Must have extension for roundtrip test.";
+    my $ext = $1;
+    my $code;
+    my $keep = 0;
+
+    my $tmp1 = "$tmp.$newext";
+    &junkfile ($tmp1) unless $keep;
+    $code = system ("$ssconvert -T $format '$file' '$tmp1' 2>&1 | sed -e 's/^/| /'");
+    &system_failure ($ssconvert, $code) if $code;
+
+    my $tmp2 = "$tmp-new.$ext";
+    &junkfile ($tmp2) unless $keep;
+    $code = system ("$ssconvert '$tmp1' '$tmp2' 2>&1 | sed -e 's/^/| /'");
+    &system_failure ($ssconvert, $code) if $code;
+
+    my $tmp_xml = "$tmp.xml";
+    &junkfile ($tmp_xml) unless $keep;
+    $code = system ("zcat -f '$file' >'$tmp_xml'");
+    &system_failure ('zcat', $code) if $code;
+
+    my $tmp2_xml = "$tmp-new.xml";
+    &junkfile ($tmp2_xml) unless $keep;
+    $code = system ("zcat -f '$tmp2' >'$tmp2_xml'");
+    &system_failure ('zcat', $code) if $code;
+
+    $code = system ('diff', '-u', $tmp_xml, $tmp2_xml);
+    # Ignore failures for now.
+    # &system_failure ('diff', $code) if $code;
+
+    print STDERR "Pass\n";
+}
+
+# -----------------------------------------------------------------------------
+
 sub test_valgrind {
     my ($cmd,$uselibtool) = @_;
 
diff --git a/test/Makefile.am b/test/Makefile.am
index 04cf0f4..61b5bb6 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -71,6 +71,7 @@ TESTS =       t1000-statfuns.pl                       \
        t6102-objs-ods.pl                       \
        t6103-lookfuns-ods.pl                   \
        t6104-finfuns-ods.pl                    \
+       t6500-strings.pl                        \
        t7000-goal-seek.pl                      \
        t7100-solver-blend.pl                   \
        t7101-solver-afiro.pl                   \
diff --git a/test/t6500-strings.pl b/test/t6500-strings.pl
new file mode 100755
index 0000000..137e2f8
--- /dev/null
+++ b/test/t6500-strings.pl
@@ -0,0 +1,20 @@
+#!/usr/bin/perl -w
+# -----------------------------------------------------------------------------
+
+use strict;
+use lib ($0 =~ m|^(.*/)| ? $1 : ".");
+use GnumericTest;
+
+my $file = "$samples/string-tests.gnumeric";
+
+&message ("Check string ods roundtrip.");
+&test_roundtrip ($file, 'Gnumeric_OpenCalc:odf', "ods");
+
+&message ("Check string xls/BIFF7 roundtrip.");
+&test_roundtrip ($file, 'Gnumeric_Excel:excel_biff7', "xls");
+
+&message ("Check string xls/BIFF8 roundtrip.");
+&test_roundtrip ($file, 'Gnumeric_Excel:excel_biff8', "xls");
+
+&message ("Check string xlsx roundtrip.");
+&test_roundtrip ($file, 'Gnumeric_Excel:xlsx', "xlsx");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]