groff-commit
[Top][All Lists]
Advanced

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

[groff] 10/50: [tbl]: Add unit tests.


From: G. Branden Robinson
Subject: [groff] 10/50: [tbl]: Add unit tests.
Date: Sat, 21 May 2022 12:17:23 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 33dddf6d5e346f54c55b362290e36081aa9dc0b9
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Tue May 17 00:25:54 2022 -0500

    [tbl]: Add unit tests.
    
    ...including one XFAIL for bad behavior.
    
    * 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:
    * src/preproc/tbl/tests/table-lacks-spurious-top-border.sh: Do it.
    
    * src/preproc/tbl/tbl.am (tbl_TESTS): Run tests.
    
      (tbl_XFAIL_TESTS, XFAIL_TESTS): Expect one test failure.
---
 ChangeLog                                          | 12 ++++
 src/preproc/tbl/tbl.am                             | 10 ++-
 .../tbl/tests/check-horizontal-line-length.sh      | 78 ++++++++++++++++++++++
 src/preproc/tbl/tests/check-line-intersections.sh  | 50 ++++++++++++++
 .../tbl/tests/check-vertical-line-length.sh        | 49 ++++++++++++++
 .../tbl/tests/table-lacks-spurious-top-border.sh   | 55 +++++++++++++++
 6 files changed, 253 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index b2cbc109..a5e8e5c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2022-05-17  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [tbl]: Add unit tests, including one XFAIL for bad behavior.
+
+       * 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:
+       * src/preproc/tbl/tests/table-lacks-spurious-top-border.sh: Do
+       it.
+       * src/preproc/tbl/tbl.am (tbl_TESTS): Run tests.
+       (tbl_XFAIL_TESTS, XFAIL_TESTS): Expect one test failure.
+
 2022-05-16  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/devices/grotty/tty.cpp (tty_printer::add_char): Modify
diff --git a/src/preproc/tbl/tbl.am b/src/preproc/tbl/tbl.am
index e155c76b..f271e7cd 100644
--- a/src/preproc/tbl/tbl.am
+++ b/src/preproc/tbl/tbl.am
@@ -25,16 +25,24 @@ PREFIXMAN1 += src/preproc/tbl/tbl.1
 EXTRA_DIST += src/preproc/tbl/tbl.1.man
 
 tbl_TESTS = \
+  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 \
   src/preproc/tbl/tests/cooperate-with-nm-request.sh \
   src/preproc/tbl/tests/count-continued-input-lines.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/format-time-diagnostics-work.sh \
   src/preproc/tbl/tests/save-and-restore-hyphenation-parameters.sh \
-  src/preproc/tbl/tests/save-and-restore-tab-stops.sh
+  src/preproc/tbl/tests/save-and-restore-tab-stops.sh \
+  src/preproc/tbl/tests/table-lacks-spurious-top-border.sh
 TESTS += $(tbl_TESTS)
 EXTRA_DIST += $(tbl_TESTS)
 
+tbl_XFAIL_TESTS = \
+  src/preproc/tbl/tests/table-lacks-spurious-top-border.sh
+XFAIL_TESTS += $(tbl_XFAIL_TESTS)
+
 
 # Local Variables:
 # fill-column: 72
