groff-commit
[Top][All Lists]
Advanced

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

[groff] 06/15: [man]: Add unit test for `TP` macro.


From: G. Branden Robinson
Subject: [groff] 06/15: [man]: Add unit test for `TP` macro.
Date: Thu, 1 Feb 2024 23:45:27 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit 509283711ea55b1a01fce01d68dabd1d557c4313
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Thu Feb 1 16:04:19 2024 -0600

    [man]: Add unit test for `TP` macro.
    
    * tmac/tests/an_TP-works.sh: Add unit test.
    * tmac/tmac.am (tmac_TESTS): Run test.
    
    Test fails at this commit.
---
 ChangeLog                 |  5 ++++
 tmac/tests/an_TP-works.sh | 59 +++++++++++++++++++++++++++++++++++++++++++++++
 tmac/tmac.am              |  1 +
 3 files changed, 65 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index f3002a679..f0a6a6f59 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-02-01  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * tmac/tests/an_TP-works.sh: Add unit test.
+       * tmac/tmac.am (tmac_TESTS): Run test.
+
 2024-02-01  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/devices/grotty/tty.cpp (tty_printer::special): Improve
diff --git a/tmac/tests/an_TP-works.sh b/tmac/tests/an_TP-works.sh
new file mode 100755
index 000000000..5623b3b27
--- /dev/null
+++ b/tmac/tests/an_TP-works.sh
@@ -0,0 +1,59 @@
+#!/bin/sh
+#
+# Copyright (C) 2024 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=$(cat <<EOF
+.TH foo 1 2024-02-01 "groff test suite"
+.TP
+tag
+ordinary tagged paragraph
+.TP
+.TP
+ill-formed but still renderable
+.TP
+foobar
+EOF
+)
+
+output=$(printf "%s" "$input" | "$groff" -ww -Tascii -P-cbou -man)
+echo "$output"
+
+echo "checking well-formed tagged paragraph" >&2
+echo "$output" | grep -Eq 'tag +ordinary tagged paragraph' || wail
+
+# We don't care about the indentation of the ill-formed input, just that
+# the words are present.
+echo "checking ill-formed tagged paragraph" >&2
+echo "$output" | grep -q 'ill-formed but still renderable' || wail
+
+echo "checking paragraph tag dangling at end of document" >&2
+echo "$output" | grep -q 'foobar' || wail
+
+test -z "$fail"
+
+# vim:set ai et sw=4 ts=4 tw=72:
diff --git a/tmac/tmac.am b/tmac/tmac.am
index 38c2a180c..d97d1cb9e 100644
--- a/tmac/tmac.am
+++ b/tmac/tmac.am
@@ -170,6 +170,7 @@ tmac_TESTS = \
   tmac/tests/an_P-register-works.sh \
   tmac/tests/an_TH-repairs-ad-damage.sh \
   tmac/tests/an_TH-repairs-hy-damage.sh \
+  tmac/tests/an_TP-works.sh \
   tmac/tests/an_TS-adds-no-vertical-space.sh \
   tmac/tests/an_TS-do-not-keep-tables-when-cR-set.sh \
   tmac/tests/an_UE-breaks-before-long-URIs.sh \



reply via email to

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