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). --- tests/test-calendar-sync--unfold-continuation.el | 53 ++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 tests/test-calendar-sync--unfold-continuation.el (limited to 'tests/test-calendar-sync--unfold-continuation.el') diff --git a/tests/test-calendar-sync--unfold-continuation.el b/tests/test-calendar-sync--unfold-continuation.el new file mode 100644 index 00000000..6c6e1705 --- /dev/null +++ b/tests/test-calendar-sync--unfold-continuation.el @@ -0,0 +1,53 @@ +;;; test-calendar-sync--unfold-continuation.el --- Tests for RFC 5545 line unfolding -*- lexical-binding: t; -*- + +;;; Commentary: +;; Tests for calendar-sync--unfold-continuation. +;; Unfolds RFC 5545 continuation lines (lines starting with space/tab after newline). +;; Returns (unfolded-value . new-position) cons. + +;;; Code: + +(require 'ert) +(require 'testutil-calendar-sync) +(require 'calendar-sync) + +;;; Normal Cases + +(ert-deftest test-calendar-sync--unfold-continuation-normal-single-continuation () + "Single continuation line is appended to value." + ;; Simulate how get-property calls unfold-continuation: match-end is + ;; the position right after the matched value on the first line. + ;; "DESCRIPTION:First part" is 22 chars, so match-end for the value = 22. + ;; The \n at position 22 starts the continuation check. + (let* ((text "DESCRIPTION:First part\n Second part\nNEXT:value")) + ;; Use get-property which exercises unfold-continuation with correct positions + (should (equal "First partSecond part" + (calendar-sync--get-property text "DESCRIPTION"))))) + +(ert-deftest test-calendar-sync--unfold-continuation-normal-multiple-continuations () + "Multiple continuation lines are all appended." + (let* ((text "DESC:Line1\n Line2\n Line3\nNEXT:x")) + (should (equal "Line1Line2Line3" + (calendar-sync--get-property text "DESC"))))) + +;;; Boundary Cases + +(ert-deftest test-calendar-sync--unfold-continuation-boundary-no-continuation () + "No continuation lines returns value unchanged." + (let* ((text "SUMMARY:Test\nDTSTART:20260315")) + (should (equal "Test" (calendar-sync--get-property text "SUMMARY"))))) + +(ert-deftest test-calendar-sync--unfold-continuation-boundary-tab-continuation () + "Tab-indented continuation lines are also unfolded." + (let* ((text "DESC:Start\n\tTabbed\nNEXT:x")) + (should (equal "StartTabbed" (calendar-sync--get-property text "DESC"))))) + +;;; Error Cases + +(ert-deftest test-calendar-sync--unfold-continuation-error-start-at-end () + "Value at end of text with no continuation returns unchanged." + (let* ((text "SUMMARY:Test")) + (should (equal "Test" (calendar-sync--get-property text "SUMMARY"))))) + +(provide 'test-calendar-sync--unfold-continuation) +;;; test-calendar-sync--unfold-continuation.el ends here -- cgit v1.2.3