Convert consecutive FSF copyright years to ranges.
[bpt/emacs.git] / test / icalendar-testsuite.el
CommitLineData
7ec01532
GM
1;; icalendar-testsuite.el --- Test suite for icalendar.el
2
73b0cd50 3;; Copyright (C) 2005, 2008-2011 Free Software Foundation, Inc.
7ec01532
GM
4
5;; Author: Ulf Jasper <ulf.jasper@web.de>
6;; Created: March 2005
7;; Keywords: calendar
8;; Human-Keywords: calendar, diary, iCalendar, vCalendar
9
10;; This file is part of GNU Emacs.
11
4f43e937 12;; GNU Emacs is free software: you can redistribute it and/or modify
7ec01532 13;; it under the terms of the GNU General Public License as published by
4f43e937
GM
14;; the Free Software Foundation, either version 3 of the License, or
15;; (at your option) any later version.
7ec01532
GM
16
17;; GNU Emacs is distributed in the hope that it will be useful,
18;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20;; GNU General Public License for more details.
21
22;; You should have received a copy of the GNU General Public License
4f43e937 23;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
7ec01532
GM
24
25;;; Commentary:
26
27;; TODO:
28;; - Add more unit tests for functions, timezone etc.
29
a4766629
GM
30;; Note: Watch the trailing blank that is added on import.
31
7ec01532
GM
32;;; Code:
33(defun icalendar-testsuite-run ()
34 "Run icalendar test suite."
35 (interactive)
81ee9410 36 (icalendar-testsuite--run-internal-tests)
7ec01532
GM
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
81ee9410
UJ
44;; ======================================================================
45;; internal
46;; ======================================================================
47(defun icalendar-testsuite--trim (string)
48 "Remove leading and trailing whitespace from STRING."
49 (replace-regexp-in-string "[ \t\n]+\\'" ""
50 (replace-regexp-in-string "\\`[ \t\n]+" "" string)))
51
52(defun icalendar-testsuite--compare-strings (str1 str2)
53 "Compare strings STR1 and STR2.
54Return t if strings are equal, else return substring indicating first difference.
55FIXME: make this a little smarter."
56 (let* ((s1 (icalendar-testsuite--trim str1))
57 (s2 (icalendar-testsuite--trim str2))
58 (result (compare-strings s1 0 nil s2 0 nil))
59 (len (length str2)))
60 (if (numberp result)
61 (if (> result 0)
62 (concat "..." (substring str2 (- result 1)
63 (min len (+ (- result 1) 3))) "...")
64 (concat "..." (substring str2 (- (+ result 1))
65 (min len (+ (- (+ result 1)) 3))) "..."))
66 t)))
67
68(defun icalendar-testsuite--run-internal-tests ()
69 "Run icalendar-testsuite internal tests."
70 (assert (equal t (icalendar-testsuite--compare-strings " abcde" "abcde ")))
71 (assert
72 (string= "...def..."
73 (icalendar-testsuite--compare-strings "abcxe" "abcdefghijklmn")))
74 (assert (string= "...xe..."
75 (icalendar-testsuite--compare-strings "abcde" "abcxe")))
76 (assert (string= "...ddd..."
77 (icalendar-testsuite--compare-strings "abc" "abcdddddd")))
78 (assert (string= "......"
79 (icalendar-testsuite--compare-strings "abcdefghij" "abc"))))
80
81
7ec01532
GM
82;; ======================================================================
83;; Test methods for functions
84;; ======================================================================
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)
a4766629
GM
90 (icalendar-testsuite--test-first-weekday-of-year)
91 (icalendar-testsuite--test-datestring-to-isodate)
92 (icalendar-testsuite--test-datetime-to-diary-date)
f052351a 93 (icalendar-testsuite--test-diarytime-to-isotime)
b4340b3f
UJ
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)
aad81014 100 (icalendar-testsuite--test-calendar-style)
6fe539d2
UJ
101 (icalendar-testsuite--test-create-uid)
102 (icalendar-testsuite--test-parse-vtimezone))
7ec01532
GM
103
104(defun icalendar-testsuite--test-format-ical-event ()
a4766629 105 "Test `icalendar--format-ical-event'."
7ec01532
GM
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")
7ec01532
GM
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
143(defun icalendar-testsuite--test-parse-summary-and-rest ()
a4766629 144 "Test `icalendar--parse-summary-and-rest'."
7ec01532
GM
145 (let ((icalendar-import-format "%s%d%l%o%t%u%c")
146 (icalendar-import-format-summary "SUM %s")
147 (icalendar-import-format-location " LOC %s")
148 (icalendar-import-format-description " DES %s")
149 (icalendar-import-format-organizer " ORG %s")
150 (icalendar-import-format-status " STA %s")
151 (icalendar-import-format-url " URL %s")
152 (icalendar-import-format-class " CLA %s")
7ec01532 153 (result))
f052351a 154 (setq result (icalendar--parse-summary-and-rest "SUM sum ORG org"))
7ec01532
GM
155 (assert (string= (cdr (assoc 'org result)) "org"))
156
157 (setq result (icalendar--parse-summary-and-rest
f052351a 158 "SUM sum DES des LOC loc ORG org STA sta URL url CLA cla"))
7ec01532
GM
159 (assert (string= (cdr (assoc 'des result)) "des"))
160 (assert (string= (cdr (assoc 'loc result)) "loc"))
161 (assert (string= (cdr (assoc 'org result)) "org"))
162 (assert (string= (cdr (assoc 'sta result)) "sta"))
163 (assert (string= (cdr (assoc 'cla result)) "cla"))
164
165 (setq icalendar-import-format (lambda () "Hello world"))
166 (setq result (icalendar--parse-summary-and-rest
167 "blah blah "))
168 (assert (not result))
169 ))
170
171(defun icalendar-testsuite--get-ical-event (ical-string)
a4766629
GM
172 "Helper function for testing `icalendar-testsuite--test-format-ical-event'.
173Return icalendar event for ICAL-STRING."
7ec01532
GM
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 ()
a4766629 197 "Test method for `icalendar-first-weekday-of-year'."
7ec01532
GM
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
a4766629
GM
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
f052351a
UJ
259(defun icalendar-testsuite--test-diarytime-to-isotime ()
260 "Test method for `icalendar--diarytime-to-isotime'."
b4340b3f
UJ
261 (assert (string= (icalendar--diarytime-to-isotime "01:15" "")
262 "T011500"))
263 (assert (string= (icalendar--diarytime-to-isotime "1:15" "")
264 "T011500"))
265 (assert (string= (icalendar--diarytime-to-isotime "0:01" "")
266 "T000100"))
f052351a
UJ
267 (assert (string= (icalendar--diarytime-to-isotime "0100" "")
268 "T010000"))
269 (assert (string= (icalendar--diarytime-to-isotime "0100" "am")
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
b4340b3f
UJ
290(defun icalendar-testsuite--test-convert-ordinary-to-ical ()
291 "Test method for `icalendar--convert-ordinary-to-ical'."
292 (let* ((calendar-date-style 'iso)
293 result)
294 ;; without time
295 (setq result (icalendar--convert-ordinary-to-ical "&?" "2010 2 15 subject"))
296 (assert (= 2 (length result)))
297 (assert (string= "\nDTSTART;VALUE=DATE:20100215\nDTEND;VALUE=DATE:20100216"
298 (car result)))
299 (assert (string= "subject" (cadr result)))
300
301 ;; with time
81ee9410 302 (setq result (icalendar--convert-ordinary-to-ical
b4340b3f
UJ
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
81ee9410 311 (setq result (icalendar--convert-ordinary-to-ical
b4340b3f
UJ
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)))
348 (assert (string= "Tag der Arbeit" (cadr result)))))
349
350(defun icalendar-testsuite--test-convert-block-to-ical ()
351 "Test method for `icalendar--convert-block-to-ical'."
352 (let* ((calendar-date-style 'iso)
353 result)
81ee9410 354 (setq result (icalendar--convert-block-to-ical
b4340b3f
UJ
355 "" "%%(diary-block 2004 7 19 2004 8 27) Sommerferien"))
356 (assert (= 2 (length result)))
357 (assert (string= (concat
358 "\nDTSTART;VALUE=DATE:20040719"
359 "\nDTEND;VALUE=DATE:20040828")
360 (car result)))
361 (assert (string= "Sommerferien" (cadr result)))))
362
363(defun icalendar-testsuite--test-convert-cyclic-to-ical ()
364 "Test method for `icalendar--convert-cyclic-to-ical'."
365 (let* ((calendar-date-style 'iso)
366 result)
81ee9410 367 (setq result (icalendar--convert-block-to-ical
b4340b3f
UJ
368 "" "%%(diary-block 2004 7 19 2004 8 27) Sommerferien"))
369 (assert (= 2 (length result)))
370 (assert (string= (concat
371 "\nDTSTART;VALUE=DATE:20040719"
372 "\nDTEND;VALUE=DATE:20040828")
373 (car result)))
374 (assert (string= "Sommerferien" (cadr result)))))
375
376(defun icalendar-testsuite--test-convert-anniversary-to-ical ()
377 "Test method for `icalendar--convert-anniversary-to-ical'."
378 (let* ((calendar-date-style 'iso)
379 result)
81ee9410 380 (setq result (icalendar--convert-anniversary-to-ical
b4340b3f
UJ
381 "" "%%(diary-anniversary 1964 6 30) g"))
382 (assert (= 2 (length result)))
383 (assert (string= (concat
384 "\nDTSTART;VALUE=DATE:19640630"
385 "\nDTEND;VALUE=DATE:19640701"
386 "\nRRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=06;BYMONTHDAY=30")
387 (car result)))
388 (assert (string= "g" (cadr result)))))
389
a4766629
GM
390(defun icalendar-testsuite--test-calendar-style ()
391 "Test method for `icalendar--date-style'."
392 (dolist (calendar-date-style '(iso american european))
393 (assert (eq (icalendar--date-style) calendar-date-style)))
394 (let ((cds calendar-date-style)
395 (european-calendar-style t))
396 (makunbound 'calendar-date-style)
397 (assert (eq (icalendar--date-style) 'european))
398 (with-no-warnings (setq european-calendar-style nil)) ;still get warning!?! FIXME
399 (assert (eq (icalendar--date-style) 'american))
400 (setq calendar-date-style cds)))
401
aad81014
UJ
402(defun icalendar-testsuite--test-create-uid ()
403 "Test method for `icalendar--create-uid'."
f052351a
UJ
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 )
aad81014
UJ
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))
f052351a
UJ
416 (assert (string= (concat "xxx-123-77-" hash "-" username "-19640630")
417 (icalendar--create-uid entry-full contents)))
aad81014
UJ
418 (assert (= 78 icalendar--uid-count))
419 (fset 'current-time (symbol-function 't-ct))
f052351a
UJ
420
421 (setq contents "blahblah")
422 (setq icalendar-uid-format "yyy%syyy")
423 (assert (string= (concat "yyyDTSTARTyyy")
424 (icalendar--create-uid entry-full contents)))
aad81014
UJ
425 ))
426
6fe539d2 427(defun icalendar-testsuite--test-parse-vtimezone ()
81ee9410 428 "Test method for `icalendar--parse-vtimezone'."
6fe539d2
UJ
429 (let (vtimezone result)
430 (setq vtimezone (icalendar-testsuite--get-ical-event "BEGIN:VTIMEZONE
431TZID:thename
432BEGIN:STANDARD
433DTSTART:16010101T040000
434TZOFFSETFROM:+0300
435TZOFFSETTO:+0200
436RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10
437END:STANDARD
438BEGIN:DAYLIGHT
439DTSTART:16010101T030000
440TZOFFSETFROM:+0200
441TZOFFSETTO:+0300
442RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3
443END:DAYLIGHT
444END:VTIMEZONE
445"))
446 (setq result (icalendar--parse-vtimezone vtimezone))
447 (assert (string= "thename" (car result)))
448 (message (cdr result))
81ee9410
UJ
449 (assert (string= "STD-02:00DST-03:00,M3.5.0/03:00:00,M10.5.0/04:00:00"
450 (cdr result)))
6fe539d2
UJ
451 (setq vtimezone (icalendar-testsuite--get-ical-event "BEGIN:VTIMEZONE
452TZID:anothername
453BEGIN:STANDARD
454DTSTART:16010101T040000
455TZOFFSETFROM:+0300
456TZOFFSETTO:+0200
457RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2MO;BYMONTH=10
458END:STANDARD
459BEGIN:DAYLIGHT
460DTSTART:16010101T030000
461TZOFFSETFROM:+0200
462TZOFFSETTO:+0300
463RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2MO;BYMONTH=3
464END:DAYLIGHT
465END:VTIMEZONE
466"))
467 (setq result (icalendar--parse-vtimezone vtimezone))
468 (assert (string= "anothername" (car result)))
469 (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)))))
f052351a 471
7ec01532
GM
472;; ======================================================================
473;; Test methods for exporting from diary to icalendar
474;; ======================================================================
475
a4766629
GM
476(defun icalendar-testsuite--test-export (input-iso input-european input-american
477 expected-output)
7ec01532 478 "Perform an export test.
a4766629 479Argument INPUT-ISO iso style diary string.
7ec01532
GM
480Argument INPUT-EUROPEAN european style diary string.
481Argument INPUT-AMERICAN american style diary string.
a4766629
GM
482Argument EXPECTED-OUTPUT expected icalendar result string.
483
484European style input data must use german month names. American
485and ISO style input data must use english month names."
7ec01532 486 (message "--- icalendar-testsuite--test-export ---")
a4766629 487 (let ((calendar-date-style 'iso)
7ec01532
GM
488 (icalendar-recurring-start-year 2000))
489 (set-time-zone-rule "CET") ;;FIXME: reset timezone!
a4766629
GM
490 (when input-iso
491 (let ((calendar-month-name-array
492 ["January" "February" "March" "April" "May" "June" "July" "August"
493 "September" "October" "November" "December"])
494 (calendar-day-name-array
495 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday"
496 "Saturday"]))
497 (setq calendar-date-style 'iso)
498 (icalendar-testsuite--do-test-export input-iso expected-output)))
7ec01532
GM
499 (when input-european
500 (let ((calendar-month-name-array
81ee9410 501 ["Januar" "Februar" "März" "April" "Mai" "Juni" "Juli" "August"
7ec01532
GM
502 "September" "Oktober" "November" "Dezember"])
503 (calendar-day-name-array
504 ["Sonntag" "Montag" "Dienstag" "Mittwoch" "Donnerstag" "Freitag"
505 "Samstag"]))
a4766629 506 (setq calendar-date-style 'european)
7ec01532
GM
507 (icalendar-testsuite--do-test-export input-european expected-output)))
508 (when input-american
509 (let ((calendar-month-name-array
510 ["January" "February" "March" "April" "May" "June" "July" "August"
511 "September" "October" "November" "December"])
512 (calendar-day-name-array
513 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday"
514 "Saturday"]))
a4766629
GM
515 (setq calendar-date-style 'american)
516 (icalendar-testsuite--do-test-export input-american expected-output)))))
7ec01532
GM
517
518(defun icalendar-testsuite--do-test-export (input expected-output)
519 "Actually perform export test.
520Argument INPUT input diary string.
521Argument EXPECTED-OUTPUT expected icalendar result string."
522 (let ((temp-file (make-temp-file "icalendar-testsuite-ics")))
523 (with-temp-buffer
524 (insert input)
525 (icalendar-export-region (point-min) (point-max) temp-file))
526 (save-excursion
527 (find-file temp-file)
528 (goto-char (point-min))
529 (unless
530 (cond (expected-output
531 (and (re-search-forward "^\\s-*BEGIN:VCALENDAR
532PRODID:-//Emacs//NONSGML icalendar.el//EN
533VERSION:2.0
534BEGIN:VEVENT
535UID:emacs[0-9]+
536\\(\\(.\\|\n\\)+\\)
537END:VEVENT
538END:VCALENDAR
539\\s-*$"
540 nil t)
541 (string-match
542 (concat "^\\s-*"
543 (regexp-quote (buffer-substring-no-properties
544 (match-beginning 1) (match-end 1)))
545 "\\s-*$")
546 expected-output)))
547 (t
548 (re-search-forward "^\\s-*BEGIN:VCALENDAR
549PRODID:-//Emacs//NONSGML icalendar.el//EN
550VERSION:2.0
551END:VCALENDAR
552\\s-*$"
553 nil t)))
554 (error
81ee9410 555 "Export test failed! Input: `%s'\nFound:\n\n%s\n\nbut expected\n\n%s\n%s"
7ec01532
GM
556 input
557 (or (and (match-beginning 1)
81ee9410
UJ
558 (buffer-substring-no-properties (match-beginning 1)
559 (match-end 1)))
560 "<nil>")
561 (or expected-output "<nil>")
562 (icalendar-testsuite--compare-strings (or (and (match-beginning 1)
563 (buffer-substring-no-properties (match-beginning 1)
564 (match-end 1)))
7ec01532 565 "<nil>")
81ee9410 566 (or expected-output "<nil>")))))
7ec01532
GM
567 (kill-buffer (find-buffer-visiting temp-file))
568 (delete-file temp-file)))
569
570;; ======================================================================
571;; Test methods for importing from icalendar to diary
572;; ======================================================================
573
a4766629 574(defun icalendar-testsuite--test-import (input expected-iso expected-european
7ec01532
GM
575 expected-american)
576 "Perform import test.
577Argument INPUT icalendar event string.
a4766629 578Argument EXPECTED-ISO expected iso style diary string.
7ec01532
GM
579Argument EXPECTED-EUROPEAN expected european style diary string.
580Argument EXPECTED-AMERICAN expected american style diary string."
581 (message "--- icalendar-testsuite--test-import ---")
582 (let ((timezone (cadr (current-time-zone))))
583 (set-time-zone-rule "CET")
584 (with-temp-buffer
585 (if (string-match "^BEGIN:VCALENDAR" input)
586 (insert input)
587 (insert "BEGIN:VCALENDAR\nPRODID:-//Emacs//NONSGML icalendar.el//EN\n")
588 (insert "VERSION:2.0\nBEGIN:VEVENT\n")
589 (insert input)
590 (unless (eq (char-before) ?\n)
591 (insert "\n"))
592 (insert "END:VEVENT\nEND:VCALENDAR\n"))
593 (let ((icalendar-import-format "%s%d%l%o%t%u%c")
594 (icalendar-import-format-summary "%s")
595 (icalendar-import-format-location "\n Location: %s")
596 (icalendar-import-format-description "\n Desc: %s")
597 (icalendar-import-format-organizer "\n Organizer: %s")
598 (icalendar-import-format-status "\n Status: %s")
599 (icalendar-import-format-url "\n URL: %s")
600 (icalendar-import-format-class "\n Class: %s")
a4766629
GM
601 calendar-date-style)
602 (when expected-iso
603 (setq calendar-date-style 'iso)
604 (icalendar-testsuite--do-test-import input expected-iso))
7ec01532 605 (when expected-european
a4766629 606 (setq calendar-date-style 'european)
7ec01532
GM
607 (icalendar-testsuite--do-test-import input expected-european))
608 (when expected-american
a4766629
GM
609 (setq calendar-date-style 'american)
610 (icalendar-testsuite--do-test-import input expected-american))))
7ec01532
GM
611 (set-time-zone-rule timezone)))
612
613(defun icalendar-testsuite--do-test-import (input expected-output)
614 "Actually perform import test.
615Argument INPUT input icalendar string.
616Argument EXPECTED-OUTPUT expected diary string."
617 (let ((temp-file (make-temp-file "icalendar-test-diary")))
618 (icalendar-import-buffer temp-file t t)
619 (save-excursion
620 (find-file temp-file)
81ee9410
UJ
621 (let* ((result (buffer-substring-no-properties (point-min) (point-max)))
622 (difference
623 (icalendar-testsuite--compare-strings result
624 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)))
7ec01532
GM
628 (kill-buffer (find-buffer-visiting temp-file))
629 (delete-file temp-file))))
630
631;; ======================================================================
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")
a4766629
GM
653 (icalendar-import-format-class "\n Class: %s"))
654 (dolist (calendar-date-style '(iso european american))
655 (icalendar-testsuite--do-test-cycle)))))
7ec01532
GM
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))))
6fe539d2
UJ
662
663 ;; step 1: import
7ec01532 664 (icalendar-import-buffer temp-diary t t)
6fe539d2
UJ
665
666 ;; step 2: export what was just imported
7ec01532
GM
667 (save-excursion
668 (find-file temp-diary)
669 (icalendar-export-region (point-min) (point-max) temp-ics))
6fe539d2
UJ
670
671 ;; compare the output of step 2 with the input of step 1
7ec01532
GM
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))))
81ee9410
UJ
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 ))
6fe539d2
UJ
684
685 ;; clean up -- Note this is done only if test is passed
7ec01532
GM
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."
699 (icalendar-testsuite--test-import
700 "SUMMARY:non-recurring
701DTSTART;VALUE=DATE-TIME:20030919T090000
702DTEND;VALUE=DATE-TIME:20030919T113000"
a4766629 703 "&2003/9/19 09:00-11:30 non-recurring"
7ec01532
GM
704 "&19/9/2003 09:00-11:30 non-recurring"
705 "&9/19/2003 09:00-11:30 non-recurring")
706
707 (icalendar-testsuite--test-import
708 "SUMMARY:non-recurring allday
709DTSTART;VALUE=DATE-TIME:20030919"
a4766629 710 "&2003/9/19 non-recurring allday"
7ec01532
GM
711 "&19/9/2003 non-recurring allday"
712 "&9/19/2003 non-recurring allday")
713
714 (icalendar-testsuite--test-import
81ee9410 715 ;; do not remove the trailing blank after "long"!
7ec01532
GM
716 "SUMMARY:long
717 summary
718DTSTART;VALUE=DATE:20030919"
a4766629 719 "&2003/9/19 long summary"
7ec01532
GM
720 "&19/9/2003 long summary"
721 "&9/19/2003 long summary")
722
723 (icalendar-testsuite--test-import
724 "UID:748f2da0-0d9b-11d8-97af-b4ec8686ea61
725SUMMARY:Sommerferien
726STATUS:TENTATIVE
727CLASS:PRIVATE
728X-MOZILLA-ALARM-DEFAULT-UNITS:Minuten
729X-MOZILLA-RECUR-DEFAULT-INTERVAL:0
730DTSTART;VALUE=DATE:20040719
731DTEND;VALUE=DATE:20040828
732DTSTAMP:20031103T011641Z
733"
81ee9410
UJ
734 "&%%(and (diary-block 2004 7 19 2004 8 27)) Sommerferien
735 Status: TENTATIVE
736 Class: PRIVATE
737"
738 "&%%(and (diary-block 19 7 2004 27 8 2004)) Sommerferien
739 Status: TENTATIVE
740 Class: PRIVATE
741"
742 "&%%(and (diary-block 7 19 2004 8 27 2004)) Sommerferien
743 Status: TENTATIVE
744 Class: PRIVATE")
a4766629 745
7ec01532
GM
746 (icalendar-testsuite--test-import
747 "UID
748 :04979712-3902-11d9-93dd-8f9f4afe08da
749SUMMARY
750 :folded summary
751STATUS
752 :TENTATIVE
753CLASS
754 :PRIVATE
755X-MOZILLA-ALARM-DEFAULT-LENGTH
756 :0
757DTSTART
758 :20041123T140000
759DTEND
760 :20041123T143000
761DTSTAMP
762 :20041118T013430Z
763LAST-MODIFIED
764 :20041118T013640Z
765"
81ee9410
UJ
766 "&2004/11/23 14:00-14:30 folded summary
767 Status: TENTATIVE
768 Class: PRIVATE"
769 "&23/11/2004 14:00-14:30 folded summary
770 Status: TENTATIVE
771 Class: PRIVATE"
772 "&11/23/2004 14:00-14:30 folded summary
773 Status: TENTATIVE
774 Class: PRIVATE")
7ec01532
GM
775 (icalendar-testsuite--test-import
776 "UID
777 :6161a312-3902-11d9-b512-f764153bb28b
778SUMMARY
779 :another example
780STATUS
781 :TENTATIVE
782CLASS
783 :PRIVATE
784X-MOZILLA-ALARM-DEFAULT-LENGTH
785 :0
786DTSTART
787 :20041123T144500
788DTEND
789 :20041123T154500
790DTSTAMP
791 :20041118T013641Z
792"
81ee9410
UJ
793 "&2004/11/23 14:45-15:45 another example
794 Status: TENTATIVE
795 Class: PRIVATE"
796 "&23/11/2004 14:45-15:45 another example
797 Status: TENTATIVE
798 Class: PRIVATE"
799 "&11/23/2004 14:45-15:45 another example
800 Status: TENTATIVE
801 Class: PRIVATE")
a4766629 802
7ec01532
GM
803 (icalendar-testsuite--test-import
804 "SUMMARY:rrule daily
805DTSTART;VALUE=DATE-TIME:20030919T090000
806DTEND;VALUE=DATE-TIME:20030919T113000
807RRULE:FREQ=DAILY;
808"
a4766629 809 "&%%(and (diary-cyclic 1 2003 9 19)) 09:00-11:30 rrule daily"
7ec01532
GM
810 "&%%(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")
812
813 ;; RRULE examples
814 (icalendar-testsuite--test-import
815 "SUMMARY:rrule daily
816DTSTART;VALUE=DATE-TIME:20030919T090000
817DTEND;VALUE=DATE-TIME:20030919T113000
818RRULE:FREQ=DAILY;INTERVAL=2
819"
a4766629 820 "&%%(and (diary-cyclic 2 2003 9 19)) 09:00-11:30 rrule daily"
7ec01532
GM
821 "&%%(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")
823 (icalendar-testsuite--test-import
824 "SUMMARY:rrule daily with exceptions
825DTSTART;VALUE=DATE-TIME:20030919T090000
826DTEND;VALUE=DATE-TIME:20030919T113000
827RRULE:FREQ=DAILY;INTERVAL=2
828EXDATE:20030921,20030925
829"
a4766629 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"
7ec01532
GM
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"
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")
a4766629 833
7ec01532
GM
834 (icalendar-testsuite--test-import
835 "SUMMARY:rrule weekly
836DTSTART;VALUE=DATE-TIME:20030919T090000
837DTEND;VALUE=DATE-TIME:20030919T113000
838RRULE:FREQ=WEEKLY;
839"
a4766629 840 "&%%(and (diary-cyclic 7 2003 9 19)) 09:00-11:30 rrule weekly"
7ec01532
GM
841 "&%%(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")
843 (icalendar-testsuite--test-import
844 "SUMMARY:rrule monthly no end
845DTSTART;VALUE=DATE-TIME:20030919T090000
846DTEND;VALUE=DATE-TIME:20030919T113000
847RRULE:FREQ=MONTHLY;
848"
a4766629 849 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 9999 1 1)) 09:00-11:30 rrule monthly no end"
7ec01532
GM
850 "&%%(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")
852 (icalendar-testsuite--test-import
853 "SUMMARY:rrule monthly with end
854DTSTART;VALUE=DATE-TIME:20030919T090000
855DTEND;VALUE=DATE-TIME:20030919T113000
856RRULE:FREQ=MONTHLY;UNTIL=20050819;
857"
a4766629 858 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2005 8 19)) 09:00-11:30 rrule monthly with end"
7ec01532
GM
859 "&%%(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")
861 (icalendar-testsuite--test-import
862 "DTSTART;VALUE=DATE:20040815
863DTEND;VALUE=DATE:20040816
864SUMMARY:Maria Himmelfahrt
865UID:CC56BEA6-49D2-11D8-8833-00039386D1C2-RID
866RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=8
867"
a4766629 868 "&%%(and (diary-anniversary 2004 8 15)) Maria Himmelfahrt"
7ec01532
GM
869 "&%%(and (diary-anniversary 15 8 2004)) Maria Himmelfahrt"
870 "&%%(and (diary-anniversary 8 15 2004)) Maria Himmelfahrt")
871 (icalendar-testsuite--test-import
872 "SUMMARY:rrule yearly
873DTSTART;VALUE=DATE-TIME:20030919T090000
874DTEND;VALUE=DATE-TIME:20030919T113000
875RRULE:FREQ=YEARLY;INTERVAL=2
876"
a4766629 877 "&%%(and (diary-anniversary 2003 9 19)) 09:00-11:30 rrule yearly" ;FIXME
7ec01532
GM
878 "&%%(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
880 (icalendar-testsuite--test-import
881 "SUMMARY:rrule count daily short
882DTSTART;VALUE=DATE-TIME:20030919T090000
883DTEND;VALUE=DATE-TIME:20030919T113000
884RRULE:FREQ=DAILY;COUNT=1;INTERVAL=1
885"
a4766629 886 "&%%(and (diary-cyclic 1 2003 9 19) (diary-block 2003 9 19 2003 9 19)) 09:00-11:30 rrule count daily short"
7ec01532
GM
887 "&%%(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")
889 (icalendar-testsuite--test-import
890 "SUMMARY:rrule count daily long
891DTSTART;VALUE=DATE-TIME:20030919T090000
892DTEND;VALUE=DATE-TIME:20030919T113000
893RRULE:FREQ=DAILY;COUNT=14;INTERVAL=1
894"
a4766629 895 "&%%(and (diary-cyclic 1 2003 9 19) (diary-block 2003 9 19 2003 10 2)) 09:00-11:30 rrule count daily long"
7ec01532
GM
896 "&%%(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")
898 (icalendar-testsuite--test-import
899 "SUMMARY:rrule count bi-weekly 3 times
900DTSTART;VALUE=DATE-TIME:20030919T090000
901DTEND;VALUE=DATE-TIME:20030919T113000
902RRULE:FREQ=WEEKLY;COUNT=3;INTERVAL=2
903"
a4766629 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"
7ec01532
GM
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"
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")
907 (icalendar-testsuite--test-import
908 "SUMMARY:rrule count monthly
909DTSTART;VALUE=DATE-TIME:20030919T090000
910DTEND;VALUE=DATE-TIME:20030919T113000
911RRULE:FREQ=MONTHLY;INTERVAL=1;COUNT=5
912"
a4766629 913 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2004 1 19)) 09:00-11:30 rrule count monthly"
7ec01532
GM
914 "&%%(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")
916 (icalendar-testsuite--test-import
917 "SUMMARY:rrule count every second month
918DTSTART;VALUE=DATE-TIME:20030919T090000
919DTEND;VALUE=DATE-TIME:20030919T113000
920RRULE:FREQ=MONTHLY;INTERVAL=2;COUNT=5
921"
a4766629 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
7ec01532
GM
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
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
925 (icalendar-testsuite--test-import
926 "SUMMARY:rrule count yearly
927DTSTART;VALUE=DATE-TIME:20030919T090000
928DTEND;VALUE=DATE-TIME:20030919T113000
929RRULE:FREQ=YEARLY;INTERVAL=1;COUNT=5
930"
a4766629 931 "&%%(and (diary-date t 9 19) (diary-block 2003 9 19 2007 9 19)) 09:00-11:30 rrule count yearly"
7ec01532
GM
932 "&%%(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")
934 (icalendar-testsuite--test-import
935 "SUMMARY:rrule count every second year
936DTSTART;VALUE=DATE-TIME:20030919T090000
937DTEND;VALUE=DATE-TIME:20030919T113000
938RRULE:FREQ=YEARLY;INTERVAL=2;COUNT=5
939"
a4766629 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!!!
7ec01532
GM
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!!!
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!!!
943
944 ;; duration
945 (icalendar-testsuite--test-import
946 "DTSTART;VALUE=DATE:20050217
947SUMMARY:duration
948DURATION:P7D
949"
a4766629 950 "&%%(and (diary-block 2005 2 17 2005 2 23)) duration"
7ec01532
GM
951 "&%%(and (diary-block 17 2 2005 23 2 2005)) duration"
952 "&%%(and (diary-block 2 17 2005 2 23 2005)) duration")
953
954 (icalendar-testsuite--test-import
955 "UID:20041127T183329Z-18215-1001-4536-49109@andromeda
956DTSTAMP:20041127T183315Z
957LAST-MODIFIED:20041127T183329
958SUMMARY:Urlaub
959DTSTART;VALUE=DATE:20011221
960DTEND;VALUE=DATE:20011221
961RRULE:FREQ=DAILY;UNTIL=20011229;INTERVAL=1;WKST=SU
962CLASS:PUBLIC
963SEQUENCE:1
964CREATED:20041127T183329
965"
81ee9410
UJ
966 "&%%(and (diary-cyclic 1 2001 12 21) (diary-block 2001 12 21 2001 12 29)) Urlaub
967 Class: PUBLIC"
968 "&%%(and (diary-cyclic 1 21 12 2001) (diary-block 21 12 2001 29 12 2001)) Urlaub
969 Class: PUBLIC"
970 "&%%(and (diary-cyclic 1 12 21 2001) (diary-block 12 21 2001 12 29 2001)) Urlaub
971 Class: PUBLIC")
972
973 ;;bug#6766 -- multiple byday values in a weekly rrule
974 (icalendar-testsuite--test-import
975"CLASS:PUBLIC
976DTEND;TZID=America/New_York:20100421T120000
977DTSTAMP:20100525T141214Z
978DTSTART;TZID=America/New_York:20100421T113000
979RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE,TH,FR
980SEQUENCE:1
981STATUS:CONFIRMED
982SUMMARY:Scrum
983TRANSP:OPAQUE
984UID:8814e3f9-7482-408f-996c-3bfe486a1262
985END:VEVENT
986BEGIN:VEVENT
987CLASS:PUBLIC
988DTSTAMP:20100525T141214Z
989DTSTART;VALUE=DATE:20100422
990DTEND;VALUE=DATE:20100423
991RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU,TH
992SEQUENCE:1
993SUMMARY:Tues + Thurs thinking
994TRANSP:OPAQUE
995UID:8814e3f9-7482-408f-996c-3bfe486a1263
996"
997"&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 2010 4 21)) 11:30-12:00 Scrum
998 Status: CONFIRMED
999 Class: PUBLIC
1000&%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 2010 4 22)) Tues + Thurs thinking
1001 Class: PUBLIC"
1002
1003"&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 21 4 2010)) 11:30-12:00 Scrum
1004 Status: CONFIRMED
1005 Class: PUBLIC
1006&%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 22 4 2010)) Tues + Thurs thinking
1007 Class: PUBLIC"
1008
1009"&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 4 21 2010)) 11:30-12:00 Scrum
1010 Status: CONFIRMED
1011 Class: PUBLIC
1012&%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 4 22 2010)) Tues + Thurs thinking
1013 Class: PUBLIC")
1014)
7ec01532
GM
1015
1016;; ======================================================================
1017;; Export tests
1018;; ======================================================================
1019(defun icalendar-testsuite--run-export-tests ()
1020 "Perform standard export tests."
1021
1022 (let ((icalendar-export-hidden-diary-entries nil))
1023 (icalendar-testsuite--test-export
a4766629 1024 "&2000 Oct 3 ordinary no time "
7ec01532
GM
1025 "&3 Okt 2000 ordinary no time "
1026 "&Oct 3 2000 ordinary no time "
1027 nil))
1028
1029 ;; "ordinary" events
1030 (icalendar-testsuite--test-export
a4766629 1031 "2000 Oct 3 ordinary no time "
7ec01532
GM
1032 "3 Okt 2000 ordinary no time "
1033 "Oct 3 2000 ordinary no time "
1034 "DTSTART;VALUE=DATE:20001003
1035DTEND;VALUE=DATE:20001004
a4766629 1036SUMMARY:ordinary no time
7ec01532
GM
1037")
1038 (icalendar-testsuite--test-export
a4766629 1039 "2000 Oct 3 16:30 ordinary with time"
7ec01532
GM
1040 "3 Okt 2000 16:30 ordinary with time"
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
a4766629 1047 "2000 10 3 16:30 ordinary with time 2"
7ec01532
GM
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
a4766629 1056 "2000/10/3 16:30 ordinary with time 3"
7ec01532
GM
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
a4766629
GM
1066 "2000 October 3 16:30 multiline
1067 17:30 multiline continued FIXME"
7ec01532
GM
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
a4766629 1081 "Monday 1:30pm weekly by day with start time"
7ec01532
GM
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
a4766629 1091 "Monday 13:30-15:00 weekly by day with start and end time"
7ec01532
GM
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
a4766629 1102 "may 1 yearly no time"
7ec01532
GM
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
1111 ;; anniversaries
1112 (icalendar-testsuite--test-export
a4766629 1113 "%%(diary-anniversary 1989 10 3) anniversary no time"
7ec01532
GM
1114 "%%(diary-anniversary 3 10 1989) anniversary no time"
1115 "%%(diary-anniversary 10 3 1989) anniversary no time"
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
a4766629 1122 "%%(diary-anniversary 1989 10 3) 19:00-20:00 anniversary with time"
7ec01532
GM
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
1131 ;; block
1132 (icalendar-testsuite--test-export
a4766629 1133 "%%(diary-block 2001 6 18 2001 7 6) block no time"
7ec01532
GM
1134 "%%(diary-block 18 6 2001 6 7 2001) block no time"
1135 "%%(diary-block 6 18 2001 7 6 2001) block no time"
1136 "DTSTART;VALUE=DATE:20010618
1137DTEND;VALUE=DATE:20010707
1138SUMMARY:block no time
1139")
1140 (icalendar-testsuite--test-export
a4766629 1141 "%%(diary-block 2001 6 18 2001 7 6) 13:00-17:00 block with time"
7ec01532
GM
1142 "%%(diary-block 18 6 2001 6 7 2001) 13:00-17:00 block with time"
1143 "%%(diary-block 6 18 2001 7 6 2001) 13:00-17:00 block with time"
1144 "DTSTART;VALUE=DATE-TIME:20010618T130000
1145DTEND;VALUE=DATE-TIME:20010618T170000
1146RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20010706
1147SUMMARY:block with time
1148")
1149 (icalendar-testsuite--test-export
a4766629 1150 "%%(diary-block 2001 6 18 2001 7 6) 13:00 block no end time"
7ec01532
GM
1151 "%%(diary-block 18 6 2001 6 7 2001) 13:00 block no end time"
1152 "%%(diary-block 6 18 2001 7 6 2001) 13:00 block no end time"
1153 "DTSTART;VALUE=DATE-TIME:20010618T130000
1154DTEND;VALUE=DATE-TIME:20010618T140000
1155RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20010706
1156SUMMARY:block no end time
1157")
1158 )
1159
1160;; ======================================================================
1161;; Real world
1162;; ======================================================================
1163(defun icalendar-testsuite--run-real-world-tests ()
1164 "Perform real-world tests, as gathered from problem reports."
1165 ;; 2003-05-29
1166 (icalendar-testsuite--test-import
1167 "BEGIN:VCALENDAR
1168METHOD:REQUEST
1169PRODID:Microsoft CDO for Microsoft Exchange
1170VERSION:2.0
1171BEGIN:VTIMEZONE
1172TZID:Kolkata\, Chennai\, Mumbai\, New Delhi
1173X-MICROSOFT-CDO-TZID:23
1174BEGIN:STANDARD
1175DTSTART:16010101T000000
1176TZOFFSETFROM:+0530
1177TZOFFSETTO:+0530
1178END:STANDARD
1179BEGIN:DAYLIGHT
1180DTSTART:16010101T000000
1181TZOFFSETFROM:+0530
1182TZOFFSETTO:+0530
1183END:DAYLIGHT
1184END:VTIMEZONE
1185BEGIN:VEVENT
1186DTSTAMP:20030509T043439Z
1187DTSTART;TZID=\"Kolkata, Chennai, Mumbai, New Delhi\":20030509T103000
1188SUMMARY:On-Site Interview
1189UID:040000008200E00074C5B7101A82E0080000000080B6DE661216C301000000000000000
1190 010000000DB823520692542408ED02D7023F9DFF9
1191ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Xxxxx
1192 xxx Xxxxxxxxxxxx\":MAILTO:xxxxxxxx@xxxxxxx.com
1193ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Yyyyyyy Y
1194 yyyy\":MAILTO:yyyyyyy@yyyyyyy.com
1195ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Zzzz Zzzz
1196 zz\":MAILTO:zzzzzz@zzzzzzz.com
1197ORGANIZER;CN=\"Aaaaaa Aaaaa\":MAILTO:aaaaaaa@aaaaaaa.com
1198LOCATION:Cccc
1199DTEND;TZID=\"Kolkata, Chennai, Mumbai, New Delhi\":20030509T153000
1200DESCRIPTION:10:30am - Blah
1201SEQUENCE:0
1202PRIORITY:5
1203CLASS:
1204CREATED:20030509T043439Z
1205LAST-MODIFIED:20030509T043459Z
1206STATUS:CONFIRMED
1207TRANSP:OPAQUE
1208X-MICROSOFT-CDO-BUSYSTATUS:BUSY
1209X-MICROSOFT-CDO-INSTTYPE:0
1210X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
1211X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
1212X-MICROSOFT-CDO-IMPORTANCE:1
1213X-MICROSOFT-CDO-OWNERAPPTID:126441427
1214BEGIN:VALARM
1215ACTION:DISPLAY
1216DESCRIPTION:REMINDER
1217TRIGGER;RELATED=START:-PT00H15M00S
1218END:VALARM
1219END:VEVENT
1220END:VCALENDAR"
a4766629 1221 nil
7ec01532
GM
1222 "&9/5/2003 10:30-15:30 On-Site Interview
1223 Desc: 10:30am - Blah
1224 Location: Cccc
81ee9410
UJ
1225 Organizer: MAILTO:aaaaaaa@aaaaaaa.com
1226 Status: CONFIRMED"
7ec01532
GM
1227 "&5/9/2003 10:30-15:30 On-Site Interview
1228 Desc: 10:30am - Blah
1229 Location: Cccc
81ee9410
UJ
1230 Organizer: MAILTO:aaaaaaa@aaaaaaa.com
1231 Status: CONFIRMED")
7ec01532
GM
1232
1233 ;; 2003-06-18 a
1234 (icalendar-testsuite--test-import
1235 "DTSTAMP:20030618T195512Z
1236DTSTART;TZID=\"Mountain Time (US & Canada)\":20030623T110000
1237SUMMARY:Dress Rehearsal for XXXX-XXXX
1238UID:040000008200E00074C5B7101A82E00800000000608AA7DA9835C301000000000000000
1239 0100000007C3A6D65EE726E40B7F3D69A23BD567E
1240ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"AAAAA,AAA
1241 AA (A-AAAAAAA,ex1)\":MAILTO:aaaaa_aaaaa@aaaaa.com
1242ORGANIZER;CN=\"ABCD,TECHTRAINING
1243 (A-Americas,exgen1)\":MAILTO:xxx@xxxxx.com
1244LOCATION:555 or TN 555-5555 ID 5555 & NochWas (see below)
1245DTEND;TZID=\"Mountain Time (US & Canada)\":20030623T120000
1246DESCRIPTION:753 Zeichen hier radiert
1247SEQUENCE:0
1248PRIORITY:5
1249CLASS:
1250CREATED:20030618T195518Z
1251LAST-MODIFIED:20030618T195527Z
1252STATUS:CONFIRMED
1253TRANSP:OPAQUE
1254X-MICROSOFT-CDO-BUSYSTATUS:BUSY
1255X-MICROSOFT-CDO-INSTTYPE:0
1256X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
1257X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
1258X-MICROSOFT-CDO-IMPORTANCE:1
1259X-MICROSOFT-CDO-OWNERAPPTID:1022519251
1260BEGIN:VALARM
1261ACTION:DISPLAY
1262DESCRIPTION:REMINDER
1263TRIGGER;RELATED=START:-PT00H15M00S
1264END:VALARM"
a4766629 1265 nil
7ec01532
GM
1266 "&23/6/2003 11:00-12:00 Dress Rehearsal for XXXX-XXXX
1267 Desc: 753 Zeichen hier radiert
1268 Location: 555 or TN 555-5555 ID 5555 & NochWas (see below)
81ee9410
UJ
1269 Organizer: MAILTO:xxx@xxxxx.com
1270 Status: CONFIRMED"
7ec01532
GM
1271 "&6/23/2003 11:00-12:00 Dress Rehearsal for XXXX-XXXX
1272 Desc: 753 Zeichen hier radiert
1273 Location: 555 or TN 555-5555 ID 5555 & NochWas (see below)
81ee9410
UJ
1274 Organizer: MAILTO:xxx@xxxxx.com
1275 Status: CONFIRMED")
7ec01532
GM
1276
1277 ;; 2003-06-18 b -- uses timezone
1278 (icalendar-testsuite--test-import
1279 "BEGIN:VCALENDAR
1280METHOD:REQUEST
1281PRODID:Microsoft CDO for Microsoft Exchange
1282VERSION:2.0
1283BEGIN:VTIMEZONE
1284TZID:Mountain Time (US & Canada)
1285X-MICROSOFT-CDO-TZID:12
1286BEGIN:STANDARD
1287DTSTART:16010101T020000
1288TZOFFSETFROM:-0600
1289TZOFFSETTO:-0700
1290RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=10;BYDAY=-1SU
1291END:STANDARD
1292BEGIN:DAYLIGHT
1293DTSTART:16010101T020000
1294TZOFFSETFROM:-0700
1295TZOFFSETTO:-0600
1296RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=4;BYDAY=1SU
1297END:DAYLIGHT
1298END:VTIMEZONE
1299BEGIN:VEVENT
1300DTSTAMP:20030618T230323Z
1301DTSTART;TZID=\"Mountain Time (US & Canada)\":20030623T090000
1302SUMMARY:Updated: Dress Rehearsal for ABC01-15
1303UID:040000008200E00074C5B7101A82E00800000000608AA7DA9835C301000000000000000
1304 0100000007C3A6D65EE726E40B7F3D69A23BD567E
1305ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;X-REPLYTIME=20030618T20
1306 0700Z;RSVP=TRUE;CN=\"AAAAA,AAAAAA
1307\(A-AAAAAAA,ex1)\":MAILTO:aaaaaa_aaaaa@aaaaa
1308 .com
1309ORGANIZER;CN=\"ABCD,TECHTRAINING
1310\(A-Americas,exgen1)\":MAILTO:bbb@bbbbb.com
1311LOCATION:123 or TN 123-1234 ID abcd & SonstWo (see below)
1312DTEND;TZID=\"Mountain Time (US & Canada)\":20030623T100000
81ee9410 1313DESCRIPTION:Viele Zeichen standen hier früher
7ec01532
GM
1314SEQUENCE:0
1315PRIORITY:5
1316CLASS:
1317CREATED:20030618T230326Z
1318LAST-MODIFIED:20030618T230335Z
1319STATUS:CONFIRMED
1320TRANSP:OPAQUE
1321X-MICROSOFT-CDO-BUSYSTATUS:BUSY
1322X-MICROSOFT-CDO-INSTTYPE:0
1323X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
1324X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
1325X-MICROSOFT-CDO-IMPORTANCE:1
1326X-MICROSOFT-CDO-OWNERAPPTID:1022519251
1327BEGIN:VALARM
1328ACTION:DISPLAY
1329DESCRIPTION:REMINDER
1330TRIGGER;RELATED=START:-PT00H15M00S
1331END:VALARM
1332END:VEVENT
1333END:VCALENDAR"
a4766629 1334 nil
7ec01532 1335 "&23/6/2003 17:00-18:00 Updated: Dress Rehearsal for ABC01-15
81ee9410 1336 Desc: Viele Zeichen standen hier früher
7ec01532
GM
1337 Location: 123 or TN 123-1234 ID abcd & SonstWo (see below)
1338 Organizer: MAILTO:bbb@bbbbb.com
1339 Status: CONFIRMED"
1340 "&6/23/2003 17:00-18:00 Updated: Dress Rehearsal for ABC01-15
81ee9410 1341 Desc: Viele Zeichen standen hier früher
7ec01532
GM
1342 Location: 123 or TN 123-1234 ID abcd & SonstWo (see below)
1343 Organizer: MAILTO:bbb@bbbbb.com
1344 Status: CONFIRMED")
1345
1346 ;; export 2004-10-28 block entries
1347 (icalendar-testsuite--test-export
a4766629 1348 nil
7ec01532
GM
1349 nil
1350 "-*- mode: text; fill-column: 256;-*-
1351
1352>>> block entries:
1353
1354%%(diary-block 11 8 2004 11 10 2004) Nov 8-10 aa
1355"
1356 "DTSTART;VALUE=DATE:20041108
1357DTEND;VALUE=DATE:20041111
1358SUMMARY:Nov 8-10 aa")
1359
1360 (icalendar-testsuite--test-export
a4766629 1361 nil
7ec01532
GM
1362 nil
1363 "%%(diary-block 12 13 2004 12 17 2004) Dec 13-17 bb"
1364 "DTSTART;VALUE=DATE:20041213
1365DTEND;VALUE=DATE:20041218
1366SUMMARY:Dec 13-17 bb")
1367
1368 (icalendar-testsuite--test-export
a4766629 1369 nil
7ec01532
GM
1370 nil
1371 "%%(diary-block 2 3 2005 2 4 2005) Feb 3-4 cc"
1372 "DTSTART;VALUE=DATE:20050203
1373DTEND;VALUE=DATE:20050205
1374SUMMARY:Feb 3-4 cc")
1375
1376 (icalendar-testsuite--test-export
a4766629 1377 nil
7ec01532
GM
1378 nil
1379 "%%(diary-block 4 24 2005 4 29 2005) April 24-29 dd"
1380 "DTSTART;VALUE=DATE:20050424
1381DTEND;VALUE=DATE:20050430
1382SUMMARY:April 24-29 dd
1383")
1384 (icalendar-testsuite--test-export
a4766629 1385 nil
7ec01532
GM
1386 nil
1387 "%%(diary-block 5 30 2005 6 1 2005) may 30 - June 1: ee"
1388 "DTSTART;VALUE=DATE:20050530
1389DTEND;VALUE=DATE:20050602
1390SUMMARY:may 30 - June 1: ee")
1391
1392 (icalendar-testsuite--test-export
a4766629 1393 nil
7ec01532
GM
1394 nil
1395 "%%(diary-block 6 6 2005 6 8 2005) ff"
1396 "DTSTART;VALUE=DATE:20050606
1397DTEND;VALUE=DATE:20050609
1398SUMMARY:ff")
1399
1400 ;; export 2004-10-28 anniversary entries
1401 (icalendar-testsuite--test-export
a4766629 1402 nil
7ec01532
GM
1403 nil
1404 "
1405>>> anniversaries:
1406
1407%%(diary-anniversary 3 28 1991) aa birthday (%d years old)"
1408 "DTSTART;VALUE=DATE:19910328
1409DTEND;VALUE=DATE:19910329
1410RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=03;BYMONTHDAY=28
1411SUMMARY:aa birthday (%d years old)
1412")
1413
1414 (icalendar-testsuite--test-export
a4766629 1415 nil
7ec01532
GM
1416 nil
1417 "%%(diary-anniversary 5 17 1957) bb birthday (%d years old)"
1418 "DTSTART;VALUE=DATE:19570517
1419DTEND;VALUE=DATE:19570518
1420RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=05;BYMONTHDAY=17
1421SUMMARY:bb birthday (%d years old)")
1422
1423 (icalendar-testsuite--test-export
a4766629 1424 nil
7ec01532
GM
1425 nil
1426 "%%(diary-anniversary 6 8 1997) cc birthday (%d years old)"
1427 "DTSTART;VALUE=DATE:19970608
1428DTEND;VALUE=DATE:19970609
1429RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=06;BYMONTHDAY=08
1430SUMMARY:cc birthday (%d years old)")
1431
1432 (icalendar-testsuite--test-export
a4766629 1433 nil
7ec01532
GM
1434 nil
1435 "%%(diary-anniversary 7 22 1983) dd (%d years ago...!)"
1436 "DTSTART;VALUE=DATE:19830722
1437DTEND;VALUE=DATE:19830723
1438RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=07;BYMONTHDAY=22
1439SUMMARY:dd (%d years ago...!)")
1440
1441 (icalendar-testsuite--test-export
a4766629 1442 nil
7ec01532
GM
1443 nil
1444 "%%(diary-anniversary 8 1 1988) ee birthday (%d years old)"
1445 "DTSTART;VALUE=DATE:19880801
1446DTEND;VALUE=DATE:19880802
1447RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=08;BYMONTHDAY=01
1448SUMMARY:ee birthday (%d years old)")
1449
1450 (icalendar-testsuite--test-export
a4766629 1451 nil
7ec01532
GM
1452 nil
1453 "%%(diary-anniversary 9 21 1957) ff birthday (%d years old)"
1454 "DTSTART;VALUE=DATE:19570921
1455DTEND;VALUE=DATE:19570922
1456RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=09;BYMONTHDAY=21
1457SUMMARY:ff birthday (%d years old)")
1458
1459
1460 ;; FIXME!
1461
1462 ;; export 2004-10-28 monthly, weekly entries
1463
1464 ;; (icalendar-testsuite--test-export
1465 ;; nil
1466 ;; "
1467 ;; >>> ------------ monthly:
1468
1469 ;; */27/* 10:00 blah blah"
1470 ;; "xxx")
1471
1472 (icalendar-testsuite--test-export
a4766629 1473 nil
7ec01532
GM
1474 nil
1475 ">>> ------------ my week:
1476
1477Monday 13:00 MAC"
1478 "DTSTART;VALUE=DATE-TIME:20000103T130000
1479DTEND;VALUE=DATE-TIME:20000103T140000
1480RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1481SUMMARY:MAC")
1482
1483 (icalendar-testsuite--test-export
a4766629 1484 nil
7ec01532
GM
1485 nil
1486 "Monday 15:00 a1"
1487 "DTSTART;VALUE=DATE-TIME:20000103T150000
1488DTEND;VALUE=DATE-TIME:20000103T160000
1489RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1490SUMMARY:a1")
1491
1492
1493 (icalendar-testsuite--test-export
a4766629 1494 nil
7ec01532
GM
1495 nil
1496 "Monday 16:00-17:00 a2"
1497 "DTSTART;VALUE=DATE-TIME:20000103T160000
1498DTEND;VALUE=DATE-TIME:20000103T170000
1499RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1500SUMMARY:a2")
1501
1502 (icalendar-testsuite--test-export
a4766629 1503 nil
7ec01532
GM
1504 nil
1505 "Tuesday 11:30-13:00 a3"
1506 "DTSTART;VALUE=DATE-TIME:20000104T113000
1507DTEND;VALUE=DATE-TIME:20000104T130000
1508RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU
1509SUMMARY:a3")
1510
1511 (icalendar-testsuite--test-export
a4766629 1512 nil
7ec01532
GM
1513 nil
1514 "Tuesday 15:00 a4"
1515 "DTSTART;VALUE=DATE-TIME:20000104T150000
1516DTEND;VALUE=DATE-TIME:20000104T160000
1517RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU
1518SUMMARY:a4")
1519
1520 (icalendar-testsuite--test-export
a4766629 1521 nil
7ec01532
GM
1522 nil
1523 "Wednesday 13:00 a5"
1524 "DTSTART;VALUE=DATE-TIME:20000105T130000
1525DTEND;VALUE=DATE-TIME:20000105T140000
1526RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE
1527SUMMARY:a5")
1528
1529 (icalendar-testsuite--test-export
a4766629 1530 nil
7ec01532
GM
1531 nil
1532 "Wednesday 11:30-13:30 a6"
1533 "DTSTART;VALUE=DATE-TIME:20000105T113000
1534DTEND;VALUE=DATE-TIME:20000105T133000
1535RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE
1536SUMMARY:a6")
1537
1538 (icalendar-testsuite--test-export
a4766629 1539 nil
7ec01532
GM
1540 nil
1541 "Wednesday 15:00 s1"
1542 "DTSTART;VALUE=DATE-TIME:20000105T150000
1543DTEND;VALUE=DATE-TIME:20000105T160000
1544RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE
1545SUMMARY:s1")
1546
1547
1548 ;; export 2004-10-28 regular entries
1549 (icalendar-testsuite--test-export
a4766629 1550 nil
7ec01532
GM
1551 nil
1552 "
1553>>> regular diary entries:
1554
1555Oct 12 2004, 14:00 Tue: [2004-10-12] q1"
1556 "DTSTART;VALUE=DATE-TIME:20041012T140000
1557DTEND;VALUE=DATE-TIME:20041012T150000
1558SUMMARY:Tue: [2004-10-12] q1")
1559
1560 ;; 2004-11-19
1561 (icalendar-testsuite--test-import
1562 "BEGIN:VCALENDAR
1563VERSION
1564 :2.0
1565PRODID
1566 :-//Mozilla.org/NONSGML Mozilla Calendar V1.0//EN
1567BEGIN:VEVENT
1568UID
1569 :04979712-3902-11d9-93dd-8f9f4afe08da
1570SUMMARY
1571 :Jjjjj & Wwwww
1572STATUS
1573 :TENTATIVE
1574CLASS
1575 :PRIVATE
1576X-MOZILLA-ALARM-DEFAULT-LENGTH
1577 :0
1578DTSTART
1579 :20041123T140000
1580DTEND
1581 :20041123T143000
1582DTSTAMP
1583 :20041118T013430Z
1584LAST-MODIFIED
1585 :20041118T013640Z
1586END:VEVENT
1587BEGIN:VEVENT
1588UID
1589 :6161a312-3902-11d9-b512-f764153bb28b
1590SUMMARY
1591 :BB Aaaaaaaa Bbbbb
1592STATUS
1593 :TENTATIVE
1594CLASS
1595 :PRIVATE
1596X-MOZILLA-ALARM-DEFAULT-LENGTH
1597 :0
1598DTSTART
1599 :20041123T144500
1600DTEND
1601 :20041123T154500
1602DTSTAMP
1603 :20041118T013641Z
1604END:VEVENT
1605BEGIN:VEVENT
1606UID
1607 :943a4d7e-3902-11d9-9ce7-c9addeadf928
1608SUMMARY
1609 :Hhhhhhhh
1610STATUS
1611 :TENTATIVE
1612CLASS
1613 :PRIVATE
1614X-MOZILLA-ALARM-DEFAULT-LENGTH
1615 :0
1616DTSTART
1617 :20041123T110000
1618DTEND
1619 :20041123T120000
1620DTSTAMP
1621 :20041118T013831Z
1622END:VEVENT
1623BEGIN:VEVENT
1624UID
1625 :fe53615e-3902-11d9-9dd8-9d38a155bf41
1626SUMMARY
1627 :MMM Aaaaaaaaa
1628STATUS
1629 :TENTATIVE
1630CLASS
1631 :PRIVATE
1632X-MOZILLA-ALARM-DEFAULT-LENGTH
1633 :0
1634X-MOZILLA-RECUR-DEFAULT-INTERVAL
1635 :2
1636RRULE
1637 :FREQ=WEEKLY;INTERVAL=2;BYDAY=FR
1638DTSTART
1639 :20041112T140000
1640DTEND
1641 :20041112T183000
1642DTSTAMP
1643 :20041118T014117Z
1644END:VEVENT
1645BEGIN:VEVENT
1646UID
1647 :87c928ee-3901-11d9-b21f-b45042155024
1648SUMMARY
1649 :Rrrr/Cccccc ii Aaaaaaaa
1650DESCRIPTION
1651 :Vvvvv Rrrr aaa Cccccc
1652STATUS
1653 :TENTATIVE
1654CLASS
1655 :PRIVATE
1656X-MOZILLA-ALARM-DEFAULT-LENGTH
1657 :0
1658DTSTART
1659 ;VALUE=DATE
1660 :20041119
1661DTEND
1662 ;VALUE=DATE
1663 :20041120
1664DTSTAMP
1665 :20041118T013107Z
1666LAST-MODIFIED
1667 :20041118T014203Z
1668END:VEVENT
1669BEGIN:VEVENT
1670UID
1671 :e8f331ae-3902-11d9-9948-dfdcb66a2872
1672SUMMARY
1673 :Wwww aa hhhh
1674STATUS
1675 :TENTATIVE
1676CLASS
1677 :PRIVATE
1678X-MOZILLA-ALARM-DEFAULT-LENGTH
1679 :0
1680RRULE
1681 :FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1682DTSTART
1683 ;VALUE=DATE
1684 :20041101
1685DTEND
1686 ;VALUE=DATE
1687 :20041102
1688DTSTAMP
1689 :20041118T014045Z
1690LAST-MODIFIED
1691 :20041118T023846Z
1692END:VEVENT
1693END:VCALENDAR
1694"
a4766629 1695 nil
7ec01532
GM
1696 "&23/11/2004 14:00-14:30 Jjjjj & Wwwww
1697 Status: TENTATIVE
6fe539d2 1698 Class: PRIVATE
7ec01532
GM
1699&23/11/2004 14:45-15:45 BB Aaaaaaaa Bbbbb
1700 Status: TENTATIVE
6fe539d2 1701 Class: PRIVATE
7ec01532
GM
1702&23/11/2004 11:00-12:00 Hhhhhhhh
1703 Status: TENTATIVE
6fe539d2 1704 Class: PRIVATE
7ec01532
GM
1705&%%(and (diary-cyclic 14 12 11 2004)) 14:00-18:30 MMM Aaaaaaaaa
1706 Status: TENTATIVE
6fe539d2 1707 Class: PRIVATE
7ec01532
GM
1708&%%(and (diary-block 19 11 2004 19 11 2004)) Rrrr/Cccccc ii Aaaaaaaa
1709 Desc: Vvvvv Rrrr aaa Cccccc
1710 Status: TENTATIVE
6fe539d2 1711 Class: PRIVATE
7ec01532
GM
1712&%%(and (diary-cyclic 7 1 11 2004)) Wwww aa hhhh
1713 Status: TENTATIVE
6fe539d2 1714 Class: PRIVATE"
7ec01532
GM
1715 "&11/23/2004 14:00-14:30 Jjjjj & Wwwww
1716 Status: TENTATIVE
6fe539d2 1717 Class: PRIVATE
7ec01532
GM
1718&11/23/2004 14:45-15:45 BB Aaaaaaaa Bbbbb
1719 Status: TENTATIVE
6fe539d2 1720 Class: PRIVATE
7ec01532
GM
1721&11/23/2004 11:00-12:00 Hhhhhhhh
1722 Status: TENTATIVE
6fe539d2 1723 Class: PRIVATE
7ec01532
GM
1724&%%(and (diary-cyclic 14 11 12 2004)) 14:00-18:30 MMM Aaaaaaaaa
1725 Status: TENTATIVE
6fe539d2 1726 Class: PRIVATE
7ec01532
GM
1727&%%(and (diary-block 11 19 2004 11 19 2004)) Rrrr/Cccccc ii Aaaaaaaa
1728 Desc: Vvvvv Rrrr aaa Cccccc
1729 Status: TENTATIVE
6fe539d2 1730 Class: PRIVATE
7ec01532
GM
1731&%%(and (diary-cyclic 7 11 1 2004)) Wwww aa hhhh
1732 Status: TENTATIVE
6fe539d2 1733 Class: PRIVATE")
7ec01532
GM
1734
1735 ;; 2004-09-09 pg
1736 (icalendar-testsuite--test-export
1737 "%%(diary-block 1 1 2004 4 1 2004) Urlaub"
1738 nil
a4766629 1739 nil
7ec01532
GM
1740 "DTSTART;VALUE=DATE:20040101
1741DTEND;VALUE=DATE:20040105
1742SUMMARY:Urlaub")
1743
1744 ;; 2004-10-25 pg
1745 (icalendar-testsuite--test-export
a4766629 1746 nil
7ec01532
GM
1747 "5 11 2004 Bla Fasel"
1748 nil
1749 "DTSTART;VALUE=DATE:20041105
1750DTEND;VALUE=DATE:20041106
1751SUMMARY:Bla Fasel")
1752
1753 ;; 2004-10-30 pg
1754 (icalendar-testsuite--test-export
a4766629 1755 nil
7ec01532
GM
1756 "2 Nov 2004 15:00-16:30 Zahnarzt"
1757 nil
1758 "DTSTART;VALUE=DATE-TIME:20041102T150000
1759DTEND;VALUE=DATE-TIME:20041102T163000
1760SUMMARY:Zahnarzt")
1761
1762 ;; 2005-02-07 lt
1763 (icalendar-testsuite--test-import
1764 "UID
1765 :b60d398e-1dd1-11b2-a159-cf8cb05139f4
1766SUMMARY
1767 :Waitangi Day
1768DESCRIPTION
1769 :abcdef
1770CATEGORIES
1771 :Public Holiday
1772STATUS
1773 :CONFIRMED
1774CLASS
1775 :PRIVATE
1776DTSTART
1777 ;VALUE=DATE
1778 :20050206
1779DTEND
1780 ;VALUE=DATE
1781 :20050207
1782DTSTAMP
1783 :20050128T011209Z"
a4766629 1784 nil
7ec01532 1785 "&%%(and (diary-block 6 2 2005 6 2 2005)) Waitangi Day
81ee9410
UJ
1786 Desc: abcdef
1787 Status: CONFIRMED
1788 Class: PRIVATE"
7ec01532 1789 "&%%(and (diary-block 2 6 2005 2 6 2005)) Waitangi Day
81ee9410
UJ
1790 Desc: abcdef
1791 Status: CONFIRMED
1792 Class: PRIVATE")
7ec01532
GM
1793
1794 ;; 2005-03-01 lt
1795 (icalendar-testsuite--test-import
1796 "DTSTART;VALUE=DATE:20050217
1797SUMMARY:Hhhhhh Aaaaa ii Aaaaaaaa
1798UID:6AFA7558-6994-11D9-8A3A-000A95A0E830-RID
1799DTSTAMP:20050118T210335Z
1800DURATION:P7D"
a4766629 1801 nil
7ec01532
GM
1802 "&%%(and (diary-block 17 2 2005 23 2 2005)) Hhhhhh Aaaaa ii Aaaaaaaa"
1803 "&%%(and (diary-block 2 17 2005 2 23 2005)) Hhhhhh Aaaaa ii Aaaaaaaa")
1804
1805 ;; 2005-03-23 lt
1806 (icalendar-testsuite--test-export
a4766629 1807 nil
7ec01532
GM
1808 "&%%(diary-cyclic 7 8 2 2005) 16:00-16:45 [WORK] Pppp"
1809 nil
1810 "DTSTART;VALUE=DATE-TIME:20050208T160000
1811DTEND;VALUE=DATE-TIME:20050208T164500
1812RRULE:FREQ=DAILY;INTERVAL=7
1813SUMMARY:[WORK] Pppp
1814")
1815
1816 ;; 2005-05-27 eu
1817 (icalendar-testsuite--test-export
a4766629 1818 nil
7ec01532
GM
1819 nil
1820 ;; FIXME: colon not allowed!
1821 ;;"Nov 1: NNN Wwwwwwww Wwwww - Aaaaaa Pppppppp rrrrrr ddd oo Nnnnnnnn 30"
1822 "Nov 1 NNN Wwwwwwww Wwwww - Aaaaaa Pppppppp rrrrrr ddd oo Nnnnnnnn 30"
1823 "DTSTART;VALUE=DATE:19001101
1824DTEND;VALUE=DATE:19001102
1825RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=11;BYMONTHDAY=1
1826SUMMARY:NNN Wwwwwwww Wwwww - Aaaaaa Pppppppp rrrrrr ddd oo Nnnnnnnn 30
1827")
1828 )
1829
1830(defun icalendar-testsuite--run-cycle-tests ()
a4766629 1831 "Perform cycling tests."
7ec01532
GM
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
6fe539d2
UJ
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")
7ec01532
GM
1853 )
1854
1855
1856(provide 'icalendar-testsuite)
1857
7ec01532 1858;;; icalendar-testsuite.el ends here