aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2021-01-10 13:20:49 +0100
committerLars Ingebrigtsen2021-01-10 13:21:06 +0100
commit4ad8fc61e7c47831e596b8ea9d5cb985cabfe3cf (patch)
treeb4c1a6d7721249dc374161a725851fe4e0c1a3d8
parentac9c4ca8c9456ea4e0cbfea2317579ac57b13289 (diff)
downloademacs-4ad8fc61e7c47831e596b8ea9d5cb985cabfe3cf.tar.gz
emacs-4ad8fc61e7c47831e596b8ea9d5cb985cabfe3cf.zip
Add more mm-decode tests
-rw-r--r--test/lisp/gnus/mm-decode-resources/win1252-multipart.bin44
-rw-r--r--test/lisp/gnus/mm-decode-tests.el29
2 files changed, 73 insertions, 0 deletions
diff --git a/test/lisp/gnus/mm-decode-resources/win1252-multipart.bin b/test/lisp/gnus/mm-decode-resources/win1252-multipart.bin
new file mode 100644
index 00000000000..d3c5026dcce
--- /dev/null
+++ b/test/lisp/gnus/mm-decode-resources/win1252-multipart.bin
@@ -0,0 +1,44 @@
1To: example <example@example.org>
2From: example <example@example.org>
3Date: Tue, 5 Jan 2021 10:30:34 +0100
4MIME-Version: 1.0
5Content-Type: multipart/mixed; boundary="------------FB569A4368539497CC91D1DC"
6Content-Language: fr
7Subject: test
8
9--------------FB569A4368539497CC91D1DC
10Content-Type: multipart/alternative;
11 boundary="------------61C81A7DC7592E4C6F856A85"
12
13
14--------------61C81A7DC7592E4C6F856A85
15Content-Type: text/plain; charset=windows-1252; format=flowed
16Content-Transfer-Encoding: 8bit
17
18déjà raté
19
20--------------61C81A7DC7592E4C6F856A85
21Content-Type: text/html; charset=windows-1252
22Content-Transfer-Encoding: 8bit
23
24<html>
25 <head>
26 <meta http-equiv="content-type" content="text/html; charset=windows-1252">
27 </head>
28 <body>
29 déjà raté
30 </body>
31</html>
32
33--------------61C81A7DC7592E4C6F856A85--
34
35--------------FB569A4368539497CC91D1DC
36Content-Type: text/plain; charset="us-ascii"
37MIME-Version: 1.0
38Content-Transfer-Encoding: 7bit
39Content-Disposition: inline
40
41mailing list signature
42
43--------------FB569A4368539497CC91D1DC--
44
diff --git a/test/lisp/gnus/mm-decode-tests.el b/test/lisp/gnus/mm-decode-tests.el
index 74591f919da..6e8fae6eaff 100644
--- a/test/lisp/gnus/mm-decode-tests.el
+++ b/test/lisp/gnus/mm-decode-tests.el
@@ -86,4 +86,33 @@
86 'charset))) 86 'charset)))
87 "ääää\n")))))) 87 "ääää\n"))))))
88 88
89(ert-deftest test-mm-dissect-buffer-win1252 ()
90 (with-temp-buffer
91 (set-buffer-multibyte nil)
92 (insert-file-contents-literally (ert-resource-file "win1252-multipart.bin"))
93 (let ((handle (mm-dissect-buffer)))
94 (should (equal (mm-handle-media-type handle) "multipart/mixed"))
95 ;; Skip multipart type.
96 (pop handle)
97 (setq handle (car handle))
98 (pop handle)
99 (let ((part (pop handle)))
100 (should (equal (mm-handle-media-type part) "text/plain"))
101 (should (eq (mm-handle-encoding part) '8bit))
102 (with-current-buffer (mm-handle-buffer part)
103 (should (equal (decode-coding-string
104 (buffer-string)
105 (intern (mail-content-type-get (mm-handle-type part)
106 'charset)))
107 "déjà raté\n"))))
108 (let ((part (pop handle)))
109 (should (equal (mm-handle-media-type part) "text/html"))
110 (should (eq (mm-handle-encoding part) '8bit))
111 (with-current-buffer (mm-handle-buffer part)
112 (should (equal (decode-coding-string
113 (buffer-string)
114 (intern (mail-content-type-get (mm-handle-type part)
115 'charset)))
116 "<html>\n <head>\n <meta http-equiv=\"content-type\" content=\"text/html; charset=windows-1252\">\n </head>\n <body>\n déjà raté\n </body>\n</html>\n")))))))
117
89;;; mm-decode-tests.el ends here 118;;; mm-decode-tests.el ends here