aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Jasper2011-02-20 15:35:58 +0100
committerUlf Jasper2011-02-20 15:35:58 +0100
commit4856384c16c050ccb57e989623853e1d1216d73d (patch)
tree0fd0fdbc321c1a1131a5cc668db41c875f553081
parent652db9c00995ca0adba35d5740ef61b651c98763 (diff)
downloademacs-4856384c16c050ccb57e989623853e1d1216d73d.tar.gz
emacs-4856384c16c050ccb57e989623853e1d1216d73d.zip
Convert test/icalendar-testsuite.el to ERT format.
* automated/icalendar-tests.el: Move from icalendar-testsuite.el; convert to ERT format.
-rw-r--r--test/ChangeLog5
-rw-r--r--test/automated/icalendar-tests.el (renamed from test/icalendar-testsuite.el)1449
2 files changed, 709 insertions, 745 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index 8c7cd6f5b13..dbfc6c6cefe 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
12011-02-20 Ulf Jasper <ulf.jasper@web.de>
2
3 * automated/icalendar-tests.el: Move from icalendar-testsuite.el;
4 convert to ERT format.
5
12011-02-14 Chong Yidong <cyd@stupidchicken.com> 62011-02-14 Chong Yidong <cyd@stupidchicken.com>
2 7
3 * automated/bytecomp-tests.el: Move from bytecomp-testsuite.el; 8 * automated/bytecomp-tests.el: Move from bytecomp-testsuite.el;
diff --git a/test/icalendar-testsuite.el b/test/automated/icalendar-tests.el
index 5a6bec30dca..d586230f642 100644
--- a/test/icalendar-testsuite.el
+++ b/test/automated/icalendar-tests.el
@@ -1,4 +1,4 @@
1;; icalendar-testsuite.el --- Test suite for icalendar.el 1;; icalendar-tests.el --- Test suite for icalendar.el
2 2
3;; Copyright (C) 2005, 2008-2011 Free Software Foundation, Inc. 3;; Copyright (C) 2005, 2008-2011 Free Software Foundation, Inc.
4 4
@@ -30,31 +30,33 @@
30;; Note: Watch the trailing blank that is added on import. 30;; Note: Watch the trailing blank that is added on import.
31 31
32;;; Code: 32;;; Code:
33(defun icalendar-testsuite-run () 33
34 "Run icalendar test suite." 34(require 'ert)
35 (interactive) 35(require 'icalendar)
36 (icalendar-testsuite--run-internal-tests)
37 (icalendar-testsuite--run-function-tests)
38 (icalendar-testsuite--run-import-tests)
39 (icalendar-testsuite--run-export-tests)
40 (icalendar-testsuite--run-cycle-tests)
41 (icalendar-testsuite--run-real-world-tests)
42 (message "All icalendar tests finished successfully."))
43 36
44;; ====================================================================== 37;; ======================================================================
45;; internal 38;; Helpers
46;; ====================================================================== 39;; ======================================================================
47(defun icalendar-testsuite--trim (string) 40
41(defun icalendar-tests--get-ical-event (ical-string)
42 "Return icalendar event for ICAL-STRING."
43 (save-excursion
44 (with-temp-buffer
45 (insert ical-string)
46 (goto-char (point-min))
47 (car (icalendar--read-element nil nil)))))
48
49(defun icalendar-tests--trim (string)
48 "Remove leading and trailing whitespace from STRING." 50 "Remove leading and trailing whitespace from STRING."
49 (replace-regexp-in-string "[ \t\n]+\\'" "" 51 (replace-regexp-in-string "[ \t\n]+\\'" ""
50 (replace-regexp-in-string "\\`[ \t\n]+" "" string))) 52 (replace-regexp-in-string "\\`[ \t\n]+" "" string)))
51 53
52(defun icalendar-testsuite--compare-strings (str1 str2) 54(defun icalendar-tests--compare-strings (str1 str2)
53 "Compare strings STR1 and STR2. 55 "Compare strings STR1 and STR2.
54Return t if strings are equal, else return substring indicating first difference. 56Return t if strings are equal, else return substring indicating first difference.
55FIXME: make this a little smarter." 57FIXME: make this a little smarter."
56 (let* ((s1 (icalendar-testsuite--trim str1)) 58 (let* ((s1 (icalendar-tests--trim str1))
57 (s2 (icalendar-testsuite--trim str2)) 59 (s2 (icalendar-tests--trim str2))
58 (result (compare-strings s1 0 nil s2 0 nil)) 60 (result (compare-strings s1 0 nil s2 0 nil))
59 (len (length str2))) 61 (len (length str2)))
60 (if (numberp result) 62 (if (numberp result)
@@ -65,369 +67,135 @@ FIXME: make this a little smarter."
65 (min len (+ (- (+ result 1)) 3))) "...")) 67 (min len (+ (- (+ result 1)) 3))) "..."))
66 t))) 68 t)))
67 69
68(defun icalendar-testsuite--run-internal-tests () 70(ert-deftest icalendar-tests--compare-strings ()
69 "Run icalendar-testsuite internal tests." 71 "Test icalendar-tests--compare-strings."
70 (assert (equal t (icalendar-testsuite--compare-strings " abcde" "abcde "))) 72 (should (equal t (icalendar-tests--compare-strings " abcde" "abcde ")))
71 (assert 73 (should
72 (string= "...def..." 74 (string= "...def..."
73 (icalendar-testsuite--compare-strings "abcxe" "abcdefghijklmn"))) 75 (icalendar-tests--compare-strings "abcxe" "abcdefghijklmn")))
74 (assert (string= "...xe..." 76 (should (string= "...xe..."
75 (icalendar-testsuite--compare-strings "abcde" "abcxe"))) 77 (icalendar-tests--compare-strings "abcde" "abcxe")))
76 (assert (string= "...ddd..." 78 (should (string= "...ddd..."
77 (icalendar-testsuite--compare-strings "abc" "abcdddddd"))) 79 (icalendar-tests--compare-strings "abc" "abcdddddd")))
78 (assert (string= "......" 80 (should (string= "......"
79 (icalendar-testsuite--compare-strings "abcdefghij" "abc")))) 81 (icalendar-tests--compare-strings "abcdefghij" "abc"))))
80
81 82
82;; ====================================================================== 83;; ======================================================================
83;; Test methods for functions 84;; Tests of functions
84;; ====================================================================== 85;; ======================================================================
85(defun icalendar-testsuite--run-function-tests ()
86 "Perform tests for single icalendar functions."
87 (icalendar-testsuite--test-parse-summary-and-rest)
88 (icalendar-testsuite--test-format-ical-event)
89 (icalendar-testsuite--test-import-format-sample)
90 (icalendar-testsuite--test-first-weekday-of-year)
91 (icalendar-testsuite--test-datestring-to-isodate)
92 (icalendar-testsuite--test-datetime-to-diary-date)
93 (icalendar-testsuite--test-diarytime-to-isotime)
94 (icalendar-testsuite--test-convert-ordinary-to-ical)
95 (icalendar-testsuite--test-convert-weekly-to-ical)
96 (icalendar-testsuite--test-convert-yearly-to-ical)
97 (icalendar-testsuite--test-convert-block-to-ical)
98 (icalendar-testsuite--test-convert-cyclic-to-ical)
99 (icalendar-testsuite--test-convert-anniversary-to-ical)
100 (icalendar-testsuite--test-calendar-style)
101 (icalendar-testsuite--test-create-uid)
102 (icalendar-testsuite--test-parse-vtimezone))
103
104(defun icalendar-testsuite--test-format-ical-event ()
105 "Test `icalendar--format-ical-event'."
106 (let ((icalendar-import-format "%s%d%l%o%t%u%c")
107 (icalendar-import-format-summary "SUM %s")
108 (icalendar-import-format-location " LOC %s")
109 (icalendar-import-format-description " DES %s")
110 (icalendar-import-format-organizer " ORG %s")
111 (icalendar-import-format-status " STA %s")
112 (icalendar-import-format-url " URL %s")
113 (icalendar-import-format-class " CLA %s")
114 (event (icalendar-testsuite--get-ical-event "BEGIN:VEVENT
115DTSTAMP:20030509T043439Z
116DTSTART:20030509T103000
117SUMMARY:sum
118ORGANIZER:org
119LOCATION:loc
120DTEND:20030509T153000
121DESCRIPTION:des
122END:VEVENT
123")))
124 (assert (string= (icalendar--format-ical-event event)
125 "SUM sum DES des LOC loc ORG org") t)
126 (setq icalendar-import-format (lambda (&rest ignore)
127 "helloworld"))
128 (assert (string= (icalendar--format-ical-event event)
129 "helloworld") t)
130 (setq icalendar-import-format
131 (lambda (e)
132 (format "-%s-%s-%s-%s-%s-%s-%s-"
133 (icalendar--get-event-property event 'SUMMARY)
134 (icalendar--get-event-property event 'DESCRIPTION)
135 (icalendar--get-event-property event 'LOCATION)
136 (icalendar--get-event-property event 'ORGANIZER)
137 (icalendar--get-event-property event 'STATUS)
138 (icalendar--get-event-property event 'URL)
139 (icalendar--get-event-property event 'CLASS))))
140 (assert (string= (icalendar--format-ical-event event)
141 "-sum-des-loc-org-nil-nil-nil-") t)))
142 86
143(defun icalendar-testsuite--test-parse-summary-and-rest () 87(ert-deftest icalendar--create-uid ()
144 "Test `icalendar--parse-summary-and-rest'." 88 "Test for `icalendar--create-uid'."
145 (let ((icalendar-import-format "%s%d%l%o%t%u%c") 89 (let* ((icalendar-uid-format "xxx-%t-%c-%h-%u-%s")
146 (icalendar-import-format-summary "SUM %s") 90 t-ct
147 (icalendar-import-format-location " LOC %s") 91 (icalendar--uid-count 77)
148 (icalendar-import-format-description " DES %s") 92 (entry-full "30.06.1964 07:01 blahblah")
149 (icalendar-import-format-organizer " ORG %s") 93 (hash (format "%d" (abs (sxhash entry-full))))
150 (icalendar-import-format-status " STA %s") 94 (contents "DTSTART:19640630T070100\nblahblah")
151 (icalendar-import-format-url " URL %s") 95 (username (or user-login-name "UNKNOWN_USER"))
152 (icalendar-import-format-class " CLA %s") 96 )
153 (result)) 97 (fset 't-ct (symbol-function 'current-time))
154 (setq result (icalendar--parse-summary-and-rest "SUM sum ORG org")) 98 (unwind-protect
155 (assert (string= (cdr (assoc 'org result)) "org")) 99 (progn
156 100 (fset 'current-time (lambda () '(1 2 3)))
157 (setq result (icalendar--parse-summary-and-rest 101 (should (= 77 icalendar--uid-count))
158 "SUM sum DES des LOC loc ORG org STA sta URL url CLA cla")) 102 (should (string= (concat "xxx-123-77-" hash "-" username "-19640630")
159 (assert (string= (cdr (assoc 'des result)) "des")) 103 (icalendar--create-uid entry-full contents)))
160 (assert (string= (cdr (assoc 'loc result)) "loc")) 104 (should (= 78 icalendar--uid-count)))
161 (assert (string= (cdr (assoc 'org result)) "org")) 105 ;; restore 'current-time
162 (assert (string= (cdr (assoc 'sta result)) "sta")) 106 (fset 'current-time (symbol-function 't-ct)))
163 (assert (string= (cdr (assoc 'cla result)) "cla")) 107 (setq contents "blahblah")
164 108 (setq icalendar-uid-format "yyy%syyy")
165 (setq icalendar-import-format (lambda () "Hello world")) 109 (should (string= (concat "yyyDTSTARTyyy")
166 (setq result (icalendar--parse-summary-and-rest 110 (icalendar--create-uid entry-full contents)))))
167 "blah blah "))
168 (assert (not result))
169 ))
170
171(defun icalendar-testsuite--get-ical-event (ical-string)
172 "Helper function for testing `icalendar-testsuite--test-format-ical-event'.
173Return icalendar event for ICAL-STRING."
174 (save-excursion
175 (with-temp-buffer
176 (insert ical-string)
177 (goto-char (point-min))
178 (car (icalendar--read-element nil nil)))))
179
180(defun icalendar-testsuite--test-import-format-sample ()
181 "Test method for `icalendar-import-format-sample'."
182 (assert (string= (icalendar-import-format-sample
183 (icalendar-testsuite--get-ical-event "BEGIN:VEVENT
184DTSTAMP:20030509T043439Z
185DTSTART:20030509T103000
186SUMMARY:a
187ORGANIZER:d
188LOCATION:c
189DTEND:20030509T153000
190DESCRIPTION:b
191END:VEVENT
192"))
193 (concat "SUMMARY=`a' DESCRIPTION=`b' LOCATION=`c' "
194 "ORGANIZER=`d' STATUS=`' URL=`' CLASS=`'"))))
195
196(defun icalendar-testsuite--test-first-weekday-of-year ()
197 "Test method for `icalendar-first-weekday-of-year'."
198 (assert (eq 1 (icalendar-first-weekday-of-year "TU" 2008)))
199 (assert (eq 3 (icalendar-first-weekday-of-year "WE" 2007)))
200 (assert (eq 5 (icalendar-first-weekday-of-year "TH" 2006)))
201 (assert (eq 7 (icalendar-first-weekday-of-year "FR" 2005)))
202 (assert (eq 3 (icalendar-first-weekday-of-year "SA" 2004)))
203 (assert (eq 5 (icalendar-first-weekday-of-year "SU" 2003)))
204 (assert (eq 7 (icalendar-first-weekday-of-year "MO" 2002)))
205 (assert (eq 3 (icalendar-first-weekday-of-year "MO" 2000)))
206 (assert (eq 1 (icalendar-first-weekday-of-year "TH" 1970))))
207
208(defun icalendar-testsuite--test-datestring-to-isodate ()
209 "Test method for `icalendar--datestring-to-isodate'."
210 (let ((calendar-date-style 'iso))
211 ;; numeric iso
212 (assert (string= (icalendar--datestring-to-isodate "2008 05 11")
213 "20080511"))
214 (assert (string= (icalendar--datestring-to-isodate "2008 05 31")
215 "20080531"))
216 (assert (string= (icalendar--datestring-to-isodate "2008 05 31" 2)
217 "20080602"))
218
219 ;; numeric european
220 (setq calendar-date-style 'european)
221 (assert (string= (icalendar--datestring-to-isodate "11 05 2008")
222 "20080511"))
223 (assert (string= (icalendar--datestring-to-isodate "31 05 2008")
224 "20080531"))
225 (assert (string= (icalendar--datestring-to-isodate "31 05 2008" 2)
226 "20080602"))
227
228 ;; numeric american
229 (setq calendar-date-style 'american)
230 (assert (string= (icalendar--datestring-to-isodate "11 05 2008")
231 "20081105"))
232 (assert (string= (icalendar--datestring-to-isodate "12 30 2008")
233 "20081230"))
234 (assert (string= (icalendar--datestring-to-isodate "12 30 2008" 2)
235 "20090101"))
236
237 ;; non-numeric
238 (setq calendar-date-style nil) ;not necessary for conversion
239 (assert (string= (icalendar--datestring-to-isodate "Nov 05 2008")
240 "20081105"))
241 (assert (string= (icalendar--datestring-to-isodate "05 Nov 2008")
242 "20081105"))
243 (assert (string= (icalendar--datestring-to-isodate "2008 Nov 05")
244 "20081105"))))
245
246(defun icalendar-testsuite--test-datetime-to-diary-date ()
247 "Test method for `icalendar--datetime-to-diary-date'."
248 (let* ((datetime '(59 59 23 31 12 2008))
249 (calendar-date-style 'iso))
250 (assert (string= (icalendar--datetime-to-diary-date datetime)
251 "2008 12 31"))
252 (setq calendar-date-style 'european)
253 (assert (string= (icalendar--datetime-to-diary-date datetime)
254 "31 12 2008"))
255 (setq calendar-date-style 'american)
256 (assert (string= (icalendar--datetime-to-diary-date datetime)
257 "12 31 2008"))))
258 111
259(defun icalendar-testsuite--test-diarytime-to-isotime () 112(ert-deftest icalendar--calendar-style ()
260 "Test method for `icalendar--diarytime-to-isotime'." 113 "Test for `icalendar--date-style'."
261 (assert (string= (icalendar--diarytime-to-isotime "01:15" "") 114 (dolist (calendar-date-style '(iso american european))
262 "T011500")) 115 (should (eq (icalendar--date-style) calendar-date-style)))
263 (assert (string= (icalendar--diarytime-to-isotime "1:15" "") 116 (let ((cds calendar-date-style)
264 "T011500")) 117 (european-calendar-style t))
265 (assert (string= (icalendar--diarytime-to-isotime "0:01" "") 118 (makunbound 'calendar-date-style)
266 "T000100")) 119 (should (eq (icalendar--date-style) 'european))
267 (assert (string= (icalendar--diarytime-to-isotime "0100" "") 120 (with-no-warnings (setq european-calendar-style nil)) ;still get warning!?! FIXME
268 "T010000")) 121 (should (eq (icalendar--date-style) 'american))
269 (assert (string= (icalendar--diarytime-to-isotime "0100" "am") 122 (setq calendar-date-style cds)))
270 "T010000"))
271 (assert (string= (icalendar--diarytime-to-isotime "0100" "pm")
272 "T130000"))
273 (assert (string= (icalendar--diarytime-to-isotime "1200" "")
274 "T120000"))
275 (assert (string= (icalendar--diarytime-to-isotime "17:17" "")
276 "T171700"))
277 (assert (string= (icalendar--diarytime-to-isotime "1200" "am")
278 "T000000"))
279 (assert (string= (icalendar--diarytime-to-isotime "1201" "am")
280 "T000100"))
281 (assert (string= (icalendar--diarytime-to-isotime "1259" "am")
282 "T005900"))
283 (assert (string= (icalendar--diarytime-to-isotime "1200" "pm")
284 "T120000"))
285 (assert (string= (icalendar--diarytime-to-isotime "1201" "pm")
286 "T120100"))
287 (assert (string= (icalendar--diarytime-to-isotime "1259" "pm")
288 "T125900")))
289 123
290(defun icalendar-testsuite--test-convert-ordinary-to-ical () 124(ert-deftest icalendar-convert-anniversary-to-ical ()
291 "Test method for `icalendar--convert-ordinary-to-ical'." 125 "Test method for `icalendar--convert-anniversary-to-ical'."
292 (let* ((calendar-date-style 'iso) 126 (let* ((calendar-date-style 'iso)
293 result) 127 result)
294 ;; without time 128 (setq result (icalendar--convert-anniversary-to-ical
295 (setq result (icalendar--convert-ordinary-to-ical "&?" "2010 2 15 subject")) 129 "" "%%(diary-anniversary 1964 6 30) g"))
296 (assert (= 2 (length result))) 130 (should (= 2 (length result)))
297 (assert (string= "\nDTSTART;VALUE=DATE:20100215\nDTEND;VALUE=DATE:20100216" 131 (should (string= (concat
298 (car result))) 132 "\nDTSTART;VALUE=DATE:19640630"
299 (assert (string= "subject" (cadr result))) 133 "\nDTEND;VALUE=DATE:19640701"
300 134 "\nRRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=06;BYMONTHDAY=30")
301 ;; with time
302 (setq result (icalendar--convert-ordinary-to-ical
303 "&?" "&2010 2 15 12:34-23:45 s"))
304 (assert (= 2 (length result)))
305 (assert (string= (concat "\nDTSTART;VALUE=DATE-TIME:20100215T123400"
306 "\nDTEND;VALUE=DATE-TIME:20100215T234500")
307 (car result)))
308 (assert (string= "s" (cadr result)))
309
310 ;; with time, again -- test bug#5549
311 (setq result (icalendar--convert-ordinary-to-ical
312 "x?" "x2010 2 15 0:34-1:45 s"))
313 (assert (= 2 (length result)))
314 (assert (string= (concat "\nDTSTART;VALUE=DATE-TIME:20100215T003400"
315 "\nDTEND;VALUE=DATE-TIME:20100215T014500")
316 (car result)))
317 (assert (string= "s" (cadr result)))))
318
319(defun icalendar-testsuite--test-convert-weekly-to-ical ()
320 "Test method for `icalendar--convert-weekly-to-ical'."
321 (let* ((calendar-date-style 'iso)
322 result
323 (calendar-day-name-array
324 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday"
325 "Saturday"]))
326 (setq result (icalendar--convert-weekly-to-ical "" "Monday 8:30 subject"))
327 (assert (= 2 (length result)))
328 (assert (string= (concat "\nDTSTART;VALUE=DATE-TIME:20050103T083000"
329 "\nDTEND;VALUE=DATE-TIME:20050103T093000"
330 "\nRRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO")
331 (car result)))
332 (assert (string= "subject" (cadr result)))))
333
334(defun icalendar-testsuite--test-convert-yearly-to-ical ()
335 "Test method for `icalendar--convert-yearly-to-ical'."
336 (let* ((calendar-date-style 'iso)
337 result
338 (calendar-month-name-array
339 ["January" "February" "March" "April" "May" "June" "July" "August"
340 "September" "October" "November" "December"]))
341 (setq result (icalendar--convert-yearly-to-ical "" "May 1 Tag der Arbeit"))
342 (assert (= 2 (length result)))
343 (assert (string= (concat
344 "\nDTSTART;VALUE=DATE:19000501"
345 "\nDTEND;VALUE=DATE:19000502"
346 "\nRRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=5;BYMONTHDAY=1")
347 (car result))) 135 (car result)))
348 (assert (string= "Tag der Arbeit" (cadr result))))) 136 (should (string= "g" (cadr result)))))
349 137
350(defun icalendar-testsuite--test-convert-block-to-ical () 138(ert-deftest icalendar--convert-cyclic-to-ical ()
351 "Test method for `icalendar--convert-block-to-ical'." 139 "Test method for `icalendar--convert-cyclic-to-ical'."
352 (let* ((calendar-date-style 'iso) 140 (let* ((calendar-date-style 'iso)
353 result) 141 result)
354 (setq result (icalendar--convert-block-to-ical 142 (setq result (icalendar--convert-block-to-ical
355 "" "%%(diary-block 2004 7 19 2004 8 27) Sommerferien")) 143 "" "%%(diary-block 2004 7 19 2004 8 27) Sommerferien"))
356 (assert (= 2 (length result))) 144 (should (= 2 (length result)))
357 (assert (string= (concat 145 (should (string= (concat
358 "\nDTSTART;VALUE=DATE:20040719" 146 "\nDTSTART;VALUE=DATE:20040719"
359 "\nDTEND;VALUE=DATE:20040828") 147 "\nDTEND;VALUE=DATE:20040828")
360 (car result))) 148 (car result)))
361 (assert (string= "Sommerferien" (cadr result))))) 149 (should (string= "Sommerferien" (cadr result)))))
362 150
363(defun icalendar-testsuite--test-convert-cyclic-to-ical () 151(ert-deftest icalendar--convert-block-to-ical ()
364 "Test method for `icalendar--convert-cyclic-to-ical'." 152 "Test method for `icalendar--convert-block-to-ical'."
365 (let* ((calendar-date-style 'iso) 153 (let* ((calendar-date-style 'iso)
366 result) 154 result)
367 (setq result (icalendar--convert-block-to-ical 155 (setq result (icalendar--convert-block-to-ical
368 "" "%%(diary-block 2004 7 19 2004 8 27) Sommerferien")) 156 "" "%%(diary-block 2004 7 19 2004 8 27) Sommerferien"))
369 (assert (= 2 (length result))) 157 (should (= 2 (length result)))
370 (assert (string= (concat 158 (should (string= (concat
371 "\nDTSTART;VALUE=DATE:20040719" 159 "\nDTSTART;VALUE=DATE:20040719"
372 "\nDTEND;VALUE=DATE:20040828") 160 "\nDTEND;VALUE=DATE:20040828")
373 (car result))) 161 (car result)))
374 (assert (string= "Sommerferien" (cadr result))))) 162 (should (string= "Sommerferien" (cadr result)))))
375 163
376(defun icalendar-testsuite--test-convert-anniversary-to-ical () 164(ert-deftest icalendar--convert-yearly-to-ical ()
377 "Test method for `icalendar--convert-anniversary-to-ical'." 165 "Test method for `icalendar--convert-yearly-to-ical'."
378 (let* ((calendar-date-style 'iso) 166 (let* ((calendar-date-style 'iso)
379 result) 167 result
380 (setq result (icalendar--convert-anniversary-to-ical 168 (calendar-month-name-array
381 "" "%%(diary-anniversary 1964 6 30) g")) 169 ["January" "February" "March" "April" "May" "June" "July" "August"
382 (assert (= 2 (length result))) 170 "September" "October" "November" "December"]))
383 (assert (string= (concat 171 (setq result (icalendar--convert-yearly-to-ical "" "May 1 Tag der Arbeit"))
384 "\nDTSTART;VALUE=DATE:19640630" 172 (should (= 2 (length result)))
385 "\nDTEND;VALUE=DATE:19640701" 173 (should (string= (concat
386 "\nRRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=06;BYMONTHDAY=30") 174 "\nDTSTART;VALUE=DATE:19000501"
175 "\nDTEND;VALUE=DATE:19000502"
176 "\nRRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=5;BYMONTHDAY=1")
387 (car result))) 177 (car result)))
388 (assert (string= "g" (cadr result))))) 178 (should (string= "Tag der Arbeit" (cadr result)))))
389 179
390(defun icalendar-testsuite--test-calendar-style () 180(ert-deftest icalendar--convert-weekly-to-ical ()
391 "Test method for `icalendar--date-style'." 181 "Test method for `icalendar--convert-weekly-to-ical'."
392 (dolist (calendar-date-style '(iso american european)) 182 (let* ((calendar-date-style 'iso)
393 (assert (eq (icalendar--date-style) calendar-date-style))) 183 result
394 (let ((cds calendar-date-style) 184 (calendar-day-name-array
395 (european-calendar-style t)) 185 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday"
396 (makunbound 'calendar-date-style) 186 "Saturday"]))
397 (assert (eq (icalendar--date-style) 'european)) 187 (setq result (icalendar--convert-weekly-to-ical "" "Monday 8:30 subject"))
398 (with-no-warnings (setq european-calendar-style nil)) ;still get warning!?! FIXME 188 (should (= 2 (length result)))
399 (assert (eq (icalendar--date-style) 'american)) 189 (should (string= (concat "\nDTSTART;VALUE=DATE-TIME:20050103T083000"
400 (setq calendar-date-style cds))) 190 "\nDTEND;VALUE=DATE-TIME:20050103T093000"
401 191 "\nRRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO")
402(defun icalendar-testsuite--test-create-uid () 192 (car result)))
403 "Test method for `icalendar--create-uid'." 193 (should (string= "subject" (cadr result)))))
404 (let* ((icalendar-uid-format "xxx-%t-%c-%h-%u-%s")
405 t-ct
406 (icalendar--uid-count 77)
407 (entry-full "30.06.1964 07:01 blahblah")
408 (hash (format "%d" (abs (sxhash entry-full))))
409 (contents "DTSTART:19640630T070100\nblahblah")
410 (username (or user-login-name "UNKNOWN_USER"))
411 )
412 ;; FIXME! If a test fails 'current-time is screwed. FIXME!
413 (fset 't-ct (symbol-function 'current-time))
414 (fset 'current-time (lambda () '(1 2 3)))
415 (assert (= 77 icalendar--uid-count))
416 (assert (string= (concat "xxx-123-77-" hash "-" username "-19640630")
417 (icalendar--create-uid entry-full contents)))
418 (assert (= 78 icalendar--uid-count))
419 (fset 'current-time (symbol-function 't-ct))
420
421 (setq contents "blahblah")
422 (setq icalendar-uid-format "yyy%syyy")
423 (assert (string= (concat "yyyDTSTARTyyy")
424 (icalendar--create-uid entry-full contents)))
425 ))
426 194
427(defun icalendar-testsuite--test-parse-vtimezone () 195(ert-deftest icalendar--parse-vtimezone ()
428 "Test method for `icalendar--parse-vtimezone'." 196 "Test method for `icalendar--parse-vtimezone'."
429 (let (vtimezone result) 197 (let (vtimezone result)
430 (setq vtimezone (icalendar-testsuite--get-ical-event "BEGIN:VTIMEZONE 198 (setq vtimezone (icalendar-tests--get-ical-event "BEGIN:VTIMEZONE
431TZID:thename 199TZID:thename
432BEGIN:STANDARD 200BEGIN:STANDARD
433DTSTART:16010101T040000 201DTSTART:16010101T040000
@@ -444,11 +212,11 @@ END:DAYLIGHT
444END:VTIMEZONE 212END:VTIMEZONE
445")) 213"))
446 (setq result (icalendar--parse-vtimezone vtimezone)) 214 (setq result (icalendar--parse-vtimezone vtimezone))
447 (assert (string= "thename" (car result))) 215 (should (string= "thename" (car result)))
448 (message (cdr result)) 216 (message (cdr result))
449 (assert (string= "STD-02:00DST-03:00,M3.5.0/03:00:00,M10.5.0/04:00:00" 217 (should (string= "STD-02:00DST-03:00,M3.5.0/03:00:00,M10.5.0/04:00:00"
450 (cdr result))) 218 (cdr result)))
451 (setq vtimezone (icalendar-testsuite--get-ical-event "BEGIN:VTIMEZONE 219 (setq vtimezone (icalendar-tests--get-ical-event "BEGIN:VTIMEZONE
452TZID:anothername 220TZID:anothername
453BEGIN:STANDARD 221BEGIN:STANDARD
454DTSTART:16010101T040000 222DTSTART:16010101T040000
@@ -465,16 +233,223 @@ END:DAYLIGHT
465END:VTIMEZONE 233END:VTIMEZONE
466")) 234"))
467 (setq result (icalendar--parse-vtimezone vtimezone)) 235 (setq result (icalendar--parse-vtimezone vtimezone))
468 (assert (string= "anothername" (car result))) 236 (should (string= "anothername" (car result)))
469 (message (cdr result)) 237 (message (cdr result))
470 (assert (string= "STD-02:00DST-03:00,M3.2.1/03:00:00,M10.2.1/04:00:00" (cdr result))))) 238 (should (string= "STD-02:00DST-03:00,M3.2.1/03:00:00,M10.2.1/04:00:00"
239 (cdr result)))))
240
241(ert-deftest icalendar--convert-ordinary-to-ical ()
242 "Test method for `icalendar--convert-ordinary-to-ical'."
243 (let* ((calendar-date-style 'iso)
244 result)
245 ;; without time
246 (setq result (icalendar--convert-ordinary-to-ical "&?" "2010 2 15 subject"))
247 (should (= 2 (length result)))
248 (should (string= "\nDTSTART;VALUE=DATE:20100215\nDTEND;VALUE=DATE:20100216"
249 (car result)))
250 (should (string= "subject" (cadr result)))
251
252 ;; with time
253 (setq result (icalendar--convert-ordinary-to-ical
254 "&?" "&2010 2 15 12:34-23:45 s"))
255 (should (= 2 (length result)))
256 (should (string= (concat "\nDTSTART;VALUE=DATE-TIME:20100215T123400"
257 "\nDTEND;VALUE=DATE-TIME:20100215T234500")
258 (car result)))
259 (should (string= "s" (cadr result)))
260
261 ;; with time, again -- test bug#5549
262 (setq result (icalendar--convert-ordinary-to-ical
263 "x?" "x2010 2 15 0:34-1:45 s"))
264 (should (= 2 (length result)))
265 (should (string= (concat "\nDTSTART;VALUE=DATE-TIME:20100215T003400"
266 "\nDTEND;VALUE=DATE-TIME:20100215T014500")
267 (car result)))
268 (should (string= "s" (cadr result)))))
269
270(ert-deftest icalendar--diarytime-to-isotime ()
271 "Test method for `icalendar--diarytime-to-isotime'."
272 (should (string= (icalendar--diarytime-to-isotime "01:15" "")
273 "T011500"))
274 (should (string= (icalendar--diarytime-to-isotime "1:15" "")
275 "T011500"))
276 (should (string= (icalendar--diarytime-to-isotime "0:01" "")
277 "T000100"))
278 (should (string= (icalendar--diarytime-to-isotime "0100" "")
279 "T010000"))
280 (should (string= (icalendar--diarytime-to-isotime "0100" "am")
281 "T010000"))
282 (should (string= (icalendar--diarytime-to-isotime "0100" "pm")
283 "T130000"))
284 (should (string= (icalendar--diarytime-to-isotime "1200" "")
285 "T120000"))
286 (should (string= (icalendar--diarytime-to-isotime "17:17" "")
287 "T171700"))
288 (should (string= (icalendar--diarytime-to-isotime "1200" "am")
289 "T000000"))
290 (should (string= (icalendar--diarytime-to-isotime "1201" "am")
291 "T000100"))
292 (should (string= (icalendar--diarytime-to-isotime "1259" "am")
293 "T005900"))
294 (should (string= (icalendar--diarytime-to-isotime "1200" "pm")
295 "T120000"))
296 (should (string= (icalendar--diarytime-to-isotime "1201" "pm")
297 "T120100"))
298 (should (string= (icalendar--diarytime-to-isotime "1259" "pm")
299 "T125900")))
300
301(ert-deftest icalendar--datetime-to-diary-date ()
302 "Test method for `icalendar--datetime-to-diary-date'."
303 (let* ((datetime '(59 59 23 31 12 2008))
304 (calendar-date-style 'iso))
305 (should (string= (icalendar--datetime-to-diary-date datetime)
306 "2008 12 31"))
307 (setq calendar-date-style 'european)
308 (should (string= (icalendar--datetime-to-diary-date datetime)
309 "31 12 2008"))
310 (setq calendar-date-style 'american)
311 (should (string= (icalendar--datetime-to-diary-date datetime)
312 "12 31 2008"))))
313
314(ert-deftest icalendar--datestring-to-isodate ()
315 "Test method for `icalendar--datestring-to-isodate'."
316 (let ((calendar-date-style 'iso))
317 ;; numeric iso
318 (should (string= (icalendar--datestring-to-isodate "2008 05 11")
319 "20080511"))
320 (should (string= (icalendar--datestring-to-isodate "2008 05 31")
321 "20080531"))
322 (should (string= (icalendar--datestring-to-isodate "2008 05 31" 2)
323 "20080602"))
324
325 ;; numeric european
326 (setq calendar-date-style 'european)
327 (should (string= (icalendar--datestring-to-isodate "11 05 2008")
328 "20080511"))
329 (should (string= (icalendar--datestring-to-isodate "31 05 2008")
330 "20080531"))
331 (should (string= (icalendar--datestring-to-isodate "31 05 2008" 2)
332 "20080602"))
333
334 ;; numeric american
335 (setq calendar-date-style 'american)
336 (should (string= (icalendar--datestring-to-isodate "11 05 2008")
337 "20081105"))
338 (should (string= (icalendar--datestring-to-isodate "12 30 2008")
339 "20081230"))
340 (should (string= (icalendar--datestring-to-isodate "12 30 2008" 2)
341 "20090101"))
342
343 ;; non-numeric
344 (setq calendar-date-style nil) ;not necessary for conversion
345 (should (string= (icalendar--datestring-to-isodate "Nov 05 2008")
346 "20081105"))
347 (should (string= (icalendar--datestring-to-isodate "05 Nov 2008")
348 "20081105"))
349 (should (string= (icalendar--datestring-to-isodate "2008 Nov 05")
350 "20081105"))))
351
352(ert-deftest icalendar--first-weekday-of-year ()
353 "Test method for `icalendar-first-weekday-of-year'."
354 (should (eq 1 (icalendar-first-weekday-of-year "TU" 2008)))
355 (should (eq 3 (icalendar-first-weekday-of-year "WE" 2007)))
356 (should (eq 5 (icalendar-first-weekday-of-year "TH" 2006)))
357 (should (eq 7 (icalendar-first-weekday-of-year "FR" 2005)))
358 (should (eq 3 (icalendar-first-weekday-of-year "SA" 2004)))
359 (should (eq 5 (icalendar-first-weekday-of-year "SU" 2003)))
360 (should (eq 7 (icalendar-first-weekday-of-year "MO" 2002)))
361 (should (eq 3 (icalendar-first-weekday-of-year "MO" 2000)))
362 (should (eq 1 (icalendar-first-weekday-of-year "TH" 1970))))
363
364(ert-deftest icalendar--import-format-sample ()
365 "Test method for `icalendar-import-format-sample'."
366 (should (string= (icalendar-import-format-sample
367 (icalendar-tests--get-ical-event "BEGIN:VEVENT
368DTSTAMP:20030509T043439Z
369DTSTART:20030509T103000
370SUMMARY:a
371ORGANIZER:d
372LOCATION:c
373DTEND:20030509T153000
374DESCRIPTION:b
375END:VEVENT
376"))
377 (concat "SUMMARY=`a' DESCRIPTION=`b' LOCATION=`c' "
378 "ORGANIZER=`d' STATUS=`' URL=`' CLASS=`'"))))
379
380(ert-deftest icalendar--format-ical-event ()
381 "Test `icalendar--format-ical-event'."
382 (let ((icalendar-import-format "%s%d%l%o%t%u%c")
383 (icalendar-import-format-summary "SUM %s")
384 (icalendar-import-format-location " LOC %s")
385 (icalendar-import-format-description " DES %s")
386 (icalendar-import-format-organizer " ORG %s")
387 (icalendar-import-format-status " STA %s")
388 (icalendar-import-format-url " URL %s")
389 (icalendar-import-format-class " CLA %s")
390 (event (icalendar-tests--get-ical-event "BEGIN:VEVENT
391DTSTAMP:20030509T043439Z
392DTSTART:20030509T103000
393SUMMARY:sum
394ORGANIZER:org
395LOCATION:loc
396DTEND:20030509T153000
397DESCRIPTION:des
398END:VEVENT
399")))
400 (should (string= (icalendar--format-ical-event event)
401 "SUM sum DES des LOC loc ORG org"))
402 (setq icalendar-import-format (lambda (&rest ignore)
403 "helloworld"))
404 (should (string= (icalendar--format-ical-event event)
405 "helloworld"))
406 (setq icalendar-import-format
407 (lambda (e)
408 (format "-%s-%s-%s-%s-%s-%s-%s-"
409 (icalendar--get-event-property event 'SUMMARY)
410 (icalendar--get-event-property event 'DESCRIPTION)
411 (icalendar--get-event-property event 'LOCATION)
412 (icalendar--get-event-property event 'ORGANIZER)
413 (icalendar--get-event-property event 'STATUS)
414 (icalendar--get-event-property event 'URL)
415 (icalendar--get-event-property event 'CLASS))))
416 (should (string= (icalendar--format-ical-event event)
417 "-sum-des-loc-org-nil-nil-nil-"))))
418
419(ert-deftest icalendar--parse-summary-and-rest ()
420 "Test `icalendar--parse-summary-and-rest'."
421 (let ((icalendar-import-format "%s%d%l%o%t%u%c")
422 (icalendar-import-format-summary "SUM %s")
423 (icalendar-import-format-location " LOC %s")
424 (icalendar-import-format-description " DES %s")
425 (icalendar-import-format-organizer " ORG %s")
426 (icalendar-import-format-status " STA %s")
427 (icalendar-import-format-url " URL %s")
428 (icalendar-import-format-class " CLA %s")
429 (result))
430 (setq result (icalendar--parse-summary-and-rest "SUM sum ORG org"))
431 (should (string= (cdr (assoc 'org result)) "org"))
432
433 (setq result (icalendar--parse-summary-and-rest
434 "SUM sum DES des LOC loc ORG org STA sta URL url CLA cla"))
435 (should (string= (cdr (assoc 'des result)) "des"))
436 (should (string= (cdr (assoc 'loc result)) "loc"))
437 (should (string= (cdr (assoc 'org result)) "org"))
438 (should (string= (cdr (assoc 'sta result)) "sta"))
439 (should (string= (cdr (assoc 'cla result)) "cla"))
440
441 (setq icalendar-import-format (lambda () "Hello world"))
442 (setq result (icalendar--parse-summary-and-rest
443 "blah blah "))
444 (should (not result))
445 ))
471 446
472;; ====================================================================== 447;; ======================================================================
473;; Test methods for exporting from diary to icalendar 448;; Export tests
474;; ====================================================================== 449;; ======================================================================
475 450
476(defun icalendar-testsuite--test-export (input-iso input-european input-american 451(defun icalendar-tests--test-export (input-iso input-european input-american
477 expected-output) 452 expected-output)
478 "Perform an export test. 453 "Perform an export test.
479Argument INPUT-ISO iso style diary string. 454Argument INPUT-ISO iso style diary string.
480Argument INPUT-EUROPEAN european style diary string. 455Argument INPUT-EUROPEAN european style diary string.
@@ -483,52 +458,57 @@ Argument EXPECTED-OUTPUT expected icalendar result string.
483 458
484European style input data must use german month names. American 459European style input data must use german month names. American
485and ISO style input data must use english month names." 460and ISO style input data must use english month names."
486 (message "--- icalendar-testsuite--test-export ---") 461 (let ((tz (cadr (current-time-zone)))
487 (let ((calendar-date-style 'iso) 462 (calendar-date-style 'iso)
488 (icalendar-recurring-start-year 2000)) 463 (icalendar-recurring-start-year 2000))
489 (set-time-zone-rule "CET") ;;FIXME: reset timezone! 464 (unwind-protect
490 (when input-iso 465 (progn
491 (let ((calendar-month-name-array 466 (set-time-zone-rule "CET")
492 ["January" "February" "March" "April" "May" "June" "July" "August" 467 (when input-iso
493 "September" "October" "November" "December"]) 468 (let ((calendar-month-name-array
494 (calendar-day-name-array 469 ["January" "February" "March" "April" "May" "June" "July" "August"
495 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" 470 "September" "October" "November" "December"])
496 "Saturday"])) 471 (calendar-day-name-array
497 (setq calendar-date-style 'iso) 472 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday"
498 (icalendar-testsuite--do-test-export input-iso expected-output))) 473 "Saturday"]))
499 (when input-european 474 (setq calendar-date-style 'iso)
500 (let ((calendar-month-name-array 475 (icalendar-tests--do-test-export input-iso expected-output)))
501 ["Januar" "Februar" "März" "April" "Mai" "Juni" "Juli" "August" 476 (when input-european
502 "September" "Oktober" "November" "Dezember"]) 477 (let ((calendar-month-name-array
503 (calendar-day-name-array 478 ["Januar" "Februar" "März" "April" "Mai" "Juni" "Juli" "August"
504 ["Sonntag" "Montag" "Dienstag" "Mittwoch" "Donnerstag" "Freitag" 479 "September" "Oktober" "November" "Dezember"])
505 "Samstag"])) 480 (calendar-day-name-array
506 (setq calendar-date-style 'european) 481 ["Sonntag" "Montag" "Dienstag" "Mittwoch" "Donnerstag" "Freitag"
507 (icalendar-testsuite--do-test-export input-european expected-output))) 482 "Samstag"]))
508 (when input-american 483 (setq calendar-date-style 'european)
509 (let ((calendar-month-name-array 484 (icalendar-tests--do-test-export input-european expected-output)))
510 ["January" "February" "March" "April" "May" "June" "July" "August" 485 (when input-american
511 "September" "October" "November" "December"]) 486 (let ((calendar-month-name-array
512 (calendar-day-name-array 487 ["January" "February" "March" "April" "May" "June" "July" "August"
513 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" 488 "September" "October" "November" "December"])
514 "Saturday"])) 489 (calendar-day-name-array
515 (setq calendar-date-style 'american) 490 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday"
516 (icalendar-testsuite--do-test-export input-american expected-output))))) 491 "Saturday"]))
517 492 (setq calendar-date-style 'american)
518(defun icalendar-testsuite--do-test-export (input expected-output) 493 (icalendar-tests--do-test-export input-american expected-output))))
494 ;; restore time-zone if something went terribly wrong
495 (set-time-zone-rule tz))))
496
497(defun icalendar-tests--do-test-export (input expected-output)
519 "Actually perform export test. 498 "Actually perform export test.
520Argument INPUT input diary string. 499Argument INPUT input diary string.
521Argument EXPECTED-OUTPUT expected icalendar result string." 500Argument EXPECTED-OUTPUT expected icalendar result string."
522 (let ((temp-file (make-temp-file "icalendar-testsuite-ics"))) 501 (let ((temp-file (make-temp-file "icalendar-tests-ics")))
523 (with-temp-buffer 502 (unwind-protect
524 (insert input) 503 (progn
525 (icalendar-export-region (point-min) (point-max) temp-file)) 504 (with-temp-buffer
526 (save-excursion 505 (insert input)
527 (find-file temp-file) 506 (icalendar-export-region (point-min) (point-max) temp-file))
528 (goto-char (point-min)) 507 (save-excursion
529 (unless 508 (find-file temp-file)
530 (cond (expected-output 509 (goto-char (point-min))
531 (and (re-search-forward "^\\s-*BEGIN:VCALENDAR 510 (cond (expected-output
511 (should (re-search-forward "^\\s-*BEGIN:VCALENDAR
532PRODID:-//Emacs//NONSGML icalendar.el//EN 512PRODID:-//Emacs//NONSGML icalendar.el//EN
533VERSION:2.0 513VERSION:2.0
534BEGIN:VEVENT 514BEGIN:VEVENT
@@ -537,48 +517,190 @@ UID:emacs[0-9]+
537END:VEVENT 517END:VEVENT
538END:VCALENDAR 518END:VCALENDAR
539\\s-*$" 519\\s-*$"
540 nil t) 520 nil t))
541 (string-match 521 (should (string-match
542 (concat "^\\s-*" 522 (concat "^\\s-*"
543 (regexp-quote (buffer-substring-no-properties 523 (regexp-quote (buffer-substring-no-properties
544 (match-beginning 1) (match-end 1))) 524 (match-beginning 1) (match-end 1)))
545 "\\s-*$") 525 "\\s-*$")
546 expected-output))) 526 expected-output)))
547 (t 527 (t
548 (re-search-forward "^\\s-*BEGIN:VCALENDAR 528 (should (re-search-forward "^\\s-*BEGIN:VCALENDAR
549PRODID:-//Emacs//NONSGML icalendar.el//EN 529PRODID:-//Emacs//NONSGML icalendar.el//EN
550VERSION:2.0 530VERSION:2.0
551END:VCALENDAR 531END:VCALENDAR
552\\s-*$" 532\\s-*$"
553 nil t))) 533 nil t))))))
554 (error 534 ;; cleanup!!
555 "Export test failed! Input: `%s'\nFound:\n\n%s\n\nbut expected\n\n%s\n%s" 535 (kill-buffer (find-buffer-visiting temp-file))
556 input 536 (delete-file temp-file))))
557 (or (and (match-beginning 1) 537
558 (buffer-substring-no-properties (match-beginning 1) 538(ert-deftest icalendar-export-ordinary-no-time ()
559 (match-end 1))) 539 "Perform export test."
560 "<nil>") 540
561 (or expected-output "<nil>") 541 (let ((icalendar-export-hidden-diary-entries nil))
562 (icalendar-testsuite--compare-strings (or (and (match-beginning 1) 542 (icalendar-tests--test-export
563 (buffer-substring-no-properties (match-beginning 1) 543 "&2000 Oct 3 ordinary no time "
564 (match-end 1))) 544 "&3 Okt 2000 ordinary no time "
565 "<nil>") 545 "&Oct 3 2000 ordinary no time "
566 (or expected-output "<nil>"))))) 546 nil))
567 (kill-buffer (find-buffer-visiting temp-file)) 547
568 (delete-file temp-file))) 548 (icalendar-tests--test-export
549 "2000 Oct 3 ordinary no time "
550 "3 Okt 2000 ordinary no time "
551 "Oct 3 2000 ordinary no time "
552 "DTSTART;VALUE=DATE:20001003
553DTEND;VALUE=DATE:20001004
554SUMMARY:ordinary no time
555"))
556
557(ert-deftest icalendar-export-ordinary ()
558 "Perform export test."
559
560 (icalendar-tests--test-export
561 "2000 Oct 3 16:30 ordinary with time"
562 "3 Okt 2000 16:30 ordinary with time"
563 "Oct 3 2000 16:30 ordinary with time"
564 "DTSTART;VALUE=DATE-TIME:20001003T163000
565DTEND;VALUE=DATE-TIME:20001003T173000
566SUMMARY:ordinary with time
567")
568 (icalendar-tests--test-export
569 "2000 10 3 16:30 ordinary with time 2"
570 "3 10 2000 16:30 ordinary with time 2"
571 "10 3 2000 16:30 ordinary with time 2"
572 "DTSTART;VALUE=DATE-TIME:20001003T163000
573DTEND;VALUE=DATE-TIME:20001003T173000
574SUMMARY:ordinary with time 2
575")
576
577 (icalendar-tests--test-export
578 "2000/10/3 16:30 ordinary with time 3"
579 "3/10/2000 16:30 ordinary with time 3"
580 "10/3/2000 16:30 ordinary with time 3"
581 "DTSTART;VALUE=DATE-TIME:20001003T163000
582DTEND;VALUE=DATE-TIME:20001003T173000
583SUMMARY:ordinary with time 3
584"))
585
586(ert-deftest icalendar-export-multiline ()
587 "Perform export test."
588
589 ;; multiline -- FIXME!!!
590 (icalendar-tests--test-export
591 "2000 October 3 16:30 multiline
592 17:30 multiline continued FIXME"
593 "3 Oktober 2000 16:30 multiline
594 17:30 multiline continued FIXME"
595 "October 3 2000 16:30 multiline
596 17:30 multiline continued FIXME"
597 "DTSTART;VALUE=DATE-TIME:20001003T163000
598DTEND;VALUE=DATE-TIME:20001003T173000
599SUMMARY:multiline
600DESCRIPTION:
601 17:30 multiline continued FIXME
602"))
603
604(ert-deftest icalendar-export-weekly-by-day ()
605 "Perform export test."
606
607 ;; weekly by day
608 (icalendar-tests--test-export
609 "Monday 1:30pm weekly by day with start time"
610 "Montag 13:30 weekly by day with start time"
611 "Monday 1:30pm weekly by day with start time"
612 "DTSTART;VALUE=DATE-TIME:20000103T133000
613DTEND;VALUE=DATE-TIME:20000103T143000
614RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
615SUMMARY:weekly by day with start time
616")
617
618 (icalendar-tests--test-export
619 "Monday 13:30-15:00 weekly by day with start and end time"
620 "Montag 13:30-15:00 weekly by day with start and end time"
621 "Monday 01:30pm-03:00pm weekly by day with start and end time"
622 "DTSTART;VALUE=DATE-TIME:20000103T133000
623DTEND;VALUE=DATE-TIME:20000103T150000
624RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
625SUMMARY:weekly by day with start and end time
626"))
627
628(ert-deftest icalendar-export-yearly ()
629 "Perform export test."
630 ;; yearly
631 (icalendar-tests--test-export
632 "may 1 yearly no time"
633 "1 Mai yearly no time"
634 "may 1 yearly no time"
635 "DTSTART;VALUE=DATE:19000501
636DTEND;VALUE=DATE:19000502
637RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=5;BYMONTHDAY=1
638SUMMARY:yearly no time
639"))
640
641(ert-deftest icalendar-export-anniversary ()
642 "Perform export test."
643 ;; anniversaries
644 (icalendar-tests--test-export
645 "%%(diary-anniversary 1989 10 3) anniversary no time"
646 "%%(diary-anniversary 3 10 1989) anniversary no time"
647 "%%(diary-anniversary 10 3 1989) anniversary no time"
648 "DTSTART;VALUE=DATE:19891003
649DTEND;VALUE=DATE:19891004
650RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=10;BYMONTHDAY=03
651SUMMARY:anniversary no time
652")
653 (icalendar-tests--test-export
654 "%%(diary-anniversary 1989 10 3) 19:00-20:00 anniversary with time"
655 "%%(diary-anniversary 3 10 1989) 19:00-20:00 anniversary with time"
656 "%%(diary-anniversary 10 3 1989) 19:00-20:00 anniversary with time"
657 "DTSTART;VALUE=DATE-TIME:19891003T190000
658DTEND;VALUE=DATE-TIME:19891004T200000
659RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=10;BYMONTHDAY=03
660SUMMARY:anniversary with time
661"))
662
663(ert-deftest icalendar-export-block ()
664 "Perform export test."
665 ;; block
666 (icalendar-tests--test-export
667 "%%(diary-block 2001 6 18 2001 7 6) block no time"
668 "%%(diary-block 18 6 2001 6 7 2001) block no time"
669 "%%(diary-block 6 18 2001 7 6 2001) block no time"
670 "DTSTART;VALUE=DATE:20010618
671DTEND;VALUE=DATE:20010707
672SUMMARY:block no time
673")
674 (icalendar-tests--test-export
675 "%%(diary-block 2001 6 18 2001 7 6) 13:00-17:00 block with time"
676 "%%(diary-block 18 6 2001 6 7 2001) 13:00-17:00 block with time"
677 "%%(diary-block 6 18 2001 7 6 2001) 13:00-17:00 block with time"
678 "DTSTART;VALUE=DATE-TIME:20010618T130000
679DTEND;VALUE=DATE-TIME:20010618T170000
680RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20010706
681SUMMARY:block with time
682")
683 (icalendar-tests--test-export
684 "%%(diary-block 2001 6 18 2001 7 6) 13:00 block no end time"
685 "%%(diary-block 18 6 2001 6 7 2001) 13:00 block no end time"
686 "%%(diary-block 6 18 2001 7 6 2001) 13:00 block no end time"
687 "DTSTART;VALUE=DATE-TIME:20010618T130000
688DTEND;VALUE=DATE-TIME:20010618T140000
689RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20010706
690SUMMARY:block no end time
691"))
569 692
570;; ====================================================================== 693;; ======================================================================
571;; Test methods for importing from icalendar to diary 694;; Import tests
572;; ====================================================================== 695;; ======================================================================
573 696
574(defun icalendar-testsuite--test-import (input expected-iso expected-european 697(defun icalendar-tests--test-import (input expected-iso expected-european
575 expected-american) 698 expected-american)
576 "Perform import test. 699 "Perform import test.
577Argument INPUT icalendar event string. 700Argument INPUT icalendar event string.
578Argument EXPECTED-ISO expected iso style diary string. 701Argument EXPECTED-ISO expected iso style diary string.
579Argument EXPECTED-EUROPEAN expected european style diary string. 702Argument EXPECTED-EUROPEAN expected european style diary string.
580Argument EXPECTED-AMERICAN expected american style diary string." 703Argument EXPECTED-AMERICAN expected american style diary string."
581 (message "--- icalendar-testsuite--test-import ---")
582 (let ((timezone (cadr (current-time-zone)))) 704 (let ((timezone (cadr (current-time-zone))))
583 (set-time-zone-rule "CET") 705 (set-time-zone-rule "CET")
584 (with-temp-buffer 706 (with-temp-buffer
@@ -601,126 +723,54 @@ Argument EXPECTED-AMERICAN expected american style diary string."
601 calendar-date-style) 723 calendar-date-style)
602 (when expected-iso 724 (when expected-iso
603 (setq calendar-date-style 'iso) 725 (setq calendar-date-style 'iso)
604 (icalendar-testsuite--do-test-import input expected-iso)) 726 (icalendar-tests--do-test-import input expected-iso))
605 (when expected-european 727 (when expected-european
606 (setq calendar-date-style 'european) 728 (setq calendar-date-style 'european)
607 (icalendar-testsuite--do-test-import input expected-european)) 729 (icalendar-tests--do-test-import input expected-european))
608 (when expected-american 730 (when expected-american
609 (setq calendar-date-style 'american) 731 (setq calendar-date-style 'american)
610 (icalendar-testsuite--do-test-import input expected-american)))) 732 (icalendar-tests--do-test-import input expected-american))))
611 (set-time-zone-rule timezone))) 733 (set-time-zone-rule timezone)))
612 734
613(defun icalendar-testsuite--do-test-import (input expected-output) 735(defun icalendar-tests--do-test-import (input expected-output)
614 "Actually perform import test. 736 "Actually perform import test.
615Argument INPUT input icalendar string. 737Argument INPUT input icalendar string.
616Argument EXPECTED-OUTPUT expected diary string." 738Argument EXPECTED-OUTPUT expected diary string."
617 (let ((temp-file (make-temp-file "icalendar-test-diary"))) 739 (let ((temp-file (make-temp-file "icalendar-test-diary")))
618 (icalendar-import-buffer temp-file t t) 740 (icalendar-import-buffer temp-file t t)
619 (save-excursion 741 (unwind-protect
620 (find-file temp-file) 742 (save-excursion
621 (let* ((result (buffer-substring-no-properties (point-min) (point-max))) 743 (find-file temp-file)
622 (difference 744 (let ((result (buffer-substring-no-properties (point-min) (point-max))))
623 (icalendar-testsuite--compare-strings result 745 (should (icalendar-tests--compare-strings result
624 expected-output))) 746 expected-output))))
625 (if (stringp difference)
626 (error "Import test failed! Found\n`%s'\nbut expected\n`%s'\n%s'"
627 result expected-output difference)))
628 (kill-buffer (find-buffer-visiting temp-file)) 747 (kill-buffer (find-buffer-visiting temp-file))
629 (delete-file temp-file)))) 748 (delete-file temp-file))))
630 749
631;; ====================================================================== 750(ert-deftest icalendar-import-non-recurring ()
632;; Test methods for cycle...
633;; ======================================================================
634(defun icalendar-testsuite--test-cycle (input)
635 "Perform cycle test.
636Argument INPUT icalendar event string."
637 (with-temp-buffer
638 (if (string-match "^BEGIN:VCALENDAR" input)
639 (insert input)
640 (insert "BEGIN:VCALENDAR\nPRODID:-//Emacs//NONSGML icalendar.el//EN\n")
641 (insert "VERSION:2.0\nBEGIN:VEVENT\n")
642 (insert input)
643 (unless (eq (char-before) ?\n)
644 (insert "\n"))
645 (insert "END:VEVENT\nEND:VCALENDAR\n"))
646 (let ((icalendar-import-format "%s%d%l%o%t%u%c")
647 (icalendar-import-format-summary "%s")
648 (icalendar-import-format-location "\n Location: %s")
649 (icalendar-import-format-description "\n Desc: %s")
650 (icalendar-import-format-organizer "\n Organizer: %s")
651 (icalendar-import-format-status "\n Status: %s")
652 (icalendar-import-format-url "\n URL: %s")
653 (icalendar-import-format-class "\n Class: %s"))
654 (dolist (calendar-date-style '(iso european american))
655 (icalendar-testsuite--do-test-cycle)))))
656
657(defun icalendar-testsuite--do-test-cycle ()
658 "Actually perform import/export cycle test."
659 (let ((temp-diary (make-temp-file "icalendar-test-diary"))
660 (temp-ics (make-temp-file "icalendar-test-ics"))
661 (org-input (buffer-substring-no-properties (point-min) (point-max))))
662
663 ;; step 1: import
664 (icalendar-import-buffer temp-diary t t)
665
666 ;; step 2: export what was just imported
667 (save-excursion
668 (find-file temp-diary)
669 (icalendar-export-region (point-min) (point-max) temp-ics))
670
671 ;; compare the output of step 2 with the input of step 1
672 (save-excursion
673 (find-file temp-ics)
674 (goto-char (point-min))
675 (when (re-search-forward "\nUID:.*\n" nil t)
676 (replace-match "\n"))
677 (let ((cycled (buffer-substring-no-properties (point-min) (point-max))))
678 (let ((difference (icalendar-testsuite--compare-strings cycled
679 org-input)))
680 (if (stringp difference)
681 (error "Import test failed! Found\n`%s'\nbut expected\n`%s'\n%s'"
682 cycled org-input difference)))
683 ))
684
685 ;; clean up -- Note this is done only if test is passed
686 (kill-buffer (find-buffer-visiting temp-diary))
687 (save-excursion
688 (set-buffer (find-buffer-visiting temp-ics))
689 (set-buffer-modified-p nil)
690 (kill-buffer (current-buffer)))
691 (delete-file temp-diary)
692 (delete-file temp-ics)))
693
694;; ======================================================================
695;; Import tests
696;; ======================================================================
697(defun icalendar-testsuite--run-import-tests ()
698 "Perform standard import tests." 751 "Perform standard import tests."
699 (icalendar-testsuite--test-import 752 (icalendar-tests--test-import
700 "SUMMARY:non-recurring 753 "SUMMARY:non-recurring
701DTSTART;VALUE=DATE-TIME:20030919T090000 754DTSTART;VALUE=DATE-TIME:20030919T090000
702DTEND;VALUE=DATE-TIME:20030919T113000" 755DTEND;VALUE=DATE-TIME:20030919T113000"
703 "&2003/9/19 09:00-11:30 non-recurring" 756 "&2003/9/19 09:00-11:30 non-recurring"
704 "&19/9/2003 09:00-11:30 non-recurring" 757 "&19/9/2003 09:00-11:30 non-recurring"
705 "&9/19/2003 09:00-11:30 non-recurring") 758 "&9/19/2003 09:00-11:30 non-recurring")
706 759 (icalendar-tests--test-import
707 (icalendar-testsuite--test-import
708 "SUMMARY:non-recurring allday 760 "SUMMARY:non-recurring allday
709DTSTART;VALUE=DATE-TIME:20030919" 761DTSTART;VALUE=DATE-TIME:20030919"
710 "&2003/9/19 non-recurring allday" 762 "&2003/9/19 non-recurring allday"
711 "&19/9/2003 non-recurring allday" 763 "&19/9/2003 non-recurring allday"
712 "&9/19/2003 non-recurring allday") 764 "&9/19/2003 non-recurring allday")
713 765 (icalendar-tests--test-import
714 (icalendar-testsuite--test-import
715 ;; do not remove the trailing blank after "long"! 766 ;; do not remove the trailing blank after "long"!
716 "SUMMARY:long 767 "SUMMARY:long
717 summary 768 summary
718DTSTART;VALUE=DATE:20030919" 769DTSTART;VALUE=DATE:20030919"
719 "&2003/9/19 long summary" 770 "&2003/9/19 long summary"
720 "&19/9/2003 long summary" 771 "&19/9/2003 long summary"
721 "&9/19/2003 long summary") 772 "&9/19/2003 long summary")
722 773 (icalendar-tests--test-import
723 (icalendar-testsuite--test-import
724 "UID:748f2da0-0d9b-11d8-97af-b4ec8686ea61 774 "UID:748f2da0-0d9b-11d8-97af-b4ec8686ea61
725SUMMARY:Sommerferien 775SUMMARY:Sommerferien
726STATUS:TENTATIVE 776STATUS:TENTATIVE
@@ -742,8 +792,7 @@ DTSTAMP:20031103T011641Z
742 "&%%(and (diary-block 7 19 2004 8 27 2004)) Sommerferien 792 "&%%(and (diary-block 7 19 2004 8 27 2004)) Sommerferien
743 Status: TENTATIVE 793 Status: TENTATIVE
744 Class: PRIVATE") 794 Class: PRIVATE")
745 795 (icalendar-tests--test-import
746 (icalendar-testsuite--test-import
747 "UID 796 "UID
748 :04979712-3902-11d9-93dd-8f9f4afe08da 797 :04979712-3902-11d9-93dd-8f9f4afe08da
749SUMMARY 798SUMMARY
@@ -772,7 +821,8 @@ LAST-MODIFIED
772 "&11/23/2004 14:00-14:30 folded summary 821 "&11/23/2004 14:00-14:30 folded summary
773 Status: TENTATIVE 822 Status: TENTATIVE
774 Class: PRIVATE") 823 Class: PRIVATE")
775 (icalendar-testsuite--test-import 824
825 (icalendar-tests--test-import
776 "UID 826 "UID
777 :6161a312-3902-11d9-b512-f764153bb28b 827 :6161a312-3902-11d9-b512-f764153bb28b
778SUMMARY 828SUMMARY
@@ -798,9 +848,10 @@ DTSTAMP
798 Class: PRIVATE" 848 Class: PRIVATE"
799 "&11/23/2004 14:45-15:45 another example 849 "&11/23/2004 14:45-15:45 another example
800 Status: TENTATIVE 850 Status: TENTATIVE
801 Class: PRIVATE") 851 Class: PRIVATE"))
802 852
803 (icalendar-testsuite--test-import 853(ert-deftest icalendar-import-rrule ()
854 (icalendar-tests--test-import
804 "SUMMARY:rrule daily 855 "SUMMARY:rrule daily
805DTSTART;VALUE=DATE-TIME:20030919T090000 856DTSTART;VALUE=DATE-TIME:20030919T090000
806DTEND;VALUE=DATE-TIME:20030919T113000 857DTEND;VALUE=DATE-TIME:20030919T113000
@@ -809,9 +860,8 @@ RRULE:FREQ=DAILY;
809 "&%%(and (diary-cyclic 1 2003 9 19)) 09:00-11:30 rrule daily" 860 "&%%(and (diary-cyclic 1 2003 9 19)) 09:00-11:30 rrule daily"
810 "&%%(and (diary-cyclic 1 19 9 2003)) 09:00-11:30 rrule daily" 861 "&%%(and (diary-cyclic 1 19 9 2003)) 09:00-11:30 rrule daily"
811 "&%%(and (diary-cyclic 1 9 19 2003)) 09:00-11:30 rrule daily") 862 "&%%(and (diary-cyclic 1 9 19 2003)) 09:00-11:30 rrule daily")
812
813 ;; RRULE examples 863 ;; RRULE examples
814 (icalendar-testsuite--test-import 864 (icalendar-tests--test-import
815 "SUMMARY:rrule daily 865 "SUMMARY:rrule daily
816DTSTART;VALUE=DATE-TIME:20030919T090000 866DTSTART;VALUE=DATE-TIME:20030919T090000
817DTEND;VALUE=DATE-TIME:20030919T113000 867DTEND;VALUE=DATE-TIME:20030919T113000
@@ -820,7 +870,7 @@ RRULE:FREQ=DAILY;INTERVAL=2
820 "&%%(and (diary-cyclic 2 2003 9 19)) 09:00-11:30 rrule daily" 870 "&%%(and (diary-cyclic 2 2003 9 19)) 09:00-11:30 rrule daily"
821 "&%%(and (diary-cyclic 2 19 9 2003)) 09:00-11:30 rrule daily" 871 "&%%(and (diary-cyclic 2 19 9 2003)) 09:00-11:30 rrule daily"
822 "&%%(and (diary-cyclic 2 9 19 2003)) 09:00-11:30 rrule daily") 872 "&%%(and (diary-cyclic 2 9 19 2003)) 09:00-11:30 rrule daily")
823 (icalendar-testsuite--test-import 873 (icalendar-tests--test-import
824 "SUMMARY:rrule daily with exceptions 874 "SUMMARY:rrule daily with exceptions
825DTSTART;VALUE=DATE-TIME:20030919T090000 875DTSTART;VALUE=DATE-TIME:20030919T090000
826DTEND;VALUE=DATE-TIME:20030919T113000 876DTEND;VALUE=DATE-TIME:20030919T113000
@@ -830,8 +880,7 @@ EXDATE:20030921,20030925
830 "&%%(and (not (diary-date 2003 9 25)) (not (diary-date 2003 9 21)) (diary-cyclic 2 2003 9 19)) 09:00-11:30 rrule daily with exceptions" 880 "&%%(and (not (diary-date 2003 9 25)) (not (diary-date 2003 9 21)) (diary-cyclic 2 2003 9 19)) 09:00-11:30 rrule daily with exceptions"
831 "&%%(and (not (diary-date 25 9 2003)) (not (diary-date 21 9 2003)) (diary-cyclic 2 19 9 2003)) 09:00-11:30 rrule daily with exceptions" 881 "&%%(and (not (diary-date 25 9 2003)) (not (diary-date 21 9 2003)) (diary-cyclic 2 19 9 2003)) 09:00-11:30 rrule daily with exceptions"
832 "&%%(and (not (diary-date 9 25 2003)) (not (diary-date 9 21 2003)) (diary-cyclic 2 9 19 2003)) 09:00-11:30 rrule daily with exceptions") 882 "&%%(and (not (diary-date 9 25 2003)) (not (diary-date 9 21 2003)) (diary-cyclic 2 9 19 2003)) 09:00-11:30 rrule daily with exceptions")
833 883 (icalendar-tests--test-import
834 (icalendar-testsuite--test-import
835 "SUMMARY:rrule weekly 884 "SUMMARY:rrule weekly
836DTSTART;VALUE=DATE-TIME:20030919T090000 885DTSTART;VALUE=DATE-TIME:20030919T090000
837DTEND;VALUE=DATE-TIME:20030919T113000 886DTEND;VALUE=DATE-TIME:20030919T113000
@@ -840,7 +889,7 @@ RRULE:FREQ=WEEKLY;
840 "&%%(and (diary-cyclic 7 2003 9 19)) 09:00-11:30 rrule weekly" 889 "&%%(and (diary-cyclic 7 2003 9 19)) 09:00-11:30 rrule weekly"
841 "&%%(and (diary-cyclic 7 19 9 2003)) 09:00-11:30 rrule weekly" 890 "&%%(and (diary-cyclic 7 19 9 2003)) 09:00-11:30 rrule weekly"
842 "&%%(and (diary-cyclic 7 9 19 2003)) 09:00-11:30 rrule weekly") 891 "&%%(and (diary-cyclic 7 9 19 2003)) 09:00-11:30 rrule weekly")
843 (icalendar-testsuite--test-import 892 (icalendar-tests--test-import
844 "SUMMARY:rrule monthly no end 893 "SUMMARY:rrule monthly no end
845DTSTART;VALUE=DATE-TIME:20030919T090000 894DTSTART;VALUE=DATE-TIME:20030919T090000
846DTEND;VALUE=DATE-TIME:20030919T113000 895DTEND;VALUE=DATE-TIME:20030919T113000
@@ -849,7 +898,7 @@ RRULE:FREQ=MONTHLY;
849 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 9999 1 1)) 09:00-11:30 rrule monthly no end" 898 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 9999 1 1)) 09:00-11:30 rrule monthly no end"
850 "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 1 1 9999)) 09:00-11:30 rrule monthly no end" 899 "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 1 1 9999)) 09:00-11:30 rrule monthly no end"
851 "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 1 1 9999)) 09:00-11:30 rrule monthly no end") 900 "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 1 1 9999)) 09:00-11:30 rrule monthly no end")
852 (icalendar-testsuite--test-import 901 (icalendar-tests--test-import
853 "SUMMARY:rrule monthly with end 902 "SUMMARY:rrule monthly with end
854DTSTART;VALUE=DATE-TIME:20030919T090000 903DTSTART;VALUE=DATE-TIME:20030919T090000
855DTEND;VALUE=DATE-TIME:20030919T113000 904DTEND;VALUE=DATE-TIME:20030919T113000
@@ -858,7 +907,7 @@ RRULE:FREQ=MONTHLY;UNTIL=20050819;
858 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2005 8 19)) 09:00-11:30 rrule monthly with end" 907 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2005 8 19)) 09:00-11:30 rrule monthly with end"
859 "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 19 8 2005)) 09:00-11:30 rrule monthly with end" 908 "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 19 8 2005)) 09:00-11:30 rrule monthly with end"
860 "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 8 19 2005)) 09:00-11:30 rrule monthly with end") 909 "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 8 19 2005)) 09:00-11:30 rrule monthly with end")
861 (icalendar-testsuite--test-import 910 (icalendar-tests--test-import
862 "DTSTART;VALUE=DATE:20040815 911 "DTSTART;VALUE=DATE:20040815
863DTEND;VALUE=DATE:20040816 912DTEND;VALUE=DATE:20040816
864SUMMARY:Maria Himmelfahrt 913SUMMARY:Maria Himmelfahrt
@@ -868,7 +917,7 @@ RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=8
868 "&%%(and (diary-anniversary 2004 8 15)) Maria Himmelfahrt" 917 "&%%(and (diary-anniversary 2004 8 15)) Maria Himmelfahrt"
869 "&%%(and (diary-anniversary 15 8 2004)) Maria Himmelfahrt" 918 "&%%(and (diary-anniversary 15 8 2004)) Maria Himmelfahrt"
870 "&%%(and (diary-anniversary 8 15 2004)) Maria Himmelfahrt") 919 "&%%(and (diary-anniversary 8 15 2004)) Maria Himmelfahrt")
871 (icalendar-testsuite--test-import 920 (icalendar-tests--test-import
872 "SUMMARY:rrule yearly 921 "SUMMARY:rrule yearly
873DTSTART;VALUE=DATE-TIME:20030919T090000 922DTSTART;VALUE=DATE-TIME:20030919T090000
874DTEND;VALUE=DATE-TIME:20030919T113000 923DTEND;VALUE=DATE-TIME:20030919T113000
@@ -877,7 +926,7 @@ RRULE:FREQ=YEARLY;INTERVAL=2
877 "&%%(and (diary-anniversary 2003 9 19)) 09:00-11:30 rrule yearly" ;FIXME 926 "&%%(and (diary-anniversary 2003 9 19)) 09:00-11:30 rrule yearly" ;FIXME
878 "&%%(and (diary-anniversary 19 9 2003)) 09:00-11:30 rrule yearly" ;FIXME 927 "&%%(and (diary-anniversary 19 9 2003)) 09:00-11:30 rrule yearly" ;FIXME
879 "&%%(and (diary-anniversary 9 19 2003)) 09:00-11:30 rrule yearly") ;FIXME 928 "&%%(and (diary-anniversary 9 19 2003)) 09:00-11:30 rrule yearly") ;FIXME
880 (icalendar-testsuite--test-import 929 (icalendar-tests--test-import
881 "SUMMARY:rrule count daily short 930 "SUMMARY:rrule count daily short
882DTSTART;VALUE=DATE-TIME:20030919T090000 931DTSTART;VALUE=DATE-TIME:20030919T090000
883DTEND;VALUE=DATE-TIME:20030919T113000 932DTEND;VALUE=DATE-TIME:20030919T113000
@@ -886,7 +935,7 @@ RRULE:FREQ=DAILY;COUNT=1;INTERVAL=1
886 "&%%(and (diary-cyclic 1 2003 9 19) (diary-block 2003 9 19 2003 9 19)) 09:00-11:30 rrule count daily short" 935 "&%%(and (diary-cyclic 1 2003 9 19) (diary-block 2003 9 19 2003 9 19)) 09:00-11:30 rrule count daily short"
887 "&%%(and (diary-cyclic 1 19 9 2003) (diary-block 19 9 2003 19 9 2003)) 09:00-11:30 rrule count daily short" 936 "&%%(and (diary-cyclic 1 19 9 2003) (diary-block 19 9 2003 19 9 2003)) 09:00-11:30 rrule count daily short"
888 "&%%(and (diary-cyclic 1 9 19 2003) (diary-block 9 19 2003 9 19 2003)) 09:00-11:30 rrule count daily short") 937 "&%%(and (diary-cyclic 1 9 19 2003) (diary-block 9 19 2003 9 19 2003)) 09:00-11:30 rrule count daily short")
889 (icalendar-testsuite--test-import 938 (icalendar-tests--test-import
890 "SUMMARY:rrule count daily long 939 "SUMMARY:rrule count daily long
891DTSTART;VALUE=DATE-TIME:20030919T090000 940DTSTART;VALUE=DATE-TIME:20030919T090000
892DTEND;VALUE=DATE-TIME:20030919T113000 941DTEND;VALUE=DATE-TIME:20030919T113000
@@ -895,7 +944,7 @@ RRULE:FREQ=DAILY;COUNT=14;INTERVAL=1
895 "&%%(and (diary-cyclic 1 2003 9 19) (diary-block 2003 9 19 2003 10 2)) 09:00-11:30 rrule count daily long" 944 "&%%(and (diary-cyclic 1 2003 9 19) (diary-block 2003 9 19 2003 10 2)) 09:00-11:30 rrule count daily long"
896 "&%%(and (diary-cyclic 1 19 9 2003) (diary-block 19 9 2003 2 10 2003)) 09:00-11:30 rrule count daily long" 945 "&%%(and (diary-cyclic 1 19 9 2003) (diary-block 19 9 2003 2 10 2003)) 09:00-11:30 rrule count daily long"
897 "&%%(and (diary-cyclic 1 9 19 2003) (diary-block 9 19 2003 10 2 2003)) 09:00-11:30 rrule count daily long") 946 "&%%(and (diary-cyclic 1 9 19 2003) (diary-block 9 19 2003 10 2 2003)) 09:00-11:30 rrule count daily long")
898 (icalendar-testsuite--test-import 947 (icalendar-tests--test-import
899 "SUMMARY:rrule count bi-weekly 3 times 948 "SUMMARY:rrule count bi-weekly 3 times
900DTSTART;VALUE=DATE-TIME:20030919T090000 949DTSTART;VALUE=DATE-TIME:20030919T090000
901DTEND;VALUE=DATE-TIME:20030919T113000 950DTEND;VALUE=DATE-TIME:20030919T113000
@@ -904,7 +953,7 @@ RRULE:FREQ=WEEKLY;COUNT=3;INTERVAL=2
904 "&%%(and (diary-cyclic 14 2003 9 19) (diary-block 2003 9 19 2003 10 31)) 09:00-11:30 rrule count bi-weekly 3 times" 953 "&%%(and (diary-cyclic 14 2003 9 19) (diary-block 2003 9 19 2003 10 31)) 09:00-11:30 rrule count bi-weekly 3 times"
905 "&%%(and (diary-cyclic 14 19 9 2003) (diary-block 19 9 2003 31 10 2003)) 09:00-11:30 rrule count bi-weekly 3 times" 954 "&%%(and (diary-cyclic 14 19 9 2003) (diary-block 19 9 2003 31 10 2003)) 09:00-11:30 rrule count bi-weekly 3 times"
906 "&%%(and (diary-cyclic 14 9 19 2003) (diary-block 9 19 2003 10 31 2003)) 09:00-11:30 rrule count bi-weekly 3 times") 955 "&%%(and (diary-cyclic 14 9 19 2003) (diary-block 9 19 2003 10 31 2003)) 09:00-11:30 rrule count bi-weekly 3 times")
907 (icalendar-testsuite--test-import 956 (icalendar-tests--test-import
908 "SUMMARY:rrule count monthly 957 "SUMMARY:rrule count monthly
909DTSTART;VALUE=DATE-TIME:20030919T090000 958DTSTART;VALUE=DATE-TIME:20030919T090000
910DTEND;VALUE=DATE-TIME:20030919T113000 959DTEND;VALUE=DATE-TIME:20030919T113000
@@ -913,7 +962,7 @@ RRULE:FREQ=MONTHLY;INTERVAL=1;COUNT=5
913 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2004 1 19)) 09:00-11:30 rrule count monthly" 962 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2004 1 19)) 09:00-11:30 rrule count monthly"
914 "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 19 1 2004)) 09:00-11:30 rrule count monthly" 963 "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 19 1 2004)) 09:00-11:30 rrule count monthly"
915 "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 1 19 2004)) 09:00-11:30 rrule count monthly") 964 "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 1 19 2004)) 09:00-11:30 rrule count monthly")
916 (icalendar-testsuite--test-import 965 (icalendar-tests--test-import
917 "SUMMARY:rrule count every second month 966 "SUMMARY:rrule count every second month
918DTSTART;VALUE=DATE-TIME:20030919T090000 967DTSTART;VALUE=DATE-TIME:20030919T090000
919DTEND;VALUE=DATE-TIME:20030919T113000 968DTEND;VALUE=DATE-TIME:20030919T113000
@@ -922,7 +971,7 @@ RRULE:FREQ=MONTHLY;INTERVAL=2;COUNT=5
922 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2004 5 19)) 09:00-11:30 rrule count every second month" ;FIXME 971 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2004 5 19)) 09:00-11:30 rrule count every second month" ;FIXME
923 "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 19 5 2004)) 09:00-11:30 rrule count every second month" ;FIXME 972 "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 19 5 2004)) 09:00-11:30 rrule count every second month" ;FIXME
924 "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 5 19 2004)) 09:00-11:30 rrule count every second month") ;FIXME 973 "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 5 19 2004)) 09:00-11:30 rrule count every second month") ;FIXME
925 (icalendar-testsuite--test-import 974 (icalendar-tests--test-import
926 "SUMMARY:rrule count yearly 975 "SUMMARY:rrule count yearly
927DTSTART;VALUE=DATE-TIME:20030919T090000 976DTSTART;VALUE=DATE-TIME:20030919T090000
928DTEND;VALUE=DATE-TIME:20030919T113000 977DTEND;VALUE=DATE-TIME:20030919T113000
@@ -931,7 +980,7 @@ RRULE:FREQ=YEARLY;INTERVAL=1;COUNT=5
931 "&%%(and (diary-date t 9 19) (diary-block 2003 9 19 2007 9 19)) 09:00-11:30 rrule count yearly" 980 "&%%(and (diary-date t 9 19) (diary-block 2003 9 19 2007 9 19)) 09:00-11:30 rrule count yearly"
932 "&%%(and (diary-date 19 9 t) (diary-block 19 9 2003 19 9 2007)) 09:00-11:30 rrule count yearly" 981 "&%%(and (diary-date 19 9 t) (diary-block 19 9 2003 19 9 2007)) 09:00-11:30 rrule count yearly"
933 "&%%(and (diary-date 9 19 t) (diary-block 9 19 2003 9 19 2007)) 09:00-11:30 rrule count yearly") 982 "&%%(and (diary-date 9 19 t) (diary-block 9 19 2003 9 19 2007)) 09:00-11:30 rrule count yearly")
934 (icalendar-testsuite--test-import 983 (icalendar-tests--test-import
935 "SUMMARY:rrule count every second year 984 "SUMMARY:rrule count every second year
936DTSTART;VALUE=DATE-TIME:20030919T090000 985DTSTART;VALUE=DATE-TIME:20030919T090000
937DTEND;VALUE=DATE-TIME:20030919T113000 986DTEND;VALUE=DATE-TIME:20030919T113000
@@ -940,9 +989,11 @@ RRULE:FREQ=YEARLY;INTERVAL=2;COUNT=5
940 "&%%(and (diary-date t 9 19) (diary-block 2003 9 19 2011 9 19)) 09:00-11:30 rrule count every second year" ;FIXME!!! 989 "&%%(and (diary-date t 9 19) (diary-block 2003 9 19 2011 9 19)) 09:00-11:30 rrule count every second year" ;FIXME!!!
941 "&%%(and (diary-date 19 9 t) (diary-block 19 9 2003 19 9 2011)) 09:00-11:30 rrule count every second year" ;FIXME!!! 990 "&%%(and (diary-date 19 9 t) (diary-block 19 9 2003 19 9 2011)) 09:00-11:30 rrule count every second year" ;FIXME!!!
942 "&%%(and (diary-date 9 19 t) (diary-block 9 19 2003 9 19 2011)) 09:00-11:30 rrule count every second year") ;FIXME!!! 991 "&%%(and (diary-date 9 19 t) (diary-block 9 19 2003 9 19 2011)) 09:00-11:30 rrule count every second year") ;FIXME!!!
992)
943 993
994(ert-deftest icalendar-import-duration ()
944 ;; duration 995 ;; duration
945 (icalendar-testsuite--test-import 996 (icalendar-tests--test-import
946 "DTSTART;VALUE=DATE:20050217 997 "DTSTART;VALUE=DATE:20050217
947SUMMARY:duration 998SUMMARY:duration
948DURATION:P7D 999DURATION:P7D
@@ -950,8 +1001,7 @@ DURATION:P7D
950 "&%%(and (diary-block 2005 2 17 2005 2 23)) duration" 1001 "&%%(and (diary-block 2005 2 17 2005 2 23)) duration"
951 "&%%(and (diary-block 17 2 2005 23 2 2005)) duration" 1002 "&%%(and (diary-block 17 2 2005 23 2 2005)) duration"
952 "&%%(and (diary-block 2 17 2005 2 23 2005)) duration") 1003 "&%%(and (diary-block 2 17 2005 2 23 2005)) duration")
953 1004 (icalendar-tests--test-import
954 (icalendar-testsuite--test-import
955 "UID:20041127T183329Z-18215-1001-4536-49109@andromeda 1005 "UID:20041127T183329Z-18215-1001-4536-49109@andromeda
956DTSTAMP:20041127T183315Z 1006DTSTAMP:20041127T183315Z
957LAST-MODIFIED:20041127T183329 1007LAST-MODIFIED:20041127T183329
@@ -968,10 +1018,11 @@ CREATED:20041127T183329
968 "&%%(and (diary-cyclic 1 21 12 2001) (diary-block 21 12 2001 29 12 2001)) Urlaub 1018 "&%%(and (diary-cyclic 1 21 12 2001) (diary-block 21 12 2001 29 12 2001)) Urlaub
969 Class: PUBLIC" 1019 Class: PUBLIC"
970 "&%%(and (diary-cyclic 1 12 21 2001) (diary-block 12 21 2001 12 29 2001)) Urlaub 1020 "&%%(and (diary-cyclic 1 12 21 2001) (diary-block 12 21 2001 12 29 2001)) Urlaub
971 Class: PUBLIC") 1021 Class: PUBLIC"))
972 1022
1023(ert-deftest icalendar-import-bug-6766 ()
973 ;;bug#6766 -- multiple byday values in a weekly rrule 1024 ;;bug#6766 -- multiple byday values in a weekly rrule
974 (icalendar-testsuite--test-import 1025 (icalendar-tests--test-import
975"CLASS:PUBLIC 1026"CLASS:PUBLIC
976DTEND;TZID=America/New_York:20100421T120000 1027DTEND;TZID=America/New_York:20100421T120000
977DTSTAMP:20100525T141214Z 1028DTSTAMP:20100525T141214Z
@@ -1010,160 +1061,97 @@ UID:8814e3f9-7482-408f-996c-3bfe486a1263
1010 Status: CONFIRMED 1061 Status: CONFIRMED
1011 Class: PUBLIC 1062 Class: PUBLIC
1012&%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 4 22 2010)) Tues + Thurs thinking 1063&%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 4 22 2010)) Tues + Thurs thinking
1013 Class: PUBLIC") 1064 Class: PUBLIC"))
1014) 1065
1015 1066
1016;; ====================================================================== 1067;; ======================================================================
1017;; Export tests 1068;; Cycle
1018;; ====================================================================== 1069;; ======================================================================
1019(defun icalendar-testsuite--run-export-tests () 1070(defun icalendar-tests--test-cycle (input)
1020 "Perform standard export tests." 1071 "Perform cycle test.
1021 1072Argument INPUT icalendar event string."
1022 (let ((icalendar-export-hidden-diary-entries nil)) 1073 (with-temp-buffer
1023 (icalendar-testsuite--test-export 1074 (if (string-match "^BEGIN:VCALENDAR" input)
1024 "&2000 Oct 3 ordinary no time " 1075 (insert input)
1025 "&3 Okt 2000 ordinary no time " 1076 (insert "BEGIN:VCALENDAR\nPRODID:-//Emacs//NONSGML icalendar.el//EN\n")
1026 "&Oct 3 2000 ordinary no time " 1077 (insert "VERSION:2.0\nBEGIN:VEVENT\n")
1027 nil)) 1078 (insert input)
1028 1079 (unless (eq (char-before) ?\n)
1029 ;; "ordinary" events 1080 (insert "\n"))
1030 (icalendar-testsuite--test-export 1081 (insert "END:VEVENT\nEND:VCALENDAR\n"))
1031 "2000 Oct 3 ordinary no time " 1082 (let ((icalendar-import-format "%s%d%l%o%t%u%c")
1032 "3 Okt 2000 ordinary no time " 1083 (icalendar-import-format-summary "%s")
1033 "Oct 3 2000 ordinary no time " 1084 (icalendar-import-format-location "\n Location: %s")
1034 "DTSTART;VALUE=DATE:20001003 1085 (icalendar-import-format-description "\n Desc: %s")
1035DTEND;VALUE=DATE:20001004 1086 (icalendar-import-format-organizer "\n Organizer: %s")
1036SUMMARY:ordinary no time 1087 (icalendar-import-format-status "\n Status: %s")
1037") 1088 (icalendar-import-format-url "\n URL: %s")
1038 (icalendar-testsuite--test-export 1089 (icalendar-import-format-class "\n Class: %s"))
1039 "2000 Oct 3 16:30 ordinary with time" 1090 (dolist (calendar-date-style '(iso european american))
1040 "3 Okt 2000 16:30 ordinary with time" 1091 (icalendar-tests--do-test-cycle)))))
1041 "Oct 3 2000 16:30 ordinary with time"
1042 "DTSTART;VALUE=DATE-TIME:20001003T163000
1043DTEND;VALUE=DATE-TIME:20001003T173000
1044SUMMARY:ordinary with time
1045")
1046 (icalendar-testsuite--test-export
1047 "2000 10 3 16:30 ordinary with time 2"
1048 "3 10 2000 16:30 ordinary with time 2"
1049 "10 3 2000 16:30 ordinary with time 2"
1050 "DTSTART;VALUE=DATE-TIME:20001003T163000
1051DTEND;VALUE=DATE-TIME:20001003T173000
1052SUMMARY:ordinary with time 2
1053")
1054
1055 (icalendar-testsuite--test-export
1056 "2000/10/3 16:30 ordinary with time 3"
1057 "3/10/2000 16:30 ordinary with time 3"
1058 "10/3/2000 16:30 ordinary with time 3"
1059 "DTSTART;VALUE=DATE-TIME:20001003T163000
1060DTEND;VALUE=DATE-TIME:20001003T173000
1061SUMMARY:ordinary with time 3
1062")
1063
1064 ;; multiline -- FIXME!!!
1065 (icalendar-testsuite--test-export
1066 "2000 October 3 16:30 multiline
1067 17:30 multiline continued FIXME"
1068 "3 Oktober 2000 16:30 multiline
1069 17:30 multiline continued FIXME"
1070 "October 3 2000 16:30 multiline
1071 17:30 multiline continued FIXME"
1072 "DTSTART;VALUE=DATE-TIME:20001003T163000
1073DTEND;VALUE=DATE-TIME:20001003T173000
1074SUMMARY:multiline
1075DESCRIPTION:
1076 17:30 multiline continued FIXME
1077")
1078
1079 ;; weekly by day
1080 (icalendar-testsuite--test-export
1081 "Monday 1:30pm weekly by day with start time"
1082 "Montag 13:30 weekly by day with start time"
1083 "Monday 1:30pm weekly by day with start time"
1084 "DTSTART;VALUE=DATE-TIME:20000103T133000
1085DTEND;VALUE=DATE-TIME:20000103T143000
1086RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1087SUMMARY:weekly by day with start time
1088")
1089
1090 (icalendar-testsuite--test-export
1091 "Monday 13:30-15:00 weekly by day with start and end time"
1092 "Montag 13:30-15:00 weekly by day with start and end time"
1093 "Monday 01:30pm-03:00pm weekly by day with start and end time"
1094 "DTSTART;VALUE=DATE-TIME:20000103T133000
1095DTEND;VALUE=DATE-TIME:20000103T150000
1096RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1097SUMMARY:weekly by day with start and end time
1098")
1099
1100 ;; yearly
1101 (icalendar-testsuite--test-export
1102 "may 1 yearly no time"
1103 "1 Mai yearly no time"
1104 "may 1 yearly no time"
1105 "DTSTART;VALUE=DATE:19000501
1106DTEND;VALUE=DATE:19000502
1107RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=5;BYMONTHDAY=1
1108SUMMARY:yearly no time
1109")
1110 1092
1111 ;; anniversaries 1093(defun icalendar-tests--do-test-cycle ()
1112 (icalendar-testsuite--test-export 1094 "Actually perform import/export cycle test."
1113 "%%(diary-anniversary 1989 10 3) anniversary no time" 1095 (let ((temp-diary (make-temp-file "icalendar-test-diary"))
1114 "%%(diary-anniversary 3 10 1989) anniversary no time" 1096 (temp-ics (make-temp-file "icalendar-test-ics"))
1115 "%%(diary-anniversary 10 3 1989) anniversary no time" 1097 (org-input (buffer-substring-no-properties (point-min) (point-max))))
1116 "DTSTART;VALUE=DATE:19891003
1117DTEND;VALUE=DATE:19891004
1118RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=10;BYMONTHDAY=03
1119SUMMARY:anniversary no time
1120")
1121 (icalendar-testsuite--test-export
1122 "%%(diary-anniversary 1989 10 3) 19:00-20:00 anniversary with time"
1123 "%%(diary-anniversary 3 10 1989) 19:00-20:00 anniversary with time"
1124 "%%(diary-anniversary 10 3 1989) 19:00-20:00 anniversary with time"
1125 "DTSTART;VALUE=DATE-TIME:19891003T190000
1126DTEND;VALUE=DATE-TIME:19891004T200000
1127RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=10;BYMONTHDAY=03
1128SUMMARY:anniversary with time
1129")
1130 1098
1131 ;; block 1099 (unwind-protect
1132 (icalendar-testsuite--test-export 1100 (progn
1133 "%%(diary-block 2001 6 18 2001 7 6) block no time" 1101 ;; step 1: import
1134 "%%(diary-block 18 6 2001 6 7 2001) block no time" 1102 (icalendar-import-buffer temp-diary t t)
1135 "%%(diary-block 6 18 2001 7 6 2001) block no time" 1103
1136 "DTSTART;VALUE=DATE:20010618 1104 ;; step 2: export what was just imported
1137DTEND;VALUE=DATE:20010707 1105 (save-excursion
1138SUMMARY:block no time 1106 (find-file temp-diary)
1139") 1107 (icalendar-export-region (point-min) (point-max) temp-ics))
1140 (icalendar-testsuite--test-export 1108
1141 "%%(diary-block 2001 6 18 2001 7 6) 13:00-17:00 block with time" 1109 ;; compare the output of step 2 with the input of step 1
1142 "%%(diary-block 18 6 2001 6 7 2001) 13:00-17:00 block with time" 1110 (save-excursion
1143 "%%(diary-block 6 18 2001 7 6 2001) 13:00-17:00 block with time" 1111 (find-file temp-ics)
1144 "DTSTART;VALUE=DATE-TIME:20010618T130000 1112 (goto-char (point-min))
1145DTEND;VALUE=DATE-TIME:20010618T170000 1113 (when (re-search-forward "\nUID:.*\n" nil t)
1146RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20010706 1114 (replace-match "\n"))
1147SUMMARY:block with time 1115 (let ((cycled (buffer-substring-no-properties (point-min) (point-max))))
1116 (should (icalendar-tests--compare-strings cycled org-input)))))
1117 ;; clean up
1118 (kill-buffer (find-buffer-visiting temp-diary))
1119 (save-excursion
1120 (set-buffer (find-buffer-visiting temp-ics))
1121 (set-buffer-modified-p nil)
1122 (kill-buffer (current-buffer)))
1123 (delete-file temp-diary)
1124 (delete-file temp-ics))))
1125
1126(ert-deftest icalendar-cycle ()
1127 "Perform cycling tests."
1128 (icalendar-tests--test-cycle
1129 "DTSTART;VALUE=DATE-TIME:20030919T090000
1130DTEND;VALUE=DATE-TIME:20030919T113000
1131SUMMARY:Cycletest
1148") 1132")
1149 (icalendar-testsuite--test-export 1133 (icalendar-tests--test-cycle
1150 "%%(diary-block 2001 6 18 2001 7 6) 13:00 block no end time" 1134 "DTSTART;VALUE=DATE-TIME:20030919T090000
1151 "%%(diary-block 18 6 2001 6 7 2001) 13:00 block no end time" 1135DTEND;VALUE=DATE-TIME:20030919T113000
1152 "%%(diary-block 6 18 2001 7 6 2001) 13:00 block no end time" 1136SUMMARY:Cycletest
1153 "DTSTART;VALUE=DATE-TIME:20010618T130000 1137DESCRIPTION:beschreibung!
1154DTEND;VALUE=DATE-TIME:20010618T140000 1138LOCATION:nowhere
1155RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20010706 1139ORGANIZER:ulf
1156SUMMARY:block no end time
1157") 1140")
1158 ) 1141 (icalendar-tests--test-cycle
1142 "DTSTART;VALUE=DATE:19190909
1143DTEND;VALUE=DATE:19190910
1144RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=09;BYMONTHDAY=09
1145SUMMARY:and diary-anniversary
1146"))
1159 1147
1160;; ====================================================================== 1148;; ======================================================================
1161;; Real world 1149;; Real world
1162;; ====================================================================== 1150;; ======================================================================
1163(defun icalendar-testsuite--run-real-world-tests () 1151(ert-deftest icalendar-real-world ()
1164 "Perform real-world tests, as gathered from problem reports." 1152 "Perform real-world tests, as gathered from problem reports."
1165 ;; 2003-05-29 1153 ;; 2003-05-29
1166 (icalendar-testsuite--test-import 1154 (icalendar-tests--test-import
1167 "BEGIN:VCALENDAR 1155 "BEGIN:VCALENDAR
1168METHOD:REQUEST 1156METHOD:REQUEST
1169PRODID:Microsoft CDO for Microsoft Exchange 1157PRODID:Microsoft CDO for Microsoft Exchange
@@ -1231,7 +1219,7 @@ END:VCALENDAR"
1231 Status: CONFIRMED") 1219 Status: CONFIRMED")
1232 1220
1233 ;; 2003-06-18 a 1221 ;; 2003-06-18 a
1234 (icalendar-testsuite--test-import 1222 (icalendar-tests--test-import
1235 "DTSTAMP:20030618T195512Z 1223 "DTSTAMP:20030618T195512Z
1236DTSTART;TZID=\"Mountain Time (US & Canada)\":20030623T110000 1224DTSTART;TZID=\"Mountain Time (US & Canada)\":20030623T110000
1237SUMMARY:Dress Rehearsal for XXXX-XXXX 1225SUMMARY:Dress Rehearsal for XXXX-XXXX
@@ -1273,9 +1261,8 @@ END:VALARM"
1273 Location: 555 or TN 555-5555 ID 5555 & NochWas (see below) 1261 Location: 555 or TN 555-5555 ID 5555 & NochWas (see below)
1274 Organizer: MAILTO:xxx@xxxxx.com 1262 Organizer: MAILTO:xxx@xxxxx.com
1275 Status: CONFIRMED") 1263 Status: CONFIRMED")
1276
1277 ;; 2003-06-18 b -- uses timezone 1264 ;; 2003-06-18 b -- uses timezone
1278 (icalendar-testsuite--test-import 1265 (icalendar-tests--test-import
1279 "BEGIN:VCALENDAR 1266 "BEGIN:VCALENDAR
1280METHOD:REQUEST 1267METHOD:REQUEST
1281PRODID:Microsoft CDO for Microsoft Exchange 1268PRODID:Microsoft CDO for Microsoft Exchange
@@ -1342,9 +1329,8 @@ END:VCALENDAR"
1342 Location: 123 or TN 123-1234 ID abcd & SonstWo (see below) 1329 Location: 123 or TN 123-1234 ID abcd & SonstWo (see below)
1343 Organizer: MAILTO:bbb@bbbbb.com 1330 Organizer: MAILTO:bbb@bbbbb.com
1344 Status: CONFIRMED") 1331 Status: CONFIRMED")
1345
1346 ;; export 2004-10-28 block entries 1332 ;; export 2004-10-28 block entries
1347 (icalendar-testsuite--test-export 1333 (icalendar-tests--test-export
1348 nil 1334 nil
1349 nil 1335 nil
1350 "-*- mode: text; fill-column: 256;-*- 1336 "-*- mode: text; fill-column: 256;-*-
@@ -1357,7 +1343,7 @@ END:VCALENDAR"
1357DTEND;VALUE=DATE:20041111 1343DTEND;VALUE=DATE:20041111
1358SUMMARY:Nov 8-10 aa") 1344SUMMARY:Nov 8-10 aa")
1359 1345
1360 (icalendar-testsuite--test-export 1346 (icalendar-tests--test-export
1361 nil 1347 nil
1362 nil 1348 nil
1363 "%%(diary-block 12 13 2004 12 17 2004) Dec 13-17 bb" 1349 "%%(diary-block 12 13 2004 12 17 2004) Dec 13-17 bb"
@@ -1365,7 +1351,7 @@ SUMMARY:Nov 8-10 aa")
1365DTEND;VALUE=DATE:20041218 1351DTEND;VALUE=DATE:20041218
1366SUMMARY:Dec 13-17 bb") 1352SUMMARY:Dec 13-17 bb")
1367 1353
1368 (icalendar-testsuite--test-export 1354 (icalendar-tests--test-export
1369 nil 1355 nil
1370 nil 1356 nil
1371 "%%(diary-block 2 3 2005 2 4 2005) Feb 3-4 cc" 1357 "%%(diary-block 2 3 2005 2 4 2005) Feb 3-4 cc"
@@ -1373,7 +1359,7 @@ SUMMARY:Dec 13-17 bb")
1373DTEND;VALUE=DATE:20050205 1359DTEND;VALUE=DATE:20050205
1374SUMMARY:Feb 3-4 cc") 1360SUMMARY:Feb 3-4 cc")
1375 1361
1376 (icalendar-testsuite--test-export 1362 (icalendar-tests--test-export
1377 nil 1363 nil
1378 nil 1364 nil
1379 "%%(diary-block 4 24 2005 4 29 2005) April 24-29 dd" 1365 "%%(diary-block 4 24 2005 4 29 2005) April 24-29 dd"
@@ -1381,7 +1367,7 @@ SUMMARY:Feb 3-4 cc")
1381DTEND;VALUE=DATE:20050430 1367DTEND;VALUE=DATE:20050430
1382SUMMARY:April 24-29 dd 1368SUMMARY:April 24-29 dd
1383") 1369")
1384 (icalendar-testsuite--test-export 1370 (icalendar-tests--test-export
1385 nil 1371 nil
1386 nil 1372 nil
1387 "%%(diary-block 5 30 2005 6 1 2005) may 30 - June 1: ee" 1373 "%%(diary-block 5 30 2005 6 1 2005) may 30 - June 1: ee"
@@ -1389,16 +1375,16 @@ SUMMARY:April 24-29 dd
1389DTEND;VALUE=DATE:20050602 1375DTEND;VALUE=DATE:20050602
1390SUMMARY:may 30 - June 1: ee") 1376SUMMARY:may 30 - June 1: ee")
1391 1377
1392 (icalendar-testsuite--test-export 1378 (icalendar-tests--test-export
1393 nil 1379 nil
1394 nil 1380 nil
1395 "%%(diary-block 6 6 2005 6 8 2005) ff" 1381 "%%(diary-block 6 6 2005 6 8 2005) ff"
1396 "DTSTART;VALUE=DATE:20050606 1382 "DTSTART;VALUE=DATE:20050606
1397DTEND;VALUE=DATE:20050609 1383DTEND;VALUE=DATE:20050609
1398SUMMARY:ff") 1384SUMMARY:ff")
1399 1385
1400 ;; export 2004-10-28 anniversary entries 1386 ;; export 2004-10-28 anniversary entries
1401 (icalendar-testsuite--test-export 1387 (icalendar-tests--test-export
1402 nil 1388 nil
1403 nil 1389 nil
1404 " 1390 "
@@ -1411,7 +1397,7 @@ RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=03;BYMONTHDAY=28
1411SUMMARY:aa birthday (%d years old) 1397SUMMARY:aa birthday (%d years old)
1412") 1398")
1413 1399
1414 (icalendar-testsuite--test-export 1400 (icalendar-tests--test-export
1415 nil 1401 nil
1416 nil 1402 nil
1417 "%%(diary-anniversary 5 17 1957) bb birthday (%d years old)" 1403 "%%(diary-anniversary 5 17 1957) bb birthday (%d years old)"
@@ -1420,7 +1406,7 @@ DTEND;VALUE=DATE:19570518
1420RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=05;BYMONTHDAY=17 1406RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=05;BYMONTHDAY=17
1421SUMMARY:bb birthday (%d years old)") 1407SUMMARY:bb birthday (%d years old)")
1422 1408
1423 (icalendar-testsuite--test-export 1409 (icalendar-tests--test-export
1424 nil 1410 nil
1425 nil 1411 nil
1426 "%%(diary-anniversary 6 8 1997) cc birthday (%d years old)" 1412 "%%(diary-anniversary 6 8 1997) cc birthday (%d years old)"
@@ -1429,7 +1415,7 @@ DTEND;VALUE=DATE:19970609
1429RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=06;BYMONTHDAY=08 1415RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=06;BYMONTHDAY=08
1430SUMMARY:cc birthday (%d years old)") 1416SUMMARY:cc birthday (%d years old)")
1431 1417
1432 (icalendar-testsuite--test-export 1418 (icalendar-tests--test-export
1433 nil 1419 nil
1434 nil 1420 nil
1435 "%%(diary-anniversary 7 22 1983) dd (%d years ago...!)" 1421 "%%(diary-anniversary 7 22 1983) dd (%d years ago...!)"
@@ -1438,7 +1424,7 @@ DTEND;VALUE=DATE:19830723
1438RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=07;BYMONTHDAY=22 1424RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=07;BYMONTHDAY=22
1439SUMMARY:dd (%d years ago...!)") 1425SUMMARY:dd (%d years ago...!)")
1440 1426
1441 (icalendar-testsuite--test-export 1427 (icalendar-tests--test-export
1442 nil 1428 nil
1443 nil 1429 nil
1444 "%%(diary-anniversary 8 1 1988) ee birthday (%d years old)" 1430 "%%(diary-anniversary 8 1 1988) ee birthday (%d years old)"
@@ -1447,7 +1433,7 @@ DTEND;VALUE=DATE:19880802
1447RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=08;BYMONTHDAY=01 1433RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=08;BYMONTHDAY=01
1448SUMMARY:ee birthday (%d years old)") 1434SUMMARY:ee birthday (%d years old)")
1449 1435
1450 (icalendar-testsuite--test-export 1436 (icalendar-tests--test-export
1451 nil 1437 nil
1452 nil 1438 nil
1453 "%%(diary-anniversary 9 21 1957) ff birthday (%d years old)" 1439 "%%(diary-anniversary 9 21 1957) ff birthday (%d years old)"
@@ -1461,7 +1447,7 @@ SUMMARY:ff birthday (%d years old)")
1461 1447
1462 ;; export 2004-10-28 monthly, weekly entries 1448 ;; export 2004-10-28 monthly, weekly entries
1463 1449
1464 ;; (icalendar-testsuite--test-export 1450 ;; (icalendar-tests--test-export
1465 ;; nil 1451 ;; nil
1466 ;; " 1452 ;; "
1467 ;; >>> ------------ monthly: 1453 ;; >>> ------------ monthly:
@@ -1469,7 +1455,7 @@ SUMMARY:ff birthday (%d years old)")
1469 ;; */27/* 10:00 blah blah" 1455 ;; */27/* 10:00 blah blah"
1470 ;; "xxx") 1456 ;; "xxx")
1471 1457
1472 (icalendar-testsuite--test-export 1458 (icalendar-tests--test-export
1473 nil 1459 nil
1474 nil 1460 nil
1475 ">>> ------------ my week: 1461 ">>> ------------ my week:
@@ -1480,7 +1466,7 @@ DTEND;VALUE=DATE-TIME:20000103T140000
1480RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO 1466RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1481SUMMARY:MAC") 1467SUMMARY:MAC")
1482 1468
1483 (icalendar-testsuite--test-export 1469 (icalendar-tests--test-export
1484 nil 1470 nil
1485 nil 1471 nil
1486 "Monday 15:00 a1" 1472 "Monday 15:00 a1"
@@ -1490,7 +1476,7 @@ RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1490SUMMARY:a1") 1476SUMMARY:a1")
1491 1477
1492 1478
1493 (icalendar-testsuite--test-export 1479 (icalendar-tests--test-export
1494 nil 1480 nil
1495 nil 1481 nil
1496 "Monday 16:00-17:00 a2" 1482 "Monday 16:00-17:00 a2"
@@ -1499,7 +1485,7 @@ DTEND;VALUE=DATE-TIME:20000103T170000
1499RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO 1485RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1500SUMMARY:a2") 1486SUMMARY:a2")
1501 1487
1502 (icalendar-testsuite--test-export 1488 (icalendar-tests--test-export
1503 nil 1489 nil
1504 nil 1490 nil
1505 "Tuesday 11:30-13:00 a3" 1491 "Tuesday 11:30-13:00 a3"
@@ -1508,7 +1494,7 @@ DTEND;VALUE=DATE-TIME:20000104T130000
1508RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU 1494RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU
1509SUMMARY:a3") 1495SUMMARY:a3")
1510 1496
1511 (icalendar-testsuite--test-export 1497 (icalendar-tests--test-export
1512 nil 1498 nil
1513 nil 1499 nil
1514 "Tuesday 15:00 a4" 1500 "Tuesday 15:00 a4"
@@ -1517,7 +1503,7 @@ DTEND;VALUE=DATE-TIME:20000104T160000
1517RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU 1503RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU
1518SUMMARY:a4") 1504SUMMARY:a4")
1519 1505
1520 (icalendar-testsuite--test-export 1506 (icalendar-tests--test-export
1521 nil 1507 nil
1522 nil 1508 nil
1523 "Wednesday 13:00 a5" 1509 "Wednesday 13:00 a5"
@@ -1526,7 +1512,7 @@ DTEND;VALUE=DATE-TIME:20000105T140000
1526RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE 1512RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE
1527SUMMARY:a5") 1513SUMMARY:a5")
1528 1514
1529 (icalendar-testsuite--test-export 1515 (icalendar-tests--test-export
1530 nil 1516 nil
1531 nil 1517 nil
1532 "Wednesday 11:30-13:30 a6" 1518 "Wednesday 11:30-13:30 a6"
@@ -1535,7 +1521,7 @@ DTEND;VALUE=DATE-TIME:20000105T133000
1535RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE 1521RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE
1536SUMMARY:a6") 1522SUMMARY:a6")
1537 1523
1538 (icalendar-testsuite--test-export 1524 (icalendar-tests--test-export
1539 nil 1525 nil
1540 nil 1526 nil
1541 "Wednesday 15:00 s1" 1527 "Wednesday 15:00 s1"
@@ -1546,7 +1532,7 @@ SUMMARY:s1")
1546 1532
1547 1533
1548 ;; export 2004-10-28 regular entries 1534 ;; export 2004-10-28 regular entries
1549 (icalendar-testsuite--test-export 1535 (icalendar-tests--test-export
1550 nil 1536 nil
1551 nil 1537 nil
1552 " 1538 "
@@ -1558,7 +1544,7 @@ DTEND;VALUE=DATE-TIME:20041012T150000
1558SUMMARY:Tue: [2004-10-12] q1") 1544SUMMARY:Tue: [2004-10-12] q1")
1559 1545
1560 ;; 2004-11-19 1546 ;; 2004-11-19
1561 (icalendar-testsuite--test-import 1547 (icalendar-tests--test-import
1562 "BEGIN:VCALENDAR 1548 "BEGIN:VCALENDAR
1563VERSION 1549VERSION
1564 :2.0 1550 :2.0
@@ -1733,7 +1719,7 @@ END:VCALENDAR
1733 Class: PRIVATE") 1719 Class: PRIVATE")
1734 1720
1735 ;; 2004-09-09 pg 1721 ;; 2004-09-09 pg
1736 (icalendar-testsuite--test-export 1722 (icalendar-tests--test-export
1737 "%%(diary-block 1 1 2004 4 1 2004) Urlaub" 1723 "%%(diary-block 1 1 2004 4 1 2004) Urlaub"
1738 nil 1724 nil
1739 nil 1725 nil
@@ -1742,7 +1728,7 @@ DTEND;VALUE=DATE:20040105
1742SUMMARY:Urlaub") 1728SUMMARY:Urlaub")
1743 1729
1744 ;; 2004-10-25 pg 1730 ;; 2004-10-25 pg
1745 (icalendar-testsuite--test-export 1731 (icalendar-tests--test-export
1746 nil 1732 nil
1747 "5 11 2004 Bla Fasel" 1733 "5 11 2004 Bla Fasel"
1748 nil 1734 nil
@@ -1751,7 +1737,7 @@ DTEND;VALUE=DATE:20041106
1751SUMMARY:Bla Fasel") 1737SUMMARY:Bla Fasel")
1752 1738
1753 ;; 2004-10-30 pg 1739 ;; 2004-10-30 pg
1754 (icalendar-testsuite--test-export 1740 (icalendar-tests--test-export
1755 nil 1741 nil
1756 "2 Nov 2004 15:00-16:30 Zahnarzt" 1742 "2 Nov 2004 15:00-16:30 Zahnarzt"
1757 nil 1743 nil
@@ -1760,7 +1746,7 @@ DTEND;VALUE=DATE-TIME:20041102T163000
1760SUMMARY:Zahnarzt") 1746SUMMARY:Zahnarzt")
1761 1747
1762 ;; 2005-02-07 lt 1748 ;; 2005-02-07 lt
1763 (icalendar-testsuite--test-import 1749 (icalendar-tests--test-import
1764 "UID 1750 "UID
1765 :b60d398e-1dd1-11b2-a159-cf8cb05139f4 1751 :b60d398e-1dd1-11b2-a159-cf8cb05139f4
1766SUMMARY 1752SUMMARY
@@ -1792,7 +1778,7 @@ DTSTAMP
1792 Class: PRIVATE") 1778 Class: PRIVATE")
1793 1779
1794 ;; 2005-03-01 lt 1780 ;; 2005-03-01 lt
1795 (icalendar-testsuite--test-import 1781 (icalendar-tests--test-import
1796 "DTSTART;VALUE=DATE:20050217 1782 "DTSTART;VALUE=DATE:20050217
1797SUMMARY:Hhhhhh Aaaaa ii Aaaaaaaa 1783SUMMARY:Hhhhhh Aaaaa ii Aaaaaaaa
1798UID:6AFA7558-6994-11D9-8A3A-000A95A0E830-RID 1784UID:6AFA7558-6994-11D9-8A3A-000A95A0E830-RID
@@ -1803,7 +1789,7 @@ DURATION:P7D"
1803 "&%%(and (diary-block 2 17 2005 2 23 2005)) Hhhhhh Aaaaa ii Aaaaaaaa") 1789 "&%%(and (diary-block 2 17 2005 2 23 2005)) Hhhhhh Aaaaa ii Aaaaaaaa")
1804 1790
1805 ;; 2005-03-23 lt 1791 ;; 2005-03-23 lt
1806 (icalendar-testsuite--test-export 1792 (icalendar-tests--test-export
1807 nil 1793 nil
1808 "&%%(diary-cyclic 7 8 2 2005) 16:00-16:45 [WORK] Pppp" 1794 "&%%(diary-cyclic 7 8 2 2005) 16:00-16:45 [WORK] Pppp"
1809 nil 1795 nil
@@ -1814,7 +1800,7 @@ SUMMARY:[WORK] Pppp
1814") 1800")
1815 1801
1816 ;; 2005-05-27 eu 1802 ;; 2005-05-27 eu
1817 (icalendar-testsuite--test-export 1803 (icalendar-tests--test-export
1818 nil 1804 nil
1819 nil 1805 nil
1820 ;; FIXME: colon not allowed! 1806 ;; FIXME: colon not allowed!
@@ -1827,32 +1813,5 @@ SUMMARY:NNN Wwwwwwww Wwwww - Aaaaaa Pppppppp rrrrrr ddd oo Nnnnnnnn 30
1827") 1813")
1828 ) 1814 )
1829 1815
1830(defun icalendar-testsuite--run-cycle-tests () 1816(provide 'icalendar-tests)
1831 "Perform cycling tests." 1817;;; icalendar-tests.el ends here
1832 (icalendar-testsuite--test-cycle
1833 "DTSTART;VALUE=DATE-TIME:20030919T090000
1834DTEND;VALUE=DATE-TIME:20030919T113000
1835SUMMARY:Cycletest
1836")
1837
1838 (icalendar-testsuite--test-cycle
1839 "DTSTART;VALUE=DATE-TIME:20030919T090000
1840DTEND;VALUE=DATE-TIME:20030919T113000
1841SUMMARY:Cycletest
1842DESCRIPTION:beschreibung!
1843LOCATION:nowhere
1844ORGANIZER:ulf
1845")
1846
1847 (icalendar-testsuite--test-cycle
1848 "DTSTART;VALUE=DATE:19190909
1849DTEND;VALUE=DATE:19190910
1850RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=09;BYMONTHDAY=09
1851SUMMARY:and diary-anniversary
1852")
1853 )
1854
1855
1856(provide 'icalendar-testsuite)
1857
1858;;; icalendar-testsuite.el ends here