]> git.eshelyaron.com Git - emacs.git/commitdiff
Test format-time-string with zone arg
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 27 Apr 2017 22:22:49 +0000 (15:22 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 27 Apr 2017 22:24:07 +0000 (15:24 -0700)
* test/src/editfns-tests.el (format-time-string-with-zone)
(format-time-string-with-outlandish-zone): New tests.

test/src/editfns-tests.el

index 14124ef85fbf2d6684be9cae1ffb61f92a60bfcb..44595be3ee2ba0eab1c79adbf03c5b832a857f5e 100644 (file)
 (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