]> diplodocus.org Git - nmh/blob - test/mhshow/test-charset
Try to fix Encoded parameter value test on FreeBSD10 buildbot.
[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 test "$ICONV_ENABLED" -eq 0 && text_size=10 || text_size=11
24
25 expected=$MH_TEST_DIR/$$.expected
26 actual=$MH_TEST_DIR/$$.actual
27
28 echo 'mhshow-charset-windows-1252: echo "This is a test"' >> "$MH"
29
30 # Write message with bogus quoted-printable data.
31 start_test 'Write message with bogus quoted-printable data'
32 msgfile=`mhpath new`
33 msgnum=`basename $msgfile`
34 cat > $msgfile <<EOF
35 From: foo@example.edu
36 To: bar@example.edu
37 Subject: test
38 MIME-Version: 1.0
39 Content-Type: text/plain; charset=windows-1252
40 Content-Transfer-Encoding: quoted-printable
41 Content-Description: bogus quoted-printable data
42 Date: Sun, 18 Dec 2005 00:52:39 +0100
43
44 4 =F7 2 =3D 2
45 EOF
46
47 cat > $expected <<EOF
48 [ Message inbox:11 ]
49 Date: Sun, 18 Dec 2005 00:52:39 +0100
50 To: bar@example.edu
51 From: foo@example.edu
52 Subject: test
53
54 MIME-Version: 1.0
55 Content-Description: bogus quoted-printable data
56
57 [ part - text/plain - bogus quoted-printable data ${text_size}B ]
58 This is a test
59 EOF
60
61 run_prog mhshow $msgnum > $actual 2>&1
62 check "$expected" "$actual" 'keep first' : bogus quoted-printable data
63
64
65 start_test 'locale profile component'
66 #### Used LC_ALL above, now use locale profile component instead.
67 printf "locale: $LC_ALL\n" >> "${MH}"
68 unset LC_ALL
69
70 run_prog mhshow $msgnum > $actual 2>&1
71 check "$expected" "$actual" : locale profile component
72
73
74 start_test 'Encoded parameter value'
75 msgfile=`mhpath new`
76 msgnum=`basename $msgfile`
77 #### The encoded charset name is really UTF-8 encoded,
78 #### but say it's UTF-16 to exercise the iconv code,
79 #### if it's available, in get_param_value().
80 cat > $msgfile <<EOF
81 From: foo@example.edu
82 To: bar@example.edu
83 Subject: test
84 MIME-Version: 1.0
85 Content-Type: text/plain; charset*=UTF-16''%55%54%46%2d%38
86 Content-Transfer-Encoding: quoted-printable
87 Content-Description: bogus quoted-printable data
88 Date: Sun, 18 Dec 2005 00:52:39 +0100
89
90 4 =C3=B7 2 =3D 2
91 EOF
92
93 cat > $expected <<EOF
94 [ Message inbox:12 ]
95 Date: Sun, 18 Dec 2005 00:52:39 +0100
96 To: bar@example.edu
97 From: foo@example.edu
98 Subject: test
99
100 MIME-Version: 1.0
101 Content-Description: bogus quoted-printable data
102
103 [ part - text/plain - bogus quoted-printable data 11B ]
104 4 รท 2 = 2
105 EOF
106
107 run_prog mhshow $msgnum > $actual 2>&1
108 check "$expected" "$actual" : encoded parameter value
109
110
111 start_test 'replacement character in parameter value'
112 #### The output of this test doesn't show it, but it covers the
113 #### noiconv: portion of get_param_value().
114 cat > $msgfile <<'EOF'
115 Subject: invalid parameter value charset
116 MIME-Version: 1.0
117 Content-Type: text/plain; charset*=invalid''%0Dus-ascii
118 EOF
119
120 cat > $expected <<EOF
121 [ Message inbox:12 ]
122 Subject: invalid parameter value charset
123
124 MIME-Version: 1.0
125
126 [ part - text/plain - 0B ]
127 EOF
128
129 run_prog mhshow $msgnum > $actual 2>&1
130 check "$expected" "$actual"
131
132
133 finish_test
134 exit $failed