Expand testing of time-stamp format "%y"
authorStephen Gildea <stepheng+savannah@gildea.com>
Wed, 9 Oct 2019 16:06:23 +0000 (09:06 -0700)
committerStephen Gildea <stepheng+savannah@gildea.com>
Wed, 9 Oct 2019 16:08:19 +0000 (09:08 -0700)
* time-stamp-tests.el (time-stamp-test-year): break into two tests,
time-stamp-test-year-2digit and time-stamp-test-year-4digit.  Expand
time-stamp-test-year-2digit to look more like tests for other 2-digit
conversions.

test/lisp/time-stamp-tests.el

index d710564c36d61854566b8934edc5d0d3f43b4487..287b5f486c3d2b2768260b411b847a0fd75b49d7 100644 (file)
@@ -248,6 +248,32 @@ In use before 2019 changes; will be used again after those changes settle."
     (should (equal (time-stamp-string "%S" ref-time) "05"))
     (should (equal (time-stamp-string "%S" ref-time2) "15"))))
 
+(ert-deftest time-stamp-test-year-2digit ()
+  "Test time-stamp formats for %y."
+  (with-time-stamp-test-env
+    ;; implemented and documented since 1995
+    (should (equal (time-stamp-string "%02y" ref-time) "06"))
+    (should (equal (time-stamp-string "%02y" ref-time2) "16"))
+    ;; documented 1997-2019
+    (should (equal (time-stamp-string "%:y" ref-time) "2006"))
+    (should (equal (time-stamp-string "%:y" ref-time2) "2016"))
+    ;; warned 1997-2019, changed in 2019
+    ;; (We don't expect the %-y or %_y form to be useful,
+    ;; but we test both so that we can confidently state that
+    ;; `-' and `_' affect all 2-digit conversions identically.)
+    (should (equal (time-stamp-string "%-y" ref-time) "6"))
+    (should (equal (time-stamp-string "%-y" ref-time2) "16"))
+    (should (equal (time-stamp-string "%_y" ref-time) " 6"))
+    (should (equal (time-stamp-string "%_y" ref-time2) "16"))
+    (should (equal (time-stamp-string "%y" ref-time) "06"))
+    (should (equal (time-stamp-string "%y" ref-time2) "16"))))
+
+(ert-deftest time-stamp-test-year-4digit ()
+  "Test time-stamp format %Y."
+  (with-time-stamp-test-env
+    ;; implemented since 1997, documented since 2019
+    (should (equal (time-stamp-string "%Y" ref-time) "2006"))))
+
 (ert-deftest time-stamp-test-am-pm ()
   "Test time-stamp formats for AM and PM strings."
   (with-time-stamp-test-env
@@ -267,18 +293,6 @@ In use before 2019 changes; will be used again after those changes settle."
     (should (equal (time-stamp-string "%w" ref-time2) "5"))
     (should (equal (time-stamp-string "%w" ref-time3) "0"))))
 
-(ert-deftest time-stamp-test-year ()
-  "Test time-stamp formats for year."
-  (with-time-stamp-test-env
-    ;; implemented and documented since 1995
-    (should (equal (time-stamp-string "%02y" ref-time) "06"))
-    ;; documented 1997-2019
-    (should (equal (time-stamp-string "%:y" ref-time) "2006"))
-    ;; implemented since 1997, documented since 2019
-    (should (equal (time-stamp-string "%Y" ref-time) "2006"))
-    ;; warned 1997-2019, changed in 2019
-    (should (equal (time-stamp-string "%y" ref-time) "06"))))
-
 (ert-deftest time-stamp-test-time-zone ()
   "Test time-stamp formats for time zone."
   (with-time-stamp-test-env