(ert-deftest rmail-undigest-test-rfc934-digest ()
"Test that we can undigest a RFC 934 digest."
(let ((file (make-temp-file "undigest-test-")))
- (with-temp-file file
- (insert rmail-rfc934-digest)
- (write-region nil nil file)
- (rmail file)
- (undigestify-rmail-message)
- (should (= rmail-total-messages 4))
- (should (string= (rmail-message-content 2) "Testing the undigester.\n\n"))
- (should (string= (rmail-message-content 3) "This is message one.\n\n"))
- (should (string= (rmail-message-content 4) "This is message two.\n")))))
+ (unwind-protect
+ (with-temp-buffer
+ (insert rmail-rfc934-digest)
+ (write-region nil nil file)
+ (rmail file)
+ (undigestify-rmail-message)
+ (should (= rmail-total-messages 4))
+ (should (string= (rmail-message-content 2) "Testing the undigester.\n\n"))
+ (should (string= (rmail-message-content 3) "This is message one.\n\n"))
+ (should (string= (rmail-message-content 4) "This is message two.\n")))
+ (delete-file file))))
(ert-deftest rmail-undigest-test-rfc1153-digest-strict ()
"Test that we can undigest a strict RFC 1153 digest."
:expected-result :failed
(let ((file (make-temp-file "undigest-test-")))
- (with-temp-file file
- (insert rmail-rfc1153-digest-strict)
- (write-region nil nil file)
- (rmail file)
- (should
- (condition-case nil
- (progn
+ (unwind-protect
+ (with-temp-buffer
+ (insert rmail-rfc1153-digest-strict)
+ (write-region nil nil file)
+ (rmail file)
+ (should
+ (ignore-errors
;; This throws an error, because the Trailer is not recognized
;; as a valid RFC 822 (or later) message.
(undigestify-rmail-message)
(should (string= (rmail-message-content 2) "Testing the undigester.\n\n"))
(should (string= (rmail-message-content 3) "This is message one.\n\n"))
(should (string= (rmail-message-content 4) "This is message two.\n"))
- t)
- (error nil))))))
+ t)))
+ (delete-file file))))
(ert-deftest rmail-undigest-test-rfc1153-less-strict-digest ()
"Test that we can undigest a RFC 1153 with a Subject header in its footer."
(let ((file (make-temp-file "undigest-test-")))
- (with-temp-file file
- (insert rmail-rfc1153-digest-less-strict)
- (write-region nil nil file)
- (rmail file)
- (undigestify-rmail-message)
- (should (= rmail-total-messages 5))
- (should (string= (rmail-message-content 3) "This is message one.\n\n"))
- (should (string= (rmail-message-content 4) "This is message two.\n\n")))))
+ (unwind-protect
+ (with-temp-buffer
+ (insert rmail-rfc1153-digest-less-strict)
+ (write-region nil nil file)
+ (rmail file)
+ (undigestify-rmail-message)
+ (should (= rmail-total-messages 5))
+ (should (string= (rmail-message-content 3) "This is message one.\n\n"))
+ (should (string= (rmail-message-content 4) "This is message two.\n\n")))
+ (delete-file file))))
(ert-deftest rmail-undigest-test-rfc1153-sloppy-digest ()
"Test that we can undigest a sloppy RFC 1153 digest."
(let ((file (make-temp-file "undigest-test-")))
- (with-temp-file file
- (insert rmail-rfc1153-digest-sloppy)
- (write-region nil nil file)
- (rmail file)
- (undigestify-rmail-message)
- (should (= rmail-total-messages 5))
- (should (string= (rmail-message-content 3) "This is message one.\n\n"))
- (should (string= (rmail-message-content 4) "This is message two.\n\n")))))
+ (unwind-protect
+ (with-temp-buffer
+ (insert rmail-rfc1153-digest-sloppy)
+ (write-region nil nil file)
+ (rmail file)
+ (undigestify-rmail-message)
+ (should (= rmail-total-messages 5))
+ (should (string= (rmail-message-content 3) "This is message one.\n\n"))
+ (should (string= (rmail-message-content 4) "This is message two.\n\n")))
+ (delete-file file))))
;; This fails because `rmail-digest-parse-mime' combines the preamble with the
;; first message of the digest. And then, it doesn't get rid of the last
"Test that we can undigest a RFC 1521 MIME digest."
:expected-result :failed
(let ((file (make-temp-file "undigest-test-")))
- (with-temp-file file
- (insert rmail-rfc1521-mime-digest)
- (write-region nil nil file)
- (rmail file)
- (undigestify-rmail-message)
- (should (= rmail-total-messages 3))
- (should (string= (rmail-message-content 2) "Message one.\n\n"))
- (should (string= (rmail-message-content 3) "Message two.\n\n")))))
+ (unwind-protect
+ (with-temp-buffer
+ (insert rmail-rfc1521-mime-digest)
+ (write-region nil nil file)
+ (rmail file)
+ (undigestify-rmail-message)
+ (should (= rmail-total-messages 3))
+ (should (string= (rmail-message-content 2) "Message one.\n\n"))
+ (should (string= (rmail-message-content 3) "Message two.\n\n")))
+ (delete-file file))))
(ert-deftest rmail-undigest-test-multipart-mixed-digest ()
"Test that we can undigest a digest inside a multipart/mixed digest."
(let ((file (make-temp-file "undigest-test-")))
- (with-temp-file file
- (insert rmail-multipart-mixed-digest)
- (write-region nil nil file)
- (rmail file)
- (undigestify-rmail-message)
- (should (= rmail-total-messages 4))
- (should (string= (rmail-message-content 2) "Message one.\n\n"))
- (should (string= (rmail-message-content 3) "Message two.\n\n")))))
+ (unwind-protect
+ (with-temp-buffer
+ (insert rmail-multipart-mixed-digest)
+ (write-region nil nil file)
+ (rmail file)
+ (undigestify-rmail-message)
+ (should (= rmail-total-messages 4))
+ (should (string= (rmail-message-content 2) "Message one.\n\n"))
+ (should (string= (rmail-message-content 3) "Message two.\n\n")))
+ (delete-file file))))