gbranden pushed a commit to branch master
in repository groff.
commit fdf2e3e0628c4329090a0e0e3a5041940df8cce0
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Mar 22 17:25:42 2026 -0500
[groff]: Unit-test no-op `substring` behavior.
Unit-test no-op behavior of `substring` request when one of its index
arguments is both negative and out-of-range.
* src/roff/groff/tests/substring-request-on-invalid-range-is-no-op.sh:
Do it.
* src/roff/groff/groff.am (groff_TESTS): Run test.
---
ChangeLog | 9 +++
src/roff/groff/groff.am | 1 +
.../substring-request-on-invalid-range-is-no-op.sh | 70 ++++++++++++++++++++++
3 files changed, 80 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 21c4c6308..d1d22359c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-03-22 G. Branden Robinson <[email protected]>
+
+ [groff]: Unit-test no-op behavior of `substring` request when
+ one of its index arguments is both negative and out-of-range.
+
+ * src/roff/groff/tests/\
+ substring-request-on-invalid-range-is-no-op.sh: Do it.
+ * src/roff/groff/groff.am (groff_TESTS): Run test.
+
2026-03-22 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp (substring_request): Revise wording
diff --git a/src/roff/groff/groff.am b/src/roff/groff/groff.am
index d821dc73d..6475b7b8c 100644
--- a/src/roff/groff/groff.am
+++ b/src/roff/groff/groff.am
@@ -124,6 +124,7 @@ groff_TESTS = \
src/roff/groff/tests/stringdown-and-stringup-requests-work.sh \
src/roff/groff/tests/stringdown-request-rejects-request-names.sh \
src/roff/groff/tests/stringup-request-transforms-non-basic-latin.sh \
+ src/roff/groff/tests/substring-request-on-invalid-range-is-no-op.sh \
src/roff/groff/tests/substring-request-works.sh \
src/roff/groff/tests/sy-request-works.sh \
src/roff/groff/tests/trf-request-works.sh \
diff --git
a/src/roff/groff/tests/substring-request-on-invalid-range-is-no-op.sh
b/src/roff/groff/tests/substring-request-on-invalid-range-is-no-op.sh
new file mode 100755
index 000000000..bf92d5f2d
--- /dev/null
+++ b/src/roff/groff/tests/substring-request-on-invalid-range-is-no-op.sh
@@ -0,0 +1,70 @@
+#!/bin/sh
+#
+# Copyright 2026 G. Branden Robinson
+#
+# This file is part of groff, the GNU roff typesetting system.
+#
+# 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"
+ fail=yes
+}
+
+# Verify that invoking the `substring` request with both index arguments
+# invalid performs no operation.
+
+input='
+.nf
+.ds r abc
+.substring r -4 8
+\*r
+.ds s def
+.substring s 4 -5
+\*s
+.ds t ghi
+.substring t 4 8
+\*t
+.ds u jkl
+.substring u -4 -5
+\*u
+.'
+
+
+output=$(printf '%s\n' "$input" | "$groff" -a -ww)
+echo "$output"
+
+echo "verifying that 'substring' request with out-of-range index" \
+ "arguments (starting index negative) performs no operation" >&2
+echo "$output" | grep -qx "abc" || wail
+
+echo "verifying that 'substring' request with out-of-range index" \
+ "arguments (ending index negative) performs no operation" >&2
+echo "$output" | grep -qx "def" || wail
+
+#echo "verifying that 'substring' request with out-of-range index" \
+# "arguments (both indices positive) performs no operation" >&2
+#echo "$output" | grep -qx "ghi" || wail
+#
+#echo "verifying that 'substring' request with out-of-range index" \
+# "arguments (both indices negative) performs no operation" >&2
+#echo "$output" | grep -qx "jkl" || wail
+
+test -z "$fail"
+
+# vim:set autoindent expandtab shiftwidth=4 tabstop=4 textwidth=72:
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit