summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorG. Branden Robinson <g.branden.robinson@gmail.com>2024-01-08 19:31:59 -0600
committerG. Branden Robinson <g.branden.robinson@gmail.com>2024-01-10 22:34:29 -0600
commit76b48901e8815939636edb91040c4ff2ac2bca1a (patch)
treed4e806cb158addc18363f5d9f49a545f4a35542a
parentbe2ec136145ef72d76c620866e28c56368207e84 (diff)
[troff]: Add unit test for `device` request.
* src/roff/groff/tests/device-request-works.sh: Add test. * src/roff/groff/groff.am (groff_TESTS): Run test. Fixes <https://savannah.gnu.org/bugs/?64959>.
-rw-r--r--ChangeLog9
-rw-r--r--src/roff/groff/groff.am1
-rwxr-xr-xsrc/roff/groff/tests/device-request-works.sh75
3 files changed, 85 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index ad0a6b8f6..c660d4ec8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2024-01-08 G. Branden Robinson <g.branden.robinson@gmail.com>
+ [troff]: Add unit test for `device` request.
+
+ * src/roff/groff/tests/device-request-works.sh: Add test.
+ * src/roff/groff/groff.am (groff_TESTS): Run test.
+
+ Fixes <https://savannah.gnu.org/bugs/?64959>.
+
+2024-01-08 G. Branden Robinson <g.branden.robinson@gmail.com>
+
* doc/groff.texi (Postprocessor Access):
* man/groff_diff.7.man (New requests): Clarify a point of
`device` request behavior; a partially collected line in the
diff --git a/src/roff/groff/groff.am b/src/roff/groff/groff.am
index c90756552..94c7249bd 100644
--- a/src/roff/groff/groff.am
+++ b/src/roff/groff/groff.am
@@ -42,6 +42,7 @@ groff_TESTS = \
src/roff/groff/tests/break_zero-length_output_line_sanely.sh \
src/roff/groff/tests/cf-request-early-does-not-fail.sh \
src/roff/groff/tests/detect-evil-link-time-optimizer.sh \
+ src/roff/groff/tests/device-request-works.sh \
src/roff/groff/tests/device_control_escapes_express_basic_latin.sh \
src/roff/groff/tests/do_not_loop_infinitely_when_breaking_cjk.sh \
src/roff/groff/tests/dot-cp_register_works.sh \
diff --git a/src/roff/groff/tests/device-request-works.sh b/src/roff/groff/tests/device-request-works.sh
new file mode 100755
index 000000000..f30853676
--- /dev/null
+++ b/src/roff/groff/tests/device-request-works.sh
@@ -0,0 +1,75 @@
+#!/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
+}
+
+# A break request is necessary to create a partially collected line in
+# the top-level diversion.
+
+input_plain='.device ps: nop
+.br'
+
+input_quoted='.device " ps: nop
+.br'
+
+# We need to portably get a backslash into the string, and we can't
+# change the escape character because despite appearances, this notation
+# isn't a groff escape sequence: it's passed to the output device.
+#
+# Omit the trailing newline; it is supplied below.
+#
+# 8 backslashes
+input_special=$(printf ".device pdf: \\\\\\\\[u007E]\n.br")
+
+for device in ascii cp1047 dvi html xhtml latin1 lbp lj4 pdf ps utf8 \
+ X75 X75-12 X100 X100-12
+do
+ echo "checking 'device' request basic operation on $device device" >&2
+ output=$(printf "%s\n" "$input_plain" | "$groff" -T $device -Z) \
+ || wail
+ echo "$output"
+ echo "$output" | grep -Eq 'x * X *ps: nop' || wail
+
+ echo "checking quoteful 'device' operation on $device device" >&2
+ output=$(printf "%s\n" "$input_quoted" | "$groff" -T $device -Z) \
+ || wail
+ echo "$output"
+ # 2 spaces before '*ps:'
+ echo "$output" | grep -Eq 'x * X *ps: nop' || wail
+
+ echo "checking that Unicode escape sequence is preserved on $device" \
+ " device" >&2
+ output=$(printf "%s\n" "$input_special" | "$groff" -T $device -Z) \
+ || wail
+ echo "$output"
+ # 3 backslashes
+ echo "$output" | grep -Eq 'x * X *pdf: \\\[u007E\]' || wail
+done
+
+test -z "$fail"
+
+# vim:set autoindent expandtab shiftwidth=2 tabstop=2 textwidth=72: