From 7e80aecc248a78eab923005b266c939c18936c1b Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Thu, 7 Jan 2021 14:32:28 +0100 Subject: Add tests for mm-decode.el --- .../lisp/gnus/mm-decode-resources/8bit-multipart.bin | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/lisp/gnus/mm-decode-resources/8bit-multipart.bin (limited to 'test/lisp/gnus/mm-decode-resources') diff --git a/test/lisp/gnus/mm-decode-resources/8bit-multipart.bin b/test/lisp/gnus/mm-decode-resources/8bit-multipart.bin new file mode 100644 index 00000000000..0b193a27234 --- /dev/null +++ b/test/lisp/gnus/mm-decode-resources/8bit-multipart.bin @@ -0,0 +1,20 @@ +From: example +To: example +Content-Type: multipart/alternative; boundary="===============2877195075946974246==" +Date: Thu, 29 Oct 2020 14:47:55 +0100 +MIME-Version: 1.0 +Subject: test + +--===============2877195075946974246== +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +ääää + +--===============2877195075946974246== +Content-Type: text/html; charset="utf-8" +Content-Transfer-Encoding: 8bit + +ääää + +--===============2877195075946974246==-- -- cgit v1.2.3 From 4ad8fc61e7c47831e596b8ea9d5cb985cabfe3cf Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sun, 10 Jan 2021 13:20:49 +0100 Subject: Add more mm-decode tests --- .../gnus/mm-decode-resources/win1252-multipart.bin | 44 ++++++++++++++++++++++ test/lisp/gnus/mm-decode-tests.el | 29 ++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 test/lisp/gnus/mm-decode-resources/win1252-multipart.bin (limited to 'test/lisp/gnus/mm-decode-resources') 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 @@ +To: example +From: example +Date: Tue, 5 Jan 2021 10:30:34 +0100 +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="------------FB569A4368539497CC91D1DC" +Content-Language: fr +Subject: test + +--------------FB569A4368539497CC91D1DC +Content-Type: multipart/alternative; + boundary="------------61C81A7DC7592E4C6F856A85" + + +--------------61C81A7DC7592E4C6F856A85 +Content-Type: text/plain; charset=windows-1252; format=flowed +Content-Transfer-Encoding: 8bit + +déjà raté + +--------------61C81A7DC7592E4C6F856A85 +Content-Type: text/html; charset=windows-1252 +Content-Transfer-Encoding: 8bit + + + + + + + déjà raté + + + +--------------61C81A7DC7592E4C6F856A85-- + +--------------FB569A4368539497CC91D1DC +Content-Type: text/plain; charset="us-ascii" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Disposition: inline + +mailing list signature + +--------------FB569A4368539497CC91D1DC-- + 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 @@ 'charset))) "ääää\n")))))) +(ert-deftest test-mm-dissect-buffer-win1252 () + (with-temp-buffer + (set-buffer-multibyte nil) + (insert-file-contents-literally (ert-resource-file "win1252-multipart.bin")) + (let ((handle (mm-dissect-buffer))) + (should (equal (mm-handle-media-type handle) "multipart/mixed")) + ;; Skip multipart type. + (pop handle) + (setq handle (car handle)) + (pop handle) + (let ((part (pop handle))) + (should (equal (mm-handle-media-type part) "text/plain")) + (should (eq (mm-handle-encoding part) '8bit)) + (with-current-buffer (mm-handle-buffer part) + (should (equal (decode-coding-string + (buffer-string) + (intern (mail-content-type-get (mm-handle-type part) + 'charset))) + "déjà raté\n")))) + (let ((part (pop handle))) + (should (equal (mm-handle-media-type part) "text/html")) + (should (eq (mm-handle-encoding part) '8bit)) + (with-current-buffer (mm-handle-buffer part) + (should (equal (decode-coding-string + (buffer-string) + (intern (mail-content-type-get (mm-handle-type part) + 'charset))) + "\n \n \n \n \n déjà raté\n \n\n"))))))) + ;;; mm-decode-tests.el ends here -- cgit v1.2.3