aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
Diffstat (limited to 'test/src')
-rw-r--r--test/src/timefns-tests.el46
1 files changed, 29 insertions, 17 deletions
diff --git a/test/src/timefns-tests.el b/test/src/timefns-tests.el
index 362e7655a91..13ab7d83c3e 100644
--- a/test/src/timefns-tests.el
+++ b/test/src/timefns-tests.el
@@ -40,25 +40,31 @@
40 (7879679999900 . 100000) 40 (7879679999900 . 100000)
41 (78796799999999999999 . 1000000000000))) 41 (78796799999999999999 . 1000000000000)))
42 ;; UTC. 42 ;; UTC.
43 (let ((subsec (time-subtract (time-convert look t) 43 (let ((sec (time-add 59 (time-subtract (time-convert look t)
44 (time-convert look 'integer)))) 44 (time-convert look 'integer)))))
45 (should (string-equal 45 (should (string-equal
46 (format-time-string "%Y-%m-%d %H:%M:%S.%3N %z" look t) 46 (format-time-string "%Y-%m-%d %H:%M:%S.%3N %z" look t)
47 "1972-06-30 23:59:59.999 +0000")) 47 "1972-06-30 23:59:59.999 +0000"))
48 (should (equal (decode-time look t) 48 (should (equal (decode-time look t 'integer)
49 (list 59 59 23 30 6 1972 5 nil 0 subsec))) 49 '(59 59 23 30 6 1972 5 nil 0)))
50 (should (equal (decode-time look t t)
51 (list sec 59 23 30 6 1972 5 nil 0)))
50 ;; "UTC0". 52 ;; "UTC0".
51 (should (string-equal 53 (should (string-equal
52 (format-time-string format look "UTC0") 54 (format-time-string format look "UTC0")
53 "1972-06-30 23:59:59.999 +0000 (UTC)")) 55 "1972-06-30 23:59:59.999 +0000 (UTC)"))
54 (should (equal (decode-time look "UTC0") 56 (should (equal (decode-time look "UTC0" 'integer)
55 (list 59 59 23 30 6 1972 5 nil 0 subsec))) 57 '(59 59 23 30 6 1972 5 nil 0)))
58 (should (equal (decode-time look "UTC0" t)
59 (list sec 59 23 30 6 1972 5 nil 0)))
56 ;; Negative UTC offset, as a Lisp list. 60 ;; Negative UTC offset, as a Lisp list.
57 (should (string-equal 61 (should (string-equal
58 (format-time-string format look '(-28800 "PST")) 62 (format-time-string format look '(-28800 "PST"))
59 "1972-06-30 15:59:59.999 -0800 (PST)")) 63 "1972-06-30 15:59:59.999 -0800 (PST)"))
60 (should (equal (decode-time look '(-28800 "PST")) 64 (should (equal (decode-time look '(-28800 "PST") 'integer)
61 (list 59 59 15 30 6 1972 5 nil -28800 subsec))) 65 '(59 59 15 30 6 1972 5 nil -28800)))
66 (should (equal (decode-time look '(-28800 "PST") t)
67 (list sec 59 15 30 6 1972 5 nil -28800)))
62 ;; Negative UTC offset, as a Lisp integer. 68 ;; Negative UTC offset, as a Lisp integer.
63 (should (string-equal 69 (should (string-equal
64 (format-time-string format look -28800) 70 (format-time-string format look -28800)
@@ -67,14 +73,18 @@
67 (if (eq system-type 'windows-nt) 73 (if (eq system-type 'windows-nt)
68 "1972-06-30 15:59:59.999 -0800 (ZZZ)" 74 "1972-06-30 15:59:59.999 -0800 (ZZZ)"
69 "1972-06-30 15:59:59.999 -0800 (-08)"))) 75 "1972-06-30 15:59:59.999 -0800 (-08)")))
70 (should (equal (decode-time look -28800) 76 (should (equal (decode-time look -28800 'integer)
71 (list 59 59 15 30 6 1972 5 nil -28800 subsec))) 77 '(59 59 15 30 6 1972 5 nil -28800)))
78 (should (equal (decode-time look -28800 t)
79 (list sec 59 15 30 6 1972 5 nil -28800)))
72 ;; Positive UTC offset that is not an hour multiple, as a string. 80 ;; Positive UTC offset that is not an hour multiple, as a string.
73 (should (string-equal 81 (should (string-equal
74 (format-time-string format look "IST-5:30") 82 (format-time-string format look "IST-5:30")
75 "1972-07-01 05:29:59.999 +0530 (IST)")) 83 "1972-07-01 05:29:59.999 +0530 (IST)"))
76 (should (equal (decode-time look "IST-5:30") 84 (should (equal (decode-time look "IST-5:30" 'integer)
77 (list 59 29 5 1 7 1972 6 nil 19800 subsec))))))) 85 '(59 29 5 1 7 1972 6 nil 19800)))
86 (should (equal (decode-time look "IST-5:30" t)
87 (list sec 29 5 1 7 1972 6 nil 19800)))))))
78 88
79(ert-deftest decode-then-encode-time () 89(ert-deftest decode-then-encode-time ()
80 (let ((time-values (list 0 -2 1 0.0 -0.0 -2.0 1.0 90 (let ((time-values (list 0 -2 1 0.0 -0.0 -2.0 1.0
@@ -87,11 +97,13 @@
87 (cons (1+ most-positive-fixnum) 1000000000000) 97 (cons (1+ most-positive-fixnum) 1000000000000)
88 (cons 1000000000000 (1+ most-positive-fixnum))))) 98 (cons 1000000000000 (1+ most-positive-fixnum)))))
89 (dolist (a time-values) 99 (dolist (a time-values)
90 (let* ((d (ignore-errors (decode-time a t))) 100 (let* ((d (ignore-errors (decode-time a t t)))
101 (d-integer (ignore-errors (decode-time a t 'integer)))
91 (e (if d (encode-time d))) 102 (e (if d (encode-time d)))
92 (diff (float-time (time-subtract a e)))) 103 (e-integer (if d-integer (encode-time d-integer))))
93 (should (or (not d) 104 (should (or (not d) (time-equal-p a e)))
94 (and (<= 0 diff) (< diff 1)))))))) 105 (should (or (not d-integer) (time-equal-p (time-convert a 'integer)
106 e-integer)))))))
95 107
96;;; This should not dump core. 108;;; This should not dump core.
97(ert-deftest format-time-string-with-outlandish-zone () 109(ert-deftest format-time-string-with-outlandish-zone ()
@@ -151,7 +163,7 @@
151(ert-deftest encode-time-dst-numeric-zone () 163(ert-deftest encode-time-dst-numeric-zone ()
152 "Check for Bug#35502." 164 "Check for Bug#35502."
153 (should (time-equal-p 165 (should (time-equal-p
154 (encode-time '(29 31 17 30 4 2019 2 t 7200 0)) 166 (encode-time '(29 31 17 30 4 2019 2 t 7200))
155 '(23752 27217)))) 167 '(23752 27217))))
156 168
157(ert-deftest float-time-precision () 169(ert-deftest float-time-precision ()