diff options
| author | Stephen Gildea | 2019-09-28 15:46:27 -0700 |
|---|---|---|
| committer | Stephen Gildea | 2019-09-28 15:48:45 -0700 |
| commit | c359782ae6441bba2fad2b6d53bcbcd5a8be7057 (patch) | |
| tree | 1b0c338612cbb4b92bc5b205d3ec3018fd51fa9c | |
| parent | bc94e2dd4be04cbe7b5ab6749e30ef6c305c0588 (diff) | |
| download | emacs-c359782ae6441bba2fad2b6d53bcbcd5a8be7057.tar.gz emacs-c359782ae6441bba2fad2b6d53bcbcd5a8be7057.zip | |
Reorganize time-stamp tests
* time-stamp-tests.el: Group tests by when the format was or will be
documented. Add tests for a few more undocumented, volatile formats.
Change AM hours test time to be a different hour from PM test time.
(Making these changes to the tests now will minimize test changes
needed later with anticipated code changes.)
| -rw-r--r-- | test/lisp/time-stamp-tests.el | 215 |
1 files changed, 112 insertions, 103 deletions
diff --git a/test/lisp/time-stamp-tests.el b/test/lisp/time-stamp-tests.el index 165b4f13c2f..452d83ddba9 100644 --- a/test/lisp/time-stamp-tests.el +++ b/test/lisp/time-stamp-tests.el | |||
| @@ -31,7 +31,7 @@ | |||
| 31 | (mail-host-address "test-mail-host-name") | 31 | (mail-host-address "test-mail-host-name") |
| 32 | (ref-time '(17337 16613)) ;Monday, Jan 2, 2006, 3:04:05 PM | 32 | (ref-time '(17337 16613)) ;Monday, Jan 2, 2006, 3:04:05 PM |
| 33 | (ref-time2 '(22574 61591)) ;Friday, Nov 18, 2016, 12:14:15 PM | 33 | (ref-time2 '(22574 61591)) ;Friday, Nov 18, 2016, 12:14:15 PM |
| 34 | (ref-time3 '(21377 23973 123456)) ;Sun, May 25, 2014, 03:04:05.123456am | 34 | (ref-time3 '(21377 34956)) ;Sunday, May 25, 2014, 06:07:08 AM |
| 35 | (time-stamp-time-zone t)) ;use UTC | 35 | (time-stamp-time-zone t)) ;use UTC |
| 36 | (cl-letf (((symbol-function 'time-stamp-conv-warn) | 36 | (cl-letf (((symbol-function 'time-stamp-conv-warn) |
| 37 | (lambda (old-format _new) | 37 | (lambda (old-format _new) |
| @@ -57,181 +57,187 @@ | |||
| 57 | 57 | ||
| 58 | ;;; Tests: | 58 | ;;; Tests: |
| 59 | 59 | ||
| 60 | (ert-deftest time-stamp-test-day-of-week-documented () | 60 | (ert-deftest time-stamp-test-day-of-week () |
| 61 | "Test documented time-stamp formats for day of week." | 61 | "Test time-stamp formats for named day of week." |
| 62 | (with-time-stamp-test-env | 62 | (with-time-stamp-test-env |
| 63 | ;; implemented and documented since 1997 | ||
| 63 | (should (equal (time-stamp-string "%3a" ref-time) "Mon")) | 64 | (should (equal (time-stamp-string "%3a" ref-time) "Mon")) |
| 65 | (should (equal (time-stamp-string "%#A" ref-time) "MONDAY")) | ||
| 64 | (should (equal (time-stamp-string "%3A" ref-time) "MON")) | 66 | (should (equal (time-stamp-string "%3A" ref-time) "MON")) |
| 65 | (should (equal (time-stamp-string "%:a" ref-time) "Monday")) | 67 | (should (equal (time-stamp-string "%:a" ref-time) "Monday")) |
| 66 | (should (equal (time-stamp-string "%#A" ref-time) "MONDAY")) | 68 | ;; implemented since 2001, undocumented future formats |
| 67 | (should (equal (time-stamp-string "%3a" ref-time2) "Fri")) | ||
| 68 | (should (equal (time-stamp-string "%3A" ref-time2) "FRI")) | ||
| 69 | (should (equal (time-stamp-string "%:a" ref-time2) "Friday")) | ||
| 70 | (should (equal (time-stamp-string "%#A" ref-time2) "FRIDAY")))) | ||
| 71 | |||
| 72 | (ert-deftest time-stamp-test-day-of-week-future () | ||
| 73 | "Test implemented but as yet undocumented time-stamp formats for day of week." | ||
| 74 | (with-time-stamp-test-env | ||
| 75 | (should (equal (time-stamp-string "%#a" ref-time) "MON")) | 69 | (should (equal (time-stamp-string "%#a" ref-time) "MON")) |
| 76 | (should (equal (time-stamp-string "%:A" ref-time) "Monday")) | 70 | (should (equal (time-stamp-string "%:A" ref-time) "Monday")) |
| 77 | (should (equal (time-stamp-string "%#a" ref-time2) "FRI")) | 71 | ;; warned since 1997, will change |
| 78 | (should (equal (time-stamp-string "%:A" ref-time2) "Friday")))) | 72 | (time-stamp-should-warn (equal |
| 79 | 73 | (time-stamp-string "%a" ref-time) "Monday")) | |
| 80 | (ert-deftest time-stamp-test-day-of-week-volatile-warns () | ||
| 81 | "Test time-stamp formats for day of week that will change. | ||
| 82 | Test that each generates a warning." | ||
| 83 | (with-time-stamp-test-env | ||
| 84 | (time-stamp-should-warn (equal | 74 | (time-stamp-should-warn (equal |
| 85 | (time-stamp-string "%a" ref-time) "Monday")) | 75 | (time-stamp-string "%^a" ref-time) "Monday")) |
| 86 | (time-stamp-should-warn (equal | 76 | (time-stamp-should-warn (equal |
| 87 | (time-stamp-string "%A" ref-time) "MONDAY")))) | 77 | (time-stamp-string "%A" ref-time) "MONDAY")))) |
| 88 | 78 | ||
| 89 | (ert-deftest time-stamp-test-month-name-documented () | 79 | (ert-deftest time-stamp-test-month-name () |
| 90 | "Test documented time-stamp formats for month name." | 80 | "Test time-stamp formats for month name." |
| 91 | (with-time-stamp-test-env | 81 | (with-time-stamp-test-env |
| 82 | ;; implemented and documented since 1997 | ||
| 92 | (should (equal (time-stamp-string "%3b" ref-time) "Jan")) | 83 | (should (equal (time-stamp-string "%3b" ref-time) "Jan")) |
| 84 | (should (equal (time-stamp-string "%#B" ref-time) "JANUARY")) | ||
| 93 | (should (equal (time-stamp-string "%3B" ref-time) "JAN")) | 85 | (should (equal (time-stamp-string "%3B" ref-time) "JAN")) |
| 94 | (should (equal (time-stamp-string "%:b" ref-time) "January")) | 86 | (should (equal (time-stamp-string "%:b" ref-time) "January")) |
| 95 | (should (equal (time-stamp-string "%#B" ref-time) "JANUARY")))) | 87 | ;; implemented since 2001, undocumented future formats |
| 96 | |||
| 97 | (ert-deftest time-stamp-test-month-name-future () | ||
| 98 | "Test implemented but as yet undocumented time-stamp formats for month name." | ||
| 99 | (with-time-stamp-test-env | ||
| 100 | (should (equal (time-stamp-string "%#b" ref-time) "JAN")) | 88 | (should (equal (time-stamp-string "%#b" ref-time) "JAN")) |
| 101 | (should (equal (time-stamp-string "%:B" ref-time) "January")))) | 89 | (should (equal (time-stamp-string "%:B" ref-time) "January")) |
| 102 | 90 | ;; warned since 1997, will change | |
| 103 | (ert-deftest time-stamp-test-month-name-volatile-warns () | ||
| 104 | "Test time-stamp formats for month name that will change. | ||
| 105 | Test that each generates a warning." | ||
| 106 | (with-time-stamp-test-env | ||
| 107 | (time-stamp-should-warn (equal | 91 | (time-stamp-should-warn (equal |
| 108 | (time-stamp-string "%b" ref-time) "January")) | 92 | (time-stamp-string "%b" ref-time) "January")) |
| 109 | (time-stamp-should-warn (equal | 93 | (time-stamp-should-warn (equal |
| 94 | (time-stamp-string "%^b" ref-time) "January")) | ||
| 95 | (time-stamp-should-warn (equal | ||
| 110 | (time-stamp-string "%B" ref-time) "JANUARY")))) | 96 | (time-stamp-string "%B" ref-time) "JANUARY")))) |
| 111 | 97 | ||
| 112 | (ert-deftest time-stamp-test-day-of-month () | 98 | (ert-deftest time-stamp-test-day-of-month () |
| 113 | "Test time-stamp formats for day of month." | 99 | "Test time-stamp formats for day of month." |
| 114 | (with-time-stamp-test-env | 100 | (with-time-stamp-test-env |
| 115 | ;; documented 1-digit | 101 | ;; implemented and documented since 1995 |
| 116 | (should (equal (time-stamp-string "%:d" ref-time) "2")) | ||
| 117 | (should (equal (time-stamp-string "%2d" ref-time) " 2")) | 102 | (should (equal (time-stamp-string "%2d" ref-time) " 2")) |
| 118 | (should (equal (time-stamp-string "%02d" ref-time) "02")) | ||
| 119 | ;; documented 2-digit | ||
| 120 | (should (equal (time-stamp-string "%:d" ref-time2) "18")) | ||
| 121 | (should (equal (time-stamp-string "%2d" ref-time2) "18")) | 103 | (should (equal (time-stamp-string "%2d" ref-time2) "18")) |
| 104 | (should (equal (time-stamp-string "%02d" ref-time) "02")) | ||
| 122 | (should (equal (time-stamp-string "%02d" ref-time2) "18")) | 105 | (should (equal (time-stamp-string "%02d" ref-time2) "18")) |
| 123 | ;; undocumented future formats | 106 | ;; implemented and documented since 1997 |
| 107 | (should (equal (time-stamp-string "%:d" ref-time) "2")) | ||
| 108 | (should (equal (time-stamp-string "%:d" ref-time2) "18")) | ||
| 109 | ;; implemented since 1997, undocumented future format | ||
| 124 | (should (equal (time-stamp-string "%1d" ref-time) "2")) | 110 | (should (equal (time-stamp-string "%1d" ref-time) "2")) |
| 125 | (should (equal (time-stamp-string "%1d" ref-time2) "18")) | 111 | (should (equal (time-stamp-string "%1d" ref-time2) "18")) |
| 126 | ;; changing formats | 112 | ;; warned since 1997, will change |
| 113 | (time-stamp-should-warn (equal (time-stamp-string "%_d" ref-time) "2")) | ||
| 114 | (time-stamp-should-warn (equal (time-stamp-string "%_d" ref-time2) "18")) | ||
| 127 | (time-stamp-should-warn (equal (time-stamp-string "%d" ref-time) "2")) | 115 | (time-stamp-should-warn (equal (time-stamp-string "%d" ref-time) "2")) |
| 128 | (time-stamp-should-warn (equal (time-stamp-string "%_d" ref-time) "2")))) | 116 | (time-stamp-should-warn (equal (time-stamp-string "%d" ref-time2) "18")))) |
| 129 | 117 | ||
| 130 | (ert-deftest time-stamp-test-hours-24 () | 118 | (ert-deftest time-stamp-test-hours-24 () |
| 131 | "Test time-stamp formats for hour on a 24-hour clock." | 119 | "Test time-stamp formats for hour on a 24-hour clock." |
| 132 | (with-time-stamp-test-env | 120 | (with-time-stamp-test-env |
| 133 | ;; documented PM | 121 | ;; implemented and documented since 1995 |
| 134 | (should (equal (time-stamp-string "%:H" ref-time) "15")) | ||
| 135 | (should (equal (time-stamp-string "%2H" ref-time) "15")) | 122 | (should (equal (time-stamp-string "%2H" ref-time) "15")) |
| 136 | (should (equal (time-stamp-string "%02H" ref-time) "15")) | ||
| 137 | ;; documented AM | ||
| 138 | (should (equal (time-stamp-string "%:H" ref-time2) "12")) | ||
| 139 | (should (equal (time-stamp-string "%2H" ref-time2) "12")) | 123 | (should (equal (time-stamp-string "%2H" ref-time2) "12")) |
| 124 | (should (equal (time-stamp-string "%2H" ref-time3) " 6")) | ||
| 125 | (should (equal (time-stamp-string "%02H" ref-time) "15")) | ||
| 140 | (should (equal (time-stamp-string "%02H" ref-time2) "12")) | 126 | (should (equal (time-stamp-string "%02H" ref-time2) "12")) |
| 141 | ;; documented 1-digit | 127 | (should (equal (time-stamp-string "%02H" ref-time3) "06")) |
| 142 | (should (equal (time-stamp-string "%:H" ref-time3) "3")) | 128 | ;; implemented and documented since 1997 |
| 143 | (should (equal (time-stamp-string "%2H" ref-time3) " 3")) | 129 | (should (equal (time-stamp-string "%:H" ref-time) "15")) |
| 144 | (should (equal (time-stamp-string "%02H" ref-time3) "03")) | 130 | (should (equal (time-stamp-string "%:H" ref-time2) "12")) |
| 145 | ;; undocumented future formats | 131 | (should (equal (time-stamp-string "%:H" ref-time3) "6")) |
| 132 | ;; implemented since 1997, undocumented future format | ||
| 146 | (should (equal (time-stamp-string "%1H" ref-time) "15")) | 133 | (should (equal (time-stamp-string "%1H" ref-time) "15")) |
| 147 | (should (equal (time-stamp-string "%1H" ref-time2) "12")) | 134 | (should (equal (time-stamp-string "%1H" ref-time2) "12")) |
| 148 | (should (equal (time-stamp-string "%1H" ref-time3) "3")) | 135 | (should (equal (time-stamp-string "%1H" ref-time3) "6")) |
| 149 | ;; changing formats | 136 | ;; warned since 1997, will change |
| 137 | (time-stamp-should-warn (equal (time-stamp-string "%_H" ref-time) "15")) | ||
| 138 | (time-stamp-should-warn (equal (time-stamp-string "%_H" ref-time2) "12")) | ||
| 139 | (time-stamp-should-warn (equal (time-stamp-string "%_H" ref-time3) "6")) | ||
| 150 | (time-stamp-should-warn (equal (time-stamp-string "%H" ref-time) "15")) | 140 | (time-stamp-should-warn (equal (time-stamp-string "%H" ref-time) "15")) |
| 151 | (time-stamp-should-warn (equal (time-stamp-string "%_H" ref-time) "15")))) | 141 | (time-stamp-should-warn (equal (time-stamp-string "%H" ref-time2) "12")) |
| 142 | (time-stamp-should-warn (equal (time-stamp-string "%H" ref-time3) "6")))) | ||
| 152 | 143 | ||
| 153 | (ert-deftest time-stamp-test-hours-12 () | 144 | (ert-deftest time-stamp-test-hours-12 () |
| 154 | "Test time-stamp formats for hour on a 12-hour clock." | 145 | "Test time-stamp formats for hour on a 12-hour clock." |
| 155 | (with-time-stamp-test-env | 146 | (with-time-stamp-test-env |
| 156 | ;; documented 1-digit, PM | 147 | ;; implemented and documented since 1995 |
| 157 | (should (equal (time-stamp-string "%:I" ref-time) "3")) | ||
| 158 | (should (equal (time-stamp-string "%2I" ref-time) " 3")) | 148 | (should (equal (time-stamp-string "%2I" ref-time) " 3")) |
| 159 | (should (equal (time-stamp-string "%02I" ref-time) "03")) | ||
| 160 | ;; documented 2-digit | ||
| 161 | (should (equal (time-stamp-string "%:I" ref-time2) "12")) | ||
| 162 | (should (equal (time-stamp-string "%2I" ref-time2) "12")) | 149 | (should (equal (time-stamp-string "%2I" ref-time2) "12")) |
| 150 | (should (equal (time-stamp-string "%2I" ref-time3) " 6")) | ||
| 151 | (should (equal (time-stamp-string "%02I" ref-time) "03")) | ||
| 163 | (should (equal (time-stamp-string "%02I" ref-time2) "12")) | 152 | (should (equal (time-stamp-string "%02I" ref-time2) "12")) |
| 164 | ;; undocumented future formats | 153 | (should (equal (time-stamp-string "%02I" ref-time3) "06")) |
| 154 | ;; implemented and documented since 1997 | ||
| 155 | (should (equal (time-stamp-string "%:I" ref-time) "3")) ;PM | ||
| 156 | (should (equal (time-stamp-string "%:I" ref-time2) "12")) ;PM | ||
| 157 | (should (equal (time-stamp-string "%:I" ref-time3) "6")) ;AM | ||
| 158 | ;; implemented since 1997, undocumented future format | ||
| 165 | (should (equal (time-stamp-string "%1I" ref-time) "3")) | 159 | (should (equal (time-stamp-string "%1I" ref-time) "3")) |
| 166 | (should (equal (time-stamp-string "%1I" ref-time2) "12")) | 160 | (should (equal (time-stamp-string "%1I" ref-time2) "12")) |
| 167 | ;; changing formats | 161 | (should (equal (time-stamp-string "%1I" ref-time3) "6")) |
| 162 | ;; warned since 1997, will change | ||
| 163 | (time-stamp-should-warn (equal (time-stamp-string "%_I" ref-time) "3")) | ||
| 164 | (time-stamp-should-warn (equal (time-stamp-string "%_I" ref-time2) "12")) | ||
| 165 | (time-stamp-should-warn (equal (time-stamp-string "%_I" ref-time3) "6")) | ||
| 168 | (time-stamp-should-warn (equal (time-stamp-string "%I" ref-time) "3")) | 166 | (time-stamp-should-warn (equal (time-stamp-string "%I" ref-time) "3")) |
| 169 | (time-stamp-should-warn (equal (time-stamp-string "%_I" ref-time) "3")))) | 167 | (time-stamp-should-warn (equal (time-stamp-string "%I" ref-time2) "12")) |
| 168 | (time-stamp-should-warn (equal (time-stamp-string "%I" ref-time3) "6")))) | ||
| 170 | 169 | ||
| 171 | (ert-deftest time-stamp-test-month-number () | 170 | (ert-deftest time-stamp-test-month-number () |
| 172 | "Test time-stamp formats for month number." | 171 | "Test time-stamp formats for month number." |
| 173 | (with-time-stamp-test-env | 172 | (with-time-stamp-test-env |
| 174 | ;; documented 1-digit | 173 | ;; implemented and documented since 1995 |
| 175 | (should (equal (time-stamp-string "%:m" ref-time) "1")) | ||
| 176 | (should (equal (time-stamp-string "%2m" ref-time) " 1")) | 174 | (should (equal (time-stamp-string "%2m" ref-time) " 1")) |
| 177 | (should (equal (time-stamp-string "%02m" ref-time) "01")) | ||
| 178 | ;; documented 2-digit | ||
| 179 | (should (equal (time-stamp-string "%:m" ref-time2) "11")) | ||
| 180 | (should (equal (time-stamp-string "%2m" ref-time2) "11")) | 175 | (should (equal (time-stamp-string "%2m" ref-time2) "11")) |
| 176 | (should (equal (time-stamp-string "%02m" ref-time) "01")) | ||
| 181 | (should (equal (time-stamp-string "%02m" ref-time2) "11")) | 177 | (should (equal (time-stamp-string "%02m" ref-time2) "11")) |
| 182 | ;; undocumented future formats | 178 | ;; implemented and documented since 1997 |
| 179 | (should (equal (time-stamp-string "%:m" ref-time) "1")) | ||
| 180 | (should (equal (time-stamp-string "%:m" ref-time2) "11")) | ||
| 181 | ;; implemented since 1997, undocumented future format | ||
| 183 | (should (equal (time-stamp-string "%1m" ref-time) "1")) | 182 | (should (equal (time-stamp-string "%1m" ref-time) "1")) |
| 184 | (should (equal (time-stamp-string "%1m" ref-time2) "11")) | 183 | (should (equal (time-stamp-string "%1m" ref-time2) "11")) |
| 185 | ;; changing formats | 184 | ;; warned since 1997, will change |
| 185 | (time-stamp-should-warn (equal (time-stamp-string "%_m" ref-time) "1")) | ||
| 186 | (time-stamp-should-warn (equal (time-stamp-string "%_m" ref-time2) "11")) | ||
| 186 | (time-stamp-should-warn (equal (time-stamp-string "%m" ref-time) "1")) | 187 | (time-stamp-should-warn (equal (time-stamp-string "%m" ref-time) "1")) |
| 187 | (time-stamp-should-warn (equal (time-stamp-string "%_m" ref-time) "1")))) | 188 | (time-stamp-should-warn (equal (time-stamp-string "%m" ref-time2) "11")))) |
| 188 | 189 | ||
| 189 | (ert-deftest time-stamp-test-minute () | 190 | (ert-deftest time-stamp-test-minute () |
| 190 | "Test time-stamp formats for minute." | 191 | "Test time-stamp formats for minute." |
| 191 | (with-time-stamp-test-env | 192 | (with-time-stamp-test-env |
| 192 | ;; documented 1-digit | 193 | ;; implemented and documented since 1995 |
| 193 | (should (equal (time-stamp-string "%:M" ref-time) "4")) | ||
| 194 | (should (equal (time-stamp-string "%2M" ref-time) " 4")) | 194 | (should (equal (time-stamp-string "%2M" ref-time) " 4")) |
| 195 | (should (equal (time-stamp-string "%02M" ref-time) "04")) | ||
| 196 | ;; documented 2-digit | ||
| 197 | (should (equal (time-stamp-string "%:M" ref-time2) "14")) | ||
| 198 | (should (equal (time-stamp-string "%2M" ref-time2) "14")) | 195 | (should (equal (time-stamp-string "%2M" ref-time2) "14")) |
| 196 | (should (equal (time-stamp-string "%02M" ref-time) "04")) | ||
| 199 | (should (equal (time-stamp-string "%02M" ref-time2) "14")) | 197 | (should (equal (time-stamp-string "%02M" ref-time2) "14")) |
| 200 | ;; undocumented future formats | 198 | ;; implemented and documented since 1997 |
| 199 | (should (equal (time-stamp-string "%:M" ref-time) "4")) | ||
| 200 | (should (equal (time-stamp-string "%:M" ref-time2) "14")) | ||
| 201 | ;; implemented since 1997, undocumented future format | ||
| 201 | (should (equal (time-stamp-string "%1M" ref-time) "4")) | 202 | (should (equal (time-stamp-string "%1M" ref-time) "4")) |
| 202 | (should (equal (time-stamp-string "%1M" ref-time2) "14")) | 203 | (should (equal (time-stamp-string "%1M" ref-time2) "14")) |
| 203 | ;; changing formats | 204 | ;; warned since 1997, will change |
| 205 | (time-stamp-should-warn (equal (time-stamp-string "%_M" ref-time) "4")) | ||
| 206 | (time-stamp-should-warn (equal (time-stamp-string "%_M" ref-time2) "14")) | ||
| 204 | (time-stamp-should-warn (equal (time-stamp-string "%M" ref-time) "4")) | 207 | (time-stamp-should-warn (equal (time-stamp-string "%M" ref-time) "4")) |
| 205 | (time-stamp-should-warn (equal (time-stamp-string "%_M" ref-time) "4")))) | 208 | (time-stamp-should-warn (equal (time-stamp-string "%M" ref-time2) "14")))) |
| 206 | 209 | ||
| 207 | (ert-deftest time-stamp-test-second () | 210 | (ert-deftest time-stamp-test-second () |
| 208 | "Test time-stamp formats for second." | 211 | "Test time-stamp formats for second." |
| 209 | (with-time-stamp-test-env | 212 | (with-time-stamp-test-env |
| 210 | ;; documented 1-digit | 213 | ;; implemented and documented since 1995 |
| 211 | (should (equal (time-stamp-string "%:S" ref-time) "5")) | ||
| 212 | (should (equal (time-stamp-string "%2S" ref-time) " 5")) | 214 | (should (equal (time-stamp-string "%2S" ref-time) " 5")) |
| 213 | (should (equal (time-stamp-string "%02S" ref-time) "05")) | ||
| 214 | ;; documented 2-digit | ||
| 215 | (should (equal (time-stamp-string "%:S" ref-time2) "15")) | ||
| 216 | (should (equal (time-stamp-string "%2S" ref-time2) "15")) | 215 | (should (equal (time-stamp-string "%2S" ref-time2) "15")) |
| 216 | (should (equal (time-stamp-string "%02S" ref-time) "05")) | ||
| 217 | (should (equal (time-stamp-string "%02S" ref-time2) "15")) | 217 | (should (equal (time-stamp-string "%02S" ref-time2) "15")) |
| 218 | ;; undocumented future formats | 218 | ;; implemented and documented since 1997 |
| 219 | (should (equal (time-stamp-string "%:S" ref-time) "5")) | ||
| 220 | (should (equal (time-stamp-string "%:S" ref-time2) "15")) | ||
| 221 | ;; implemented since 1997, undocumented future format | ||
| 219 | (should (equal (time-stamp-string "%1S" ref-time) "5")) | 222 | (should (equal (time-stamp-string "%1S" ref-time) "5")) |
| 220 | (should (equal (time-stamp-string "%1S" ref-time2) "15")) | 223 | (should (equal (time-stamp-string "%1S" ref-time2) "15")) |
| 221 | ;; changing formats | 224 | ;; warned since 1997, will change |
| 225 | (time-stamp-should-warn (equal (time-stamp-string "%_S" ref-time) "5")) | ||
| 226 | (time-stamp-should-warn (equal (time-stamp-string "%_S" ref-time2) "15")) | ||
| 222 | (time-stamp-should-warn (equal (time-stamp-string "%S" ref-time) "5")) | 227 | (time-stamp-should-warn (equal (time-stamp-string "%S" ref-time) "5")) |
| 223 | (time-stamp-should-warn (equal (time-stamp-string "%_S" ref-time) "5")))) | 228 | (time-stamp-should-warn (equal (time-stamp-string "%S" ref-time2) "15")))) |
| 224 | 229 | ||
| 225 | (ert-deftest time-stamp-test-am-pm () | 230 | (ert-deftest time-stamp-test-am-pm () |
| 226 | "Test time-stamp formats for AM and PM strings." | 231 | "Test time-stamp formats for AM and PM strings." |
| 227 | (with-time-stamp-test-env | 232 | (with-time-stamp-test-env |
| 228 | ;; documented | 233 | ;; implemented and documented since 1997 |
| 229 | (should (equal (time-stamp-string "%#p" ref-time) "pm")) | 234 | (should (equal (time-stamp-string "%#p" ref-time) "pm")) |
| 230 | (should (equal (time-stamp-string "%P" ref-time) "PM")) | ||
| 231 | (should (equal (time-stamp-string "%#p" ref-time3) "am")) | 235 | (should (equal (time-stamp-string "%#p" ref-time3) "am")) |
| 236 | (should (equal (time-stamp-string "%P" ref-time) "PM")) | ||
| 232 | (should (equal (time-stamp-string "%P" ref-time3) "AM")) | 237 | (should (equal (time-stamp-string "%P" ref-time3) "AM")) |
| 233 | ;; changing | 238 | ;; warned since 1997, will change |
| 234 | (time-stamp-should-warn (equal (time-stamp-string "%p" ref-time) "pm")))) | 239 | (time-stamp-should-warn (equal (time-stamp-string "%p" ref-time) "pm")) |
| 240 | (time-stamp-should-warn (equal (time-stamp-string "%p" ref-time3) "am")))) | ||
| 235 | 241 | ||
| 236 | (ert-deftest time-stamp-test-day-number-in-week () | 242 | (ert-deftest time-stamp-test-day-number-in-week () |
| 237 | "Test time-stamp formats for day number in week." | 243 | "Test time-stamp formats for day number in week." |
| @@ -243,40 +249,42 @@ Test that each generates a warning." | |||
| 243 | (ert-deftest time-stamp-test-year () | 249 | (ert-deftest time-stamp-test-year () |
| 244 | "Test time-stamp formats for year." | 250 | "Test time-stamp formats for year." |
| 245 | (with-time-stamp-test-env | 251 | (with-time-stamp-test-env |
| 246 | ;; documented | 252 | ;; implemented and documented since 1995 |
| 247 | (should (equal (time-stamp-string "%02y" ref-time) "06")) | 253 | (should (equal (time-stamp-string "%02y" ref-time) "06")) |
| 254 | ;; implemented and documented since 1997 | ||
| 248 | (should (equal (time-stamp-string "%:y" ref-time) "2006")) | 255 | (should (equal (time-stamp-string "%:y" ref-time) "2006")) |
| 249 | ;; undocumented future formats | 256 | ;; implemented since 1997, undocumented future format |
| 250 | (should (equal (time-stamp-string "%Y" ref-time) "2006")) | 257 | (should (equal (time-stamp-string "%Y" ref-time) "2006")) |
| 251 | ;; changing | 258 | ;; warned since 1997, will change |
| 252 | (time-stamp-should-warn (equal (time-stamp-string "%y" ref-time) "2006")))) | 259 | (time-stamp-should-warn (equal (time-stamp-string "%y" ref-time) "2006")))) |
| 253 | 260 | ||
| 254 | (ert-deftest time-stamp-test-time-zone () | 261 | (ert-deftest time-stamp-test-time-zone () |
| 255 | "Test time-stamp formats for time zone." | 262 | "Test time-stamp formats for time zone." |
| 256 | (with-time-stamp-test-env | 263 | (with-time-stamp-test-env |
| 257 | ;; documented | 264 | ;; implemented and documented since 1995 |
| 258 | (should (equal (time-stamp-string "%z" ref-time) "gmt")) | ||
| 259 | (should (equal (time-stamp-string "%Z" ref-time) "GMT")) | 265 | (should (equal (time-stamp-string "%Z" ref-time) "GMT")) |
| 260 | ;; undocumented future formats | 266 | (should (equal (time-stamp-string "%z" ref-time) "gmt")) |
| 267 | ;; implemented since 1997, undocumented future format | ||
| 261 | (should (equal (time-stamp-string "%#Z" ref-time) "gmt")))) | 268 | (should (equal (time-stamp-string "%#Z" ref-time) "gmt")))) |
| 262 | 269 | ||
| 263 | (ert-deftest time-stamp-test-non-date-conversions () | 270 | (ert-deftest time-stamp-test-non-date-conversions () |
| 264 | "Test time-stamp formats for non-date items." | 271 | "Test time-stamp formats for non-date items." |
| 265 | (with-time-stamp-test-env | 272 | (with-time-stamp-test-env |
| 266 | ;; documented | 273 | ;; implemented and documented since 1995 |
| 267 | (should (equal (time-stamp-string "%%" ref-time) "%")) ;% last char | 274 | (should (equal (time-stamp-string "%%" ref-time) "%")) ;% last char |
| 268 | (should (equal (time-stamp-string "%%P" ref-time) "%P")) ;% not last char | 275 | (should (equal (time-stamp-string "%%P" ref-time) "%P")) ;% not last char |
| 269 | (should (equal (time-stamp-string "%f" ref-time) "time-stamped-file")) | 276 | (should (equal (time-stamp-string "%f" ref-time) "time-stamped-file")) |
| 270 | (should (equal | 277 | (should (equal |
| 271 | (time-stamp-string "%F" ref-time) "/emacs/test/time-stamped-file")) | 278 | (time-stamp-string "%F" ref-time) "/emacs/test/time-stamped-file")) |
| 272 | (should | ||
| 273 | (equal (time-stamp-string "%s" ref-time) "test-system-name.example.org")) | ||
| 274 | (should (equal (time-stamp-string "%u" ref-time) "test-logname")) | ||
| 275 | (should (equal (time-stamp-string "%U" ref-time) "Time Stamp Tester")) | ||
| 276 | (should (equal (time-stamp-string "%h" ref-time) "test-mail-host-name")) | 279 | (should (equal (time-stamp-string "%h" ref-time) "test-mail-host-name")) |
| 277 | ;; undocumented | 280 | (should (equal |
| 281 | (time-stamp-string "%s" ref-time) "test-system-name.example.org")) | ||
| 282 | (should (equal (time-stamp-string "%U" ref-time) "Time Stamp Tester")) | ||
| 283 | (should (equal (time-stamp-string "%u" ref-time) "test-logname")) | ||
| 284 | ;; implemented since 2001, undocumented future formats | ||
| 278 | (should (equal (time-stamp-string "%L" ref-time) "Time Stamp Tester")) | 285 | (should (equal (time-stamp-string "%L" ref-time) "Time Stamp Tester")) |
| 279 | (should (equal (time-stamp-string "%l" ref-time) "test-logname")) | 286 | (should (equal (time-stamp-string "%l" ref-time) "test-logname")) |
| 287 | ;; implemented since 2007, undocumented future formats | ||
| 280 | (should (equal | 288 | (should (equal |
| 281 | (time-stamp-string "%Q" ref-time) "test-system-name.example.org")) | 289 | (time-stamp-string "%Q" ref-time) "test-system-name.example.org")) |
| 282 | (should (equal | 290 | (should (equal |
| @@ -306,6 +314,7 @@ Test that each generates a warning." | |||
| 306 | (should (equal (time-stamp-string "%0%" ref-time3) "")) | 314 | (should (equal (time-stamp-string "%0%" ref-time3) "")) |
| 307 | (should (equal (time-stamp-string "%1%" ref-time3) "%")) | 315 | (should (equal (time-stamp-string "%1%" ref-time3) "%")) |
| 308 | (should (equal (time-stamp-string "%2%" ref-time3) " %")) | 316 | (should (equal (time-stamp-string "%2%" ref-time3) " %")) |
| 309 | (should (equal (time-stamp-string "%#3a" ref-time3) "SUN")))) | 317 | (should (equal (time-stamp-string "%#3a" ref-time3) "SUN")) |
| 318 | (should (equal (time-stamp-string "%#3b" ref-time2) "NOV")))) | ||
| 310 | 319 | ||
| 311 | ;;; time-stamp-tests.el ends here | 320 | ;;; time-stamp-tests.el ends here |