]> diplodocus.org Git - nmh/blob - test/mhbuild/test-cte
More CTE tests.
[nmh] / test / mhbuild / test-cte
1 #!/bin/sh
2 #########################################################
3 #
4 # Test the use of explicit Content-Transfer-Encoding tags
5 #
6 #########################################################
7
8 if test -z "${MH_OBJ_DIR}"; then
9 srcdir=`dirname "$0"`/../..
10 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
11 fi
12
13 . "$MH_OBJ_DIR/test/common.sh"
14
15 setup_test
16
17 LC_ALL=en_US.UTF-8; export LC_ALL
18
19 draft="$MH_TEST_DIR/$$.draft"
20 expected="$MH_TEST_DIR/$$.expected"
21
22 #
23 # Force some text to be quoted-printable
24 #
25
26 cat > "$draft" <<EOF
27 To: Mr Test <mrtest@example.com>
28 cc:
29 Fcc: +outbox
30 ------
31 #<text/plain *qp
32 This is a test of a message with a shørt line.
33 EOF
34
35 run_prog mhbuild "$draft"
36
37 cat > "$expected" <<EOF
38 To: Mr Test <mrtest@example.com>
39 cc:
40 Fcc: +outbox
41 MIME-Version: 1.0
42 Content-Type: text/plain; charset="UTF-8"
43 Content-Transfer-Encoding: quoted-printable
44
45 This is a test of a message with a sh=C3=B8rt line.
46 EOF
47
48 #
49 # Force some text to be base64, to test out the encoder. Try at different
50 # line lengths to check out the padding on the routines to convert LF to
51 # CR LF. The current implementation reads in using a 3 byte buffer, so make
52 # sure we catch all of those cases.
53 #
54
55 cat > "$draft" <<EOF
56 To: Mr Test <mrtest@example.com>
57 cc:
58 Fcc: +outbox
59 ------
60 #<text/plain *b64
61 This is a test of a message with a shørt line.
62 EOF
63
64 run_prog mhbuild "$draft"
65
66 cat > "$expected" <<EOF
67 To: Mr Test <mrtest@example.com>
68 cc:
69 Fcc: +outbox
70 MIME-Version: 1.0
71 Content-Type: text/plain; charset="UTF-8"
72 Content-Transfer-Encoding: base64
73
74 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtZXNzYWdlIHdpdGggYSBzaMO4cnQgbGluZS4NCg==
75 EOF
76
77 check "$draft" "$expected"
78
79 cat > "$draft" <<EOF
80 To: Mr Test <mrtest@example.com>
81 cc:
82 Fcc: +outbox
83 ------
84 #<text/plain *b64
85 This is a test of a mëssage with a shørt line.
86 EOF
87
88 run_prog mhbuild "$draft"
89
90 cat > "$expected" <<EOF
91 To: Mr Test <mrtest@example.com>
92 cc:
93 Fcc: +outbox
94 MIME-Version: 1.0
95 Content-Type: text/plain; charset="UTF-8"
96 Content-Transfer-Encoding: base64
97
98 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc2FnZSB3aXRoIGEgc2jDuHJ0IGxpbmUuDQo=
99 EOF
100
101 check "$draft" "$expected"
102
103 cat > "$draft" <<EOF
104 To: Mr Test <mrtest@example.com>
105 cc:
106 Fcc: +outbox
107 ------
108 #<text/plain *b64
109 This is a test of a mëssäge with a shørt line.
110 EOF
111
112 run_prog mhbuild "$draft"
113
114 cat > "$expected" <<EOF
115 To: Mr Test <mrtest@example.com>
116 cc:
117 Fcc: +outbox
118 MIME-Version: 1.0
119 Content-Type: text/plain; charset="UTF-8"
120 Content-Transfer-Encoding: base64
121
122 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc8OkZ2Ugd2l0aCBhIHNow7hydCBsaW5lLg0K
123 EOF
124
125 check "$draft" "$expected"
126
127 cat > "$draft" <<EOF
128 To: Mr Test <mrtest@example.com>
129 cc:
130 Fcc: +outbox
131 ------
132 #<text/plain *b64
133 This is a test of a message with a shørt line.
134 This is a second line.
135 EOF
136
137 run_prog mhbuild "$draft"
138
139 cat > "$expected" <<EOF
140 To: Mr Test <mrtest@example.com>
141 cc:
142 Fcc: +outbox
143 MIME-Version: 1.0
144 Content-Type: text/plain; charset="UTF-8"
145 Content-Transfer-Encoding: base64
146
147 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtZXNzYWdlIHdpdGggYSBzaMO4cnQgbGluZS4NClRoaXMgaXMg
148 YSBzZWNvbmQgbGluZS4NCg==
149 EOF
150
151 check "$draft" "$expected"
152
153 cat > "$draft" <<EOF
154 To: Mr Test <mrtest@example.com>
155 cc:
156 Fcc: +outbox
157 ------
158 #<text/plain *b64
159 This is a test of a mëssage with a shørt line.
160 This is a second line.
161 EOF
162
163 run_prog mhbuild "$draft"
164
165 cat > "$expected" <<EOF
166 To: Mr Test <mrtest@example.com>
167 cc:
168 Fcc: +outbox
169 MIME-Version: 1.0
170 Content-Type: text/plain; charset="UTF-8"
171 Content-Transfer-Encoding: base64
172
173 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc2FnZSB3aXRoIGEgc2jDuHJ0IGxpbmUuDQpUaGlzIGlz
174 IGEgc2Vjb25kIGxpbmUuDQo=
175 EOF
176
177 check "$draft" "$expected"
178
179 cat > "$draft" <<EOF
180 To: Mr Test <mrtest@example.com>
181 cc:
182 Fcc: +outbox
183 ------
184 #<text/plain *b64
185 This is a test of a mëssäge with a shørt line.
186 This is a second line.
187 EOF
188
189 run_prog mhbuild "$draft"
190
191 cat > "$expected" <<EOF
192 To: Mr Test <mrtest@example.com>
193 cc:
194 Fcc: +outbox
195 MIME-Version: 1.0
196 Content-Type: text/plain; charset="UTF-8"
197 Content-Transfer-Encoding: base64
198
199 VGhpcyBpcyBhIHRlc3Qgb2YgYSBtw6tzc8OkZ2Ugd2l0aCBhIHNow7hydCBsaW5lLg0KVGhpcyBp
200 cyBhIHNlY29uZCBsaW5lLg0K
201 EOF
202
203 check "$draft" "$expected"
204
205 exit ${failed:-0}