Merge
[mmh] / test / tests / mhbuild / test-header-encode
1 #!/bin/sh
2 ######################################################
3 #
4 # Test encoding headers according to RFC 2047
5 #
6 ######################################################
7
8 # TODO: Move to a common file tests can source; need more framework...
9 failed=0
10 export MM_CHARSET=UTF-8
11 check() {
12     diff -u $expected $actual
13     if [ $? -ne 0 ]; then
14         failed=$((failed + 1))
15     fi
16 }
17
18 # Make a draft file forwarding two messages.
19 mkdraft() {
20     cat > $draft <<EOF
21 From: Mr Foo Bar <foobar@example.com>
22 To: Somebody <somebody@example.com>
23 Subject: This is รค test
24
25 This is a test
26 EOF
27 }
28
29 # Munge the Content-Id from the draft after mhbuild, so we have a reliable
30 # value to check.
31 mungedraft() {
32     sed 's/\(Content-ID:\) <[^>][^>]*>/\1 <TESTID>/' $draft > $actual
33 }
34
35 draft=$MH_TEST_DIR/$$.draft
36 expected=$MH_TEST_DIR/$$.expected
37 actual=$MH_TEST_DIR/$$.actual
38
39 # check mhbuild
40 cat > $expected <<EOF
41 From: Mr Foo Bar <foobar@example.com>
42 To: Somebody <somebody@example.com>
43 Subject: =?UTF-8?Q?This_is_=C3=A4_test?=
44 MIME-Version: 1.0
45 Content-Type: text/plain; charset="us-ascii"
46 Content-ID: <TESTID>
47
48 This is a test
49 EOF
50 mkdraft
51 mhbuild $draft
52 mungedraft
53 check
54
55 exit $failed