summaryrefslogtreecommitdiffstats
path: root/src/tests/man-recode-suffix
blob: 7c0a32cce490fecdf24362e4b56a47a556388490 (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
#! /bin/sh

# Test man-recode's --suffix behaviour.

: "${srcdir=.}"
# shellcheck source-path=SCRIPTDIR
. "$srcdir/testlib.sh"

: "${MAN_RECODE=man-recode}"

init

cat >"$tmpdir/a.1.exp" <<'EOF'
.SH NAME
a \- á
EOF
cp "$tmpdir/a.1.exp" "$tmpdir/a.1"
cat >"$tmpdir/b.1.exp" <<'EOF'
'\" -*- coding: UTF-8 -*-
.SH NAME
b \- é
EOF
gzip -c <"$tmpdir/b.1.exp" >"$tmpdir/b.1.gz"
cat >"$tmpdir/c.1.exp" <<'EOF'
'\" -*- coding: UTF-8
.SH NAME
b \- é
EOF
cat >"$tmpdir/c.1" <<'EOF'
'\" -*- coding: ISO-8859-1
EOF
<"$tmpdir/c.1.exp" tail -n +2 | iconv -f UTF-8 -t ISO-8859-1 >>"$tmpdir/c.1"
gzip "$tmpdir/c.1"

run $MAN_RECODE -t UTF-8 --suffix .out \
	"$tmpdir/a.1" "$tmpdir/b.1.gz" "$tmpdir/c.1.gz"
expect_files_equal '--suffix with no coding tag' \
	"$tmpdir/a.1.exp" "$tmpdir/a.1.out"
expect_files_equal \
	'--suffix with gzip and coding tag matching target encoding' \
	"$tmpdir/b.1.exp" "$tmpdir/b.1.out"
expect_files_equal \
	'--suffix with gzip and coding tag not matching target encoding' \
	"$tmpdir/c.1.exp" "$tmpdir/c.1.out"

finish