summaryrefslogtreecommitdiffstats
path: root/src/roff/groff/tests/device-request-works.sh
blob: f308536762d678650b7d27de6a0ca005608f5224 (plain) (blame)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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: