gbranden pushed a commit to branch master
in repository groff.

commit b2676693d25f95e5cb75e9c05768d619106c1046
Author: G. Branden Robinson <g.branden.robin...@gmail.com>
AuthorDate: Wed Aug 6 16:04:47 2025 -0500

    [ms]: Unit-test vertical margins.
    
    * tmac/tests/s_vertical-margins-are-correct.sh: Add unit test of correct
      vertical margins.
    
    * tmac/tmac.am (tmac_TESTS): Run test.
    
    Test passes, but reveals an error: bottom margin should be 3v, not 2v.
---
 ChangeLog                                    |   6 +
 tmac/tests/s_vertical-margins-are-correct.sh | 183 +++++++++++++++++++++++++++
 tmac/tmac.am                                 |   3 +-
 3 files changed, 191 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index ff19197d2..976da8e0b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-08-06  G. Branden Robinson <g.branden.robin...@gmail.com>
+
+       * tmac/tests/s_vertical-margins-are-correct.sh: Add unit test of
+       correct vertical margins.
+       * tmac/tmac.am (tmac_TESTS): Run test.
+
 2025-08-05  G. Branden Robinson <g.branden.robin...@gmail.com>
 
        * src/utils/afmtodit/afmtodit.pl: Stop throwing duplicate
