summaryrefslogtreecommitdiffstats
path: root/src/roff/groff/tests/device_control_escapes_express_basic_latin.sh
blob: 64189138fa8d56f3ed54ea9ac78687958233f2e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
#
# Copyright (C) 2021 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=

# Confirm translation of a groff special character escape sequence to a
# basic Latin character when used in a device control escape sequence.
#
# $1 is the special character escape _without_ the leading backslash.
# $2 is the expected output character _shell-quoted as necessary_.
# $3 is a human-readable glyph description for the test log.
# $4 is the groff -T device name under test.
check_char () {
  sc=$1
  output=$2
  description=$3
  device=$4
  printf 'checking conversion of \\%s to %s (%s) on device %s' \
    "$sc" "$output" "$description" "$device" >&2
  if ! printf '\\X#\\%s %s#\n' "$sc" "$desc" | "$groff" -T$device -Z \
    | grep -Fqx 'x X '$output' '
  then
    printf '...FAILED' >&2
    fail=yes
  fi
  printf '\n' >&2
}

for device in utf8 html
do
  check_char - - "minus sign" $device
  check_char '[aq]' "'" "neutral apostrophe" $device
  check_char '[dq]' '"' "double quote" $device
  check_char '[ga]' '`' "grave accent" $device
  check_char '[ha]' ^ "caret/hat" $device
  check_char '[rs]' '\' "reverse solidus/backslash" $device
  check_char '[ti]' '~' "tilde" $device
done

test -z "$fail" || exit 1

# vim:set autoindent expandtab shiftwidth=2 tabstop=2 textwidth=72: