aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2017-05-01 10:41:50 -0700
committerPaul Eggert2017-05-01 10:43:44 -0700
commita4dc24cf4f09dd4a52d525416bb231718e0ee8cd (patch)
tree98a5a26b3cce2af52cc9c8fa885ab16aa2b4bcfd
parent6f0dfad84e1c1608bff9d691395bbe4ba1a39a52 (diff)
downloademacs-a4dc24cf4f09dd4a52d525416bb231718e0ee8cd.tar.gz
emacs-a4dc24cf4f09dd4a52d525416bb231718e0ee8cd.zip
Don’t stress-test time zones near the Epoch
* test/src/editfns-tests.el (format-time-string-with-zone) (format-time-string-with-outlandish-zone): Don’t format timestamps near the Epoch, as this runs into bugs on MS-Windows, and we don’t want to worry about those bugs.
-rw-r--r--test/src/editfns-tests.el39
1 files changed, 28 insertions, 11 deletions
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el
index 44595be3ee2..3fd3cc1305f 100644
--- a/test/src/editfns-tests.el
+++ b/test/src/editfns-tests.el
@@ -140,21 +140,38 @@
140;;; Use only POSIX-compatible TZ values, since the tests should work 140;;; Use only POSIX-compatible TZ values, since the tests should work
141;;; even if tzdb is not in use. 141;;; even if tzdb is not in use.
142(ert-deftest format-time-string-with-zone () 142(ert-deftest format-time-string-with-zone ()
143 (should (string-equal 143 ;; Don’t use (0 0 0 0) as the test case, as there are too many bugs
144 (format-time-string "%Y-%m-%d %H:%M:%S %z" '(0 0 0 0) t) 144 ;; in MSVC (and presumably other) C libraries when formatting time
145 "1970-01-01 00:00:00 +0000")) 145 ;; stamps near the Epoch of 1970-01-01 00:00:00 UTC, and this test
146 (should (string-equal 146 ;; is for GNU Emacs, not for C runtimes. Instead, look before you
147 (format-time-string "%Y-%m-%d %H:%M:%S %z (%Z)" '(0 0 0 0) "PST8") 147 ;; leap: "look" is the timestamp just before the first leap second
148 "1969-12-31 16:00:00 -0800 (PST)")) 148 ;; on 1972-06-30 23:59:60 UTC, so it should format to the same
149 (should (string-equal 149 ;; string regardless of whether the underlying C library ignores
150 (format-time-string "%Y-%m-%d %H:%M:%S %z (%Z)" '(0 0 0 0) 150 ;; leap seconds, while avoiding circa-1970 glitches.
151 "NZST-12NZDT,M9.5.0,M4.1.0/3") 151 (let ((look '(1202 22527 999999 999999)))
152 "1970-01-01 13:00:00 +1300 (NZDT)"))) 152 ;; UTC.
153 (should (string-equal
154 (format-time-string "%Y-%m-%d %H:%M:%S.%3N %z" look t)
155 "1972-06-30 23:59:59.999 +0000"))
156 ;; Time zone without DST in 1972.
157 (should (string-equal
158 (format-time-string "%Y-%m-%d %H:%M:%S.%3N %z (%Z)" look "NZST-12")
159 "1972-07-01 11:59:59.999 +1200 (NZST)"))
160 ;; United States DST in 1972.
161 (should (string-equal
162 (format-time-string "%Y-%m-%d %H:%M:%S.%3N %z (%Z)" look
163 "PST8PDT,M4.5.0,M10.5,0")
164 "1972-06-30 16:59:59.999 -0700 (PDT)"))
165 ;; New South Wales DST in 1971-2.
166 (should (string-equal
167 (format-time-string "%Y-%m-%d %H:%M:%S.%3N %z (%Z)" look
168 "AEST-10AEDT,M10.5.0,M2.5.0/3")
169 "1972-07-01 09:59:59.999 +1000 (AEST)"))))
153 170
154;;; This should not dump core. 171;;; This should not dump core.
155(ert-deftest format-time-string-with-outlandish-zone () 172(ert-deftest format-time-string-with-outlandish-zone ()
156 (should (stringp 173 (should (stringp
157 (format-time-string "%Y-%m-%d %H:%M:%S %z" '(0 0 0 0) 174 (format-time-string "%Y-%m-%d %H:%M:%S.%3N %z" nil
158 (concat (make-string 2048 ?X) "0"))))) 175 (concat (make-string 2048 ?X) "0")))))
159 176
160;;; editfns-tests.el ends here 177;;; editfns-tests.el ends here