summaryrefslogtreecommitdiff
path: root/test/lisp/mail
diff options
context:
space:
mode:
authorStefan Kangas <stefankangas@gmail.com>2019-06-09 17:05:15 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2019-06-09 17:07:09 -0700
commit4503310cac33da4da74fd6376244da82c7134432 (patch)
tree55596d1643c1dea1a30b1e42888aee0c101e78c7 /test/lisp/mail
parent45c525a685041c274a26c70caed4088726a790de (diff)
downloademacs-4503310cac33da4da74fd6376244da82c7134432.tar.gz
Add tests for mail/uudecode.el
* lisp/mail/uudecode.el: Remove redundant :group usage. * test/lisp/mail/uudecode-resources/uudecoded.txt, test/lisp/mail/uudecode-resources/uuencoded.txt, test/lisp/mail/uudecode-tests.el: New files.
Diffstat (limited to 'test/lisp/mail')
-rw-r--r--test/lisp/mail/uudecode-resources/uudecoded.txt16
-rw-r--r--test/lisp/mail/uudecode-resources/uuencoded.txt19
-rw-r--r--test/lisp/mail/uudecode-tests.el89
3 files changed, 124 insertions, 0 deletions
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