]> diplodocus.org Git - nmh/blob - test/mhshow/test-subpart
Alter HasSuffixC()'s char * to be const.
[nmh] / test / mhshow / test-subpart
1 #!/bin/sh
2 ######################################################
3 #
4 # Test show of one part, fixed by
5 # 31cba404636730df219dd009ca5893ccc56d46af
6 #
7 ######################################################
8
9 set -e
10
11 if test -z "${MH_OBJ_DIR}"; then
12 srcdir=`dirname "$0"`/../..
13 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
14 fi
15
16 . "$MH_OBJ_DIR/test/common.sh"
17
18 setup_test
19
20 expected=$MH_TEST_DIR/$$.expected
21 actual=$MH_TEST_DIR/$$.actual
22
23 # Write message with a text/plain subpart.
24 msgfile=`mhpath new`
25 msgnum=`basename $msgfile`
26 cat > $msgfile <<EOF
27 MIME-Version: 1.0
28 Content-Type: multipart/mixed; boundary="NextPart_001"
29 Content-class: urn:content-classes:message
30 Date: Thu, 19 May 2011 00:00:00 -0000
31 From: sender@example.com
32 To: recipient@example.com
33
34 This is a multi-part message in MIME format.
35
36 --NextPart_001
37 Content-Type: multipart/related;
38 type="multipart/alternative";
39 boundary="NextPart_002"
40
41 --NextPart_002
42 Content-Type: text/plain;
43 charset="utf-8"
44
45 This is the text/plain part.
46
47 --NextPart_002--
48
49 --NextPart_001--
50 EOF
51
52 # Write the expected output.
53 cat > $expected <<EOF
54 [ Message inbox:11 ]
55 [ part 1.1 - text/plain - 29B ]
56 This is the text/plain part.
57 EOF
58
59 # check it
60 run_prog mhshow -part 1.1 -form mhl.null $msgnum > $actual 2>&1
61 check "$expected" "$actual" : part 1.1
62
63
64 # tests of -part/-type/-prefer
65
66 cat > $msgfile <<EOF
67 To: example@example.org
68 From: someone <someone@example.com>
69 Subject: mhshow -part/-type/-prefer test
70 Date: Thu, 29 Jan 2015 18:12:21 +0000 (GMT)
71 Content-Type: multipart/mixed; boundary="BoundaryMixed"
72
73 --BoundaryMixed
74 Content-type: multipart/alternative;
75 boundary="BoundaryAlternative1"
76
77 --BoundaryAlternative1
78 Content-type: text/plain; charset=US-ASCII; format=flowed
79 Content-transfer-encoding: 8bit
80
81 This is the body text/plain part.
82 --BoundaryAlternative1
83 Content-type: multipart/related;
84 boundary="BoundaryAlternative2"; type="text/html"
85
86 --BoundaryAlternative2
87 Content-type: text/html; CHARSET=US-ASCII
88 Content-transfer-encoding: quoted-printable
89
90 <html><body><div><span style=3D"line-height: 1.5;">
91 This is the text/html body part.
92 </span></div></body></html>
93
94 --BoundaryAlternative2--
95
96 --BoundaryAlternative1--
97
98 --BoundaryMixed
99 Content-Type: text/plain; charset="us-ascii"
100 MIME-Version: 1.0
101 Content-Transfer-Encoding: 7bit
102 Content-Disposition: inline
103
104 _______________________________________________
105 This is the final text/plain signature part.
106
107 --BoundaryMixed--
108 EOF
109
110 # Write the expected output.
111 cat > $expected <<EOF
112 [ Message inbox:11 ]
113 [ part 1.1.1 - text/html - 111B ]
114 This is the text/html body part.
115 EOF
116
117 # check it
118 # The sed command removes blank lines and leading space that lynx inserts.
119 run_prog mhshow -part 1.1.1 -form mhl.null $msgnum |
120 sed '/^$/D; s/^ *//;' > $actual 2>&1
121 check "$expected" "$actual" : part 1.1.1
122
123 # Write the expected output.
124 cat > $expected <<EOF
125 [ Message inbox:11 ]
126 [ part 1.2 - text/plain - 33B ]
127 This is the body text/plain part.
128 EOF
129
130 # check it
131 run_prog mhshow -part 1.2 -form mhl.null $msgnum > $actual 2>&1
132 check "$expected" "$actual" : part 1.2
133
134 # Write the expected output.
135 cat > $expected <<EOF
136 [ Message inbox:11 ]
137 [ part 1.1 - text/plain - 33B ]
138 This is the body text/plain part.
139 EOF
140
141 # check it
142 run_prog mhshow -prefer text/plain -part 1 -form mhl.null $msgnum > $actual 2>&1
143 check "$expected" "$actual" : part conflicting text/plain, part 1 switches
144
145 # Write the expected output.
146 cat > $expected <<EOF
147 [ Message inbox:11 ]
148 [ part 2 - text/plain - 93B ]
149 _______________________________________________
150 This is the final text/plain signature part.
151 EOF
152
153 # check it
154 run_prog mhshow -part 2 -form mhl.null $msgnum > $actual 2>&1
155 check "$expected" "$actual" : part 2
156
157 # Write the expected output.
158 cat > $expected <<EOF
159 [ Message inbox:11 ]
160 [ part 1.2 - text/plain - 33B ]
161 This is the body text/plain part.
162 [ part 2 - text/plain - 93B ]
163 _______________________________________________
164 This is the final text/plain signature part.
165 EOF
166
167 # check it
168 run_prog mhshow -type text/plain -form mhl.null $msgnum > $actual 2>&1
169 check "$expected" "$actual" : type text/plain
170
171 # Write the expected output.
172 cat > $expected <<EOF
173 [ Message inbox:11 ]
174 [ part 1.1 - text/plain - 33B ]
175 This is the body text/plain part.
176 [ part 2 - text/plain - 93B ]
177 _______________________________________________
178 This is the final text/plain signature part.
179 EOF
180
181 run_prog mhshow -prefer text/plain -form mhl.null $msgnum > $actual 2>&1
182 check "$expected" "$actual" : prefer text/plain
183
184 exit $failed