aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2020-08-04 18:53:47 +0200
committerLars Ingebrigtsen2020-08-04 19:28:51 +0200
commitfbfa70f486522e1b752ebf3d8590375508ea2a55 (patch)
tree1639207299ff36965ddee1fea811009b9977c38a
parent9eb04d87409db48ce63ef5d40201c92bc9e7028c (diff)
downloademacs-fbfa70f486522e1b752ebf3d8590375508ea2a55.tar.gz
emacs-fbfa70f486522e1b752ebf3d8590375508ea2a55.zip
Add test file lost when merged from Gnus in 2016
-rw-r--r--test/lisp/gnus/gnus-util-tests.el76
1 files changed, 76 insertions, 0 deletions
diff --git a/test/lisp/gnus/gnus-util-tests.el b/test/lisp/gnus/gnus-util-tests.el
new file mode 100644
index 00000000000..b01e2fc2966
--- /dev/null
+++ b/test/lisp/gnus/gnus-util-tests.el
@@ -0,0 +1,76 @@
1;;; gnus-util-tests.el --- Selectived tests only.
2;; Copyright (C) 2015-2020 Free Software Foundation, Inc.
3
4;; Author: Jens Lechtenbörger <jens.lechtenboerger@fsfe.org>
5
6;; This file is not part of GNU Emacs.
7
8;; GNU Emacs is free software; you can redistribute it and/or modify
9;; it under the terms of the GNU General Public License as published by
10;; the Free Software Foundation; either version 3, or (at your option)
11;; any later version.
12
13;; GNU Emacs is distributed in the hope that it will be useful,
14;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16;; GNU General Public License for more details.
17
18;; You should have received a copy of the GNU General Public License
19;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
20
21;;; Commentary:
22
23;;; Code:
24
25(require 'ert)
26(require 'gnus-util)
27
28(ert-deftest gnus-subsetp ()
29 ;; False for non-lists.
30 (should-not (gnus-subsetp "1" "1"))
31 (should-not (gnus-subsetp "1" '("1")))
32 (should-not (gnus-subsetp '("1") "1"))
33
34 ;; Real tests.
35 (should (gnus-subsetp '() '()))
36 (should (gnus-subsetp '() '("1")))
37 (should (gnus-subsetp '("1") '("1")))
38 (should (gnus-subsetp '(42) '("1" 42)))
39 (should (gnus-subsetp '(42) '(42 "1")))
40 (should (gnus-subsetp '(42) '("1" 42 2)))
41 (should-not (gnus-subsetp '("1") '()))
42 (should-not (gnus-subsetp '("1") '(2)))
43 (should-not (gnus-subsetp '("1" 2) '(2)))
44 (should-not (gnus-subsetp '(2 "1") '(2)))
45 (should-not (gnus-subsetp '("1" 2) '(2 3)))
46
47 ;; Duplicates don't matter for sets.
48 (should (gnus-subsetp '("1" "1") '("1")))
49 (should (gnus-subsetp '("1" 2 "1") '(2 "1")))
50 (should (gnus-subsetp '("1" 2 "1") '(2 "1" "1" 2)))
51 (should-not (gnus-subsetp '("1" 2 "1" 3) '(2 "1" "1" 2))))
52
53(ert-deftest gnus-setdiff ()
54 ;; False for non-lists.
55 (should-not (gnus-setdiff "1" "1"))
56 (should-not (gnus-setdiff "1" '()))
57 (should-not (gnus-setdiff '() "1"))
58
59 ;; Real tests.
60 (should-not (gnus-setdiff '() '()))
61 (should-not (gnus-setdiff '() '("1")))
62 (should-not (gnus-setdiff '("1") '("1")))
63 (should (equal '("1") (gnus-setdiff '("1") '())))
64 (should (equal '("1") (gnus-setdiff '("1") '(2))))
65 (should (equal '("1") (gnus-setdiff '("1" 2) '(2))))
66 (should (equal '("1") (gnus-setdiff '("1" 2 3) '(3 2))))
67 (should (equal '("1") (gnus-setdiff '(2 "1" 3) '(3 2))))
68 (should (equal '("1") (gnus-setdiff '(2 3 "1") '(3 2))))
69 (should (equal '(2 "1") (gnus-setdiff '(2 3 "1") '(3))))
70
71 ;; Duplicates aren't touched for sets if they are not removed.
72 (should-not (gnus-setdiff '("1" "1") '("1")))
73 (should (equal '("1") (gnus-setdiff '(2 "1" 2) '(2))))
74 (should (equal '("1" "1") (gnus-setdiff '(2 "1" 2 "1") '(2)))))
75
76;;; gnustest-gnus-util.el ends here