diff --git a/tmac/tests/s_vertical-margins-are-correct.sh 
b/tmac/tests/s_vertical-margins-are-correct.sh
new file mode 100755
index 000000000..1ee071e1b
--- /dev/null
+++ b/tmac/tests/s_vertical-margins-are-correct.sh
@@ -0,0 +1,183 @@
+#!/bin/sh
+#
+# Copyright (C) 2025 G. Branden Robinson
+#
+# 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
+}
+
+# Unit-test the vertical page margins (before and after titles).
+
+input='.
+.ds FR 1\"
+.P1
+.if \nT .ds CH Header
+.if \nT .ds CF Footer
+.de pp
+.LP
+Sed ut perspiciatis, unde omnis iste natus error sit voluptatem
+accusantium doloremque laudantium, totam rem aperiam eaque ipsa, quae ab
+illo inventore veritatis et quasi architecto beatae vitae dicta sunt,
+explicabo.  Nemo enim ipsam voluptatem, quia voluptas sit, aspernatur
+aut odit aut fugit, sed quia consequuntur magni dolores eos, qui ratione
+voluptatem sequi nesciunt, neque porro quisquam est, qui dolorem ipsum,
+quia dolor sit amet consectetur adipiscivelit, sed quia non-numquam eius
+modi tempora incidunt, ut labore et dolore magnam aliquam quaerat
+voluptatem.  Ut enim ad minima veniam, quis nostrum exercitationem ullam
+corporis suscipitlaboriosam, nisi ut aliquid ex ea commodi consequatur?
+Quis autem vel eum iure reprehenderit, qui inea voluptate velit esse,
+quam nihil molestiae consequatur, vel illum, qui dolorem eum fugiat, quo
+voluptas nulla pariatur?  At vero eos et accusamus et iusto odio
+dignissimos ducimus, qui blanditiis praesentium voluptatum deleniti
+atque corrupti, quos dolores et quas molestias excepturi sint, obcaecati
+cupiditate non-provident, similique sunt in culpa, qui officia deserunt
+mollitia animi, id est laborum et dolorum fuga.  Et harum quidem rerum
+facilis est et expedita distinctio.  Nam libero tempore, cum soluta
+nobis est eligendi optio, cumque nihil impedit, quo minus id, quod
+maxime placeat, facere possimus, omnis voluptas assumenda est, omnis
+dolor repellendus.  Temporibus autem quibusdam et aut officiis debitis
+aut rerum necessitatibus saepe eveniet, ut et voluptates repudiandae
+sint et molestiae non-recusandae.
+..
+.pp
+.if \nF \{\
+See below.\**
+.  FS
+.  if \nF=1 This is a short footnote.
+.  if \nF=2 \{\
+This is a longer footnote.
+Ne forte ex homine et veterino semine equorum
+confieri credas Centauros posse neque esse,
+aut rabidis canibus succinctas semimarinis
+corporibus Scyllas et cetera de genere horum.
+.  \}
+.  FE
+.\}
+.pp
+.'
+
+# Check that body text stops and starts in the correct places even
+# without titles.
+
+# GNU coreutils's `nl` command adds trailing tabs to empty lines.
+output=$(printf '%s\n' "$input" | "$groff" -Tascii -P-cbou -ms \
+    | nl -ba | sed 's/[         ]*$//') # That's [tab space].
+echo "$output"
+
+echo "checking that body text begins on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *7[         ]*Sed  *ut  *perspiciatis' || wail
+
+echo "checking that body text ends on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *57[        ]*sint et molestiae' || wail
+
+# Now check _with_ titles...
+
+output=$(printf '%s\n' "$input" | "$groff" -Tascii -P-cbou -ms -rT1 \
+    | nl -ba | sed 's/[         ]*$//') # That's [tab space].
+echo "$output"
+
+echo "checking for header on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -qx ' *4[         ]*Header' || wail
+
+echo "checking that body text begins on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *7[         ]*Sed  *ut  *perspiciatis' || wail
+
+echo "checking that body text ends on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *57[        ]*sint et molestiae' || wail
+
+echo "checking for footer on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -qx ' *64[        ]*Footer' || wail
+
+# ...with titles and a short footnote...
+
+output=$(printf '%s\n' "$input" \
+    | "$groff" -Tascii -P-cbou -ms -rT1 -rF1 \
+    | nl -ba | sed 's/[         ]*$//') # That's [tab space].
+echo "$output"
+
+echo "checking for header on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -qx ' *4[         ]*Header' || wail
+
+echo "checking that body text begins on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *7[         ]*Sed  *ut  *perspiciatis' || wail
+
+echo "checking that body text ends on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *57[        ]*sint et molestiae' || wail
+
+echo "checking for footnote separator rule on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q ' *59[         ]*---' || wail
+
+echo "checking for footnote text on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q ' *60[         ]*.*short footnote' || wail
+
+echo "checking for footer on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -qx ' *64[        ]*Footer' || wail
+
+# ...and with titles and a longer footnote.
+
+output=$(printf '%s\n' "$input" \
+    | "$groff" -Tascii -P-cbou -ms -rT1 -rF2 \
+    | nl -ba | sed 's/[         ]*$//') # That's [tab space].
+echo "$output"
+
+echo "checking for header on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -qx ' *4[         ]*Header' || wail
+
+echo "checking that body text begins on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *7[         ]*Sed  *ut  *perspiciatis' || wail
+
+# The long footnote causes the footnote area to retreat up the page,
+# spilling body text that formerly fit on one page to a second.
+echo "checking that body text ends on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q '^ *74[        ]*sint et molestiae' || wail
+
+echo "checking for footnote separator rule on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q ' *56[         ]*---' || wail
+
+echo "checking for footnote text on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -q ' *57[         ]*.*longer footnote' || wail
+
+echo "checking for footer on correct output line" >&2
+# That's [tab space] on the next line.
+echo "$output" | grep -qx ' *64[        ]*Footer' || wail
+
+test -z "$fail"
+
+# vim:set autoindent expandtab shiftwidth=4 tabstop=4 textwidth=72:
diff --git a/tmac/tmac.am b/tmac/tmac.am
index ed86a27e1..8fa1c2a5f 100644
--- a/tmac/tmac.am
+++ b/tmac/tmac.am
@@ -242,7 +242,8 @@ tmac_TESTS = \
   tmac/tests/s_honor-page-break-in-text.sh \
   tmac/tests/s_mark-column-start-correctly.sh \
   tmac/tests/s_no-excess-space-around-displays.sh \
-  tmac/tests/s_rejects-too-short-page-lengths.sh
+  tmac/tests/s_rejects-too-short-page-lengths.sh \
+  tmac/tests/s_vertical-margins-are-correct.sh
 TESTS += $(tmac_TESTS)
 EXTRA_DIST += $(tmac_TESTS)
 

_______________________________________________
groff-commit mailing list
groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to