[gnumeric] Tests: test some conditional format dependences.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Tests: test some conditional format dependences.
- Date: Sun, 14 Feb 2021 23:51:46 +0000 (UTC)
commit 8f9f90ff6c0af20bb4ba0f970b359f9933640127
Author: Morten Welinder <terra gnome org>
Date: Sun Feb 14 18:51:22 2021 -0500
Tests: test some conditional format dependences.
samples/cond-format-deps.gnumeric | Bin 0 -> 1982 bytes
test/Makefile.am | 1 +
test/t2006-cond-format-deps.pl | 65 ++++++++++++++++++++++++++++++++++++++
3 files changed, 66 insertions(+)
---
diff --git a/samples/cond-format-deps.gnumeric b/samples/cond-format-deps.gnumeric
new file mode 100644
index 000000000..7b92d884e
Binary files /dev/null and b/samples/cond-format-deps.gnumeric differ
diff --git a/test/Makefile.am b/test/Makefile.am
index ce0d61de4..0914c8744 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -69,6 +69,7 @@ TESTS = t1000-statfuns.pl \
t2003-random-generators.pl \
t2004-insdel-colrow.pl \
t2005-recalc.pl \
+ t2006-cond-format-deps.pl \
t2800-style-optimizer.pl \
t5800-csv-date.pl \
t5801-csv-number.pl \
diff --git a/test/t2006-cond-format-deps.pl b/test/t2006-cond-format-deps.pl
new file mode 100755
index 000000000..22058cfdd
--- /dev/null
+++ b/test/t2006-cond-format-deps.pl
@@ -0,0 +1,65 @@
+#!/usr/bin/perl -w
+# -----------------------------------------------------------------------------
+
+use strict;
+use lib ($0 =~ m|^(.*/)| ? $1 : ".");
+use GnumericTest;
+
+&message ("Check that conditional format dependency tracking works.");
+
+my $src = "$samples/cond-format-deps.gnumeric";
+&GnumericTest::report_skip ("file $src does not exist") unless -r $src;
+
+my $nbad = 0;
+
+&test1 (['A4' => 0], 'C4', "0");
+&test1 (['A4' => 1], 'C4', "0.00");
+
+&test1 (['A5' => 0], 'C5', "0");
+&test1 (['A5' => 1], 'C5', "0.00");
+
+&test1 (['A5' => 0, 'A6' => 0], 'C6', "0.00");
+&test1 (['A5' => 1, 'A6' => 0], 'C6', "0");
+&test1 (['A5' => 0, 'A6' => 1], 'C6', "0");
+&test1 (['A5' => 1, 'A6' => 1], 'C6', "0.00");
+
+&test1 (['A4' => 0, 'A5' => 0, 'A6' => 0, 'A7' => 0], 'C7', "0");
+&test1 (['A4' => 0.5, 'A5' => 0.5, 'A6' => 0.5, 'A7' => 0.5], 'C7', "0.00");
+&test1 (['A4' => 0, 'A5' => 0.5, 'A6' => 0.5, 'A7' => 0.5], 'C7', "0");
+&test1 (['A4' => 0.5, 'A5' => 0, 'A6' => 0.5, 'A7' => 0.5], 'C7', "0");
+&test1 (['A4' => 0.5, 'A5' => 0.5, 'A6' => 0, 'A7' => 0.5], 'C7', "0");
+&test1 (['A4' => 0.5, 'A5' => 0.5, 'A6' => 0.5, 'A7' => 0], 'C7', "0");
+&test1 (['A3' => 1, 'A4' => 0.5, 'A5' => 0.5, 'A6' => 0.5, 'A7' => 0.5, 'A8' => 1], 'C7', "0.00");
+
+sub test1 {
+ my ($set, $rescell, $expected) = @_;
+
+ my @args = ('-T', 'Gnumeric_stf:stf_assistant',
+ '-O', 'format=preserve',
+ '--recalc', "--export-range=$rescell");
+ while (@$set >= 2) {
+ my $c = shift @$set;
+ my $v = shift @$set;
+ push @args, "--set", "$c=$v";
+ }
+
+ my $cmd = "$ssconvert " . &GnumericTest::quotearg (@args, $src, 'fd://1');
+ print STDERR "# $cmd\n";
+ my $result = `$cmd 2>&1`;
+ chomp $result;
+ if ($result eq $expected) {
+ } else {
+ print STDERR "No good. Expected $expected, but got\n";
+ for my $line (split ("\n", $result)) {
+ print STDERR "| $line\n";
+ }
+ $nbad++;
+ }
+}
+
+
+if ($nbad > 0) {
+ die "Fail\n";
+} else {
+ print STDERR "Pass\n";
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]