Ver Fonte

org-macs: Add basic tests for org-matcher-time

* testing/lisp/test-org-macs.el (test-org-matcher-time): Add tests.

This includes of a test for the missing hour modifier added in the
previous commit.
Kyle Meyer há 4 anos atrás
pai
commit
b99beaad18
1 ficheiros alterados com 29 adições e 0 exclusões
  1. 29 0
      testing/lisp/test-org-macs.el

+ 29 - 0
testing/lisp/test-org-macs.el

@@ -103,5 +103,34 @@
    (org-test-with-temp-text "xx abc<point> xx"
      (org-in-regexp "abc" nil t))))
 
+
+;;; Time
+
+(ert-deftest test-org-matcher-time ()
+  "Test `org-matcher-time'."
+  (let ((system-time-locale "en_US"))
+    (org-test-at-time "<2021-01-11 Mon 13:00>"
+      (should (equal (list 0 0 13 11 1 2021)
+                     (butlast (org-decode-time (org-matcher-time "<now>"))
+                              3)))
+      (should (equal (list 0 0 0 14 1 2021)
+                     (butlast (org-decode-time (org-matcher-time "<+3d>"))
+                              3)))
+      (should (equal (list 0 0 0 9 1 2021)
+                     (butlast (org-decode-time (org-matcher-time "<-2d>"))
+                              3)))
+      (should (equal (list 0 0 0 18 1 2021)
+                     (butlast (org-decode-time (org-matcher-time "<+1w>"))
+                              3)))
+      (should (equal (list 0 0 17 11 1 2021)
+                     (butlast (org-decode-time (org-matcher-time "<+4h>"))
+                              3)))
+      (should (equal (list 0 0 11 11 1 2021)
+                     (butlast (org-decode-time (org-matcher-time "<-2h>"))
+                              3)))
+      (should (equal (list 0 0 3 12 1 2021)
+                     (butlast (org-decode-time (org-matcher-time "<+14h>"))
+                              3))))))
+
 (provide 'test-org-macs)
 ;;; test-org-macs.el ends here