summaryrefslogtreecommitdiff
path: root/tests/test-calendar-sync--extract-cn.el
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-calendar-sync--extract-cn.el')
-rw-r--r--tests/test-calendar-sync--extract-cn.el48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/test-calendar-sync--extract-cn.el b/tests/test-calendar-sync--extract-cn.el
new file mode 100644
index 00000000..0cb8f80c
--- /dev/null
+++ b/tests/test-calendar-sync--extract-cn.el
@@ -0,0 +1,48 @@
+;;; test-calendar-sync--extract-cn.el --- Tests for CN parameter extraction -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; Tests for calendar-sync--extract-cn.
+;; Extracts and dequotes the CN= parameter from iCal property lines.
+
+;;; Code:
+
+(require 'ert)
+(require 'testutil-calendar-sync)
+(require 'calendar-sync)
+
+;;; Normal Cases
+
+(ert-deftest test-calendar-sync--extract-cn-normal-unquoted ()
+ "Extracts unquoted CN value."
+ (should (equal "Craig Jennings"
+ (calendar-sync--extract-cn
+ "ATTENDEE;CN=Craig Jennings;PARTSTAT=ACCEPTED:mailto:c@test.com"))))
+
+(ert-deftest test-calendar-sync--extract-cn-normal-quoted ()
+ "Strips surrounding quotes from CN value."
+ (should (equal "Craig Jennings"
+ (calendar-sync--extract-cn
+ "ATTENDEE;CN=\"Craig Jennings\";PARTSTAT=ACCEPTED:mailto:c@test.com"))))
+
+;;; Boundary Cases
+
+(ert-deftest test-calendar-sync--extract-cn-boundary-cn-at-end ()
+ "CN as last parameter before colon."
+ (should (equal "Bob"
+ (calendar-sync--extract-cn "ORGANIZER;CN=Bob:mailto:bob@test.com"))))
+
+(ert-deftest test-calendar-sync--extract-cn-boundary-special-chars ()
+ "CN with accented characters."
+ (should (equal "José García"
+ (calendar-sync--extract-cn
+ "ATTENDEE;CN=José García;PARTSTAT=ACCEPTED:mailto:j@test.com"))))
+
+;;; Error Cases
+
+(ert-deftest test-calendar-sync--extract-cn-error-no-cn ()
+ "Line without CN= returns nil."
+ (should (null (calendar-sync--extract-cn
+ "ATTENDEE;PARTSTAT=ACCEPTED:mailto:c@test.com"))))
+
+(provide 'test-calendar-sync--extract-cn)
+;;; test-calendar-sync--extract-cn.el ends here