From 085c7f608657d2aa19a6b2b0fe29d3deaa8eb6ff Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 27 Apr 2017 15:22:49 -0700 Subject: [PATCH] Test format-time-string with zone arg * test/src/editfns-tests.el (format-time-string-with-zone) (format-time-string-with-outlandish-zone): New tests. --- test/src/editfns-tests.el | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el index 14124ef85fb..44595be3ee2 100644 --- a/test/src/editfns-tests.el +++ b/test/src/editfns-tests.el @@ -136,4 +136,25 @@ (ert-deftest format-c-float () (should-error (format "%c" 0.5))) +;;; Check format-time-string with various TZ settings. +;;; Use only POSIX-compatible TZ values, since the tests should work +;;; even if tzdb is not in use. +(ert-deftest format-time-string-with-zone () + (should (string-equal + (format-time-string "%Y-%m-%d %H:%M:%S %z" '(0 0 0 0) t) + "1970-01-01 00:00:00 +0000")) + (should (string-equal + (format-time-string "%Y-%m-%d %H:%M:%S %z (%Z)" '(0 0 0 0) "PST8") + "1969-12-31 16:00:00 -0800 (PST)")) + (should (string-equal + (format-time-string "%Y-%m-%d %H:%M:%S %z (%Z)" '(0 0 0 0) + "NZST-12NZDT,M9.5.0,M4.1.0/3") + "1970-01-01 13:00:00 +1300 (NZDT)"))) + +;;; This should not dump core. +(ert-deftest format-time-string-with-outlandish-zone () + (should (stringp + (format-time-string "%Y-%m-%d %H:%M:%S %z" '(0 0 0 0) + (concat (make-string 2048 ?X) "0"))))) + ;;; editfns-tests.el ends here -- 2.39.5