aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRichard Lawrence2024-12-13 10:41:02 +0100
committerEli Zaretskii2024-12-14 14:42:15 +0200
commit77f73abd92f1a627ddec0648dcfe14e56b525f4d (patch)
tree9764fd5d3a597b1e1cbfed38cbd538054369089b /test
parentfd021c07606264a73cd4c1f6fa6fe80a756defe0 (diff)
downloademacs-77f73abd92f1a627ddec0648dcfe14e56b525f4d.tar.gz
emacs-77f73abd92f1a627ddec0648dcfe14e56b525f4d.zip
Check for presuppositions in `calendar-date-is-valid-p'
Do not signal an error in `calendar-date-is-valid-p' if passed a value which is not a three-element list of integers. Signaling an error makes the function unusable as a predicate for valid date values. (Bug#74848) * lisp/calendar/calendar.el (calendar-date-is-valid-p): Add the check that input is a 3-element list. * test/lisp/calendar/calendar-tests.el: New file with tests.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/calendar/calendar-tests.el34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/lisp/calendar/calendar-tests.el b/test/lisp/calendar/calendar-tests.el
new file mode 100644
index 00000000000..c41f14d3b54
--- /dev/null
+++ b/test/lisp/calendar/calendar-tests.el
@@ -0,0 +1,34 @@
1;;; calendar-tests.el --- tests for calendar/calendar.el -*- lexical-binding:t -*-
2
3;; Copyright (C) 2024 Free Software Foundation, Inc.
4
5;; Author: Richard Lawrence <rwl@recursewithless.net>
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;;; Code:
23
24(require 'ert)
25(require 'calendar)
26
27(ert-deftest calendar-test-validity-predicate ()
28 (should (eq (calendar-date-is-valid-p nil) nil))
29 (should (eq (calendar-date-is-valid-p "invalid") nil))
30 (should (eq (calendar-date-is-valid-p (list 1 2)) nil))
31 (should (eq (calendar-date-is-valid-p (list 5 1 2025)) t)))
32
33(provide 'calendar-tests)
34;;; calendar-tests.el ends here