diff --git a/src/preproc/tbl/tests/check-horizontal-line-length.sh 
b/src/preproc/tbl/tests/check-horizontal-line-length.sh
new file mode 100755
index 00000000..eeb49133
--- /dev/null
+++ b/src/preproc/tbl/tests/check-horizontal-line-length.sh
@@ -0,0 +1,78 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 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
+    echo "$output"
+    fail=yes
+}
+
+# GNU tbl draws horizontal lines 1n wider than they need to be on nroff
+# devices to enable them to cross a vertical line on the right-hand
+# side.
+
+input='.ll 10n
+.TS
+L.
+_
+1234567890
+.TE
+.pl \n(nlu
+'
+
+echo "checking length of plain horizontal rule" >&2
+output=$(printf "%s" "$input" | "$groff" -Tascii -t)
+echo "$output" | grep -Eqx -- '-{11}' || wail
+
+input='.ll 12n
+.TS
+| L |.
+_
+1234567890
+_
+.TE
+.pl \n(nlu
+'
+
+echo "checking intersection of vertical and horizontal rules" >&2
+output=$(printf "%s" "$input" | "$groff" -Tascii -t)
+echo "$output" | sed -n '1p' | grep -Eqx '\+-{11}\+' || wail
+echo "$output" | sed -n '3p' | grep -Eqx '\+-{11}\+' || wail
+
+input='.ll 12n
+.TS
+box;
+L.
+1234567890
+.TE
+.pl \n(nlu
+'
+
+echo "checking width of boxed table" >&2
+output=$(printf "%s" "$input" | "$groff" -Tascii -t)
+echo "$output" | sed -n '1p' | grep -Eqx '\+-{11}\+' || wail
+echo "$output" | sed -n '3p' | grep -Eqx '\+-{11}\+' || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/src/preproc/tbl/tests/check-line-intersections.sh 
b/src/preproc/tbl/tests/check-line-intersections.sh
new file mode 100755
index 00000000..6555e96d
--- /dev/null
+++ b/src/preproc/tbl/tests/check-line-intersections.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 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
+}
+
+input='.TS
+allbox tab(@);
+L L L.
+a@b@c
+d@e@f
+g@h@i
+.TE
+'
+
+output=$(printf "%s" "$input" | "$groff" -Tascii -t)
+
+for l in 1 3 5 7
+do
+    echo "checking intersections on line $l"
+    echo "$output" | sed -n ${l}p | grep -Fqx '+--+---+---+' || wail
+done
+
+# TODO: Check `-Tutf8` output for correct crossing glyph identities.
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/src/preproc/tbl/tests/check-vertical-line-length.sh 
b/src/preproc/tbl/tests/check-vertical-line-length.sh
new file mode 100755
index 00000000..9b08dcb6
--- /dev/null
+++ b/src/preproc/tbl/tests/check-vertical-line-length.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 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
+    echo "$output"
+    fail=yes
+}
+
+# GNU tbl draws vertical lines 1v taller than they need to be on nroff
+# devices to enable them to cross a potential horizontal line in the
+# table.
+
+input='.ll 12n
+.TS
+| L |.
+_
+1234567890
+.TE
+.pl \n(nlu
+'
+
+echo "checking length of plain vertical rule" >&2
+output=$(printf "%s" "$input" | "$groff" -Tascii -t)
+echo "$output" | sed -n '2p' | grep -Fqx -- '|1234567890 |' || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/src/preproc/tbl/tests/table-lacks-spurious-top-border.sh 
b/src/preproc/tbl/tests/table-lacks-spurious-top-border.sh
new file mode 100755
index 00000000..5a0a8294
--- /dev/null
+++ b/src/preproc/tbl/tests/table-lacks-spurious-top-border.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+#
+# Copyright (C) 2022 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
+    echo "$output"
+    fail=yes
+}
+
+# GNU tbl draws vertical lines 1v taller than they need to be on nroff
+# devices to enable them to cross a potential horizontal line in the
+# table.  This can lead to a spurious top border.
+
+input='.ll 12n
+.TS
+| L |.
+_
+1234567890
+.TE
+.pl \n(nlu
+'
+
+echo "checking height of table with plain vertical rules" >&2
+output=$(printf "%s" "$input" | "$groff" -Tascii -t)
+lines=$(echo "$output" | wc -l)
+test $lines -eq 1 || wail
+
+echo "checking content of table with plain vertical rules" >&2
+output=$(printf "%s" "$input" | "$groff" -Tascii -t)
+# If we fix the horizontal width issue (Savannah #62471), take out " ?".
+echo "$output" | sed -n '1p' | grep -Eqx -- '\|1234567890 ?\|' || 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]