groff-commit
[Top][All Lists]
Advanced

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

[groff] 10/20: [tbl]: Add more tests.


From: G. Branden Robinson
Subject: [groff] 10/20: [tbl]: Add more tests.
Date: Fri, 3 Feb 2023 16:47:54 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit 159d8346f3756301e436d2f55bfe0fa729b48f94
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri Feb 3 03:02:09 2023 -0600

    [tbl]: Add more tests.
    
    * src/preproc/tbl/tests/boxes-and-vertical-rules.sh:
    * src/preproc/tbl/tests/expand-region-option-works.sh:
    * src/preproc/tbl/tests/x-column-modifier-works.sh: Do it.
    
    * src/preproc/tbl/tbl.am (tbl_TESTS): Run tests.
    
      (tbl_XFAIL_TESTS): Add; future changes will resolve these.
---
 ChangeLog                                          |  11 ++
 src/preproc/tbl/tbl.am                             |  10 +-
 src/preproc/tbl/tests/boxes-and-vertical-rules.sh  | 174 +++++++++++++++++++++
 .../tbl/tests/expand-region-option-works.sh        | 173 ++++++++++++++++++++
 src/preproc/tbl/tests/x-column-modifier-works.sh   | 172 ++++++++++++++++++++
 5 files changed, 538 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7b3034b02..2427e45a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2023-02-03  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [tbl]: Add more tests.
+
+       * src/preproc/tbl/tests/boxes-and-vertical-rules.sh:
+       * src/preproc/tbl/tests/expand-region-option-works.sh:
+       * src/preproc/tbl/tests/x-column-modifier-works.sh: Do it.
+
+       * src/preproc/tbl/tbl.am (tbl_TESTS): Run tests.
+       (tbl_XFAIL_TESTS): Add; future changes will resolve these.
+
 2023-02-02  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/preproc/tbl/table.cpp (table::compute_total_separation):
diff --git a/src/preproc/tbl/tbl.am b/src/preproc/tbl/tbl.am
index 3926384dd..8de8da607 100644
--- a/src/preproc/tbl/tbl.am
+++ b/src/preproc/tbl/tbl.am
@@ -25,6 +25,7 @@ PREFIXMAN1 += src/preproc/tbl/tbl.1
 EXTRA_DIST += src/preproc/tbl/tbl.1.man
 
 tbl_TESTS = \
+  src/preproc/tbl/tests/boxes-and-vertical-rules.sh \
   src/preproc/tbl/tests/check-horizontal-line-length.sh \
   src/preproc/tbl/tests/check-line-intersections.sh \
   src/preproc/tbl/tests/check-vertical-line-length.sh \
@@ -34,18 +35,23 @@ tbl_TESTS = \
   src/preproc/tbl/tests/do-not-overlap-bottom-border-in-nroff.sh \
   src/preproc/tbl/tests/do-not-segv-on-invalid-vertical-span-entry.sh \
   src/preproc/tbl/tests/do-not-segv-when-backslash-R-in-text-block.sh \
+  src/preproc/tbl/tests/expand-region-option-works.sh \
   src/preproc/tbl/tests/format-time-diagnostics-work.sh \
   src/preproc/tbl/tests/save-and-restore-hyphenation-parameters.sh \
   src/preproc/tbl/tests/save-and-restore-inter-sentence-space.sh \
   src/preproc/tbl/tests/save-and-restore-line-numbering.sh \
   src/preproc/tbl/tests/save-and-restore-tab-stops.sh \
   src/preproc/tbl/tests/table-lacks-spurious-top-border.sh \
-  src/preproc/tbl/tests/warn-on-long-boxed-unkept-table.sh
+  src/preproc/tbl/tests/warn-on-long-boxed-unkept-table.sh \
+  src/preproc/tbl/tests/x-column-modifier-works.sh
 TESTS += $(tbl_TESTS)
 EXTRA_DIST += $(tbl_TESTS)
 
 tbl_XFAIL_TESTS = \
