]> diplodocus.org Git - nmh/blob - test/mhshow/test-charset
dtimep.l: Delete unused macros SKIPSP and SKIPTOSP.
[nmh] / test / mhshow / test-charset
1 #!/bin/sh
2 ######################################################
3 #
4 # Test charset conversion functionality
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 check_exit '-eq 1' mhshow -
20
21 require_locale en_US.UTF-8 en_US.UTF8 en_US.utf-8 en_US.utf8
22
23 skip_param_value_checks=0
24 if test "$ICONV_ENABLED" -eq 0; then
25 text_size=10
26 else
27 text_size=11
28 #### For unknown reasons, the parameter values checks fail on the
29 #### FreeBSD10 buildbot. It doesn't support EBCDIC-US, which is used
30 #### by the checks, so check for that. Though that doesn't seem to be
31 #### the reason.
32 utf8="`printf '\344' | iconv -f EBCDIC-US -t UTF-8 2>/dev/null`" &&
33 test x"$utf8" = xU ||
34 skip_param_value_checks=1
35 fi
36
37 expected=$MH_TEST_DIR/$$.expected
38 actual=$MH_TEST_DIR/$$.actual
39
40 echo 'mhshow-charset-windows-1252: echo "This is a test"' >> "$MH"
41
42 # Write message with bogus quoted-printable data.
43 start_test 'Write message with bogus quoted-printable data'
44 msgfile=`mhpath new`
45 msgnum=`basename $msgfile`
46 cat > $msgfile <<EOF
47 From: foo@example.edu
48 To: bar@example.edu
49 Subject: test
50 MIME-Version: 1.0
51 Content-Type: text/plain; charset=windows-1252
52 Content-Transfer-Encoding: quoted-printable
53 Content-Description: bogus quoted-printable data
54 Date: Sun, 18 Dec 2005 00:52:39 +0100
55
56 4 =F7 2 =3D 2
57 EOF
58
59 cat > $expected <<EOF
60 [ Message inbox:11 ]
61 Date: Sun, 18 Dec 2005 00:52:39 +0100
62 To: bar@example.edu
63 From: foo@example.edu
64 Subject: test
65
66 MIME-Version: 1.0
67 Content-Description: bogus quoted-printable data
68
69 [ part - text/plain - bogus quoted-printable data ${text_size}B ]
70 This is a test
71 EOF
72
73 run_prog mhshow $msgnum > $actual 2>&1
74 check "$expected" "$actual" 'keep first' : bogus quoted-printable data
75
76
77 start_test 'locale profile component'
78 #### Used LC_ALL above, now use locale profile component instead.
79 printf "locale: $LC_ALL\n" >> "${MH}"
80 unset LC_ALL
81
82 run_prog mhshow $msgnum > $actual 2>&1
83 check "$expected" "$actual" : locale profile component
84
85
86 if test $skip_param_value_checks -eq 1; then
87 finish_test
88 exit $failed
89 fi
90
91
92 start_test 'Encoded parameter value'
93 msgfile=`mhpath new`
94 msgnum=`basename $msgfile`
95 #### The encoded charset name is really UTF-8 encoded,
96 #### but say it's UTF-16 to exercise the iconv code,
97 #### if it's available, in get_param_value().
98 cat > $msgfile <<EOF
99 From: foo@example.edu
100 To: bar@example.edu
101 Subject: test
102 MIME-Version: 1.0
103 Content-Type: text/plain; charset*=EBCDIC-US''%e4%e3%c6%60%f8
104 Content-Transfer-Encoding: quoted-printable
105 Content-Description: bogus quoted-printable data
106 Date: Sun, 18 Dec 2005 00:52:39 +0100
107
108 4 =C3=B7 2 =3D 2
109 EOF
110
111 cat > $expected <<EOF
112 [ Message inbox:12 ]
113 Date: Sun, 18 Dec 2005 00:52:39 +0100
114 To: bar@example.edu
115 From: foo@example.edu
116 Subject: test
117
118 MIME-Version: 1.0
119 Content-Description: bogus quoted-printable data
120
121 [ part - text/plain - bogus quoted-printable data 11B ]
122 4 รท 2 = 2
123 EOF
124
125 run_prog mhshow $msgnum > $actual 2>&1
126 check "$expected" "$actual" : encoded parameter value
127
128
129 start_test 'replacement character in parameter value'
130 #### The output of this test doesn't show it, but it covers the
131 #### noiconv: portion of get_param_value().
132 cat > $msgfile <<'EOF'
133 Subject: invalid parameter value charset
134 MIME-Version: 1.0
135 Content-Type: text/plain; charset*=invalid''%0Dus-ascii
136 EOF
137
138 cat > $expected <<EOF
139 [ Message inbox:12 ]
140 Subject: invalid parameter value charset
141
142 MIME-Version: 1.0
143
144 [ part - text/plain - 0B ]
145 EOF
146
147 run_prog mhshow $msgnum > $actual 2>&1
148 check "$expected" "$actual"
149
150
151 finish_test
152 exit $failed