aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorStefan Kangas2019-06-09 17:05:15 -0700
committerPaul Eggert2019-06-09 17:07:09 -0700
commit4503310cac33da4da74fd6376244da82c7134432 (patch)
tree55596d1643c1dea1a30b1e42888aee0c101e78c7 /test
parent45c525a685041c274a26c70caed4088726a790de (diff)
downloademacs-4503310cac33da4da74fd6376244da82c7134432.tar.gz
emacs-4503310cac33da4da74fd6376244da82c7134432.zip
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')
-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 @@
1This is a test file encoded with uuencode.
2
3This file is part of GNU Emacs.
4
5GNU Emacs is free software: you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation, either version 3 of the License, or
8(at your option) any later version.
9
10GNU Emacs is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along 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 @@
1begin 644 uudecoded.txt
2M5&AI<R!I<R!A('1E<W0@9FEL92!E;F-O9&5D('=I=&@@=75E;F-O9&4N"@I4
3M:&ES(&9I;&4@:7,@<&%R="!O9B!'3E4@16UA8W,N"@I'3E4@16UA8W,@:7,@
4M9G)E92!S;V9T=V%R93H@>6]U(&-A;B!R961I<W1R:6)U=&4@:70@86YD+V]R
5M(&UO9&EF>0II="!U;F1E<B!T:&4@=&5R;7,@;V8@=&AE($=.52!'96YE<F%L
6M(%!U8FQI8R!,:6-E;G-E(&%S('!U8FQI<VAE9"!B>0IT:&4@1G)E92!3;V9T
7M=V%R92!&;W5N9&%T:6]N+"!E:71H97(@=F5R<VEO;B`S(&]F('1H92!,:6-E
8M;G-E+"!O<@HH870@>6]U<B!O<'1I;VXI(&%N>2!L871E<B!V97)S:6]N+@H*
9M1TY5($5M86-S(&ES(&1I<W1R:6)U=&5D(&EN('1H92!H;W!E('1H870@:70@
10M=VEL;"!B92!U<V5F=6PL"F)U="!7251(3U54($%.62!705)204Y463L@=VET
11M:&]U="!E=F5N('1H92!I;7!L:65D('=A<G)A;G1Y(&]F"DU%4D-(04Y404))
12M3$E462!O<B!&251.15-3($9/4B!!(%!!4E1)0U5,05(@4%524$]312X@(%-E
13M92!T:&4*1TY5($=E;F5R86P@4'5B;&EC($QI8V5N<V4@9F]R(&UO<F4@9&5T
14M86EL<RX*"EEO=2!S:&]U;&0@:&%V92!R96-E:79E9"!A(&-O<'D@;V8@=&AE
15M($=.52!'96YE<F%L(%!U8FQI8R!,:6-E;G-E"F%L;VYG('=I=&@@1TY5($5M
16M86-S+B`@268@;F]T+"!S964@/&AT='!S.B\O=W=W+F=N=2YO<F<O;&EC96YS
17&97,O/BX*
18`
19end
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 @@
1;;; uudecode-tests.el --- Tests for uudecode.el -*- lexical-binding: t -*-
2
3;; Copyright (C) 2019 Free Software Foundation, Inc.
4
5;; Author: Stefan Kangas <stefankangas@gmail.com>
6
7;; This file is part of GNU Emacs.
8
9;; GNU Emacs is free software: you can redistribute it and/or modify
10;; it under the terms of the GNU General Public License as published by
11;; the Free Software Foundation, either version 3 of the License, or
12;; (at your option) any later version.
13
14;; GNU Emacs is distributed in the hope that it will be useful,
15;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;; GNU General Public License for more details.
18
19;; You should have received a copy of the GNU General Public License
20;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
21
22;;; Commentary:
23
24;;; Code:
25
26(require 'ert)
27(require 'uudecode)
28
29(defvar uudecode-tests-data-dir
30 (file-truename
31 (expand-file-name "uudecode-resources/"
32 (file-name-directory (or load-file-name
33 buffer-file-name))))
34 "Base directory of uudecode-tests.el test data files.")
35
36(defun uudecode-tests-read-file (file)
37 "Read contents of FILE and return as string."
38 (with-temp-buffer
39 (insert-file-contents file)
40 (buffer-string)))
41
42(defvar uudecode-tests-encoded-str
43 (uudecode-tests-read-file
44 (expand-file-name "uuencoded.txt" uudecode-tests-data-dir))
45 "Uuencoded data for bookmark-tests.el
46Same as `bookmark-tests-decoded-str' but uuencoded.")
47(defvar uudecode-tests-decoded-str
48 (uudecode-tests-read-file
49 (expand-file-name "uudecoded.txt" uudecode-tests-data-dir))
50 "Plain text data for bookmark-tests.el
51Same as `bookmark-tests-encoded-str' but plain text.")
52
53(ert-deftest uudecode-tests-decode-region-internal ()
54 ;; Write to buffer
55 (with-temp-buffer
56 (insert uudecode-tests-encoded-str)
57 (uudecode-decode-region-internal (point-min) (point-max))
58 (should (equal (buffer-string) uudecode-tests-decoded-str)))
59 ;; Write to file
60 (with-temp-buffer
61 (let ((tmpfile (make-temp-file "uudecode-tests-")))
62 (unwind-protect
63 (progn
64 (insert uudecode-tests-encoded-str)
65 (uudecode-decode-region-internal (point-min) (point-max) tmpfile)
66 (should (equal (uudecode-tests-read-file tmpfile)
67 uudecode-tests-decoded-str)))
68 (delete-file tmpfile)))))
69
70(ert-deftest uudecode-tests-decode-region-external ()
71 ;; Write to buffer
72 (when uudecode-use-external
73 (with-temp-buffer
74 (insert uudecode-tests-encoded-str)
75 (uudecode-decode-region-external (point-min) (point-max))
76 (should (equal (buffer-string) uudecode-tests-decoded-str)))
77 ;; Write to file
78 (with-temp-buffer
79 (let ((tmpfile (make-temp-file "uudecode-tests-")))
80 (unwind-protect
81 (progn
82 (insert uudecode-tests-encoded-str)
83 (uudecode-decode-region-external (point-min) (point-max) tmpfile)
84 (should (equal (uudecode-tests-read-file tmpfile)
85 uudecode-tests-decoded-str)))
86 (delete-file tmpfile))))))
87
88(provide 'uudecode-tests)
89;;; uudecode-tests.el ends here