diff options
Diffstat (limited to 'test/lisp/mail')
-rw-r--r-- | test/lisp/mail/flow-fill-tests.el | 92 | ||||
-rw-r--r-- | test/lisp/mail/footnote-tests.el | 47 | ||||
-rw-r--r-- | test/lisp/mail/rmail-tests.el | 2 | ||||
-rw-r--r-- | test/lisp/mail/uudecode-resources/uudecoded.txt | 16 | ||||
-rw-r--r-- | test/lisp/mail/uudecode-resources/uuencoded.txt | 19 | ||||
-rw-r--r-- | test/lisp/mail/uudecode-tests.el | 89 |
6 files changed, 264 insertions, 1 deletions
diff --git a/test/lisp/mail/flow-fill-tests.el b/test/lisp/mail/flow-fill-tests.el new file mode 100644 index 00000000000..a05950bb70a --- /dev/null +++ b/test/lisp/mail/flow-fill-tests.el @@ -0,0 +1,92 @@ +;;; flow-fill-tests.el --- Tests for flow-fill.el -*- lexical-binding: t -*- + +;; Copyright (C) 2019 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;;; Code: + +(require 'ert) +(require 'flow-fill) + +(ert-deftest fill-flow-tests-fill-flowed-encode () + (let ((input + (concat + "> Thou villainous ill-breeding spongy dizzy-eyed \n" + "> reeky elf-skinned pigeon-egg! \n" + ">> Thou artless swag-bellied milk-livered \n" + ">> dismal-dreaming idle-headed scut!\n" + ">>> Thou errant folly-fallen spleeny reeling-ripe \n" + ">>> unmuzzled ratsbane!\n" + ">>>> Henceforth, the coding style is to be strictly \n" + ">>>> enforced, including the use of only upper case.\n" + ">>>>> I've noticed a lack of adherence to the coding \n" + ">>>>> styles, of late.\n" + ">>>>>> Any complaints?\n")) + (output + (concat + "> Thou villainous ill-breeding spongy dizzy-eyed reeky elf-skinned\n" + "> pigeon-egg! \n" + ">> Thou artless swag-bellied milk-livered dismal-dreaming idle-headed\n" + ">> scut!\n" + ">>> Thou errant folly-fallen spleeny reeling-ripe unmuzzled ratsbane!\n" + ">>>> Henceforth, the coding style is to be strictly enforced,\n" + ">>>> including the use of only upper case.\n" + ">>>>> I've noticed a lack of adherence to the coding styles, of late.\n" + ">>>>>> Any complaints?\n")) + (fill-flowed-display-column 69)) + (with-temp-buffer + (insert input) + (fill-flowed) + (should (equal (buffer-string) output))))) + +(ert-deftest fill-flow-tests-fill-flowed-encode () + (let ((input + (concat + "> Thou villainous ill-breeding spongy dizzy-eyed \n" + "> reeky elf-skinned pigeon-egg! \n" + ">> Thou artless swag-bellied milk-livered \n" + ">> dismal-dreaming idle-headed scut!\n" + ">>> Thou errant folly-fallen spleeny reeling-ripe \n" + ">>> unmuzzled ratsbane!\n" + ">>>> Henceforth, the coding style is to be strictly \n" + ">>>> enforced, including the use of only upper case.\n" + ">>>>> I've noticed a lack of adherence to the coding \n" + ">>>>> styles, of late.\n" + ">>>>>> Any complaints?\n")) + (output + (concat + "> Thou villainous ill-breeding spongy dizzy-eyed \n" + "> reeky elf-skinned pigeon-egg! \n" + ">> Thou artless swag-bellied milk-livered \n" + ">> dismal-dreaming idle-headed scut!\n" + ">>> Thou errant folly-fallen spleeny reeling-ripe \n" + ">>> unmuzzled ratsbane!\n" + ">>>> Henceforth, the coding style is to be strictly \n" + ">>>> enforced, including the use of only upper case.\n" + ">>>>> I've noticed a lack of adherence to the coding \n" + ">>>>> styles, of late.\n" + ">>>>>> Any complaints?\n")) + (fill-flowed-display-column 69)) + (with-temp-buffer + (insert input) + (fill-flowed-encode) + (should (equal (buffer-string) output))))) + +(provide 'flow-fill-tests) +;;; flow-fill-tests.el ends here diff --git a/test/lisp/mail/footnote-tests.el b/test/lisp/mail/footnote-tests.el new file mode 100644 index 00000000000..464443f4039 --- /dev/null +++ b/test/lisp/mail/footnote-tests.el @@ -0,0 +1,47 @@ +;;; footnote-tests.el --- Tests for footnote-mode -*- lexical-binding: t; -*- + +;; Copyright (C) 2019 Free Software Foundation, Inc. + +;; Author: Stefan Monnier <monnier@iro.umontreal.ca> +;; Keywords: + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; + +;;; Code: + +(ert-deftest footnote-tests-same-place () + (with-temp-buffer + (footnote-mode 1) + (insert "hello world") + (beginning-of-line) (forward-word) + (footnote-add-footnote) + (insert "footnote") + (footnote-back-to-message) + (should (equal (buffer-substring (point-min) (point)) + "hello[1]")) + (beginning-of-line) (forward-word) + (footnote-add-footnote) + (insert "other footnote") + (footnote-back-to-message) + (should (equal (buffer-substring (point-min) (point)) + "hello[1]")) + (should (equal (buffer-substring (point-min) (line-end-position)) + "hello[1][2] world")))) + +(provide 'footnote-tests) +;;; footnote-tests.el ends here diff --git a/test/lisp/mail/rmail-tests.el b/test/lisp/mail/rmail-tests.el index 00f4583335b..3a0fdbc2614 100644 --- a/test/lisp/mail/rmail-tests.el +++ b/test/lisp/mail/rmail-tests.el @@ -23,7 +23,7 @@ (ert-deftest rmail-autoload () - "Tests to see whether reftex-auc has been autoloaded" + "Test that `rmail-edit-current-message' has been autoloaded." (should (fboundp 'rmail-edit-current-message)) (should diff --git a/test/lisp/mail/uudecode-resources/uudecoded.txt b/test/lisp/mail/uudecode-resources/uudecoded.txt new file mode 100644 index 00000000000..a6f75519a17 --- /dev/null +++ b/test/lisp/mail/uudecode-resources/uudecoded.txt @@ -0,0 +1,16 @@ +This is a test file encoded with uuencode. + +This file is part of GNU Emacs. + +GNU Emacs is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +GNU Emacs is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. diff --git a/test/lisp/mail/uudecode-resources/uuencoded.txt b/test/lisp/mail/uudecode-resources/uuencoded.txt new file mode 100644 index 00000000000..1d2f888bea3 --- /dev/null +++ b/test/lisp/mail/uudecode-resources/uuencoded.txt @@ -0,0 +1,19 @@ +begin 644 uudecoded.txt +M5&AI<R!I<R!A('1E<W0@9FEL92!E;F-O9&5D('=I=&@@=75E;F-O9&4N"@I4 +M:&ES(&9I;&4@:7,@<&%R="!O9B!'3E4@16UA8W,N"@I'3E4@16UA8W,@:7,@ +M9G)E92!S;V9T=V%R93H@>6]U(&-A;B!R961I<W1R:6)U=&4@:70@86YD+V]R +M(&UO9&EF>0II="!U;F1E<B!T:&4@=&5R;7,@;V8@=&AE($=.52!'96YE<F%L +M(%!U8FQI8R!,:6-E;G-E(&%S('!U8FQI<VAE9"!B>0IT:&4@1G)E92!3;V9T +M=V%R92!&;W5N9&%T:6]N+"!E:71H97(@=F5R<VEO;B`S(&]F('1H92!,:6-E +M;G-E+"!O<@HH870@>6]U<B!O<'1I;VXI(&%N>2!L871E<B!V97)S:6]N+@H* +M1TY5($5M86-S(&ES(&1I<W1R:6)U=&5D(&EN('1H92!H;W!E('1H870@:70@ +M=VEL;"!B92!U<V5F=6PL"F)U="!7251(3U54($%.62!705)204Y463L@=VET +M:&]U="!E=F5N('1H92!I;7!L:65D('=A<G)A;G1Y(&]F"DU%4D-(04Y404)) +M3$E462!O<B!&251.15-3($9/4B!!(%!!4E1)0U5,05(@4%524$]312X@(%-E +M92!T:&4*1TY5($=E;F5R86P@4'5B;&EC($QI8V5N<V4@9F]R(&UO<F4@9&5T +M86EL<RX*"EEO=2!S:&]U;&0@:&%V92!R96-E:79E9"!A(&-O<'D@;V8@=&AE +M($=.52!'96YE<F%L(%!U8FQI8R!,:6-E;G-E"F%L;VYG('=I=&@@1TY5($5M +M86-S+B`@268@;F]T+"!S964@/&AT='!S.B\O=W=W+F=N=2YO<F<O;&EC96YS +&97,O/BX* +` +end diff --git a/test/lisp/mail/uudecode-tests.el b/test/lisp/mail/uudecode-tests.el new file mode 100644 index 00000000000..510cbd7fbc5 --- /dev/null +++ b/test/lisp/mail/uudecode-tests.el @@ -0,0 +1,89 @@ +;;; uudecode-tests.el --- Tests for uudecode.el -*- lexical-binding: t -*- + +;; Copyright (C) 2019 Free Software Foundation, Inc. + +;; Author: Stefan Kangas <stefankangas@gmail.com> + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;;; Code: + +(require 'ert) +(require 'uudecode) + +(defvar uudecode-tests-data-dir + (file-truename + (expand-file-name "uudecode-resources/" + (file-name-directory (or load-file-name + buffer-file-name)))) + "Base directory of uudecode-tests.el test data files.") + +(defun uudecode-tests-read-file (file) + "Read contents of FILE and return as string." + (with-temp-buffer + (insert-file-contents file) + (buffer-string))) + +(defvar uudecode-tests-encoded-str + (uudecode-tests-read-file + (expand-file-name "uuencoded.txt" uudecode-tests-data-dir)) + "Uuencoded data for bookmark-tests.el +Same as `bookmark-tests-decoded-str' but uuencoded.") +(defvar uudecode-tests-decoded-str + (uudecode-tests-read-file + (expand-file-name "uudecoded.txt" uudecode-tests-data-dir)) + "Plain text data for bookmark-tests.el +Same as `bookmark-tests-encoded-str' but plain text.") + +(ert-deftest uudecode-tests-decode-region-internal () + ;; Write to buffer + (with-temp-buffer + (insert uudecode-tests-encoded-str) + (uudecode-decode-region-internal (point-min) (point-max)) + (should (equal (buffer-string) uudecode-tests-decoded-str))) + ;; Write to file + (with-temp-buffer + (let ((tmpfile (make-temp-file "uudecode-tests-"))) + (unwind-protect + (progn + (insert uudecode-tests-encoded-str) + (uudecode-decode-region-internal (point-min) (point-max) tmpfile) + (should (equal (uudecode-tests-read-file tmpfile) + uudecode-tests-decoded-str))) + (delete-file tmpfile))))) + +(ert-deftest uudecode-tests-decode-region-external () + ;; Write to buffer + (when uudecode-use-external + (with-temp-buffer + (insert uudecode-tests-encoded-str) + (uudecode-decode-region-external (point-min) (point-max)) + (should (equal (buffer-string) uudecode-tests-decoded-str))) + ;; Write to file + (with-temp-buffer + (let ((tmpfile (make-temp-file "uudecode-tests-"))) + (unwind-protect + (progn + (insert uudecode-tests-encoded-str) + (uudecode-decode-region-external (point-min) (point-max) tmpfile) + (should (equal (uudecode-tests-read-file tmpfile) + uudecode-tests-decoded-str))) + (delete-file tmpfile)))))) + +(provide 'uudecode-tests) +;;; uudecode-tests.el ends here |