aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/play/morse.el2
-rw-r--r--lisp/play/studly.el2
-rw-r--r--test/lisp/play/morse-tests.el60
-rw-r--r--test/lisp/play/studly-tests.el52
4 files changed, 114 insertions, 2 deletions
diff --git a/lisp/play/morse.el b/lisp/play/morse.el
index 1f62ec3c03c..f4989716556 100644
--- a/lisp/play/morse.el
+++ b/lisp/play/morse.el
@@ -1,4 +1,4 @@
1;;; morse.el --- convert text to morse code and back 1;;; morse.el --- convert text to morse code and back -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 1995, 2001-2019 Free Software Foundation, Inc. 3;; Copyright (C) 1995, 2001-2019 Free Software Foundation, Inc.
4 4
diff --git a/lisp/play/studly.el b/lisp/play/studly.el
index ff1bf03e118..c4b32414bd4 100644
--- a/lisp/play/studly.el
+++ b/lisp/play/studly.el
@@ -1,4 +1,4 @@
1;;; studly.el --- StudlyCaps (tm)(r)(c)(xxx) 1;;; studly.el --- StudlyCaps (tm)(r)(c)(xxx) -*- lexical-binding: t -*-
2 2
3;;; This is in the public domain, since it was distributed 3;;; This is in the public domain, since it was distributed
4;;; by its author in 1986 without a copyright notice. 4;;; by its author in 1986 without a copyright notice.
diff --git a/test/lisp/play/morse-tests.el b/test/lisp/play/morse-tests.el
new file mode 100644
index 00000000000..e6129f026f4
--- /dev/null
+++ b/test/lisp/play/morse-tests.el
@@ -0,0 +1,60 @@
1;;; morse-tests.el --- Tests for morse.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 'morse)
28
29(ert-deftest morse-tests-morse-region ()
30 (with-temp-buffer
31 (insert "Morse encoded")
32 (morse-region (point-min) (point-max))
33 (should (equal (buffer-string)
34 "--/---/.-./.../. ./-./-.-./---/-.././-.."))))
35
36(ert-deftest morse-tests-unmorse-region ()
37 (with-temp-buffer
38 (insert "--/---/.-./.../. ./-./-.-./---/-.././-..")
39 (unmorse-region (point-min) (point-max))
40 (should (equal (buffer-string) "morse encoded"))))
41
42(ert-deftest morse-tests-nato-region ()
43 (with-temp-buffer
44 (insert "Nato encoded")
45 (nato-region (point-min) (point-max))
46 (should (equal (buffer-string)
47 (concat
48 "November-Alfa-Tango-Oscar Echo-November"
49 "-Charlie-Oscar-Delta-Echo-Delta")))))
50
51(ert-deftest morse-tests-unnato-region ()
52 (with-temp-buffer
53 (insert (concat
54 "November-Alfa-Tango-Oscar Echo-November"
55 "-Charlie-Oscar-Delta-Echo-Delta"))
56 (denato-region (point-min) (point-max))
57 (should (equal (buffer-string) "nato encoded"))))
58
59(provide 'morse-tests)
60;;; morse-tests.el ends here
diff --git a/test/lisp/play/studly-tests.el b/test/lisp/play/studly-tests.el
new file mode 100644
index 00000000000..10135a0d96b
--- /dev/null
+++ b/test/lisp/play/studly-tests.el
@@ -0,0 +1,52 @@
1;;; studly-tests.el --- Tests for studly.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 'studly)
28
29(ert-deftest studly-tests-studlify-region ()
30 (with-temp-buffer
31 (insert "Studlify this string of text")
32 (studlify-region (point-min) (point-max))
33 (should (equal (buffer-string)
34 "StudliFy this StrinG of tExt"))))
35
36(ert-deftest studly-tests-studlify-word ()
37 (with-temp-buffer
38 (insert "normal studlified normal")
39 (goto-char 8)
40 (studlify-word 1)
41 (should (equal (buffer-string)
42 "normal stUdlIfIed normal"))))
43
44(ert-deftest studly-tests-nato-region ()
45 (with-temp-buffer
46 (insert "Studlify\n this\n buffer")
47 (studlify-buffer)
48 (should (equal (buffer-string)
49 "STuDlify\n This\n buffer"))))
50
51(provide 'studly-tests)
52;;; studly-tests.el ends here