1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
;;; test-calendar-sync--unescape-ics-text.el --- Tests for ICS text unescaping -*- lexical-binding: t; -*-
;;; Commentary:
;; Unit tests for calendar-sync--unescape-ics-text function.
;; RFC 5545 defines escape sequences: \n→newline, \,→comma, \\→backslash, \;→semicolon.
;; Covers Normal, Boundary, and Error cases.
;;; Code:
(require 'ert)
(require 'testutil-calendar-sync)
(require 'calendar-sync)
;;; Normal Cases
(ert-deftest test-calendar-sync--unescape-ics-text-normal-newline ()
"Test \\n escape is converted to actual newline."
(should (string= "line1\nline2"
(calendar-sync--unescape-ics-text "line1\\nline2"))))
(ert-deftest test-calendar-sync--unescape-ics-text-normal-comma ()
"Test \\, escape is converted to comma."
(should (string= "one, two"
(calendar-sync--unescape-ics-text "one\\, two"))))
(ert-deftest test-calendar-sync--unescape-ics-text-normal-backslash ()
"Test \\\\ escape is converted to single backslash."
(should (string= "path\\file"
(calendar-sync--unescape-ics-text "path\\\\file"))))
(ert-deftest test-calendar-sync--unescape-ics-text-normal-semicolon ()
"Test \\; escape is converted to semicolon."
(should (string= "a;b"
(calendar-sync--unescape-ics-text "a\\;b"))))
(ert-deftest test-calendar-sync--unescape-ics-text-normal-mixed ()
"Test multiple different escapes in one string."
(should (string= "Hello, World\nPath\\to;file"
(calendar-sync--unescape-ics-text "Hello\\, World\\nPath\\\\to\\;file"))))
;;; Boundary Cases
(ert-deftest test-calendar-sync--unescape-ics-text-boundary-empty-string ()
"Test empty string returns empty string."
(should (string= "" (calendar-sync--unescape-ics-text ""))))
(ert-deftest test-calendar-sync--unescape-ics-text-boundary-no-escapes ()
"Test string with no escapes passes through unchanged."
(should (string= "plain text"
(calendar-sync--unescape-ics-text "plain text"))))
(ert-deftest test-calendar-sync--unescape-ics-text-boundary-escape-at-start ()
"Test escape sequence at string start."
(should (string= "\nfoo"
(calendar-sync--unescape-ics-text "\\nfoo"))))
(ert-deftest test-calendar-sync--unescape-ics-text-boundary-escape-at-end ()
"Test escape sequence at string end."
(should (string= "foo\n"
(calendar-sync--unescape-ics-text "foo\\n"))))
(ert-deftest test-calendar-sync--unescape-ics-text-boundary-consecutive-escapes ()
"Test consecutive escape sequences."
(should (string= "\n\n"
(calendar-sync--unescape-ics-text "\\n\\n"))))
(ert-deftest test-calendar-sync--unescape-ics-text-boundary-only-escapes ()
"Test string composed entirely of escapes."
(should (string= ",;\n\\"
(calendar-sync--unescape-ics-text "\\,\\;\\n\\\\"))))
;;; Error Cases
(ert-deftest test-calendar-sync--unescape-ics-text-error-nil-input ()
"Test nil input returns nil."
(should (null (calendar-sync--unescape-ics-text nil))))
(provide 'test-calendar-sync--unescape-ics-text)
;;; test-calendar-sync--unescape-ics-text.el ends here
|