From f06cf3faa06df7593cff1f81cfbc6f2d6836d6e2 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Wed, 26 Jun 2024 09:56:14 -0500 Subject: [PATCH] Tests: Timestamps with inner time ranges --- tests/data-ts.org | 23 +++++++++++++++++++++++ tests/test-org-ql.el | 21 ++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tests/data-ts.org diff --git a/tests/data-ts.org b/tests/data-ts.org new file mode 100644 index 00000000..01ebd574 --- /dev/null +++ b/tests/data-ts.org @@ -0,0 +1,23 @@ +#+title: Timestamp-specific tests + +/Timestamps in this file are active ones./ + +* Single-timestamp ranges + +** Single-timestamp, without repeater +<2024-06-25 Tue 08:00-09:00> + +** Single-timestamp, with repeater (deadline) +DEADLINE: <2024-06-25 Tue 08:00-09:00 ++7d> + +* Multi-timestamp ranges + +/Not sure that it would make sense to use repeaters for this kind of range./ + +** Multi-timestamp, without repeater +<2024-06-25 Tue 08:00>--<2024-06-26 Wed 08:00> + +* Canary + +/This entry should never be matched./ + diff --git a/tests/test-org-ql.el b/tests/test-org-ql.el index 1259004d..15ec4497 100644 --- a/tests/test-org-ql.el +++ b/tests/test-org-ql.el @@ -1690,7 +1690,26 @@ with keyword arg NOW in PLIST." (org-ql-expect ((org-ql--query-string-to-sexp "ts-active:with-time=")) '("Take over the universe" "Take over the world" "Visit Mars" "Visit the moon" "Practice leaping tall buildings in a single bound" "Get haircut" "Internet" "Spaceship lease" "Fix flux capacitor" "/r/emacs" "Shop for groceries" "Rewrite Emacs in Common Lisp")) (org-ql-expect ((org-ql--query-string-to-sexp "ts-active:with-time=t")) - '("Skype with president of Antarctica" "Renew membership in supervillain club" "Order a pizza")))) + '("Skype with president of Antarctica" "Renew membership in supervillain club" "Order a pizza"))) + + (describe "matches timestamps with inner time ranges" + (before-each + (setq org-ql-test-buffer (org-ql-test-data-buffer "data-ts.org") + org-ql-test-num-headings (with-current-buffer org-ql-test-buffer + (org-with-wide-buffer + (goto-char (point-min)) + ;; Exclude the "Canary" heading. + (1- (cl-loop while (re-search-forward org-heading-regexp nil t) + sum 1)))))) + + (org-ql-it "without specified timestamp" + (org-ql-expect ('(ts-active)) + '("Single-timestamp, without repeater" "Single-timestamp, with repeater (deadline)" "Multi-timestamp, without repeater"))) + (org-ql-it "with specified timestamps" + (org-ql-expect ('(ts-active :on "2024-06-25")) + '("Single-timestamp, without repeater" "Single-timestamp, with repeater (deadline)" "Multi-timestamp, without repeater")) + (org-ql-expect ('(ts-active :on "2024-06-26")) + '("Multi-timestamp, without repeater"))))) (describe "inactive"