]> diplodocus.org Git - nmh/blob - test/mhshow/test-textcharset
Use test_skip in test-textcharset if not built with iconv.
[nmh] / test / mhshow / test-textcharset
1 #!/bin/sh
2 ##########################################################
3 #
4 # Test display of text/plain parts with charset conversion
5 #
6 ##########################################################
7
8 set -e
9
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir=`dirname "$0"`/../..
12 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
13 fi
14
15 . "$MH_OBJ_DIR/test/common.sh"
16
17 setup_test
18
19 if test "$ICONV_ENABLED" -eq 0; then
20 test_skip 'test-textcharset requires that nmh have been built with iconv'
21 fi
22
23 expected="$MH_TEST_DIR"/$$.expected
24 actual="$MH_TEST_DIR"/$$.actual
25
26 msgfile=`mhpath new`
27 cat >"$msgfile" <<EOF
28 From: foo@example.edu
29 To: bar@example.edu
30 Subject: test display with charset conversion
31 MIME-Version: 1.0
32 Content-Type: text/plain; charset=windows-1252
33 Content-Transfer-Encoding: quoted-printable
34 Date: Sun, 18 Dec 2005 00:52:39 +0100
35
36 4 =F7 2 =3D 2
37 EOF
38
39 # Check -notextcharset.
40 cat >"$expected" <<EOF
41 Date: Sun, 18 Dec 2005 00:52:39 +0100
42 To: bar@example.edu
43 From: foo@example.edu
44 Subject: test display with charset conversion
45
46 MIME-Version: 1.0
47
48 EOF
49
50 LC_ALL=C; export LC_ALL
51 run_prog mhshow -textcharset UTF-8 -notextcharset -nopause last >"$actual" 2>&1
52 check "$expected" "$actual"
53
54 # Check -textcharset.
55 cat >"$expected" <<EOF
56 Date: Sun, 18 Dec 2005 00:52:39 +0100
57 To: bar@example.edu
58 From: foo@example.edu
59 Subject: test display with charset conversion
60
61 MIME-Version: 1.0
62
63 part text/plain 10
64 4 รท 2 = 2
65 EOF
66
67 run_prog mhshow -textcharset UTF-8 -nopause last >"$actual" 2>&1
68 check "$expected" "$actual" 'keep first'
69
70 # Check use of user's locale.
71 LC_ALL=en_US.UTF-8; export LC_ALL
72 run_prog mhshow -nopause last >"$actual" 2>&1
73 check "$expected" "$actual"
74
75 exit $failed