emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 4503310: Add tests for mail/uudecode.el


From: Paul Eggert
Subject: [Emacs-diffs] master 4503310: Add tests for mail/uudecode.el
Date: Sun, 9 Jun 2019 20:07:14 -0400 (EDT)

branch: master
commit 4503310cac33da4da74fd6376244da82c7134432
Author: Stefan Kangas <address@hidden>
Commit: Paul Eggert <address@hidden>

    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.
---
 lisp/mail/uudecode.el                           |  5 +-
 test/lisp/mail/uudecode-resources/uudecoded.txt | 16 +++++
 test/lisp/mail/uudecode-resources/uuencoded.txt | 19 ++++++
 test/lisp/mail/uudecode-tests.el                | 89 +++++++++++++++++++++++++
 4 files changed, 125 insertions(+), 4 deletions(-)

diff --git a/lisp/mail/uudecode.el b/lisp/mail/uudecode.el
index 32e668b..57ca1cc 100644
--- a/lisp/mail/uudecode.el
+++ b/lisp/mail/uudecode.el
@@ -38,19 +38,16 @@
   "Non-nil value should be a string that names a uu decoder.
 The program should expect to read uu data on its standard
 input and write the converted data to its standard output."
-  :type 'string
-  :group 'uudecode)
+  :type 'string)
 
 (defcustom uudecode-decoder-switches nil
   "List of command line flags passed to `uudecode-decoder-program'."
-  :group 'uudecode
   :type '(repeat string))
 
 (defcustom uudecode-use-external
   (executable-find uudecode-decoder-program)
   "Use external uudecode program."
   :version "22.1"
-  :group 'uudecode
   :type 'boolean)
 
 (defconst uudecode-alphabet "\040-\140")
diff --git a/test/lisp/mail/uudecode-resources/uudecoded.txt 
b/test/lisp/mail/uudecode-resources/uudecoded.txt
new file mode 100644
index 0000000..a6f7551
--- /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 0000000..1d2f888
--- /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 0000000..510cbd7
--- /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 <address@hidden>
+
+;; 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]