Fix typos.
[bpt/emacs.git] / test / automated / icalendar-tests.el
CommitLineData
4856384c 1;; icalendar-tests.el --- Test suite for icalendar.el
7ec01532 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 32;;; Code:
4856384c
UJ
33
34(require 'ert)
35(require 'icalendar)
7ec01532 36
81ee9410 37;; ======================================================================
4856384c 38;; Helpers
81ee9410 39;; ======================================================================
4856384c
UJ
40
41(defun icalendar-tests--get-ical-event (ical-string)
7877f373 42 "Return iCalendar event for ICAL-STRING."
4856384c
UJ
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)
81ee9410
UJ
50 "Remove leading and trailing whitespace from STRING."
51 (replace-regexp-in-string "[ \t\n]+\\'" ""
52 (replace-regexp-in-string "\\`[ \t\n]+" "" string)))
53
7ec01532 54;; ======================================================================
4856384c 55;; Tests of functions
7ec01532 56;; ======================================================================
7ec01532 57
4856384c
UJ
58(ert-deftest icalendar--create-uid ()
59 "Test for `icalendar--create-uid'."
60 (let* ((icalendar-uid-format "xxx-%t-%c-%h-%u-%s")
61 t-ct
62 (icalendar--uid-count 77)
63 (entry-full "30.06.1964 07:01 blahblah")
64 (hash (format "%d" (abs (sxhash entry-full))))
65 (contents "DTSTART:19640630T070100\nblahblah")
66 (username (or user-login-name "UNKNOWN_USER"))
67 )
68 (fset 't-ct (symbol-function 'current-time))
69 (unwind-protect
70 (progn
71 (fset 'current-time (lambda () '(1 2 3)))
72 (should (= 77 icalendar--uid-count))
73 (should (string= (concat "xxx-123-77-" hash "-" username "-19640630")
74 (icalendar--create-uid entry-full contents)))
75 (should (= 78 icalendar--uid-count)))
76 ;; restore 'current-time
77 (fset 'current-time (symbol-function 't-ct)))
78 (setq contents "blahblah")
79 (setq icalendar-uid-format "yyy%syyy")
80 (should (string= (concat "yyyDTSTARTyyy")
81 (icalendar--create-uid entry-full contents)))))
a4766629 82
4856384c
UJ
83(ert-deftest icalendar--calendar-style ()
84 "Test for `icalendar--date-style'."
85 (dolist (calendar-date-style '(iso american european))
86 (should (eq (icalendar--date-style) calendar-date-style)))
87 (let ((cds calendar-date-style)
88 (european-calendar-style t))
89 (makunbound 'calendar-date-style)
90 (should (eq (icalendar--date-style) 'european))
91 (with-no-warnings (setq european-calendar-style nil)) ;still get warning!?! FIXME
92 (should (eq (icalendar--date-style) 'american))
93 (setq calendar-date-style cds)))
f052351a 94
4856384c
UJ
95(ert-deftest icalendar-convert-anniversary-to-ical ()
96 "Test method for `icalendar--convert-anniversary-to-ical'."
b4340b3f
UJ
97 (let* ((calendar-date-style 'iso)
98 result)
4856384c
UJ
99 (setq result (icalendar--convert-anniversary-to-ical
100 "" "%%(diary-anniversary 1964 6 30) g"))
101 (should (= 2 (length result)))
102 (should (string= (concat
103 "\nDTSTART;VALUE=DATE:19640630"
104 "\nDTEND;VALUE=DATE:19640701"
105 "\nRRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=06;BYMONTHDAY=30")
b4340b3f 106 (car result)))
4856384c 107 (should (string= "g" (cadr result)))))
b4340b3f 108
4856384c
UJ
109(ert-deftest icalendar--convert-cyclic-to-ical ()
110 "Test method for `icalendar--convert-cyclic-to-ical'."
b4340b3f
UJ
111 (let* ((calendar-date-style 'iso)
112 result)
81ee9410 113 (setq result (icalendar--convert-block-to-ical
b4340b3f 114 "" "%%(diary-block 2004 7 19 2004 8 27) Sommerferien"))
4856384c
UJ
115 (should (= 2 (length result)))
116 (should (string= (concat
b4340b3f
UJ
117 "\nDTSTART;VALUE=DATE:20040719"
118 "\nDTEND;VALUE=DATE:20040828")
119 (car result)))
4856384c 120 (should (string= "Sommerferien" (cadr result)))))
b4340b3f 121
4856384c
UJ
122(ert-deftest icalendar--convert-block-to-ical ()
123 "Test method for `icalendar--convert-block-to-ical'."
b4340b3f
UJ
124 (let* ((calendar-date-style 'iso)
125 result)
81ee9410 126 (setq result (icalendar--convert-block-to-ical
b4340b3f 127 "" "%%(diary-block 2004 7 19 2004 8 27) Sommerferien"))
4856384c
UJ
128 (should (= 2 (length result)))
129 (should (string= (concat
b4340b3f
UJ
130 "\nDTSTART;VALUE=DATE:20040719"
131 "\nDTEND;VALUE=DATE:20040828")
132 (car result)))
4856384c 133 (should (string= "Sommerferien" (cadr result)))))
b4340b3f 134
4856384c
UJ
135(ert-deftest icalendar--convert-yearly-to-ical ()
136 "Test method for `icalendar--convert-yearly-to-ical'."
b4340b3f 137 (let* ((calendar-date-style 'iso)
4856384c
UJ
138 result
139 (calendar-month-name-array
140 ["January" "February" "March" "April" "May" "June" "July" "August"
141 "September" "October" "November" "December"]))
142 (setq result (icalendar--convert-yearly-to-ical "" "May 1 Tag der Arbeit"))
143 (should (= 2 (length result)))
144 (should (string= (concat
145 "\nDTSTART;VALUE=DATE:19000501"
146 "\nDTEND;VALUE=DATE:19000502"
147 "\nRRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=5;BYMONTHDAY=1")
b4340b3f 148 (car result)))
4856384c 149 (should (string= "Tag der Arbeit" (cadr result)))))
a4766629 150
4856384c
UJ
151(ert-deftest icalendar--convert-weekly-to-ical ()
152 "Test method for `icalendar--convert-weekly-to-ical'."
153 (let* ((calendar-date-style 'iso)
154 result
155 (calendar-day-name-array
156 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday"
157 "Saturday"]))
158 (setq result (icalendar--convert-weekly-to-ical "" "Monday 8:30 subject"))
159 (should (= 2 (length result)))
160 (should (string= (concat "\nDTSTART;VALUE=DATE-TIME:20050103T083000"
161 "\nDTEND;VALUE=DATE-TIME:20050103T093000"
162 "\nRRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO")
163 (car result)))
164 (should (string= "subject" (cadr result)))))
aad81014 165
4856384c 166(ert-deftest icalendar--parse-vtimezone ()
81ee9410 167 "Test method for `icalendar--parse-vtimezone'."
6fe539d2 168 (let (vtimezone result)
4856384c 169 (setq vtimezone (icalendar-tests--get-ical-event "BEGIN:VTIMEZONE
6fe539d2
UJ
170TZID:thename
171BEGIN:STANDARD
172DTSTART:16010101T040000
173TZOFFSETFROM:+0300
174TZOFFSETTO:+0200
175RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10
176END:STANDARD
177BEGIN:DAYLIGHT
178DTSTART:16010101T030000
179TZOFFSETFROM:+0200
180TZOFFSETTO:+0300
181RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3
182END:DAYLIGHT
183END:VTIMEZONE
184"))
185 (setq result (icalendar--parse-vtimezone vtimezone))
4856384c 186 (should (string= "thename" (car result)))
6fe539d2 187 (message (cdr result))
4856384c 188 (should (string= "STD-02:00DST-03:00,M3.5.0/03:00:00,M10.5.0/04:00:00"
81ee9410 189 (cdr result)))
4856384c 190 (setq vtimezone (icalendar-tests--get-ical-event "BEGIN:VTIMEZONE
6fe539d2
UJ
191TZID:anothername
192BEGIN:STANDARD
193DTSTART:16010101T040000
194TZOFFSETFROM:+0300
195TZOFFSETTO:+0200
196RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2MO;BYMONTH=10
197END:STANDARD
198BEGIN:DAYLIGHT
199DTSTART:16010101T030000
200TZOFFSETFROM:+0200
201TZOFFSETTO:+0300
202RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2MO;BYMONTH=3
203END:DAYLIGHT
204END:VTIMEZONE
205"))
206 (setq result (icalendar--parse-vtimezone vtimezone))
4856384c 207 (should (string= "anothername" (car result)))
6fe539d2 208 (message (cdr result))
4856384c
UJ
209 (should (string= "STD-02:00DST-03:00,M3.2.1/03:00:00,M10.2.1/04:00:00"
210 (cdr result)))))
211
212(ert-deftest icalendar--convert-ordinary-to-ical ()
213 "Test method for `icalendar--convert-ordinary-to-ical'."
214 (let* ((calendar-date-style 'iso)
215 result)
216 ;; without time
217 (setq result (icalendar--convert-ordinary-to-ical "&?" "2010 2 15 subject"))
218 (should (= 2 (length result)))
219 (should (string= "\nDTSTART;VALUE=DATE:20100215\nDTEND;VALUE=DATE:20100216"
220 (car result)))
221 (should (string= "subject" (cadr result)))
7877f373 222
4856384c
UJ
223 ;; with time
224 (setq result (icalendar--convert-ordinary-to-ical
225 "&?" "&2010 2 15 12:34-23:45 s"))
226 (should (= 2 (length result)))
227 (should (string= (concat "\nDTSTART;VALUE=DATE-TIME:20100215T123400"
228 "\nDTEND;VALUE=DATE-TIME:20100215T234500")
229 (car result)))
230 (should (string= "s" (cadr result)))
231
232 ;; with time, again -- test bug#5549
233 (setq result (icalendar--convert-ordinary-to-ical
234 "x?" "x2010 2 15 0:34-1:45 s"))
235 (should (= 2 (length result)))
236 (should (string= (concat "\nDTSTART;VALUE=DATE-TIME:20100215T003400"
237 "\nDTEND;VALUE=DATE-TIME:20100215T014500")
238 (car result)))
239 (should (string= "s" (cadr result)))))
240
241(ert-deftest icalendar--diarytime-to-isotime ()
242 "Test method for `icalendar--diarytime-to-isotime'."
68575ab0
UJ
243 (should (string= "T011500"
244 (icalendar--diarytime-to-isotime "01:15" "")))
245 (should (string= "T011500"
246 (icalendar--diarytime-to-isotime "1:15" "")))
247 (should (string= "T000100"
248 (icalendar--diarytime-to-isotime "0:01" "")))
249 (should (string= "T010000"
250 (icalendar--diarytime-to-isotime "0100" "")))
251 (should (string= "T010000"
252 (icalendar--diarytime-to-isotime "0100" "am")))
253 (should (string= "T130000"
254 (icalendar--diarytime-to-isotime "0100" "pm")))
255 (should (string= "T120000"
256 (icalendar--diarytime-to-isotime "1200" "")))
257 (should (string= "T171700"
258 (icalendar--diarytime-to-isotime "17:17" "")))
259 (should (string= "T000000"
260 (icalendar--diarytime-to-isotime "1200" "am")))
261 (should (string= "T000100"
262 (icalendar--diarytime-to-isotime "1201" "am")))
263 (should (string= "T005900"
264 (icalendar--diarytime-to-isotime "1259" "am")))
265 (should (string= "T120000"
266 (icalendar--diarytime-to-isotime "1200" "pm")))
267 (should (string= "T120100"
268 (icalendar--diarytime-to-isotime "1201" "pm")))
269 (should (string= "T125900"
270 (icalendar--diarytime-to-isotime "1259" "pm"))))
4856384c
UJ
271
272(ert-deftest icalendar--datetime-to-diary-date ()
273 "Test method for `icalendar--datetime-to-diary-date'."
274 (let* ((datetime '(59 59 23 31 12 2008))
275 (calendar-date-style 'iso))
68575ab0
UJ
276 (should (string= "2008 12 31"
277 (icalendar--datetime-to-diary-date datetime)))
4856384c 278 (setq calendar-date-style 'european)
68575ab0
UJ
279 (should (string= "31 12 2008"
280 (icalendar--datetime-to-diary-date datetime)))
4856384c 281 (setq calendar-date-style 'american)
68575ab0
UJ
282 (should (string= "12 31 2008"
283 (icalendar--datetime-to-diary-date datetime)))))
4856384c
UJ
284
285(ert-deftest icalendar--datestring-to-isodate ()
286 "Test method for `icalendar--datestring-to-isodate'."
287 (let ((calendar-date-style 'iso))
288 ;; numeric iso
68575ab0
UJ
289 (should (string= "20080511"
290 (icalendar--datestring-to-isodate "2008 05 11")))
291 (should (string= "20080531"
292 (icalendar--datestring-to-isodate "2008 05 31")))
293 (should (string= "20080602"
294 (icalendar--datestring-to-isodate "2008 05 31" 2)))
4856384c
UJ
295
296 ;; numeric european
297 (setq calendar-date-style 'european)
68575ab0
UJ
298 (should (string= "20080511"
299 (icalendar--datestring-to-isodate "11 05 2008")))
300 (should (string= "20080531"
301 (icalendar--datestring-to-isodate "31 05 2008")))
302 (should (string= "20080602"
303 (icalendar--datestring-to-isodate "31 05 2008" 2)))
4856384c
UJ
304
305 ;; numeric american
306 (setq calendar-date-style 'american)
68575ab0
UJ
307 (should (string= "20081105"
308 (icalendar--datestring-to-isodate "11 05 2008")))
309 (should (string= "20081230"
310 (icalendar--datestring-to-isodate "12 30 2008")))
311 (should (string= "20090101"
312 (icalendar--datestring-to-isodate "12 30 2008" 2)))
4856384c
UJ
313
314 ;; non-numeric
315 (setq calendar-date-style nil) ;not necessary for conversion
68575ab0
UJ
316 (should (string= "20081105"
317 (icalendar--datestring-to-isodate "Nov 05 2008")))
318 (should (string= "20081105"
319 (icalendar--datestring-to-isodate "05 Nov 2008")))
320 (should (string= "20081105"
321 (icalendar--datestring-to-isodate "2008 Nov 05")))))
4856384c
UJ
322
323(ert-deftest icalendar--first-weekday-of-year ()
324 "Test method for `icalendar-first-weekday-of-year'."
325 (should (eq 1 (icalendar-first-weekday-of-year "TU" 2008)))
326 (should (eq 3 (icalendar-first-weekday-of-year "WE" 2007)))
327 (should (eq 5 (icalendar-first-weekday-of-year "TH" 2006)))
328 (should (eq 7 (icalendar-first-weekday-of-year "FR" 2005)))
329 (should (eq 3 (icalendar-first-weekday-of-year "SA" 2004)))
330 (should (eq 5 (icalendar-first-weekday-of-year "SU" 2003)))
331 (should (eq 7 (icalendar-first-weekday-of-year "MO" 2002)))
332 (should (eq 3 (icalendar-first-weekday-of-year "MO" 2000)))
333 (should (eq 1 (icalendar-first-weekday-of-year "TH" 1970))))
334
335(ert-deftest icalendar--import-format-sample ()
336 "Test method for `icalendar-import-format-sample'."
68575ab0
UJ
337 (should (string= (concat "SUMMARY=`a' DESCRIPTION=`b' LOCATION=`c' "
338 "ORGANIZER=`d' STATUS=`' URL=`' CLASS=`'")
339 (icalendar-import-format-sample
4856384c
UJ
340 (icalendar-tests--get-ical-event "BEGIN:VEVENT
341DTSTAMP:20030509T043439Z
342DTSTART:20030509T103000
343SUMMARY:a
344ORGANIZER:d
345LOCATION:c
346DTEND:20030509T153000
347DESCRIPTION:b
348END:VEVENT
68575ab0 349")))))
4856384c
UJ
350
351(ert-deftest icalendar--format-ical-event ()
352 "Test `icalendar--format-ical-event'."
353 (let ((icalendar-import-format "%s%d%l%o%t%u%c")
354 (icalendar-import-format-summary "SUM %s")
355 (icalendar-import-format-location " LOC %s")
356 (icalendar-import-format-description " DES %s")
357 (icalendar-import-format-organizer " ORG %s")
358 (icalendar-import-format-status " STA %s")
359 (icalendar-import-format-url " URL %s")
360 (icalendar-import-format-class " CLA %s")
361 (event (icalendar-tests--get-ical-event "BEGIN:VEVENT
362DTSTAMP:20030509T043439Z
363DTSTART:20030509T103000
364SUMMARY:sum
365ORGANIZER:org
366LOCATION:loc
367DTEND:20030509T153000
368DESCRIPTION:des
369END:VEVENT
370")))
68575ab0
UJ
371 (should (string= "SUM sum DES des LOC loc ORG org"
372 (icalendar--format-ical-event event)))
4856384c
UJ
373 (setq icalendar-import-format (lambda (&rest ignore)
374 "helloworld"))
68575ab0 375 (should (string= "helloworld" (icalendar--format-ical-event event)))
4856384c
UJ
376 (setq icalendar-import-format
377 (lambda (e)
378 (format "-%s-%s-%s-%s-%s-%s-%s-"
379 (icalendar--get-event-property event 'SUMMARY)
380 (icalendar--get-event-property event 'DESCRIPTION)
381 (icalendar--get-event-property event 'LOCATION)
382 (icalendar--get-event-property event 'ORGANIZER)
383 (icalendar--get-event-property event 'STATUS)
384 (icalendar--get-event-property event 'URL)
385 (icalendar--get-event-property event 'CLASS))))
68575ab0
UJ
386 (should (string= "-sum-des-loc-org-nil-nil-nil-"
387 (icalendar--format-ical-event event)))))
4856384c
UJ
388
389(ert-deftest icalendar--parse-summary-and-rest ()
390 "Test `icalendar--parse-summary-and-rest'."
391 (let ((icalendar-import-format "%s%d%l%o%t%u%c")
392 (icalendar-import-format-summary "SUM %s")
393 (icalendar-import-format-location " LOC %s")
394 (icalendar-import-format-description " DES %s")
395 (icalendar-import-format-organizer " ORG %s")
396 (icalendar-import-format-status " STA %s")
397 (icalendar-import-format-url " URL %s")
398 (icalendar-import-format-class " CLA %s")
399 (result))
400 (setq result (icalendar--parse-summary-and-rest "SUM sum ORG org"))
68575ab0 401 (should (string= "org" (cdr (assoc 'org result))))
4856384c
UJ
402
403 (setq result (icalendar--parse-summary-and-rest
404 "SUM sum DES des LOC loc ORG org STA sta URL url CLA cla"))
68575ab0
UJ
405 (should (string= "des" (cdr (assoc 'des result))))
406 (should (string= "loc" (cdr (assoc 'loc result))))
407 (should (string= "org" (cdr (assoc 'org result))))
408 (should (string= "sta" (cdr (assoc 'sta result))))
409 (should (string= "cla" (cdr (assoc 'cla result))))
4856384c
UJ
410
411 (setq icalendar-import-format (lambda () "Hello world"))
412 (setq result (icalendar--parse-summary-and-rest
413 "blah blah "))
414 (should (not result))
415 ))
f052351a 416
7ec01532 417;; ======================================================================
4856384c 418;; Export tests
7ec01532
GM
419;; ======================================================================
420
4856384c
UJ
421(defun icalendar-tests--test-export (input-iso input-european input-american
422 expected-output)
7ec01532 423 "Perform an export test.
a4766629 424Argument INPUT-ISO iso style diary string.
7ec01532
GM
425Argument INPUT-EUROPEAN european style diary string.
426Argument INPUT-AMERICAN american style diary string.
7877f373 427Argument EXPECTED-OUTPUT expected iCalendar result string.
a4766629
GM
428
429European style input data must use german month names. American
430and ISO style input data must use english month names."
4856384c
UJ
431 (let ((tz (cadr (current-time-zone)))
432 (calendar-date-style 'iso)
433 (icalendar-recurring-start-year 2000))
434 (unwind-protect
435 (progn
436 (set-time-zone-rule "CET")
437 (when input-iso
438 (let ((calendar-month-name-array
439 ["January" "February" "March" "April" "May" "June" "July" "August"
440 "September" "October" "November" "December"])
441 (calendar-day-name-array
442 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday"
443 "Saturday"]))
444 (setq calendar-date-style 'iso)
445 (icalendar-tests--do-test-export input-iso expected-output)))
446 (when input-european
447 (let ((calendar-month-name-array
448 ["Januar" "Februar" "März" "April" "Mai" "Juni" "Juli" "August"
449 "September" "Oktober" "November" "Dezember"])
450 (calendar-day-name-array
451 ["Sonntag" "Montag" "Dienstag" "Mittwoch" "Donnerstag" "Freitag"
452 "Samstag"]))
453 (setq calendar-date-style 'european)
454 (icalendar-tests--do-test-export input-european expected-output)))
455 (when input-american
456 (let ((calendar-month-name-array
457 ["January" "February" "March" "April" "May" "June" "July" "August"
458 "September" "October" "November" "December"])
459 (calendar-day-name-array
460 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday"
461 "Saturday"]))
462 (setq calendar-date-style 'american)
463 (icalendar-tests--do-test-export input-american expected-output))))
464 ;; restore time-zone if something went terribly wrong
465 (set-time-zone-rule tz))))
466
467(defun icalendar-tests--do-test-export (input expected-output)
7ec01532
GM
468 "Actually perform export test.
469Argument INPUT input diary string.
7877f373 470Argument EXPECTED-OUTPUT expected iCalendar result string."
4856384c
UJ
471 (let ((temp-file (make-temp-file "icalendar-tests-ics")))
472 (unwind-protect
473 (progn
474 (with-temp-buffer
475 (insert input)
476 (icalendar-export-region (point-min) (point-max) temp-file))
477 (save-excursion
478 (find-file temp-file)
479 (goto-char (point-min))
480 (cond (expected-output
481 (should (re-search-forward "^\\s-*BEGIN:VCALENDAR
7ec01532
GM
482PRODID:-//Emacs//NONSGML icalendar.el//EN
483VERSION:2.0
484BEGIN:VEVENT
485UID:emacs[0-9]+
486\\(\\(.\\|\n\\)+\\)
487END:VEVENT
488END:VCALENDAR
489\\s-*$"
4856384c
UJ
490 nil t))
491 (should (string-match
492 (concat "^\\s-*"
493 (regexp-quote (buffer-substring-no-properties
494 (match-beginning 1) (match-end 1)))
495 "\\s-*$")
496 expected-output)))
497 (t
498 (should (re-search-forward "^\\s-*BEGIN:VCALENDAR
7ec01532
GM
499PRODID:-//Emacs//NONSGML icalendar.el//EN
500VERSION:2.0
501END:VCALENDAR
502\\s-*$"
4856384c
UJ
503 nil t))))))
504 ;; cleanup!!
505 (kill-buffer (find-buffer-visiting temp-file))
506 (delete-file temp-file))))
507
508(ert-deftest icalendar-export-ordinary-no-time ()
509 "Perform export test."
510
511 (let ((icalendar-export-hidden-diary-entries nil))
512 (icalendar-tests--test-export
513 "&2000 Oct 3 ordinary no time "
514 "&3 Okt 2000 ordinary no time "
515 "&Oct 3 2000 ordinary no time "
516 nil))
517
518 (icalendar-tests--test-export
519 "2000 Oct 3 ordinary no time "
520 "3 Okt 2000 ordinary no time "
521 "Oct 3 2000 ordinary no time "
522 "DTSTART;VALUE=DATE:20001003
523DTEND;VALUE=DATE:20001004
524SUMMARY:ordinary no time
525"))
526
527(ert-deftest icalendar-export-ordinary ()
528 "Perform export test."
529
530 (icalendar-tests--test-export
531 "2000 Oct 3 16:30 ordinary with time"
532 "3 Okt 2000 16:30 ordinary with time"
533 "Oct 3 2000 16:30 ordinary with time"
534 "DTSTART;VALUE=DATE-TIME:20001003T163000
535DTEND;VALUE=DATE-TIME:20001003T173000
536SUMMARY:ordinary with time
537")
538 (icalendar-tests--test-export
539 "2000 10 3 16:30 ordinary with time 2"
540 "3 10 2000 16:30 ordinary with time 2"
541 "10 3 2000 16:30 ordinary with time 2"
542 "DTSTART;VALUE=DATE-TIME:20001003T163000
543DTEND;VALUE=DATE-TIME:20001003T173000
544SUMMARY:ordinary with time 2
545")
546
547 (icalendar-tests--test-export
548 "2000/10/3 16:30 ordinary with time 3"
549 "3/10/2000 16:30 ordinary with time 3"
550 "10/3/2000 16:30 ordinary with time 3"
551 "DTSTART;VALUE=DATE-TIME:20001003T163000
552DTEND;VALUE=DATE-TIME:20001003T173000
553SUMMARY:ordinary with time 3
554"))
555
556(ert-deftest icalendar-export-multiline ()
557 "Perform export test."
558
559 ;; multiline -- FIXME!!!
560 (icalendar-tests--test-export
561 "2000 October 3 16:30 multiline
562 17:30 multiline continued FIXME"
563 "3 Oktober 2000 16:30 multiline
564 17:30 multiline continued FIXME"
565 "October 3 2000 16:30 multiline
566 17:30 multiline continued FIXME"
567 "DTSTART;VALUE=DATE-TIME:20001003T163000
568DTEND;VALUE=DATE-TIME:20001003T173000
569SUMMARY:multiline
570DESCRIPTION:
571 17:30 multiline continued FIXME
572"))
573
574(ert-deftest icalendar-export-weekly-by-day ()
575 "Perform export test."
576
577 ;; weekly by day
578 (icalendar-tests--test-export
579 "Monday 1:30pm weekly by day with start time"
580 "Montag 13:30 weekly by day with start time"
581 "Monday 1:30pm weekly by day with start time"
582 "DTSTART;VALUE=DATE-TIME:20000103T133000
583DTEND;VALUE=DATE-TIME:20000103T143000
584RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
585SUMMARY:weekly by day with start time
586")
587
588 (icalendar-tests--test-export
589 "Monday 13:30-15:00 weekly by day with start and end time"
590 "Montag 13:30-15:00 weekly by day with start and end time"
591 "Monday 01:30pm-03:00pm weekly by day with start and end time"
592 "DTSTART;VALUE=DATE-TIME:20000103T133000
593DTEND;VALUE=DATE-TIME:20000103T150000
594RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
595SUMMARY:weekly by day with start and end time
596"))
597
598(ert-deftest icalendar-export-yearly ()
599 "Perform export test."
600 ;; yearly
601 (icalendar-tests--test-export
602 "may 1 yearly no time"
603 "1 Mai yearly no time"
604 "may 1 yearly no time"
605 "DTSTART;VALUE=DATE:19000501
606DTEND;VALUE=DATE:19000502
607RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=5;BYMONTHDAY=1
608SUMMARY:yearly no time
609"))
610
611(ert-deftest icalendar-export-anniversary ()
612 "Perform export test."
613 ;; anniversaries
614 (icalendar-tests--test-export
615 "%%(diary-anniversary 1989 10 3) anniversary no time"
616 "%%(diary-anniversary 3 10 1989) anniversary no time"
617 "%%(diary-anniversary 10 3 1989) anniversary no time"
618 "DTSTART;VALUE=DATE:19891003
619DTEND;VALUE=DATE:19891004
620RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=10;BYMONTHDAY=03
621SUMMARY:anniversary no time
622")
623 (icalendar-tests--test-export
624 "%%(diary-anniversary 1989 10 3) 19:00-20:00 anniversary with time"
625 "%%(diary-anniversary 3 10 1989) 19:00-20:00 anniversary with time"
626 "%%(diary-anniversary 10 3 1989) 19:00-20:00 anniversary with time"
627 "DTSTART;VALUE=DATE-TIME:19891003T190000
628DTEND;VALUE=DATE-TIME:19891004T200000
629RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=10;BYMONTHDAY=03
630SUMMARY:anniversary with time
631"))
632
633(ert-deftest icalendar-export-block ()
634 "Perform export test."
635 ;; block
636 (icalendar-tests--test-export
637 "%%(diary-block 2001 6 18 2001 7 6) block no time"
638 "%%(diary-block 18 6 2001 6 7 2001) block no time"
639 "%%(diary-block 6 18 2001 7 6 2001) block no time"
640 "DTSTART;VALUE=DATE:20010618
641DTEND;VALUE=DATE:20010707
642SUMMARY:block no time
643")
644 (icalendar-tests--test-export
645 "%%(diary-block 2001 6 18 2001 7 6) 13:00-17:00 block with time"
646 "%%(diary-block 18 6 2001 6 7 2001) 13:00-17:00 block with time"
647 "%%(diary-block 6 18 2001 7 6 2001) 13:00-17:00 block with time"
648 "DTSTART;VALUE=DATE-TIME:20010618T130000
649DTEND;VALUE=DATE-TIME:20010618T170000
650RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20010706
651SUMMARY:block with time
652")
653 (icalendar-tests--test-export
654 "%%(diary-block 2001 6 18 2001 7 6) 13:00 block no end time"
655 "%%(diary-block 18 6 2001 6 7 2001) 13:00 block no end time"
656 "%%(diary-block 6 18 2001 7 6 2001) 13:00 block no end time"
657 "DTSTART;VALUE=DATE-TIME:20010618T130000
658DTEND;VALUE=DATE-TIME:20010618T140000
659RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20010706
660SUMMARY:block no end time
661"))
7ec01532
GM
662
663;; ======================================================================
4856384c 664;; Import tests
7ec01532
GM
665;; ======================================================================
666
4856384c
UJ
667(defun icalendar-tests--test-import (input expected-iso expected-european
668 expected-american)
7ec01532
GM
669 "Perform import test.
670Argument INPUT icalendar event string.
a4766629 671Argument EXPECTED-ISO expected iso style diary string.
7ec01532
GM
672Argument EXPECTED-EUROPEAN expected european style diary string.
673Argument EXPECTED-AMERICAN expected american style diary string."
7ec01532
GM
674 (let ((timezone (cadr (current-time-zone))))
675 (set-time-zone-rule "CET")
676 (with-temp-buffer
677 (if (string-match "^BEGIN:VCALENDAR" input)
678 (insert input)
679 (insert "BEGIN:VCALENDAR\nPRODID:-//Emacs//NONSGML icalendar.el//EN\n")
680 (insert "VERSION:2.0\nBEGIN:VEVENT\n")
681 (insert input)
682 (unless (eq (char-before) ?\n)
683 (insert "\n"))
684 (insert "END:VEVENT\nEND:VCALENDAR\n"))
685 (let ((icalendar-import-format "%s%d%l%o%t%u%c")
686 (icalendar-import-format-summary "%s")
687 (icalendar-import-format-location "\n Location: %s")
688 (icalendar-import-format-description "\n Desc: %s")
689 (icalendar-import-format-organizer "\n Organizer: %s")
690 (icalendar-import-format-status "\n Status: %s")
691 (icalendar-import-format-url "\n URL: %s")
692 (icalendar-import-format-class "\n Class: %s")
a4766629
GM
693 calendar-date-style)
694 (when expected-iso
695 (setq calendar-date-style 'iso)
4856384c 696 (icalendar-tests--do-test-import input expected-iso))
7ec01532 697 (when expected-european
a4766629 698 (setq calendar-date-style 'european)
4856384c 699 (icalendar-tests--do-test-import input expected-european))
7ec01532 700 (when expected-american
a4766629 701 (setq calendar-date-style 'american)
4856384c 702 (icalendar-tests--do-test-import input expected-american))))
7ec01532
GM
703 (set-time-zone-rule timezone)))
704
4856384c 705(defun icalendar-tests--do-test-import (input expected-output)
7ec01532
GM
706 "Actually perform import test.
707Argument INPUT input icalendar string.
708Argument EXPECTED-OUTPUT expected diary string."
709 (let ((temp-file (make-temp-file "icalendar-test-diary")))
710 (icalendar-import-buffer temp-file t t)
68575ab0
UJ
711 (save-excursion
712 (find-file temp-file)
713 (let ((result (buffer-substring-no-properties (point-min) (point-max))))
714 (should (string= expected-output result)))
7ec01532
GM
715 (kill-buffer (find-buffer-visiting temp-file))
716 (delete-file temp-file))))
717
4856384c 718(ert-deftest icalendar-import-non-recurring ()
7ec01532 719 "Perform standard import tests."
4856384c 720 (icalendar-tests--test-import
7ec01532
GM
721 "SUMMARY:non-recurring
722DTSTART;VALUE=DATE-TIME:20030919T090000
723DTEND;VALUE=DATE-TIME:20030919T113000"
68575ab0
UJ
724 "&2003/9/19 09:00-11:30 non-recurring\n"
725 "&19/9/2003 09:00-11:30 non-recurring\n"
726 "&9/19/2003 09:00-11:30 non-recurring\n")
4856384c 727 (icalendar-tests--test-import
7ec01532
GM
728 "SUMMARY:non-recurring allday
729DTSTART;VALUE=DATE-TIME:20030919"
68575ab0
UJ
730 "&2003/9/19 non-recurring allday\n"
731 "&19/9/2003 non-recurring allday\n"
732 "&9/19/2003 non-recurring allday\n")
4856384c 733 (icalendar-tests--test-import
81ee9410 734 ;; do not remove the trailing blank after "long"!
7877f373 735 "SUMMARY:long
7ec01532
GM
736 summary
737DTSTART;VALUE=DATE:20030919"
68575ab0
UJ
738 "&2003/9/19 long summary\n"
739 "&19/9/2003 long summary\n"
740 "&9/19/2003 long summary\n")
4856384c 741 (icalendar-tests--test-import
7ec01532
GM
742 "UID:748f2da0-0d9b-11d8-97af-b4ec8686ea61
743SUMMARY:Sommerferien
744STATUS:TENTATIVE
745CLASS:PRIVATE
746X-MOZILLA-ALARM-DEFAULT-UNITS:Minuten
747X-MOZILLA-RECUR-DEFAULT-INTERVAL:0
748DTSTART;VALUE=DATE:20040719
749DTEND;VALUE=DATE:20040828
750DTSTAMP:20031103T011641Z
751"
81ee9410
UJ
752 "&%%(and (diary-block 2004 7 19 2004 8 27)) Sommerferien
753 Status: TENTATIVE
754 Class: PRIVATE
755"
756 "&%%(and (diary-block 19 7 2004 27 8 2004)) Sommerferien
757 Status: TENTATIVE
758 Class: PRIVATE
759"
760 "&%%(and (diary-block 7 19 2004 8 27 2004)) Sommerferien
761 Status: TENTATIVE
68575ab0
UJ
762 Class: PRIVATE
763")
4856384c 764 (icalendar-tests--test-import
7ec01532
GM
765 "UID
766 :04979712-3902-11d9-93dd-8f9f4afe08da
767SUMMARY
768 :folded summary
769STATUS
770 :TENTATIVE
771CLASS
772 :PRIVATE
773X-MOZILLA-ALARM-DEFAULT-LENGTH
774 :0
775DTSTART
776 :20041123T140000
777DTEND
778 :20041123T143000
779DTSTAMP
780 :20041118T013430Z
781LAST-MODIFIED
782 :20041118T013640Z
783"
81ee9410
UJ
784 "&2004/11/23 14:00-14:30 folded summary
785 Status: TENTATIVE
68575ab0 786 Class: PRIVATE\n"
81ee9410
UJ
787 "&23/11/2004 14:00-14:30 folded summary
788 Status: TENTATIVE
68575ab0 789 Class: PRIVATE\n"
81ee9410
UJ
790 "&11/23/2004 14:00-14:30 folded summary
791 Status: TENTATIVE
68575ab0 792 Class: PRIVATE\n")
4856384c
UJ
793
794 (icalendar-tests--test-import
7ec01532
GM
795 "UID
796 :6161a312-3902-11d9-b512-f764153bb28b
797SUMMARY
798 :another example
799STATUS
800 :TENTATIVE
801CLASS
802 :PRIVATE
803X-MOZILLA-ALARM-DEFAULT-LENGTH
804 :0
805DTSTART
806 :20041123T144500
807DTEND
808 :20041123T154500
809DTSTAMP
810 :20041118T013641Z
811"
81ee9410
UJ
812 "&2004/11/23 14:45-15:45 another example
813 Status: TENTATIVE
68575ab0 814 Class: PRIVATE\n"
81ee9410
UJ
815 "&23/11/2004 14:45-15:45 another example
816 Status: TENTATIVE
68575ab0 817 Class: PRIVATE\n"
81ee9410
UJ
818 "&11/23/2004 14:45-15:45 another example
819 Status: TENTATIVE
68575ab0 820 Class: PRIVATE\n"))
a4766629 821
4856384c
UJ
822(ert-deftest icalendar-import-rrule ()
823 (icalendar-tests--test-import
7ec01532
GM
824 "SUMMARY:rrule daily
825DTSTART;VALUE=DATE-TIME:20030919T090000
826DTEND;VALUE=DATE-TIME:20030919T113000
827RRULE:FREQ=DAILY;
828"
68575ab0
UJ
829 "&%%(and (diary-cyclic 1 2003 9 19)) 09:00-11:30 rrule daily\n"
830 "&%%(and (diary-cyclic 1 19 9 2003)) 09:00-11:30 rrule daily\n"
831 "&%%(and (diary-cyclic 1 9 19 2003)) 09:00-11:30 rrule daily\n")
7ec01532 832 ;; RRULE examples
4856384c 833 (icalendar-tests--test-import
7ec01532
GM
834 "SUMMARY:rrule daily
835DTSTART;VALUE=DATE-TIME:20030919T090000
836DTEND;VALUE=DATE-TIME:20030919T113000
837RRULE:FREQ=DAILY;INTERVAL=2
838"
68575ab0
UJ
839 "&%%(and (diary-cyclic 2 2003 9 19)) 09:00-11:30 rrule daily\n"
840 "&%%(and (diary-cyclic 2 19 9 2003)) 09:00-11:30 rrule daily\n"
841 "&%%(and (diary-cyclic 2 9 19 2003)) 09:00-11:30 rrule daily\n")
4856384c 842 (icalendar-tests--test-import
7ec01532
GM
843 "SUMMARY:rrule daily with exceptions
844DTSTART;VALUE=DATE-TIME:20030919T090000
845DTEND;VALUE=DATE-TIME:20030919T113000
846RRULE:FREQ=DAILY;INTERVAL=2
847EXDATE:20030921,20030925
848"
68575ab0
UJ
849 "&%%(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\n"
850 "&%%(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\n"
851 "&%%(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\n")
4856384c 852 (icalendar-tests--test-import
7ec01532
GM
853 "SUMMARY:rrule weekly
854DTSTART;VALUE=DATE-TIME:20030919T090000
855DTEND;VALUE=DATE-TIME:20030919T113000
856RRULE:FREQ=WEEKLY;
857"
68575ab0
UJ
858 "&%%(and (diary-cyclic 7 2003 9 19)) 09:00-11:30 rrule weekly\n"
859 "&%%(and (diary-cyclic 7 19 9 2003)) 09:00-11:30 rrule weekly\n"
860 "&%%(and (diary-cyclic 7 9 19 2003)) 09:00-11:30 rrule weekly\n")
4856384c 861 (icalendar-tests--test-import
7ec01532
GM
862 "SUMMARY:rrule monthly no end
863DTSTART;VALUE=DATE-TIME:20030919T090000
864DTEND;VALUE=DATE-TIME:20030919T113000
865RRULE:FREQ=MONTHLY;
866"
68575ab0
UJ
867 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 9999 1 1)) 09:00-11:30 rrule monthly no end\n"
868 "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 1 1 9999)) 09:00-11:30 rrule monthly no end\n"
869 "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 1 1 9999)) 09:00-11:30 rrule monthly no end\n")
4856384c 870 (icalendar-tests--test-import
7ec01532
GM
871 "SUMMARY:rrule monthly with end
872DTSTART;VALUE=DATE-TIME:20030919T090000
873DTEND;VALUE=DATE-TIME:20030919T113000
874RRULE:FREQ=MONTHLY;UNTIL=20050819;
875"
68575ab0
UJ
876 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2005 8 19)) 09:00-11:30 rrule monthly with end\n"
877 "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 19 8 2005)) 09:00-11:30 rrule monthly with end\n"
878 "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 8 19 2005)) 09:00-11:30 rrule monthly with end\n")
4856384c 879 (icalendar-tests--test-import
7ec01532
GM
880 "DTSTART;VALUE=DATE:20040815
881DTEND;VALUE=DATE:20040816
882SUMMARY:Maria Himmelfahrt
883UID:CC56BEA6-49D2-11D8-8833-00039386D1C2-RID
884RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=8
885"
68575ab0
UJ
886 "&%%(and (diary-anniversary 2004 8 15)) Maria Himmelfahrt\n"
887 "&%%(and (diary-anniversary 15 8 2004)) Maria Himmelfahrt\n"
888 "&%%(and (diary-anniversary 8 15 2004)) Maria Himmelfahrt\n")
4856384c 889 (icalendar-tests--test-import
7ec01532
GM
890 "SUMMARY:rrule yearly
891DTSTART;VALUE=DATE-TIME:20030919T090000
892DTEND;VALUE=DATE-TIME:20030919T113000
893RRULE:FREQ=YEARLY;INTERVAL=2
894"
68575ab0
UJ
895 "&%%(and (diary-anniversary 2003 9 19)) 09:00-11:30 rrule yearly\n" ;FIXME
896 "&%%(and (diary-anniversary 19 9 2003)) 09:00-11:30 rrule yearly\n" ;FIXME
897 "&%%(and (diary-anniversary 9 19 2003)) 09:00-11:30 rrule yearly\n") ;FIXME
4856384c 898 (icalendar-tests--test-import
7ec01532
GM
899 "SUMMARY:rrule count daily short
900DTSTART;VALUE=DATE-TIME:20030919T090000
901DTEND;VALUE=DATE-TIME:20030919T113000
902RRULE:FREQ=DAILY;COUNT=1;INTERVAL=1
903"
68575ab0
UJ
904 "&%%(and (diary-cyclic 1 2003 9 19) (diary-block 2003 9 19 2003 9 19)) 09:00-11:30 rrule count daily short\n"
905 "&%%(and (diary-cyclic 1 19 9 2003) (diary-block 19 9 2003 19 9 2003)) 09:00-11:30 rrule count daily short\n"
906 "&%%(and (diary-cyclic 1 9 19 2003) (diary-block 9 19 2003 9 19 2003)) 09:00-11:30 rrule count daily short\n")
4856384c 907 (icalendar-tests--test-import
7ec01532
GM
908 "SUMMARY:rrule count daily long
909DTSTART;VALUE=DATE-TIME:20030919T090000
910DTEND;VALUE=DATE-TIME:20030919T113000
911RRULE:FREQ=DAILY;COUNT=14;INTERVAL=1
912"
68575ab0
UJ
913 "&%%(and (diary-cyclic 1 2003 9 19) (diary-block 2003 9 19 2003 10 2)) 09:00-11:30 rrule count daily long\n"
914 "&%%(and (diary-cyclic 1 19 9 2003) (diary-block 19 9 2003 2 10 2003)) 09:00-11:30 rrule count daily long\n"
915 "&%%(and (diary-cyclic 1 9 19 2003) (diary-block 9 19 2003 10 2 2003)) 09:00-11:30 rrule count daily long\n")
4856384c 916 (icalendar-tests--test-import
7ec01532
GM
917 "SUMMARY:rrule count bi-weekly 3 times
918DTSTART;VALUE=DATE-TIME:20030919T090000
919DTEND;VALUE=DATE-TIME:20030919T113000
920RRULE:FREQ=WEEKLY;COUNT=3;INTERVAL=2
921"
68575ab0
UJ
922 "&%%(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\n"
923 "&%%(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\n"
924 "&%%(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\n")
4856384c 925 (icalendar-tests--test-import
7ec01532
GM
926 "SUMMARY:rrule count monthly
927DTSTART;VALUE=DATE-TIME:20030919T090000
928DTEND;VALUE=DATE-TIME:20030919T113000
929RRULE:FREQ=MONTHLY;INTERVAL=1;COUNT=5
930"
68575ab0
UJ
931 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2004 1 19)) 09:00-11:30 rrule count monthly\n"
932 "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 19 1 2004)) 09:00-11:30 rrule count monthly\n"
933 "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 1 19 2004)) 09:00-11:30 rrule count monthly\n")
4856384c 934 (icalendar-tests--test-import
7ec01532
GM
935 "SUMMARY:rrule count every second month
936DTSTART;VALUE=DATE-TIME:20030919T090000
937DTEND;VALUE=DATE-TIME:20030919T113000
938RRULE:FREQ=MONTHLY;INTERVAL=2;COUNT=5
939"
68575ab0
UJ
940 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2004 5 19)) 09:00-11:30 rrule count every second month\n" ;FIXME
941 "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 19 5 2004)) 09:00-11:30 rrule count every second month\n" ;FIXME
942 "&%%(and (diary-date t 19 t) (diary-block 9 19 2003 5 19 2004)) 09:00-11:30 rrule count every second month\n") ;FIXME
4856384c 943 (icalendar-tests--test-import
7ec01532
GM
944 "SUMMARY:rrule count yearly
945DTSTART;VALUE=DATE-TIME:20030919T090000
946DTEND;VALUE=DATE-TIME:20030919T113000
947RRULE:FREQ=YEARLY;INTERVAL=1;COUNT=5
948"
68575ab0
UJ
949 "&%%(and (diary-date t 9 19) (diary-block 2003 9 19 2007 9 19)) 09:00-11:30 rrule count yearly\n"
950 "&%%(and (diary-date 19 9 t) (diary-block 19 9 2003 19 9 2007)) 09:00-11:30 rrule count yearly\n"
951 "&%%(and (diary-date 9 19 t) (diary-block 9 19 2003 9 19 2007)) 09:00-11:30 rrule count yearly\n")
4856384c 952 (icalendar-tests--test-import
7ec01532
GM
953 "SUMMARY:rrule count every second year
954DTSTART;VALUE=DATE-TIME:20030919T090000
955DTEND;VALUE=DATE-TIME:20030919T113000
956RRULE:FREQ=YEARLY;INTERVAL=2;COUNT=5
957"
68575ab0
UJ
958 "&%%(and (diary-date t 9 19) (diary-block 2003 9 19 2011 9 19)) 09:00-11:30 rrule count every second year\n" ;FIXME!!!
959 "&%%(and (diary-date 19 9 t) (diary-block 19 9 2003 19 9 2011)) 09:00-11:30 rrule count every second year\n" ;FIXME!!!
960 "&%%(and (diary-date 9 19 t) (diary-block 9 19 2003 9 19 2011)) 09:00-11:30 rrule count every second year\n") ;FIXME!!!
4856384c 961)
7ec01532 962
4856384c 963(ert-deftest icalendar-import-duration ()
7ec01532 964 ;; duration
4856384c 965 (icalendar-tests--test-import
7ec01532
GM
966 "DTSTART;VALUE=DATE:20050217
967SUMMARY:duration
968DURATION:P7D
969"
68575ab0
UJ
970 "&%%(and (diary-block 2005 2 17 2005 2 23)) duration\n"
971 "&%%(and (diary-block 17 2 2005 23 2 2005)) duration\n"
972 "&%%(and (diary-block 2 17 2005 2 23 2005)) duration\n")
4856384c 973 (icalendar-tests--test-import
7ec01532
GM
974 "UID:20041127T183329Z-18215-1001-4536-49109@andromeda
975DTSTAMP:20041127T183315Z
976LAST-MODIFIED:20041127T183329
977SUMMARY:Urlaub
978DTSTART;VALUE=DATE:20011221
979DTEND;VALUE=DATE:20011221
980RRULE:FREQ=DAILY;UNTIL=20011229;INTERVAL=1;WKST=SU
981CLASS:PUBLIC
982SEQUENCE:1
983CREATED:20041127T183329
984"
81ee9410 985 "&%%(and (diary-cyclic 1 2001 12 21) (diary-block 2001 12 21 2001 12 29)) Urlaub
68575ab0 986 Class: PUBLIC\n"
81ee9410 987 "&%%(and (diary-cyclic 1 21 12 2001) (diary-block 21 12 2001 29 12 2001)) Urlaub
68575ab0 988 Class: PUBLIC\n"
81ee9410 989 "&%%(and (diary-cyclic 1 12 21 2001) (diary-block 12 21 2001 12 29 2001)) Urlaub
68575ab0 990 Class: PUBLIC\n"))
81ee9410 991
4856384c 992(ert-deftest icalendar-import-bug-6766 ()
81ee9410 993 ;;bug#6766 -- multiple byday values in a weekly rrule
4856384c 994 (icalendar-tests--test-import
81ee9410
UJ
995"CLASS:PUBLIC
996DTEND;TZID=America/New_York:20100421T120000
997DTSTAMP:20100525T141214Z
998DTSTART;TZID=America/New_York:20100421T113000
999RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE,TH,FR
1000SEQUENCE:1
1001STATUS:CONFIRMED
1002SUMMARY:Scrum
1003TRANSP:OPAQUE
1004UID:8814e3f9-7482-408f-996c-3bfe486a1262
1005END:VEVENT
1006BEGIN:VEVENT
1007CLASS:PUBLIC
1008DTSTAMP:20100525T141214Z
1009DTSTART;VALUE=DATE:20100422
1010DTEND;VALUE=DATE:20100423
1011RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU,TH
1012SEQUENCE:1
1013SUMMARY:Tues + Thurs thinking
1014TRANSP:OPAQUE
1015UID:8814e3f9-7482-408f-996c-3bfe486a1263
1016"
1017"&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 2010 4 21)) 11:30-12:00 Scrum
1018 Status: CONFIRMED
1019 Class: PUBLIC
1020&%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 2010 4 22)) Tues + Thurs thinking
68575ab0
UJ
1021 Class: PUBLIC
1022"
81ee9410
UJ
1023"&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 21 4 2010)) 11:30-12:00 Scrum
1024 Status: CONFIRMED
1025 Class: PUBLIC
1026&%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 22 4 2010)) Tues + Thurs thinking
68575ab0
UJ
1027 Class: PUBLIC
1028"
81ee9410
UJ
1029"&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 4 21 2010)) 11:30-12:00 Scrum
1030 Status: CONFIRMED
1031 Class: PUBLIC
1032&%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 4 22 2010)) Tues + Thurs thinking
68575ab0
UJ
1033 Class: PUBLIC
1034"))
4856384c 1035
68575ab0
UJ
1036(ert-deftest icalendar-import-multiple-vcalendars ()
1037 (icalendar-tests--test-import
1038 "DTSTART;VALUE=DATE:20110723
1039SUMMARY:event-1
1040"
1041 "&2011/7/23 event-1\n"
1042 "&23/7/2011 event-1\n"
1043 "&7/23/2011 event-1\n")
7877f373 1044
68575ab0
UJ
1045 (icalendar-tests--test-import
1046 "BEGIN:VCALENDAR
1047PRODID:-//Emacs//NONSGML icalendar.el//EN
1048VERSION:2.0\nBEGIN:VEVENT
1049DTSTART;VALUE=DATE:20110723
1050SUMMARY:event-1
1051END:VEVENT
1052END:VCALENDAR
1053BEGIN:VCALENDAR
1054PRODID:-//Emacs//NONSGML icalendar.el//EN
1055VERSION:2.0
1056BEGIN:VEVENT
1057DTSTART;VALUE=DATE:20110724
1058SUMMARY:event-2
1059END:VEVENT
1060END:VCALENDAR
1061BEGIN:VCALENDAR
1062PRODID:-//Emacs//NONSGML icalendar.el//EN
1063VERSION:2.0
1064BEGIN:VEVENT
1065DTSTART;VALUE=DATE:20110725
1066SUMMARY:event-3a
1067END:VEVENT
1068BEGIN:VEVENT
1069DTSTART;VALUE=DATE:20110725
1070SUMMARY:event-3b
1071END:VEVENT
1072END:VCALENDAR
1073"
1074 "&2011/7/23 event-1\n&2011/7/24 event-2\n&2011/7/25 event-3a\n&2011/7/25 event-3b\n"
1075 "&23/7/2011 event-1\n&24/7/2011 event-2\n&25/7/2011 event-3a\n&25/7/2011 event-3b\n"
1076 "&7/23/2011 event-1\n&7/24/2011 event-2\n&7/25/2011 event-3a\n&7/25/2011 event-3b\n"))
7ec01532
GM
1077
1078;; ======================================================================
4856384c 1079;; Cycle
7ec01532 1080;; ======================================================================
4856384c
UJ
1081(defun icalendar-tests--test-cycle (input)
1082 "Perform cycle test.
1083Argument INPUT icalendar event string."
1084 (with-temp-buffer
1085 (if (string-match "^BEGIN:VCALENDAR" input)
1086 (insert input)
1087 (insert "BEGIN:VCALENDAR\nPRODID:-//Emacs//NONSGML icalendar.el//EN\n")
1088 (insert "VERSION:2.0\nBEGIN:VEVENT\n")
1089 (insert input)
1090 (unless (eq (char-before) ?\n)
1091 (insert "\n"))
1092 (insert "END:VEVENT\nEND:VCALENDAR\n"))
1093 (let ((icalendar-import-format "%s%d%l%o%t%u%c")
1094 (icalendar-import-format-summary "%s")
1095 (icalendar-import-format-location "\n Location: %s")
1096 (icalendar-import-format-description "\n Desc: %s")
1097 (icalendar-import-format-organizer "\n Organizer: %s")
1098 (icalendar-import-format-status "\n Status: %s")
1099 (icalendar-import-format-url "\n URL: %s")
1100 (icalendar-import-format-class "\n Class: %s"))
1101 (dolist (calendar-date-style '(iso european american))
1102 (icalendar-tests--do-test-cycle)))))
7ec01532 1103
4856384c
UJ
1104(defun icalendar-tests--do-test-cycle ()
1105 "Actually perform import/export cycle test."
1106 (let ((temp-diary (make-temp-file "icalendar-test-diary"))
1107 (temp-ics (make-temp-file "icalendar-test-ics"))
1108 (org-input (buffer-substring-no-properties (point-min) (point-max))))
7ec01532 1109
4856384c
UJ
1110 (unwind-protect
1111 (progn
1112 ;; step 1: import
1113 (icalendar-import-buffer temp-diary t t)
7877f373 1114
4856384c
UJ
1115 ;; step 2: export what was just imported
1116 (save-excursion
1117 (find-file temp-diary)
1118 (icalendar-export-region (point-min) (point-max) temp-ics))
1119
1120 ;; compare the output of step 2 with the input of step 1
1121 (save-excursion
1122 (find-file temp-ics)
1123 (goto-char (point-min))
1124 (when (re-search-forward "\nUID:.*\n" nil t)
1125 (replace-match "\n"))
1126 (let ((cycled (buffer-substring-no-properties (point-min) (point-max))))
68575ab0 1127 (should (string= org-input cycled)))))
4856384c
UJ
1128 ;; clean up
1129 (kill-buffer (find-buffer-visiting temp-diary))
1130 (save-excursion
1131 (set-buffer (find-buffer-visiting temp-ics))
1132 (set-buffer-modified-p nil)
1133 (kill-buffer (current-buffer)))
1134 (delete-file temp-diary)
1135 (delete-file temp-ics))))
1136
1137(ert-deftest icalendar-cycle ()
1138 "Perform cycling tests."
1139 (icalendar-tests--test-cycle
1140 "DTSTART;VALUE=DATE-TIME:20030919T090000
1141DTEND;VALUE=DATE-TIME:20030919T113000
1142SUMMARY:Cycletest
7ec01532 1143")
4856384c
UJ
1144 (icalendar-tests--test-cycle
1145 "DTSTART;VALUE=DATE-TIME:20030919T090000
1146DTEND;VALUE=DATE-TIME:20030919T113000
1147SUMMARY:Cycletest
1148DESCRIPTION:beschreibung!
1149LOCATION:nowhere
1150ORGANIZER:ulf
7ec01532 1151")
4856384c
UJ
1152 (icalendar-tests--test-cycle
1153 "DTSTART;VALUE=DATE:19190909
1154DTEND;VALUE=DATE:19190910
1155RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=09;BYMONTHDAY=09
1156SUMMARY:and diary-anniversary
1157"))
7ec01532
GM
1158
1159;; ======================================================================
1160;; Real world
1161;; ======================================================================
4856384c 1162(ert-deftest icalendar-real-world ()
7ec01532
GM
1163 "Perform real-world tests, as gathered from problem reports."
1164 ;; 2003-05-29
4856384c 1165 (icalendar-tests--test-import
7ec01532
GM
1166 "BEGIN:VCALENDAR
1167METHOD:REQUEST
1168PRODID:Microsoft CDO for Microsoft Exchange
1169VERSION:2.0
1170BEGIN:VTIMEZONE
1171TZID:Kolkata\, Chennai\, Mumbai\, New Delhi
1172X-MICROSOFT-CDO-TZID:23
1173BEGIN:STANDARD
1174DTSTART:16010101T000000
1175TZOFFSETFROM:+0530
1176TZOFFSETTO:+0530
1177END:STANDARD
1178BEGIN:DAYLIGHT
1179DTSTART:16010101T000000
1180TZOFFSETFROM:+0530
1181TZOFFSETTO:+0530
1182END:DAYLIGHT
1183END:VTIMEZONE
1184BEGIN:VEVENT
1185DTSTAMP:20030509T043439Z
1186DTSTART;TZID=\"Kolkata, Chennai, Mumbai, New Delhi\":20030509T103000
1187SUMMARY:On-Site Interview
1188UID:040000008200E00074C5B7101A82E0080000000080B6DE661216C301000000000000000
1189 010000000DB823520692542408ED02D7023F9DFF9
1190ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Xxxxx
1191 xxx Xxxxxxxxxxxx\":MAILTO:xxxxxxxx@xxxxxxx.com
1192ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Yyyyyyy Y
1193 yyyy\":MAILTO:yyyyyyy@yyyyyyy.com
1194ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Zzzz Zzzz
1195 zz\":MAILTO:zzzzzz@zzzzzzz.com
1196ORGANIZER;CN=\"Aaaaaa Aaaaa\":MAILTO:aaaaaaa@aaaaaaa.com
1197LOCATION:Cccc
1198DTEND;TZID=\"Kolkata, Chennai, Mumbai, New Delhi\":20030509T153000
1199DESCRIPTION:10:30am - Blah
1200SEQUENCE:0
1201PRIORITY:5
1202CLASS:
1203CREATED:20030509T043439Z
1204LAST-MODIFIED:20030509T043459Z
1205STATUS:CONFIRMED
1206TRANSP:OPAQUE
1207X-MICROSOFT-CDO-BUSYSTATUS:BUSY
1208X-MICROSOFT-CDO-INSTTYPE:0
1209X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
1210X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
1211X-MICROSOFT-CDO-IMPORTANCE:1
1212X-MICROSOFT-CDO-OWNERAPPTID:126441427
1213BEGIN:VALARM
1214ACTION:DISPLAY
1215DESCRIPTION:REMINDER
1216TRIGGER;RELATED=START:-PT00H15M00S
1217END:VALARM
1218END:VEVENT
1219END:VCALENDAR"
a4766629 1220 nil
7ec01532
GM
1221 "&9/5/2003 10:30-15:30 On-Site Interview
1222 Desc: 10:30am - Blah
1223 Location: Cccc
81ee9410 1224 Organizer: MAILTO:aaaaaaa@aaaaaaa.com
68575ab0
UJ
1225 Status: CONFIRMED
1226"
7ec01532
GM
1227 "&5/9/2003 10:30-15:30 On-Site Interview
1228 Desc: 10:30am - Blah
1229 Location: Cccc
81ee9410 1230 Organizer: MAILTO:aaaaaaa@aaaaaaa.com
68575ab0
UJ
1231 Status: CONFIRMED
1232")
7ec01532
GM
1233
1234 ;; 2003-06-18 a
4856384c 1235 (icalendar-tests--test-import
7ec01532
GM
1236 "DTSTAMP:20030618T195512Z
1237DTSTART;TZID=\"Mountain Time (US & Canada)\":20030623T110000
1238SUMMARY:Dress Rehearsal for XXXX-XXXX
1239UID:040000008200E00074C5B7101A82E00800000000608AA7DA9835C301000000000000000
1240 0100000007C3A6D65EE726E40B7F3D69A23BD567E
1241ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"AAAAA,AAA
1242 AA (A-AAAAAAA,ex1)\":MAILTO:aaaaa_aaaaa@aaaaa.com
1243ORGANIZER;CN=\"ABCD,TECHTRAINING
1244 (A-Americas,exgen1)\":MAILTO:xxx@xxxxx.com
1245LOCATION:555 or TN 555-5555 ID 5555 & NochWas (see below)
1246DTEND;TZID=\"Mountain Time (US & Canada)\":20030623T120000
1247DESCRIPTION:753 Zeichen hier radiert
1248SEQUENCE:0
1249PRIORITY:5
1250CLASS:
1251CREATED:20030618T195518Z
1252LAST-MODIFIED:20030618T195527Z
1253STATUS:CONFIRMED
1254TRANSP:OPAQUE
1255X-MICROSOFT-CDO-BUSYSTATUS:BUSY
1256X-MICROSOFT-CDO-INSTTYPE:0
1257X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
1258X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
1259X-MICROSOFT-CDO-IMPORTANCE:1
1260X-MICROSOFT-CDO-OWNERAPPTID:1022519251
1261BEGIN:VALARM
1262ACTION:DISPLAY
1263DESCRIPTION:REMINDER
1264TRIGGER;RELATED=START:-PT00H15M00S
1265END:VALARM"
a4766629 1266 nil
7ec01532
GM
1267 "&23/6/2003 11:00-12:00 Dress Rehearsal for XXXX-XXXX
1268 Desc: 753 Zeichen hier radiert
1269 Location: 555 or TN 555-5555 ID 5555 & NochWas (see below)
81ee9410 1270 Organizer: MAILTO:xxx@xxxxx.com
68575ab0
UJ
1271 Status: CONFIRMED
1272"
7ec01532
GM
1273 "&6/23/2003 11:00-12:00 Dress Rehearsal for XXXX-XXXX
1274 Desc: 753 Zeichen hier radiert
1275 Location: 555 or TN 555-5555 ID 5555 & NochWas (see below)
81ee9410 1276 Organizer: MAILTO:xxx@xxxxx.com
68575ab0
UJ
1277 Status: CONFIRMED
1278")
7ec01532 1279 ;; 2003-06-18 b -- uses timezone
4856384c 1280 (icalendar-tests--test-import
7ec01532
GM
1281 "BEGIN:VCALENDAR
1282METHOD:REQUEST
1283PRODID:Microsoft CDO for Microsoft Exchange
1284VERSION:2.0
1285BEGIN:VTIMEZONE
1286TZID:Mountain Time (US & Canada)
1287X-MICROSOFT-CDO-TZID:12
1288BEGIN:STANDARD
1289DTSTART:16010101T020000
1290TZOFFSETFROM:-0600
1291TZOFFSETTO:-0700
1292RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=10;BYDAY=-1SU
1293END:STANDARD
1294BEGIN:DAYLIGHT
1295DTSTART:16010101T020000
1296TZOFFSETFROM:-0700
1297TZOFFSETTO:-0600
1298RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=4;BYDAY=1SU
1299END:DAYLIGHT
1300END:VTIMEZONE
1301BEGIN:VEVENT
1302DTSTAMP:20030618T230323Z
1303DTSTART;TZID=\"Mountain Time (US & Canada)\":20030623T090000
1304SUMMARY:Updated: Dress Rehearsal for ABC01-15
1305UID:040000008200E00074C5B7101A82E00800000000608AA7DA9835C301000000000000000
1306 0100000007C3A6D65EE726E40B7F3D69A23BD567E
1307ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;X-REPLYTIME=20030618T20
1308 0700Z;RSVP=TRUE;CN=\"AAAAA,AAAAAA
1309\(A-AAAAAAA,ex1)\":MAILTO:aaaaaa_aaaaa@aaaaa
1310 .com
1311ORGANIZER;CN=\"ABCD,TECHTRAINING
1312\(A-Americas,exgen1)\":MAILTO:bbb@bbbbb.com
1313LOCATION:123 or TN 123-1234 ID abcd & SonstWo (see below)
1314DTEND;TZID=\"Mountain Time (US & Canada)\":20030623T100000
81ee9410 1315DESCRIPTION:Viele Zeichen standen hier früher
7ec01532
GM
1316SEQUENCE:0
1317PRIORITY:5
1318CLASS:
1319CREATED:20030618T230326Z
1320LAST-MODIFIED:20030618T230335Z
1321STATUS:CONFIRMED
1322TRANSP:OPAQUE
1323X-MICROSOFT-CDO-BUSYSTATUS:BUSY
1324X-MICROSOFT-CDO-INSTTYPE:0
1325X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
1326X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
1327X-MICROSOFT-CDO-IMPORTANCE:1
1328X-MICROSOFT-CDO-OWNERAPPTID:1022519251
1329BEGIN:VALARM
1330ACTION:DISPLAY
1331DESCRIPTION:REMINDER
1332TRIGGER;RELATED=START:-PT00H15M00S
1333END:VALARM
1334END:VEVENT
1335END:VCALENDAR"
a4766629 1336 nil
7ec01532 1337 "&23/6/2003 17:00-18:00 Updated: Dress Rehearsal for ABC01-15
81ee9410 1338 Desc: Viele Zeichen standen hier früher
7ec01532
GM
1339 Location: 123 or TN 123-1234 ID abcd & SonstWo (see below)
1340 Organizer: MAILTO:bbb@bbbbb.com
68575ab0
UJ
1341 Status: CONFIRMED
1342"
7ec01532 1343 "&6/23/2003 17:00-18:00 Updated: Dress Rehearsal for ABC01-15
81ee9410 1344 Desc: Viele Zeichen standen hier früher
7ec01532
GM
1345 Location: 123 or TN 123-1234 ID abcd & SonstWo (see below)
1346 Organizer: MAILTO:bbb@bbbbb.com
68575ab0
UJ
1347 Status: CONFIRMED
1348")
7ec01532 1349 ;; export 2004-10-28 block entries
4856384c 1350 (icalendar-tests--test-export
a4766629 1351 nil
7ec01532
GM
1352 nil
1353 "-*- mode: text; fill-column: 256;-*-
1354
1355>>> block entries:
1356
1357%%(diary-block 11 8 2004 11 10 2004) Nov 8-10 aa
1358"
1359 "DTSTART;VALUE=DATE:20041108
1360DTEND;VALUE=DATE:20041111
1361SUMMARY:Nov 8-10 aa")
1362
4856384c 1363 (icalendar-tests--test-export
a4766629 1364 nil
7ec01532
GM
1365 nil
1366 "%%(diary-block 12 13 2004 12 17 2004) Dec 13-17 bb"
1367 "DTSTART;VALUE=DATE:20041213
1368DTEND;VALUE=DATE:20041218
1369SUMMARY:Dec 13-17 bb")
1370
4856384c 1371 (icalendar-tests--test-export
a4766629 1372 nil
7ec01532
GM
1373 nil
1374 "%%(diary-block 2 3 2005 2 4 2005) Feb 3-4 cc"
1375 "DTSTART;VALUE=DATE:20050203
1376DTEND;VALUE=DATE:20050205
1377SUMMARY:Feb 3-4 cc")
1378
4856384c 1379 (icalendar-tests--test-export
a4766629 1380 nil
7ec01532
GM
1381 nil
1382 "%%(diary-block 4 24 2005 4 29 2005) April 24-29 dd"
1383 "DTSTART;VALUE=DATE:20050424
1384DTEND;VALUE=DATE:20050430
1385SUMMARY:April 24-29 dd
1386")
4856384c 1387 (icalendar-tests--test-export
a4766629 1388 nil
7ec01532
GM
1389 nil
1390 "%%(diary-block 5 30 2005 6 1 2005) may 30 - June 1: ee"
1391 "DTSTART;VALUE=DATE:20050530
1392DTEND;VALUE=DATE:20050602
1393SUMMARY:may 30 - June 1: ee")
1394
4856384c 1395 (icalendar-tests--test-export
a4766629 1396 nil
7ec01532
GM
1397 nil
1398 "%%(diary-block 6 6 2005 6 8 2005) ff"
1399 "DTSTART;VALUE=DATE:20050606
1400DTEND;VALUE=DATE:20050609
1401SUMMARY:ff")
7877f373 1402
7ec01532 1403 ;; export 2004-10-28 anniversary entries
4856384c 1404 (icalendar-tests--test-export
a4766629 1405 nil
7ec01532
GM
1406 nil
1407 "
1408>>> anniversaries:
1409
1410%%(diary-anniversary 3 28 1991) aa birthday (%d years old)"
1411 "DTSTART;VALUE=DATE:19910328
1412DTEND;VALUE=DATE:19910329
1413RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=03;BYMONTHDAY=28
1414SUMMARY:aa birthday (%d years old)
1415")
1416
4856384c 1417 (icalendar-tests--test-export
a4766629 1418 nil
7ec01532
GM
1419 nil
1420 "%%(diary-anniversary 5 17 1957) bb birthday (%d years old)"
1421 "DTSTART;VALUE=DATE:19570517
1422DTEND;VALUE=DATE:19570518
1423RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=05;BYMONTHDAY=17
1424SUMMARY:bb birthday (%d years old)")
1425
4856384c 1426 (icalendar-tests--test-export
a4766629 1427 nil
7ec01532
GM
1428 nil
1429 "%%(diary-anniversary 6 8 1997) cc birthday (%d years old)"
1430 "DTSTART;VALUE=DATE:19970608
1431DTEND;VALUE=DATE:19970609
1432RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=06;BYMONTHDAY=08
1433SUMMARY:cc birthday (%d years old)")
1434
4856384c 1435 (icalendar-tests--test-export
a4766629 1436 nil
7ec01532
GM
1437 nil
1438 "%%(diary-anniversary 7 22 1983) dd (%d years ago...!)"
1439 "DTSTART;VALUE=DATE:19830722
1440DTEND;VALUE=DATE:19830723
1441RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=07;BYMONTHDAY=22
1442SUMMARY:dd (%d years ago...!)")
1443
4856384c 1444 (icalendar-tests--test-export
a4766629 1445 nil
7ec01532
GM
1446 nil
1447 "%%(diary-anniversary 8 1 1988) ee birthday (%d years old)"
1448 "DTSTART;VALUE=DATE:19880801
1449DTEND;VALUE=DATE:19880802
1450RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=08;BYMONTHDAY=01
1451SUMMARY:ee birthday (%d years old)")
1452
4856384c 1453 (icalendar-tests--test-export
a4766629 1454 nil
7ec01532
GM
1455 nil
1456 "%%(diary-anniversary 9 21 1957) ff birthday (%d years old)"
1457 "DTSTART;VALUE=DATE:19570921
1458DTEND;VALUE=DATE:19570922
1459RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=09;BYMONTHDAY=21
1460SUMMARY:ff birthday (%d years old)")
1461
1462
1463 ;; FIXME!
1464
1465 ;; export 2004-10-28 monthly, weekly entries
1466
4856384c 1467 ;; (icalendar-tests--test-export
7ec01532
GM
1468 ;; nil
1469 ;; "
1470 ;; >>> ------------ monthly:
1471
1472 ;; */27/* 10:00 blah blah"
1473 ;; "xxx")
1474
4856384c 1475 (icalendar-tests--test-export
a4766629 1476 nil
7ec01532
GM
1477 nil
1478 ">>> ------------ my week:
1479
1480Monday 13:00 MAC"
1481 "DTSTART;VALUE=DATE-TIME:20000103T130000
1482DTEND;VALUE=DATE-TIME:20000103T140000
1483RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1484SUMMARY:MAC")
1485
4856384c 1486 (icalendar-tests--test-export
a4766629 1487 nil
7ec01532
GM
1488 nil
1489 "Monday 15:00 a1"
1490 "DTSTART;VALUE=DATE-TIME:20000103T150000
1491DTEND;VALUE=DATE-TIME:20000103T160000
1492RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1493SUMMARY:a1")
1494
1495
4856384c 1496 (icalendar-tests--test-export
a4766629 1497 nil
7ec01532
GM
1498 nil
1499 "Monday 16:00-17:00 a2"
1500 "DTSTART;VALUE=DATE-TIME:20000103T160000
1501DTEND;VALUE=DATE-TIME:20000103T170000
1502RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1503SUMMARY:a2")
1504
4856384c 1505 (icalendar-tests--test-export
a4766629 1506 nil
7ec01532
GM
1507 nil
1508 "Tuesday 11:30-13:00 a3"
1509 "DTSTART;VALUE=DATE-TIME:20000104T113000
1510DTEND;VALUE=DATE-TIME:20000104T130000
1511RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU
1512SUMMARY:a3")
1513
4856384c 1514 (icalendar-tests--test-export
a4766629 1515 nil
7ec01532
GM
1516 nil
1517 "Tuesday 15:00 a4"
1518 "DTSTART;VALUE=DATE-TIME:20000104T150000
1519DTEND;VALUE=DATE-TIME:20000104T160000
1520RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU
1521SUMMARY:a4")
1522
4856384c 1523 (icalendar-tests--test-export
a4766629 1524 nil
7ec01532
GM
1525 nil
1526 "Wednesday 13:00 a5"
1527 "DTSTART;VALUE=DATE-TIME:20000105T130000
1528DTEND;VALUE=DATE-TIME:20000105T140000
1529RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE
1530SUMMARY:a5")
1531
4856384c 1532 (icalendar-tests--test-export
a4766629 1533 nil
7ec01532
GM
1534 nil
1535 "Wednesday 11:30-13:30 a6"
1536 "DTSTART;VALUE=DATE-TIME:20000105T113000
1537DTEND;VALUE=DATE-TIME:20000105T133000
1538RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE
1539SUMMARY:a6")
1540
4856384c 1541 (icalendar-tests--test-export
a4766629 1542 nil
7ec01532
GM
1543 nil
1544 "Wednesday 15:00 s1"
1545 "DTSTART;VALUE=DATE-TIME:20000105T150000
1546DTEND;VALUE=DATE-TIME:20000105T160000
1547RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE
1548SUMMARY:s1")
1549
1550
1551 ;; export 2004-10-28 regular entries
4856384c 1552 (icalendar-tests--test-export
a4766629 1553 nil
7ec01532
GM
1554 nil
1555 "
1556>>> regular diary entries:
1557
1558Oct 12 2004, 14:00 Tue: [2004-10-12] q1"
1559 "DTSTART;VALUE=DATE-TIME:20041012T140000
1560DTEND;VALUE=DATE-TIME:20041012T150000
1561SUMMARY:Tue: [2004-10-12] q1")
1562
1563 ;; 2004-11-19
4856384c 1564 (icalendar-tests--test-import
7ec01532
GM
1565 "BEGIN:VCALENDAR
1566VERSION
1567 :2.0
1568PRODID
1569 :-//Mozilla.org/NONSGML Mozilla Calendar V1.0//EN
1570BEGIN:VEVENT
1571UID
1572 :04979712-3902-11d9-93dd-8f9f4afe08da
1573SUMMARY
1574 :Jjjjj & Wwwww
1575STATUS
1576 :TENTATIVE
1577CLASS
1578 :PRIVATE
1579X-MOZILLA-ALARM-DEFAULT-LENGTH
1580 :0
1581DTSTART
1582 :20041123T140000
1583DTEND
1584 :20041123T143000
1585DTSTAMP
1586 :20041118T013430Z
1587LAST-MODIFIED
1588 :20041118T013640Z
1589END:VEVENT
1590BEGIN:VEVENT
1591UID
1592 :6161a312-3902-11d9-b512-f764153bb28b
1593SUMMARY
1594 :BB Aaaaaaaa Bbbbb
1595STATUS
1596 :TENTATIVE
1597CLASS
1598 :PRIVATE
1599X-MOZILLA-ALARM-DEFAULT-LENGTH
1600 :0
1601DTSTART
1602 :20041123T144500
1603DTEND
1604 :20041123T154500
1605DTSTAMP
1606 :20041118T013641Z
1607END:VEVENT
1608BEGIN:VEVENT
1609UID
1610 :943a4d7e-3902-11d9-9ce7-c9addeadf928
1611SUMMARY
1612 :Hhhhhhhh
1613STATUS
1614 :TENTATIVE
1615CLASS
1616 :PRIVATE
1617X-MOZILLA-ALARM-DEFAULT-LENGTH
1618 :0
1619DTSTART
1620 :20041123T110000
1621DTEND
1622 :20041123T120000
1623DTSTAMP
1624 :20041118T013831Z
1625END:VEVENT
1626BEGIN:VEVENT
1627UID
1628 :fe53615e-3902-11d9-9dd8-9d38a155bf41
1629SUMMARY
1630 :MMM Aaaaaaaaa
1631STATUS
1632 :TENTATIVE
1633CLASS
1634 :PRIVATE
1635X-MOZILLA-ALARM-DEFAULT-LENGTH
1636 :0
1637X-MOZILLA-RECUR-DEFAULT-INTERVAL
1638 :2
1639RRULE
1640 :FREQ=WEEKLY;INTERVAL=2;BYDAY=FR
1641DTSTART
1642 :20041112T140000
1643DTEND
1644 :20041112T183000
1645DTSTAMP
1646 :20041118T014117Z
1647END:VEVENT
1648BEGIN:VEVENT
1649UID
1650 :87c928ee-3901-11d9-b21f-b45042155024
1651SUMMARY
1652 :Rrrr/Cccccc ii Aaaaaaaa
1653DESCRIPTION
1654 :Vvvvv Rrrr aaa Cccccc
1655STATUS
1656 :TENTATIVE
1657CLASS
1658 :PRIVATE
1659X-MOZILLA-ALARM-DEFAULT-LENGTH
1660 :0
1661DTSTART
1662 ;VALUE=DATE
1663 :20041119
1664DTEND
1665 ;VALUE=DATE
1666 :20041120
1667DTSTAMP
1668 :20041118T013107Z
1669LAST-MODIFIED
1670 :20041118T014203Z
1671END:VEVENT
1672BEGIN:VEVENT
1673UID
1674 :e8f331ae-3902-11d9-9948-dfdcb66a2872
1675SUMMARY
1676 :Wwww aa hhhh
1677STATUS
1678 :TENTATIVE
1679CLASS
1680 :PRIVATE
1681X-MOZILLA-ALARM-DEFAULT-LENGTH
1682 :0
1683RRULE
1684 :FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1685DTSTART
1686 ;VALUE=DATE
1687 :20041101
1688DTEND
1689 ;VALUE=DATE
1690 :20041102
1691DTSTAMP
1692 :20041118T014045Z
1693LAST-MODIFIED
1694 :20041118T023846Z
1695END:VEVENT
1696END:VCALENDAR
1697"
a4766629 1698 nil
7ec01532
GM
1699 "&23/11/2004 14:00-14:30 Jjjjj & Wwwww
1700 Status: TENTATIVE
6fe539d2 1701 Class: PRIVATE
7ec01532
GM
1702&23/11/2004 14:45-15:45 BB Aaaaaaaa Bbbbb
1703 Status: TENTATIVE
6fe539d2 1704 Class: PRIVATE
7ec01532
GM
1705&23/11/2004 11:00-12:00 Hhhhhhhh
1706 Status: TENTATIVE
6fe539d2 1707 Class: PRIVATE
7ec01532
GM
1708&%%(and (diary-cyclic 14 12 11 2004)) 14:00-18:30 MMM Aaaaaaaaa
1709 Status: TENTATIVE
6fe539d2 1710 Class: PRIVATE
7ec01532
GM
1711&%%(and (diary-block 19 11 2004 19 11 2004)) Rrrr/Cccccc ii Aaaaaaaa
1712 Desc: Vvvvv Rrrr aaa Cccccc
1713 Status: TENTATIVE
6fe539d2 1714 Class: PRIVATE
7ec01532
GM
1715&%%(and (diary-cyclic 7 1 11 2004)) Wwww aa hhhh
1716 Status: TENTATIVE
68575ab0
UJ
1717 Class: PRIVATE
1718"
7ec01532
GM
1719 "&11/23/2004 14:00-14:30 Jjjjj & Wwwww
1720 Status: TENTATIVE
6fe539d2 1721 Class: PRIVATE
7ec01532
GM
1722&11/23/2004 14:45-15:45 BB Aaaaaaaa Bbbbb
1723 Status: TENTATIVE
6fe539d2 1724 Class: PRIVATE
7ec01532
GM
1725&11/23/2004 11:00-12:00 Hhhhhhhh
1726 Status: TENTATIVE
6fe539d2 1727 Class: PRIVATE
7ec01532
GM
1728&%%(and (diary-cyclic 14 11 12 2004)) 14:00-18:30 MMM Aaaaaaaaa
1729 Status: TENTATIVE
6fe539d2 1730 Class: PRIVATE
7ec01532
GM
1731&%%(and (diary-block 11 19 2004 11 19 2004)) Rrrr/Cccccc ii Aaaaaaaa
1732 Desc: Vvvvv Rrrr aaa Cccccc
1733 Status: TENTATIVE
6fe539d2 1734 Class: PRIVATE
7ec01532
GM
1735&%%(and (diary-cyclic 7 11 1 2004)) Wwww aa hhhh
1736 Status: TENTATIVE
68575ab0
UJ
1737 Class: PRIVATE
1738")
7ec01532
GM
1739
1740 ;; 2004-09-09 pg
4856384c 1741 (icalendar-tests--test-export
7ec01532
GM
1742 "%%(diary-block 1 1 2004 4 1 2004) Urlaub"
1743 nil
a4766629 1744 nil
7ec01532
GM
1745 "DTSTART;VALUE=DATE:20040101
1746DTEND;VALUE=DATE:20040105
1747SUMMARY:Urlaub")
1748
1749 ;; 2004-10-25 pg
4856384c 1750 (icalendar-tests--test-export
a4766629 1751 nil
7ec01532
GM
1752 "5 11 2004 Bla Fasel"
1753 nil
1754 "DTSTART;VALUE=DATE:20041105
1755DTEND;VALUE=DATE:20041106
1756SUMMARY:Bla Fasel")
1757
1758 ;; 2004-10-30 pg
4856384c 1759 (icalendar-tests--test-export
a4766629 1760 nil
7ec01532
GM
1761 "2 Nov 2004 15:00-16:30 Zahnarzt"
1762 nil
1763 "DTSTART;VALUE=DATE-TIME:20041102T150000
1764DTEND;VALUE=DATE-TIME:20041102T163000
1765SUMMARY:Zahnarzt")
1766
1767 ;; 2005-02-07 lt
4856384c 1768 (icalendar-tests--test-import
7ec01532
GM
1769 "UID
1770 :b60d398e-1dd1-11b2-a159-cf8cb05139f4
1771SUMMARY
1772 :Waitangi Day
1773DESCRIPTION
1774 :abcdef
1775CATEGORIES
1776 :Public Holiday
1777STATUS
1778 :CONFIRMED
1779CLASS
1780 :PRIVATE
1781DTSTART
1782 ;VALUE=DATE
1783 :20050206
1784DTEND
1785 ;VALUE=DATE
1786 :20050207
1787DTSTAMP
1788 :20050128T011209Z"
a4766629 1789 nil
7ec01532 1790 "&%%(and (diary-block 6 2 2005 6 2 2005)) Waitangi Day
81ee9410
UJ
1791 Desc: abcdef
1792 Status: CONFIRMED
68575ab0
UJ
1793 Class: PRIVATE
1794"
7ec01532 1795 "&%%(and (diary-block 2 6 2005 2 6 2005)) Waitangi Day
81ee9410
UJ
1796 Desc: abcdef
1797 Status: CONFIRMED
68575ab0
UJ
1798 Class: PRIVATE
1799")
7ec01532
GM
1800
1801 ;; 2005-03-01 lt
4856384c 1802 (icalendar-tests--test-import
7ec01532
GM
1803 "DTSTART;VALUE=DATE:20050217
1804SUMMARY:Hhhhhh Aaaaa ii Aaaaaaaa
1805UID:6AFA7558-6994-11D9-8A3A-000A95A0E830-RID
1806DTSTAMP:20050118T210335Z
1807DURATION:P7D"
a4766629 1808 nil
68575ab0
UJ
1809 "&%%(and (diary-block 17 2 2005 23 2 2005)) Hhhhhh Aaaaa ii Aaaaaaaa\n"
1810 "&%%(and (diary-block 2 17 2005 2 23 2005)) Hhhhhh Aaaaa ii Aaaaaaaa\n")
7ec01532
GM
1811
1812 ;; 2005-03-23 lt
4856384c 1813 (icalendar-tests--test-export
a4766629 1814 nil
7ec01532
GM
1815 "&%%(diary-cyclic 7 8 2 2005) 16:00-16:45 [WORK] Pppp"
1816 nil
1817 "DTSTART;VALUE=DATE-TIME:20050208T160000
1818DTEND;VALUE=DATE-TIME:20050208T164500
1819RRULE:FREQ=DAILY;INTERVAL=7
1820SUMMARY:[WORK] Pppp
1821")
1822
1823 ;; 2005-05-27 eu
4856384c 1824 (icalendar-tests--test-export
a4766629 1825 nil
7ec01532
GM
1826 nil
1827 ;; FIXME: colon not allowed!
1828 ;;"Nov 1: NNN Wwwwwwww Wwwww - Aaaaaa Pppppppp rrrrrr ddd oo Nnnnnnnn 30"
1829 "Nov 1 NNN Wwwwwwww Wwwww - Aaaaaa Pppppppp rrrrrr ddd oo Nnnnnnnn 30"
1830 "DTSTART;VALUE=DATE:19001101
1831DTEND;VALUE=DATE:19001102
1832RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=11;BYMONTHDAY=1
1833SUMMARY:NNN Wwwwwwww Wwwww - Aaaaaa Pppppppp rrrrrr ddd oo Nnnnnnnn 30
1834")
1835 )
1836
4856384c
UJ
1837(provide 'icalendar-tests)
1838;;; icalendar-tests.el ends here