From 4fa136a0f8bfde7852655a9fce2c44422bd32b3a Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 5 Apr 2026 07:04:37 -0500 Subject: test(calendar-sync): add 32 tests for recurrence exceptions, helpers, unfolding Cover occurrence-matches-exception-p (6), apply-single-exception (6), exdate-matches-p (6), extract-cn (5), extract-email (4), unfold-continuation (5). --- ...alendar-sync--occurrence-matches-exception-p.el | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tests/test-calendar-sync--occurrence-matches-exception-p.el (limited to 'tests/test-calendar-sync--occurrence-matches-exception-p.el') diff --git a/tests/test-calendar-sync--occurrence-matches-exception-p.el b/tests/test-calendar-sync--occurrence-matches-exception-p.el new file mode 100644 index 00000000..416dbb26 --- /dev/null +++ b/tests/test-calendar-sync--occurrence-matches-exception-p.el @@ -0,0 +1,56 @@ +;;; test-calendar-sync--occurrence-matches-exception-p.el --- Tests for occurrence-exception matching -*- lexical-binding: t; -*- + +;;; Commentary: +;; Tests for calendar-sync--occurrence-matches-exception-p. +;; Compares occurrence :start against exception :recurrence-id on year/month/day/hour/minute. + +;;; Code: + +(require 'ert) +(require 'testutil-calendar-sync) +(require 'calendar-sync) + +;;; Normal Cases + +(ert-deftest test-calendar-sync--occurrence-matches-exception-p-normal-exact-match () + "Identical datetime in occurrence and exception returns t." + (let ((occ (list :start '(2026 3 15 14 0))) + (exc (list :recurrence-id '(2026 3 15 14 0)))) + (should (calendar-sync--occurrence-matches-exception-p occ exc)))) + +(ert-deftest test-calendar-sync--occurrence-matches-exception-p-normal-no-match () + "Different dates return nil." + (let ((occ (list :start '(2026 3 15 14 0))) + (exc (list :recurrence-id '(2026 3 16 14 0)))) + (should-not (calendar-sync--occurrence-matches-exception-p occ exc)))) + +(ert-deftest test-calendar-sync--occurrence-matches-exception-p-normal-all-day () + "All-day events (nil hour/minute) match when dates are equal." + (let ((occ (list :start '(2026 3 15 nil nil))) + (exc (list :recurrence-id '(2026 3 15 nil nil)))) + (should (calendar-sync--occurrence-matches-exception-p occ exc)))) + +;;; Boundary Cases + +(ert-deftest test-calendar-sync--occurrence-matches-exception-p-boundary-different-time () + "Same date but different hour returns nil." + (let ((occ (list :start '(2026 3 15 14 0))) + (exc (list :recurrence-id '(2026 3 15 15 0)))) + (should-not (calendar-sync--occurrence-matches-exception-p occ exc)))) + +(ert-deftest test-calendar-sync--occurrence-matches-exception-p-boundary-nil-minute-vs-zero () + "Nil minute treated as 0 for comparison." + (let ((occ (list :start '(2026 3 15 14 nil))) + (exc (list :recurrence-id '(2026 3 15 14 0)))) + (should (calendar-sync--occurrence-matches-exception-p occ exc)))) + +;;; Error Cases + +(ert-deftest test-calendar-sync--occurrence-matches-exception-p-error-nil-start () + "Nil :start returns nil." + (let ((occ (list :summary "No start")) + (exc (list :recurrence-id '(2026 3 15 14 0)))) + (should-not (calendar-sync--occurrence-matches-exception-p occ exc)))) + +(provide 'test-calendar-sync--occurrence-matches-exception-p) +;;; test-calendar-sync--occurrence-matches-exception-p.el ends here -- cgit v1.2.3