groff-commit
[Top][All Lists]
Advanced

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

[groff] 15/16: [troff]: Add unit test for `\X` escape sequence.


From: G. Branden Robinson
Subject: [groff] 15/16: [troff]: Add unit test for `\X` escape sequence.
Date: Wed, 10 Jan 2024 23:55:05 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit 2f5f9c14ae897dd164a2cc4e9c7ef7288064774e
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Tue Jan 9 08:06:02 2024 -0600

    [troff]: Add unit test for `\X` escape sequence.
    
    [troff]: Add unit test for `\X` (device control) escape sequence.
    
    * src/roff/groff/tests/backslash-X-works.sh: Add test.
    * src/roff/groff/groff.am (groff_TESTS): Run test.
---
 ChangeLog                                 |  8 +++++
 src/roff/groff/groff.am                   |  1 +
 src/roff/groff/tests/backslash-X-works.sh | 57 +++++++++++++++++++++++++++++++
 3 files changed, 66 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index c660d4ec8..0137b4536 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-01-09  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [troff]: Add unit test for `\X` (device control) escape
+       sequence.
+
+       * src/roff/groff/tests/backslash-X-works.sh: Add test.
+       * src/roff/groff/groff.am (groff_TESTS): Run test.
+
 2024-01-08  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        [troff]: Add unit test for `device` request.
diff --git a/src/roff/groff/groff.am b/src/roff/groff/groff.am
index 94c7249bd..99a8ced95 100644
--- a/src/roff/groff/groff.am
+++ b/src/roff/groff/groff.am
@@ -38,6 +38,7 @@ EXTRA_DIST += src/roff/groff/groff.1.man
 groff_TESTS = \
   src/roff/groff/tests/ab_works.sh \
   src/roff/groff/tests/adjustment_works.sh \
+  src/roff/groff/tests/backslash-X-works.sh \
   src/roff/groff/tests/backslash-exclamation-early-does-not-fail.sh \
   src/roff/groff/tests/break_zero-length_output_line_sanely.sh \
   src/roff/groff/tests/cf-request-early-does-not-fail.sh \
diff --git a/src/roff/groff/tests/backslash-X-works.sh 
b/src/roff/groff/tests/backslash-X-works.sh
new file mode 100755
index 000000000..6a8e7311d
--- /dev/null
+++ b/src/roff/groff/tests/backslash-X-works.sh
@@ -0,0 +1,57 @@
+#!/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
+}
+
+# Omit the trailing newlines from input; they are supplied below.
+# 4 backslashes
+input_plain=$(printf "\\\\X'ps: nop'")
+
+# 4, 8 backslashes
+input_special=$(printf "\\\\X'pdf: \\\\\\\\[u007E]\n")
+
+for device in ascii cp1047 dvi html xhtml latin1 lbp lj4 pdf ps utf8 \
+              X75 X75-12 X100 X100-12
+do
+  echo "checking device command escape operation on $device device" >&2
+  output=$(printf "%s\n" "$input_plain" | "$groff" -T $device -Z) \
+    || wail
+  echo "$output"
+  echo "$output" | grep -q '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 -q 'x * X *pdf: \\\[u007E\]' || wail
+done
+
+test -z "$fail"
+
+# vim:set autoindent expandtab shiftwidth=2 tabstop=2 textwidth=72:



reply via email to

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