-  src/preproc/tbl/tests/table-lacks-spurious-top-border.sh
+  src/preproc/tbl/tests/boxes-and-vertical-rules.sh \
+  src/preproc/tbl/tests/expand-region-option-works.sh \
+  src/preproc/tbl/tests/table-lacks-spurious-top-border.sh \
+  src/preproc/tbl/tests/x-column-modifier-works.sh
 XFAIL_TESTS += $(tbl_XFAIL_TESTS)
 
 
diff --git a/src/preproc/tbl/tests/boxes-and-vertical-rules.sh 
b/src/preproc/tbl/tests/boxes-and-vertical-rules.sh
new file mode 100755
index 000000000..04711883a
--- /dev/null
+++ b/src/preproc/tbl/tests/boxes-and-vertical-rules.sh
@@ -0,0 +1,174 @@
+#!/bin/sh
+#
+# Copyright (C) 2023 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+groff="${abs_top_builddir:-.}/test-groff"
+
+fail=
+
+wail () {
+    echo ...FAILED >&2
+    fail=YES
+}
+
+# Test behavior of unexpanded tables using boxes and/or vertical rules.
+
+# Case 1: "naked" table
+
+input='.ll 64n
+.nf
+1234567890123456789012345678901234567890123456789012345678901234
+.fi
+.TS
+tab(@);
+L L L L L.
+abcdef@abcdef@abcdef@abcdef@abcdef
+.TE
+.pl \n(nlu'
+
+echo "checking unboxed table without vertical rules" >&2
+output=$(printf "%s\n" "$input" | "$groff" -t -Tascii)
+echo "$output"
+# 3 spaces between table entries
+echo "$output" | sed -n '2p' \
+    | grep -qx 'abcdef   abcdef   abcdef   abcdef   abcdef' || wail
+
+# Case 2: left-hand vertical rule
+
+input='.ll 64n
+.nf
+1234567890123456789012345678901234567890123456789012345678901234
+.fi
+.TS
+tab(@);
+| L L L L L.
+abcdef@abcdef@abcdef@abcdef@abcdef
+.TE
+.pl \n(nlu'
+
+echo "checking unboxed table with left-hand rule" >&2
+output=$(printf "%s\n" "$input" | "$groff" -t -Tascii)
+echo "$output"
+# 3 spaces between table entries
+echo "$output" | sed -n '3p' \
+    | grep -qx '| abcdef   abcdef   abcdef   abcdef   abcdef' || wail
+
+# Case 3: right-hand vertical rule
+
+input='.ll 64n
+.nf
+1234567890123456789012345678901234567890123456789012345678901234
+.fi
+.TS
+tab(@);
+L L L L L |.
+abcdef@abcdef@abcdef@abcdef@abcdef
+.TE
+.pl \n(nlu'
+
+echo "checking unboxed table with right-hand rule" >&2
+output=$(printf "%s\n" "$input" | "$groff" -t -Tascii)
+echo "$output"
+# 3 spaces between table entries
+echo "$output" | sed -n '3p' \
+    | grep -qx 'abcdef   abcdef   abcdef   abcdef   abcdef |' || wail
+
+# Case 4: vertical rule on both ends
+
+input='.ll 64n
+.nf
+1234567890123456789012345678901234567890123456789012345678901234
+.fi
+.TS
+tab(@);
+| L L L L L |.
+abcdef@abcdef@abcdef@abcdef@abcdef
+.TE
+.pl \n(nlu'
+
+echo "checking unboxed table with both rules" >&2
+output=$(printf "%s\n" "$input" | "$groff" -t -Tascii)
+echo "$output"
+# 3 spaces between table entries
+echo "$output" | sed -n '3p' \
+    | grep -qx '| abcdef   abcdef   abcdef   abcdef   abcdef |' || wail
+
+# Case 5: vertical rule on both ends and interior rule
+
+input='.ll 64n
+.nf
+1234567890123456789012345678901234567890123456789012345678901234
+.fi
+.TS
+tab(@);
+| L L L | L L |.
+abcdef@abcdef@abcdef@abcdef@abcdef
+.TE
+.pl \n(nlu'
+
+echo "checking unboxed table with both edge and interior rules" >&2
+output=$(printf "%s\n" "$input" | "$groff" -t -Tascii)
+echo "$output"
+# 3 spaces between table entries
+echo "$output" | sed -n '3p' \
+    | grep -qx '| abcdef   abcdef   abcdef | abcdef   abcdef |' || wail
+
+# Case 6: boxed table
+
+input='.ll 64n
+.nf
+1234567890123456789012345678901234567890123456789012345678901234
+.fi
+.TS
+box tab(@);
+L L L L L.
+abcdef@abcdef@abcdef@abcdef@abcdef
+.TE
+.pl \n(nlu'
+
+echo "checking boxed table without interior rules" >&2
+output=$(printf "%s\n" "$input" | "$groff" -t -Tascii)
+echo "$output"
+# 3 spaces between table entries
+echo "$output" | sed -n '3p' \
+    | grep -qx '| abcdef   abcdef   abcdef   abcdef   abcdef |' || wail
+
+# Case 7: boxed table with interior vertical rule
+
+input='.ll 64n
+.nf
+1234567890123456789012345678901234567890123456789012345678901234
+.fi
+.TS
+box tab(@);
+L L L | L L.
+abcdef@abcdef@abcdef@abcdef@abcdef
+.TE
+.pl \n(nlu'
+
+echo "checking boxed table with interior rules" >&2
+output=$(printf "%s\n" "$input" | "$groff" -t -Tascii)
+echo "$output"
+# 3 spaces between table entries
+echo "$output" | sed -n '3p' \
+    | grep -qx '| abcdef   abcdef   abcdef | abcdef   abcdef |' || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/src/preproc/tbl/tests/expand-region-option-works.sh 
b/src/preproc/tbl/tests/expand-region-option-works.sh
new file mode 100755
index 000000000..97da39de2
--- /dev/null
+++ b/src/preproc/tbl/tests/expand-region-option-works.sh
@@ -0,0 +1,173 @@
+#!/bin/sh
+#
+# Copyright (C) 2023 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+groff="${abs_top_builddir:-.}/test-groff"
+
+fail=
+
+wail () {
+    echo ...FAILED >&2
+    fail=YES
+}
+
+# Ensure that the "expand" region option expands to the line length.
+
+# Case 1: "naked" table
+
+input='.ll 64n
+.nf
+1234567890123456789012345678901234567890123456789012345678901234
+.fi
+.TS
+expand tab(@);
+L L L L L.
+abcdef@abcdef@abcdef@abcdef@abcdef
+.TE
+.pl \n(nlu'
+
+echo "checking unboxed table without vertical rules" >&2
+output=$(printf "%s\n" "$input" | "$groff" -t -Tascii)
+echo "$output"
+echo "$output" | sed -n '2p' \
+    | grep -Eqx '(abcdef {8,9}){4}abcdef' || wail
+
+# Case 2: left-hand vertical rule
+
+input='.ll 64n
+.nf
+1234567890123456789012345678901234567890123456789012345678901234
+.fi
+.TS
+expand tab(@);
+| L L L L L.
+abcdef@abcdef@abcdef@abcdef@abcdef
+.TE
+.pl \n(nlu'
+
+echo "checking unboxed table with left-hand rule" >&2
+output=$(printf "%s\n" "$input" | "$groff" -t -Tascii)
+echo "$output"
+echo "$output" | sed -n '3p' \
+    | grep -Eqx '\| abcdef {8}abcdef {7}abcdef {8}abcdef {9}abcdef' \
+    || wail
+
+# Case 3: right-hand vertical rule
+
+input='.ll 64n
+.nf
+1234567890123456789012345678901234567890123456789012345678901234
+.fi
+.TS
+expand tab(@);
+L L L L L |.
+abcdef@abcdef@abcdef@abcdef@abcdef
+.TE
+.pl \n(nlu'
+
+echo "checking unboxed table with right-hand rule" >&2
+output=$(printf "%s\n" "$input" | "$groff" -t -Tascii)
+echo "$output"
+echo "$output" | sed -n '3p' \
+    | grep -Eqx 'abcdef {8}abcdef {7}abcdef {8}abcdef {9}abcdef \|' \
+    || wail
+
+# Case 4: vertical rule on both ends
+
+input='.ll 64n
+.nf
+1234567890123456789012345678901234567890123456789012345678901234
+.fi
+.TS
+expand tab(@);
+| L L L L L |.
+abcdef@abcdef@abcdef@abcdef@abcdef
+.TE
+.pl \n(nlu'
+
+echo "checking unboxed table with both rules" >&2
+output=$(printf "%s\n" "$input" | "$groff" -t -Tascii)
+echo "$output"
+echo "$output" | sed -n '3p' \
+    | grep -Eqx '\| abcdef {7}abcdef {7}abcdef {8}abcdef {8}abcdef \|' \
+    || wail
+
+# Case 5: vertical rule on both ends and interior rule
+
+input='.ll 64n
+.nf
+1234567890123456789012345678901234567890123456789012345678901234
+.fi
+.TS
+expand tab(@);
+| L L L | L L |.
+abcdef@abcdef@abcdef@abcdef@abcdef
+.TE
+.pl \n(nlu'
+
+echo "checking unboxed table with both edge and interior rules" >&2
+output=$(printf "%s\n" "$input" | "$groff" -t -Tascii)
+echo "$output"
+echo "$output" | sed -n '3p' \
+    | grep -Eqx \
+    '\| abcdef {7}abcdef {7}abcdef {4}\| {3}abcdef {8}abcdef \|' || wail
+
+# Case 6: boxed table
+
+input='.ll 64n
+.nf
+1234567890123456789012345678901234567890123456789012345678901234
+.fi
+.TS
+box expand tab(@);
+L L L L L.
+abcdef@abcdef@abcdef@abcdef@abcdef
+.TE
+.pl \n(nlu'
+
+echo "checking boxed table without interior rules" >&2
+output=$(printf "%s\n" "$input" | "$groff" -t -Tascii)
+echo "$output"
+echo "$output" | sed -n '3p' \
+    | grep -Eqx '\| abcdef {7}abcdef {7}abcdef {8}abcdef {8}abcdef \|' \
+    || wail
+
+# Case 7: boxed table with interior vertical rule
+
+input='.ll 64n
+.nf
+1234567890123456789012345678901234567890123456789012345678901234
+.fi
+.TS
+box expand tab(@);
+L L L | L L.
+abcdef@abcdef@abcdef@abcdef@abcdef
+.TE
+.pl \n(nlu'
+
+echo "checking boxed table with interior rule" >&2
+output=$(printf "%s\n" "$input" | "$groff" -t -Tascii)
+echo "$output"
+echo "$output" | sed -n '3p' \
+    | grep -Eqx \
+    '\| abcdef {7}abcdef {7}abcdef {4}\| {3}abcdef {8}abcdef \|' || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/src/preproc/tbl/tests/x-column-modifier-works.sh 
b/src/preproc/tbl/tests/x-column-modifier-works.sh
new file mode 100755
index 000000000..da9b89007
--- /dev/null
+++ b/src/preproc/tbl/tests/x-column-modifier-works.sh
@@ -0,0 +1,172 @@
+#!/bin/sh
+#
+# Copyright (C) 2023 Free Software Foundation, Inc.
+#
+# This file is part of groff.
+#
+# groff is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+groff="${abs_top_builddir:-.}/test-groff"
+
+fail=
+
+wail () {
+    echo ...FAILED >&2
+    fail=YES
+}
+
+# Ensure that the "x" column modifier causes table expansion to the line
+# length.
+
+# Case 1: "naked" table
+
+input='.ll 64n
+.nf
+1234567890123456789012345678901234567890123456789012345678901234
+.fi
+.TS
+tab(@);
+Lx L L L L.
+abcdef@abcdef@abcdef@abcdef@abcdef
+.TE
+.pl \n(nlu'
+
+echo "checking unboxed table without vertical rules" >&2
+output=$(printf "%s\n" "$input" | "$groff" -t -Tascii)
+echo "$output"
+echo "$output" | sed -n '2p' \
+    | grep -Eqx 'abcdef {25}(abcdef {3}){3}abcdef' || wail
+
+# Case 2: left-hand vertical rule
+
+input='.ll 64n
+.nf
+1234567890123456789012345678901234567890123456789012345678901234
+.fi
+.TS
+tab(@);
+| Lx L L L L.
+abcdef@abcdef@abcdef@abcdef@abcdef
+.TE
+.pl \n(nlu'
+
+echo "checking unboxed table with left-hand rule" >&2
+output=$(printf "%s\n" "$input" | "$groff" -t -Tascii)
+echo "$output"
+echo "$output" | sed -n '3p' \
+    | grep -Eqx '\| abcdef {23}(abcdef {3}){3}abcdef' || wail
+
+# Case 3: right-hand vertical rule
+
+input='.ll 64n
+.nf
+1234567890123456789012345678901234567890123456789012345678901234
+.fi
+.TS
+tab(@);
+Lx L L L L |.
+abcdef@abcdef@abcdef@abcdef@abcdef
+.TE
+.pl \n(nlu'
+
+echo "checking unboxed table with right-hand rule" >&2
+output=$(printf "%s\n" "$input" | "$groff" -t -Tascii)
+echo "$output"
+echo "$output" | sed -n '3p' \
+    | grep -Eqx 'abcdef {23}(abcdef {3}){3}abcdef \|' || wail
+
+# Case 4: vertical rule on both ends
+
+input='.ll 64n
+.nf
+1234567890123456789012345678901234567890123456789012345678901234
+.fi
+.TS
+tab(@);
+| Lx L L L L |.
+abcdef@abcdef@abcdef@abcdef@abcdef
+.TE
+.pl \n(nlu'
+
+echo "checking unboxed table with both rules" >&2
+output=$(printf "%s\n" "$input" | "$groff" -t -Tascii)
+echo "$output"
+echo "$output" | sed -n '3p' \
+    | grep -Eqx '\| abcdef {21}(abcdef {3}){3}abcdef \|' || wail
+
+# Case 5: vertical rule on both ends and interior rule
+
+input='.ll 64n
+.nf
+1234567890123456789012345678901234567890123456789012345678901234
+.fi
+.TS
+tab(@);
+| Lx L L | L L |.
+abcdef@abcdef@abcdef@abcdef@abcdef
+.TE
+.pl \n(nlu'
+
+echo "checking unboxed table with both edge and interior rules" >&2
+output=$(printf "%s\n" "$input" | "$groff" -t -Tascii)
+echo "$output"
+echo "$output" | sed -n '3p' \
+    | grep -Eqx \
+    '\| abcdef {21}abcdef {3}abcdef \| abcdef {3}abcdef \|' \
+    || wail
+
+# Case 6: boxed table
+
+input='.ll 64n
+.nf
+1234567890123456789012345678901234567890123456789012345678901234
+.fi
+.TS
+box tab(@);
+Lx L L L L.
+abcdef@abcdef@abcdef@abcdef@abcdef
+.TE
+.pl \n(nlu'
+
+echo "checking boxed table without interior rules" >&2
+output=$(printf "%s\n" "$input" | "$groff" -t -Tascii)
+echo "$output"
+echo "$output" | sed -n '3p' \
+    | grep -Eqx '\| abcdef {21}(abcdef {3}){3}abcdef \|' || wail
+
+# Case 7: boxed table with interior vertical rule
+
+input='.ll 64n
+.nf
+1234567890123456789012345678901234567890123456789012345678901234
+.fi
+.TS
+box tab(@);
+Lx L L | L L.
+abcdef@abcdef@abcdef@abcdef@abcdef
+.TE
+.pl \n(nlu'
+
+echo "checking boxed table with interior rules" >&2
+output=$(printf "%s\n" "$input" | "$groff" -t -Tascii)
+echo "$output"
+echo "$output" | sed -n '3p' \
+    | grep -Eqx \
+    '\| abcdef {21}abcdef {3}abcdef \| abcdef {3}abcdef \|' \
+    || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]