1 ;; icalendar-testsuite.el --- Test suite for icalendar.el
3 ;; Copyright (C) 2005, 2008, 2009, 2010 Free Software Foundation, Inc.
5 ;; Author: Ulf Jasper <ulf.jasper@web.de>
8 ;; Human-Keywords: calendar, diary, iCalendar, vCalendar
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
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.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
28 ;; - Add more unit tests for functions, timezone etc.
30 ;; Note: Watch the trailing blank that is added on import.
33 (defun icalendar-testsuite-run ()
34 "Run icalendar test suite."
36 (icalendar-testsuite--run-internal-tests)
37 (icalendar-testsuite--run-function-tests)
38 (icalendar-testsuite--run-import-tests)
39 (icalendar-testsuite--run-export-tests)
40 (icalendar-testsuite--run-cycle-tests)
41 (icalendar-testsuite--run-real-world-tests)
42 (message "All icalendar tests finished successfully."))
44 ;; ======================================================================
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
)))
52 (defun icalendar-testsuite--compare-strings (str1 str2
)
53 "Compare strings STR1 and STR2.
54 Return t if strings are equal, else return substring indicating first difference.
55 FIXME: 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
))
62 (concat "..." (substring str2
(- result
1)
63 (min len
(+ (- result
1) 3))) "...")
64 (concat "..." (substring str2
(- (+ result
1))
65 (min len
(+ (- (+ result
1)) 3))) "..."))
68 (defun icalendar-testsuite--run-internal-tests ()
69 "Run icalendar-testsuite internal tests."
70 (assert (equal t
(icalendar-testsuite--compare-strings " abcde" "abcde ")))
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"))))
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)
90 (icalendar-testsuite--test-first-weekday-of-year)
91 (icalendar-testsuite--test-datestring-to-isodate)
92 (icalendar-testsuite--test-datetime-to-diary-date)
93 (icalendar-testsuite--test-diarytime-to-isotime)
94 (icalendar-testsuite--test-convert-ordinary-to-ical)
95 (icalendar-testsuite--test-convert-weekly-to-ical)
96 (icalendar-testsuite--test-convert-yearly-to-ical)
97 (icalendar-testsuite--test-convert-block-to-ical)
98 (icalendar-testsuite--test-convert-cyclic-to-ical)
99 (icalendar-testsuite--test-convert-anniversary-to-ical)
100 (icalendar-testsuite--test-calendar-style)
101 (icalendar-testsuite--test-create-uid)
102 (icalendar-testsuite--test-parse-vtimezone))
104 (defun icalendar-testsuite--test-format-ical-event ()
105 "Test `icalendar--format-ical-event'."
106 (let ((icalendar-import-format "%s%d%l%o%t%u%c")
107 (icalendar-import-format-summary "SUM %s")
108 (icalendar-import-format-location " LOC %s")
109 (icalendar-import-format-description " DES %s")
110 (icalendar-import-format-organizer " ORG %s")
111 (icalendar-import-format-status " STA %s")
112 (icalendar-import-format-url " URL %s")
113 (icalendar-import-format-class " CLA %s")
114 (event (icalendar-testsuite--get-ical-event "BEGIN:VEVENT
115 DTSTAMP:20030509T043439Z
116 DTSTART:20030509T103000
120 DTEND:20030509T153000
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
)
128 (assert (string= (icalendar--format-ical-event event
)
130 (setq icalendar-import-format
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
)))
143 (defun icalendar-testsuite--test-parse-summary-and-rest ()
144 "Test `icalendar--parse-summary-and-rest'."
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")
154 (setq result
(icalendar--parse-summary-and-rest "SUM sum ORG org"))
155 (assert (string= (cdr (assoc 'org result
)) "org"))
157 (setq result
(icalendar--parse-summary-and-rest
158 "SUM sum DES des LOC loc ORG org STA sta URL url CLA cla"))
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"))
165 (setq icalendar-import-format
(lambda () "Hello world"))
166 (setq result
(icalendar--parse-summary-and-rest
168 (assert (not result
))
171 (defun icalendar-testsuite--get-ical-event (ical-string)
172 "Helper function for testing `icalendar-testsuite--test-format-ical-event'.
173 Return icalendar event for ICAL-STRING."
177 (goto-char (point-min))
178 (car (icalendar--read-element nil nil
)))))
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
184 DTSTAMP:20030509T043439Z
185 DTSTART:20030509T103000
189 DTEND:20030509T153000
193 (concat "SUMMARY=`a' DESCRIPTION=`b' LOCATION=`c' "
194 "ORGANIZER=`d' STATUS=`' URL=`' CLASS=`'"))))
196 (defun icalendar-testsuite--test-first-weekday-of-year ()
197 "Test method for `icalendar-first-weekday-of-year'."
198 (assert (eq 1 (icalendar-first-weekday-of-year "TU" 2008)))
199 (assert (eq 3 (icalendar-first-weekday-of-year "WE" 2007)))
200 (assert (eq 5 (icalendar-first-weekday-of-year "TH" 2006)))
201 (assert (eq 7 (icalendar-first-weekday-of-year "FR" 2005)))
202 (assert (eq 3 (icalendar-first-weekday-of-year "SA" 2004)))
203 (assert (eq 5 (icalendar-first-weekday-of-year "SU" 2003)))
204 (assert (eq 7 (icalendar-first-weekday-of-year "MO" 2002)))
205 (assert (eq 3 (icalendar-first-weekday-of-year "MO" 2000)))
206 (assert (eq 1 (icalendar-first-weekday-of-year "TH" 1970))))
208 (defun icalendar-testsuite--test-datestring-to-isodate ()
209 "Test method for `icalendar--datestring-to-isodate'."
210 (let ((calendar-date-style 'iso
))
212 (assert (string= (icalendar--datestring-to-isodate "2008 05 11")
214 (assert (string= (icalendar--datestring-to-isodate "2008 05 31")
216 (assert (string= (icalendar--datestring-to-isodate "2008 05 31" 2)
220 (setq calendar-date-style
'european
)
221 (assert (string= (icalendar--datestring-to-isodate "11 05 2008")
223 (assert (string= (icalendar--datestring-to-isodate "31 05 2008")
225 (assert (string= (icalendar--datestring-to-isodate "31 05 2008" 2)
229 (setq calendar-date-style
'american
)
230 (assert (string= (icalendar--datestring-to-isodate "11 05 2008")
232 (assert (string= (icalendar--datestring-to-isodate "12 30 2008")
234 (assert (string= (icalendar--datestring-to-isodate "12 30 2008" 2)
238 (setq calendar-date-style nil
) ;not necessary for conversion
239 (assert (string= (icalendar--datestring-to-isodate "Nov 05 2008")
241 (assert (string= (icalendar--datestring-to-isodate "05 Nov 2008")
243 (assert (string= (icalendar--datestring-to-isodate "2008 Nov 05")
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
)
252 (setq calendar-date-style
'european
)
253 (assert (string= (icalendar--datetime-to-diary-date datetime
)
255 (setq calendar-date-style
'american
)
256 (assert (string= (icalendar--datetime-to-diary-date datetime
)
259 (defun icalendar-testsuite--test-diarytime-to-isotime ()
260 "Test method for `icalendar--diarytime-to-isotime'."
261 (assert (string= (icalendar--diarytime-to-isotime "01:15" "")
263 (assert (string= (icalendar--diarytime-to-isotime "1:15" "")
265 (assert (string= (icalendar--diarytime-to-isotime "0:01" "")
267 (assert (string= (icalendar--diarytime-to-isotime "0100" "")
269 (assert (string= (icalendar--diarytime-to-isotime "0100" "am")
271 (assert (string= (icalendar--diarytime-to-isotime "0100" "pm")
273 (assert (string= (icalendar--diarytime-to-isotime "1200" "")
275 (assert (string= (icalendar--diarytime-to-isotime "17:17" "")
277 (assert (string= (icalendar--diarytime-to-isotime "1200" "am")
279 (assert (string= (icalendar--diarytime-to-isotime "1201" "am")
281 (assert (string= (icalendar--diarytime-to-isotime "1259" "am")
283 (assert (string= (icalendar--diarytime-to-isotime "1200" "pm")
285 (assert (string= (icalendar--diarytime-to-isotime "1201" "pm")
287 (assert (string= (icalendar--diarytime-to-isotime "1259" "pm")
290 (defun icalendar-testsuite--test-convert-ordinary-to-ical ()
291 "Test method for `icalendar--convert-ordinary-to-ical'."
292 (let* ((calendar-date-style 'iso
)
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"
299 (assert (string= "subject" (cadr result
)))
302 (setq result
(icalendar--convert-ordinary-to-ical
303 "&?" "&2010 2 15 12:34-23:45 s"))
304 (assert (= 2 (length result
)))
305 (assert (string= (concat "\nDTSTART;VALUE=DATE-TIME:20100215T123400"
306 "\nDTEND;VALUE=DATE-TIME:20100215T234500")
308 (assert (string= "s" (cadr result
)))
310 ;; with time, again -- test bug#5549
311 (setq result
(icalendar--convert-ordinary-to-ical
312 "x?" "x2010 2 15 0:34-1:45 s"))
313 (assert (= 2 (length result
)))
314 (assert (string= (concat "\nDTSTART;VALUE=DATE-TIME:20100215T003400"
315 "\nDTEND;VALUE=DATE-TIME:20100215T014500")
317 (assert (string= "s" (cadr result
)))))
319 (defun icalendar-testsuite--test-convert-weekly-to-ical ()
320 "Test method for `icalendar--convert-weekly-to-ical'."
321 (let* ((calendar-date-style 'iso
)
323 (calendar-day-name-array
324 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday"
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")
332 (assert (string= "subject" (cadr result
)))))
334 (defun icalendar-testsuite--test-convert-yearly-to-ical ()
335 "Test method for `icalendar--convert-yearly-to-ical'."
336 (let* ((calendar-date-style 'iso
)
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")
348 (assert (string= "Tag der Arbeit" (cadr result
)))))
350 (defun icalendar-testsuite--test-convert-block-to-ical ()
351 "Test method for `icalendar--convert-block-to-ical'."
352 (let* ((calendar-date-style 'iso
)
354 (setq result
(icalendar--convert-block-to-ical
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")
361 (assert (string= "Sommerferien" (cadr result
)))))
363 (defun icalendar-testsuite--test-convert-cyclic-to-ical ()
364 "Test method for `icalendar--convert-cyclic-to-ical'."
365 (let* ((calendar-date-style 'iso
)
367 (setq result
(icalendar--convert-block-to-ical
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")
374 (assert (string= "Sommerferien" (cadr result
)))))
376 (defun icalendar-testsuite--test-convert-anniversary-to-ical ()
377 "Test method for `icalendar--convert-anniversary-to-ical'."
378 (let* ((calendar-date-style 'iso
)
380 (setq result
(icalendar--convert-anniversary-to-ical
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")
388 (assert (string= "g" (cadr result
)))))
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
)))
402 (defun icalendar-testsuite--test-create-uid ()
403 "Test method for `icalendar--create-uid'."
404 (let* ((icalendar-uid-format "xxx-%t-%c-%h-%u-%s")
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"))
412 ;; FIXME! If a test fails 'current-time is screwed. FIXME!
413 (fset 't-ct
(symbol-function 'current-time
))
414 (fset 'current-time
(lambda () '(1 2 3)))
415 (assert (= 77 icalendar--uid-count
))
416 (assert (string= (concat "xxx-123-77-" hash
"-" username
"-19640630")
417 (icalendar--create-uid entry-full contents
)))
418 (assert (= 78 icalendar--uid-count
))
419 (fset 'current-time
(symbol-function 't-ct
))
421 (setq contents
"blahblah")
422 (setq icalendar-uid-format
"yyy%syyy")
423 (assert (string= (concat "yyyDTSTARTyyy")
424 (icalendar--create-uid entry-full contents
)))
427 (defun icalendar-testsuite--test-parse-vtimezone ()
428 "Test method for `icalendar--parse-vtimezone'."
429 (let (vtimezone result
)
430 (setq vtimezone
(icalendar-testsuite--get-ical-event "BEGIN:VTIMEZONE
433 DTSTART:16010101T040000
436 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10
439 DTSTART:16010101T030000
442 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3
446 (setq result
(icalendar--parse-vtimezone vtimezone
))
447 (assert (string= "thename" (car result
)))
448 (message (cdr result
))
449 (assert (string= "STD-02:00DST-03:00,M3.5.0/03:00:00,M10.5.0/04:00:00"
451 (setq vtimezone
(icalendar-testsuite--get-ical-event "BEGIN:VTIMEZONE
454 DTSTART:16010101T040000
457 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2MO;BYMONTH=10
460 DTSTART:16010101T030000
463 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2MO;BYMONTH=3
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
)))))
472 ;; ======================================================================
473 ;; Test methods for exporting from diary to icalendar
474 ;; ======================================================================
476 (defun icalendar-testsuite--test-export (input-iso input-european input-american
478 "Perform an export test.
479 Argument INPUT-ISO iso style diary string.
480 Argument INPUT-EUROPEAN european style diary string.
481 Argument INPUT-AMERICAN american style diary string.
482 Argument EXPECTED-OUTPUT expected icalendar result string.
484 European style input data must use german month names. American
485 and ISO style input data must use english month names."
486 (message "--- icalendar-testsuite--test-export ---")
487 (let ((calendar-date-style 'iso
)
488 (icalendar-recurring-start-year 2000))
489 (set-time-zone-rule "CET") ;;FIXME: reset timezone!
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"
497 (setq calendar-date-style
'iso
)
498 (icalendar-testsuite--do-test-export input-iso expected-output
)))
500 (let ((calendar-month-name-array
501 ["Januar" "Februar" "März" "April" "Mai" "Juni" "Juli" "August"
502 "September" "Oktober" "November" "Dezember"])
503 (calendar-day-name-array
504 ["Sonntag" "Montag" "Dienstag" "Mittwoch" "Donnerstag" "Freitag"
506 (setq calendar-date-style
'european
)
507 (icalendar-testsuite--do-test-export input-european expected-output
)))
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"
515 (setq calendar-date-style
'american
)
516 (icalendar-testsuite--do-test-export input-american expected-output
)))))
518 (defun icalendar-testsuite--do-test-export (input expected-output
)
519 "Actually perform export test.
520 Argument INPUT input diary string.
521 Argument EXPECTED-OUTPUT expected icalendar result string."
522 (let ((temp-file (make-temp-file "icalendar-testsuite-ics")))
525 (icalendar-export-region (point-min) (point-max) temp-file
))
527 (find-file temp-file
)
528 (goto-char (point-min))
530 (cond (expected-output
531 (and (re-search-forward "^\\s-*BEGIN:VCALENDAR
532 PRODID:-//Emacs//NONSGML icalendar.el//EN
543 (regexp-quote (buffer-substring-no-properties
544 (match-beginning 1) (match-end 1)))
548 (re-search-forward "^\\s-*BEGIN:VCALENDAR
549 PRODID:-//Emacs//NONSGML icalendar.el//EN
555 "Export test failed! Input: `%s'\nFound:\n\n%s\n\nbut expected\n\n%s\n%s"
557 (or (and (match-beginning 1)
558 (buffer-substring-no-properties (match-beginning 1)
561 (or expected-output
"<nil>")
562 (icalendar-testsuite--compare-strings (or (and (match-beginning 1)
563 (buffer-substring-no-properties (match-beginning 1)
566 (or expected-output
"<nil>")))))
567 (kill-buffer (find-buffer-visiting temp-file
))
568 (delete-file temp-file
)))
570 ;; ======================================================================
571 ;; Test methods for importing from icalendar to diary
572 ;; ======================================================================
574 (defun icalendar-testsuite--test-import (input expected-iso expected-european
576 "Perform import test.
577 Argument INPUT icalendar event string.
578 Argument EXPECTED-ISO expected iso style diary string.
579 Argument EXPECTED-EUROPEAN expected european style diary string.
580 Argument 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")
585 (if (string-match "^BEGIN:VCALENDAR" input
)
587 (insert "BEGIN:VCALENDAR\nPRODID:-//Emacs//NONSGML icalendar.el//EN\n")
588 (insert "VERSION:2.0\nBEGIN:VEVENT\n")
590 (unless (eq (char-before) ?
\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")
603 (setq calendar-date-style
'iso
)
604 (icalendar-testsuite--do-test-import input expected-iso
))
605 (when expected-european
606 (setq calendar-date-style
'european
)
607 (icalendar-testsuite--do-test-import input expected-european
))
608 (when expected-american
609 (setq calendar-date-style
'american
)
610 (icalendar-testsuite--do-test-import input expected-american
))))
611 (set-time-zone-rule timezone
)))
613 (defun icalendar-testsuite--do-test-import (input expected-output
)
614 "Actually perform import test.
615 Argument INPUT input icalendar string.
616 Argument EXPECTED-OUTPUT expected diary string."
617 (let ((temp-file (make-temp-file "icalendar-test-diary")))
618 (icalendar-import-buffer temp-file t t
)
620 (find-file temp-file
)
621 (let* ((result (buffer-substring-no-properties (point-min) (point-max)))
623 (icalendar-testsuite--compare-strings result
625 (if (stringp difference
)
626 (error "Import test failed! Found\n`%s'\nbut expected\n`%s'\n%s'"
627 result expected-output difference
)))
628 (kill-buffer (find-buffer-visiting temp-file
))
629 (delete-file temp-file
))))
631 ;; ======================================================================
632 ;; Test methods for cycle...
633 ;; ======================================================================
634 (defun icalendar-testsuite--test-cycle (input)
636 Argument INPUT icalendar event string."
638 (if (string-match "^BEGIN:VCALENDAR" input
)
640 (insert "BEGIN:VCALENDAR\nPRODID:-//Emacs//NONSGML icalendar.el//EN\n")
641 (insert "VERSION:2.0\nBEGIN:VEVENT\n")
643 (unless (eq (char-before) ?
\n)
645 (insert "END:VEVENT\nEND:VCALENDAR\n"))
646 (let ((icalendar-import-format "%s%d%l%o%t%u%c")
647 (icalendar-import-format-summary "%s")
648 (icalendar-import-format-location "\n Location: %s")
649 (icalendar-import-format-description "\n Desc: %s")
650 (icalendar-import-format-organizer "\n Organizer: %s")
651 (icalendar-import-format-status "\n Status: %s")
652 (icalendar-import-format-url "\n URL: %s")
653 (icalendar-import-format-class "\n Class: %s"))
654 (dolist (calendar-date-style '(iso european american
))
655 (icalendar-testsuite--do-test-cycle)))))
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))))
664 (icalendar-import-buffer temp-diary t t
)
666 ;; step 2: export what was just imported
668 (find-file temp-diary
)
669 (icalendar-export-region (point-min) (point-max) temp-ics
))
671 ;; compare the output of step 2 with the input of step 1
674 (goto-char (point-min))
675 (when (re-search-forward "\nUID:.*\n" nil t
)
676 (replace-match "\n"))
677 (let ((cycled (buffer-substring-no-properties (point-min) (point-max))))
678 (let ((difference (icalendar-testsuite--compare-strings cycled
680 (if (stringp difference
)
681 (error "Import test failed! Found\n`%s'\nbut expected\n`%s'\n%s'"
682 cycled org-input difference
)))
685 ;; clean up -- Note this is done only if test is passed
686 (kill-buffer (find-buffer-visiting temp-diary
))
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
)))
694 ;; ======================================================================
696 ;; ======================================================================
697 (defun icalendar-testsuite--run-import-tests ()
698 "Perform standard import tests."
699 (icalendar-testsuite--test-import
700 "SUMMARY:non-recurring
701 DTSTART;VALUE=DATE-TIME:20030919T090000
702 DTEND;VALUE=DATE-TIME:20030919T113000"
703 "&2003/9/19 09:00-11:30 non-recurring"
704 "&19/9/2003 09:00-11:30 non-recurring"
705 "&9/19/2003 09:00-11:30 non-recurring")
707 (icalendar-testsuite--test-import
708 "SUMMARY:non-recurring allday
709 DTSTART;VALUE=DATE-TIME:20030919"
710 "&2003/9/19 non-recurring allday"
711 "&19/9/2003 non-recurring allday"
712 "&9/19/2003 non-recurring allday")
714 (icalendar-testsuite--test-import
715 ;; do not remove the trailing blank after "long"!
718 DTSTART;VALUE=DATE:20030919"
719 "&2003/9/19 long summary"
720 "&19/9/2003 long summary"
721 "&9/19/2003 long summary")
723 (icalendar-testsuite--test-import
724 "UID:748f2da0-0d9b-11d8-97af-b4ec8686ea61
728 X-MOZILLA-ALARM-DEFAULT-UNITS:Minuten
729 X-MOZILLA-RECUR-DEFAULT-INTERVAL:0
730 DTSTART;VALUE=DATE:20040719
731 DTEND;VALUE=DATE:20040828
732 DTSTAMP:20031103T011641Z
734 "&%%(and (diary-block 2004 7 19 2004 8 27)) Sommerferien
738 "&%%(and (diary-block 19 7 2004 27 8 2004)) Sommerferien
742 "&%%(and (diary-block 7 19 2004 8 27 2004)) Sommerferien
746 (icalendar-testsuite--test-import
748 :04979712-3902-11d9-93dd-8f9f4afe08da
755 X-MOZILLA-ALARM-DEFAULT-LENGTH
766 "&2004/11/23 14:00-14:30 folded summary
769 "&23/11/2004 14:00-14:30 folded summary
772 "&11/23/2004 14:00-14:30 folded summary
775 (icalendar-testsuite--test-import
777 :6161a312-3902-11d9-b512-f764153bb28b
784 X-MOZILLA-ALARM-DEFAULT-LENGTH
793 "&2004/11/23 14:45-15:45 another example
796 "&23/11/2004 14:45-15:45 another example
799 "&11/23/2004 14:45-15:45 another example
803 (icalendar-testsuite--test-import
805 DTSTART;VALUE=DATE-TIME:20030919T090000
806 DTEND;VALUE=DATE-TIME:20030919T113000
809 "&%%(and (diary-cyclic 1 2003 9 19)) 09:00-11:30 rrule daily"
810 "&%%(and (diary-cyclic 1 19 9 2003)) 09:00-11:30 rrule daily"
811 "&%%(and (diary-cyclic 1 9 19 2003)) 09:00-11:30 rrule daily")
814 (icalendar-testsuite--test-import
816 DTSTART;VALUE=DATE-TIME:20030919T090000
817 DTEND;VALUE=DATE-TIME:20030919T113000
818 RRULE:FREQ=DAILY;INTERVAL=2
820 "&%%(and (diary-cyclic 2 2003 9 19)) 09:00-11:30 rrule daily"
821 "&%%(and (diary-cyclic 2 19 9 2003)) 09:00-11:30 rrule daily"
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
825 DTSTART;VALUE=DATE-TIME:20030919T090000
826 DTEND;VALUE=DATE-TIME:20030919T113000
827 RRULE:FREQ=DAILY;INTERVAL=2
828 EXDATE:20030921,20030925
830 "&%%(and (not (diary-date 2003 9 25)) (not (diary-date 2003 9 21)) (diary-cyclic 2 2003 9 19)) 09:00-11:30 rrule daily with exceptions"
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")
834 (icalendar-testsuite--test-import
835 "SUMMARY:rrule weekly
836 DTSTART;VALUE=DATE-TIME:20030919T090000
837 DTEND;VALUE=DATE-TIME:20030919T113000
840 "&%%(and (diary-cyclic 7 2003 9 19)) 09:00-11:30 rrule weekly"
841 "&%%(and (diary-cyclic 7 19 9 2003)) 09:00-11:30 rrule weekly"
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
845 DTSTART;VALUE=DATE-TIME:20030919T090000
846 DTEND;VALUE=DATE-TIME:20030919T113000
849 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 9999 1 1)) 09:00-11:30 rrule monthly no end"
850 "&%%(and (diary-date 19 t t) (diary-block 19 9 2003 1 1 9999)) 09:00-11:30 rrule monthly no end"
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
854 DTSTART;VALUE=DATE-TIME:20030919T090000
855 DTEND;VALUE=DATE-TIME:20030919T113000
856 RRULE:FREQ=MONTHLY;UNTIL=20050819;
858 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2005 8 19)) 09:00-11:30 rrule monthly with end"
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
863 DTEND;VALUE=DATE:20040816
864 SUMMARY:Maria Himmelfahrt
865 UID:CC56BEA6-49D2-11D8-8833-00039386D1C2-RID
866 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=8
868 "&%%(and (diary-anniversary 2004 8 15)) Maria Himmelfahrt"
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
873 DTSTART;VALUE=DATE-TIME:20030919T090000
874 DTEND;VALUE=DATE-TIME:20030919T113000
875 RRULE:FREQ=YEARLY;INTERVAL=2
877 "&%%(and (diary-anniversary 2003 9 19)) 09:00-11:30 rrule yearly" ;FIXME
878 "&%%(and (diary-anniversary 19 9 2003)) 09:00-11:30 rrule yearly" ;FIXME
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
882 DTSTART;VALUE=DATE-TIME:20030919T090000
883 DTEND;VALUE=DATE-TIME:20030919T113000
884 RRULE:FREQ=DAILY;COUNT=1;INTERVAL=1
886 "&%%(and (diary-cyclic 1 2003 9 19) (diary-block 2003 9 19 2003 9 19)) 09:00-11:30 rrule count daily short"
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
891 DTSTART;VALUE=DATE-TIME:20030919T090000
892 DTEND;VALUE=DATE-TIME:20030919T113000
893 RRULE:FREQ=DAILY;COUNT=14;INTERVAL=1
895 "&%%(and (diary-cyclic 1 2003 9 19) (diary-block 2003 9 19 2003 10 2)) 09:00-11:30 rrule count daily long"
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
900 DTSTART;VALUE=DATE-TIME:20030919T090000
901 DTEND;VALUE=DATE-TIME:20030919T113000
902 RRULE:FREQ=WEEKLY;COUNT=3;INTERVAL=2
904 "&%%(and (diary-cyclic 14 2003 9 19) (diary-block 2003 9 19 2003 10 31)) 09:00-11:30 rrule count bi-weekly 3 times"
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
909 DTSTART;VALUE=DATE-TIME:20030919T090000
910 DTEND;VALUE=DATE-TIME:20030919T113000
911 RRULE:FREQ=MONTHLY;INTERVAL=1;COUNT=5
913 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2004 1 19)) 09:00-11:30 rrule count monthly"
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
918 DTSTART;VALUE=DATE-TIME:20030919T090000
919 DTEND;VALUE=DATE-TIME:20030919T113000
920 RRULE:FREQ=MONTHLY;INTERVAL=2;COUNT=5
922 "&%%(and (diary-date t t 19) (diary-block 2003 9 19 2004 5 19)) 09:00-11:30 rrule count every second month" ;FIXME
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
927 DTSTART;VALUE=DATE-TIME:20030919T090000
928 DTEND;VALUE=DATE-TIME:20030919T113000
929 RRULE:FREQ=YEARLY;INTERVAL=1;COUNT=5
931 "&%%(and (diary-date t 9 19) (diary-block 2003 9 19 2007 9 19)) 09:00-11:30 rrule count yearly"
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
936 DTSTART;VALUE=DATE-TIME:20030919T090000
937 DTEND;VALUE=DATE-TIME:20030919T113000
938 RRULE:FREQ=YEARLY;INTERVAL=2;COUNT=5
940 "&%%(and (diary-date t 9 19) (diary-block 2003 9 19 2011 9 19)) 09:00-11:30 rrule count every second year" ;FIXME!!!
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!!!
945 (icalendar-testsuite--test-import
946 "DTSTART;VALUE=DATE:20050217
950 "&%%(and (diary-block 2005 2 17 2005 2 23)) duration"
951 "&%%(and (diary-block 17 2 2005 23 2 2005)) duration"
952 "&%%(and (diary-block 2 17 2005 2 23 2005)) duration")
954 (icalendar-testsuite--test-import
955 "UID:20041127T183329Z-18215-1001-4536-49109@andromeda
956 DTSTAMP:20041127T183315Z
957 LAST-MODIFIED:20041127T183329
959 DTSTART;VALUE=DATE:20011221
960 DTEND;VALUE=DATE:20011221
961 RRULE:FREQ=DAILY;UNTIL=20011229;INTERVAL=1;WKST=SU
964 CREATED:20041127T183329
966 "&%%(and (diary-cyclic 1 2001 12 21) (diary-block 2001 12 21 2001 12 29)) Urlaub
968 "&%%(and (diary-cyclic 1 21 12 2001) (diary-block 21 12 2001 29 12 2001)) Urlaub
970 "&%%(and (diary-cyclic 1 12 21 2001) (diary-block 12 21 2001 12 29 2001)) Urlaub
973 ;;bug#6766 -- multiple byday values in a weekly rrule
974 (icalendar-testsuite--test-import
976 DTEND;TZID=America/New_York:20100421T120000
977 DTSTAMP:20100525T141214Z
978 DTSTART;TZID=America/New_York:20100421T113000
979 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE,TH,FR
984 UID:8814e3f9-7482-408f-996c-3bfe486a1262
988 DTSTAMP:20100525T141214Z
989 DTSTART;VALUE=DATE:20100422
990 DTEND;VALUE=DATE:20100423
991 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU,TH
993 SUMMARY:Tues + Thurs thinking
995 UID:8814e3f9-7482-408f-996c-3bfe486a1263
997 "&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 2010 4 21)) 11:30-12:00 Scrum
1000 &%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 2010 4 22)) Tues + Thurs thinking
1003 "&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 21 4 2010)) 11:30-12:00 Scrum
1006 &%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 22 4 2010)) Tues + Thurs thinking
1009 "&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 4 21 2010)) 11:30-12:00 Scrum
1012 &%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 4 22 2010)) Tues + Thurs thinking
1016 ;; ======================================================================
1018 ;; ======================================================================
1019 (defun icalendar-testsuite--run-export-tests ()
1020 "Perform standard export tests."
1022 (let ((icalendar-export-hidden-diary-entries nil
))
1023 (icalendar-testsuite--test-export
1024 "&2000 Oct 3 ordinary no time "
1025 "&3 Okt 2000 ordinary no time "
1026 "&Oct 3 2000 ordinary no time "
1029 ;; "ordinary" events
1030 (icalendar-testsuite--test-export
1031 "2000 Oct 3 ordinary no time "
1032 "3 Okt 2000 ordinary no time "
1033 "Oct 3 2000 ordinary no time "
1034 "DTSTART;VALUE=DATE:20001003
1035 DTEND;VALUE=DATE:20001004
1036 SUMMARY:ordinary no time
1038 (icalendar-testsuite--test-export
1039 "2000 Oct 3 16:30 ordinary with time"
1040 "3 Okt 2000 16:30 ordinary with time"
1041 "Oct 3 2000 16:30 ordinary with time"
1042 "DTSTART;VALUE=DATE-TIME:20001003T163000
1043 DTEND;VALUE=DATE-TIME:20001003T173000
1044 SUMMARY:ordinary with time
1046 (icalendar-testsuite--test-export
1047 "2000 10 3 16:30 ordinary with time 2"
1048 "3 10 2000 16:30 ordinary with time 2"
1049 "10 3 2000 16:30 ordinary with time 2"
1050 "DTSTART;VALUE=DATE-TIME:20001003T163000
1051 DTEND;VALUE=DATE-TIME:20001003T173000
1052 SUMMARY:ordinary with time 2
1055 (icalendar-testsuite--test-export
1056 "2000/10/3 16:30 ordinary with time 3"
1057 "3/10/2000 16:30 ordinary with time 3"
1058 "10/3/2000 16:30 ordinary with time 3"
1059 "DTSTART;VALUE=DATE-TIME:20001003T163000
1060 DTEND;VALUE=DATE-TIME:20001003T173000
1061 SUMMARY:ordinary with time 3
1064 ;; multiline -- FIXME!!!
1065 (icalendar-testsuite--test-export
1066 "2000 October 3 16:30 multiline
1067 17:30 multiline continued FIXME"
1068 "3 Oktober 2000 16:30 multiline
1069 17:30 multiline continued FIXME"
1070 "October 3 2000 16:30 multiline
1071 17:30 multiline continued FIXME"
1072 "DTSTART;VALUE=DATE-TIME:20001003T163000
1073 DTEND;VALUE=DATE-TIME:20001003T173000
1076 17:30 multiline continued FIXME
1080 (icalendar-testsuite--test-export
1081 "Monday 1:30pm weekly by day with start time"
1082 "Montag 13:30 weekly by day with start time"
1083 "Monday 1:30pm weekly by day with start time"
1084 "DTSTART;VALUE=DATE-TIME:20000103T133000
1085 DTEND;VALUE=DATE-TIME:20000103T143000
1086 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1087 SUMMARY:weekly by day with start time
1090 (icalendar-testsuite--test-export
1091 "Monday 13:30-15:00 weekly by day with start and end time"
1092 "Montag 13:30-15:00 weekly by day with start and end time"
1093 "Monday 01:30pm-03:00pm weekly by day with start and end time"
1094 "DTSTART;VALUE=DATE-TIME:20000103T133000
1095 DTEND;VALUE=DATE-TIME:20000103T150000
1096 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1097 SUMMARY:weekly by day with start and end time
1101 (icalendar-testsuite--test-export
1102 "may 1 yearly no time"
1103 "1 Mai yearly no time"
1104 "may 1 yearly no time"
1105 "DTSTART;VALUE=DATE:19000501
1106 DTEND;VALUE=DATE:19000502
1107 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=5;BYMONTHDAY=1
1108 SUMMARY:yearly no time
1112 (icalendar-testsuite--test-export
1113 "%%(diary-anniversary 1989 10 3) anniversary no time"
1114 "%%(diary-anniversary 3 10 1989) anniversary no time"
1115 "%%(diary-anniversary 10 3 1989) anniversary no time"
1116 "DTSTART;VALUE=DATE:19891003
1117 DTEND;VALUE=DATE:19891004
1118 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=10;BYMONTHDAY=03
1119 SUMMARY:anniversary no time
1121 (icalendar-testsuite--test-export
1122 "%%(diary-anniversary 1989 10 3) 19:00-20:00 anniversary with time"
1123 "%%(diary-anniversary 3 10 1989) 19:00-20:00 anniversary with time"
1124 "%%(diary-anniversary 10 3 1989) 19:00-20:00 anniversary with time"
1125 "DTSTART;VALUE=DATE-TIME:19891003T190000
1126 DTEND;VALUE=DATE-TIME:19891004T200000
1127 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=10;BYMONTHDAY=03
1128 SUMMARY:anniversary with time
1132 (icalendar-testsuite--test-export
1133 "%%(diary-block 2001 6 18 2001 7 6) block no time"
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
1137 DTEND;VALUE=DATE:20010707
1138 SUMMARY:block no time
1140 (icalendar-testsuite--test-export
1141 "%%(diary-block 2001 6 18 2001 7 6) 13:00-17:00 block with time"
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
1145 DTEND;VALUE=DATE-TIME:20010618T170000
1146 RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20010706
1147 SUMMARY:block with time
1149 (icalendar-testsuite--test-export
1150 "%%(diary-block 2001 6 18 2001 7 6) 13:00 block no end time"
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
1154 DTEND;VALUE=DATE-TIME:20010618T140000
1155 RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=20010706
1156 SUMMARY:block no end time
1160 ;; ======================================================================
1162 ;; ======================================================================
1163 (defun icalendar-testsuite--run-real-world-tests ()
1164 "Perform real-world tests, as gathered from problem reports."
1166 (icalendar-testsuite--test-import
1169 PRODID:Microsoft CDO for Microsoft Exchange
1172 TZID:Kolkata\, Chennai\, Mumbai\, New Delhi
1173 X-MICROSOFT-CDO-TZID:23
1175 DTSTART:16010101T000000
1180 DTSTART:16010101T000000
1186 DTSTAMP:20030509T043439Z
1187 DTSTART;TZID=\"Kolkata, Chennai, Mumbai, New Delhi\":20030509T103000
1188 SUMMARY:On-Site Interview
1189 UID:040000008200E00074C5B7101A82E0080000000080B6DE661216C301000000000000000
1190 010000000DB823520692542408ED02D7023F9DFF9
1191 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Xxxxx
1192 xxx Xxxxxxxxxxxx\":MAILTO:xxxxxxxx@xxxxxxx.com
1193 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Yyyyyyy Y
1194 yyyy\":MAILTO:yyyyyyy@yyyyyyy.com
1195 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"Zzzz Zzzz
1196 zz\":MAILTO:zzzzzz@zzzzzzz.com
1197 ORGANIZER;CN=\"Aaaaaa Aaaaa\":MAILTO:aaaaaaa@aaaaaaa.com
1199 DTEND;TZID=\"Kolkata, Chennai, Mumbai, New Delhi\":20030509T153000
1200 DESCRIPTION:10:30am - Blah
1204 CREATED:20030509T043439Z
1205 LAST-MODIFIED:20030509T043459Z
1208 X-MICROSOFT-CDO-BUSYSTATUS:BUSY
1209 X-MICROSOFT-CDO-INSTTYPE:0
1210 X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
1211 X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
1212 X-MICROSOFT-CDO-IMPORTANCE:1
1213 X-MICROSOFT-CDO-OWNERAPPTID:126441427
1216 DESCRIPTION:REMINDER
1217 TRIGGER;RELATED=START:-PT00H15M00S
1222 "&9/5/2003 10:30-15:30 On-Site Interview
1223 Desc: 10:30am - Blah
1225 Organizer: MAILTO:aaaaaaa@aaaaaaa.com
1227 "&5/9/2003 10:30-15:30 On-Site Interview
1228 Desc: 10:30am - Blah
1230 Organizer: MAILTO:aaaaaaa@aaaaaaa.com
1234 (icalendar-testsuite--test-import
1235 "DTSTAMP:20030618T195512Z
1236 DTSTART;TZID=\"Mountain Time (US & Canada)\":20030623T110000
1237 SUMMARY:Dress Rehearsal for XXXX-XXXX
1238 UID:040000008200E00074C5B7101A82E00800000000608AA7DA9835C301000000000000000
1239 0100000007C3A6D65EE726E40B7F3D69A23BD567E
1240 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN=\"AAAAA,AAA
1241 AA (A-AAAAAAA,ex1)\":MAILTO:aaaaa_aaaaa@aaaaa.com
1242 ORGANIZER;CN=\"ABCD,TECHTRAINING
1243 (A-Americas,exgen1)\":MAILTO:xxx@xxxxx.com
1244 LOCATION:555 or TN 555-5555 ID 5555 & NochWas (see below)
1245 DTEND;TZID=\"Mountain Time (US & Canada)\":20030623T120000
1246 DESCRIPTION:753 Zeichen hier radiert
1250 CREATED:20030618T195518Z
1251 LAST-MODIFIED:20030618T195527Z
1254 X-MICROSOFT-CDO-BUSYSTATUS:BUSY
1255 X-MICROSOFT-CDO-INSTTYPE:0
1256 X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
1257 X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
1258 X-MICROSOFT-CDO-IMPORTANCE:1
1259 X-MICROSOFT-CDO-OWNERAPPTID:1022519251
1262 DESCRIPTION:REMINDER
1263 TRIGGER;RELATED=START:-PT00H15M00S
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)
1269 Organizer: MAILTO:xxx@xxxxx.com
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)
1274 Organizer: MAILTO:xxx@xxxxx.com
1277 ;; 2003-06-18 b -- uses timezone
1278 (icalendar-testsuite--test-import
1281 PRODID:Microsoft CDO for Microsoft Exchange
1284 TZID:Mountain Time (US & Canada)
1285 X-MICROSOFT-CDO-TZID:12
1287 DTSTART:16010101T020000
1290 RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=10;BYDAY=-1SU
1293 DTSTART:16010101T020000
1296 RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=4;BYDAY=1SU
1300 DTSTAMP:20030618T230323Z
1301 DTSTART;TZID=\"Mountain Time (US & Canada)\":20030623T090000
1302 SUMMARY:Updated: Dress Rehearsal for ABC01-15
1303 UID:040000008200E00074C5B7101A82E00800000000608AA7DA9835C301000000000000000
1304 0100000007C3A6D65EE726E40B7F3D69A23BD567E
1305 ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;X-REPLYTIME=20030618T20
1306 0700Z;RSVP=TRUE;CN=\"AAAAA,AAAAAA
1307 \(A-AAAAAAA,ex1)\":MAILTO:aaaaaa_aaaaa@aaaaa
1309 ORGANIZER;CN=\"ABCD,TECHTRAINING
1310 \(A-Americas,exgen1)\":MAILTO:bbb@bbbbb.com
1311 LOCATION:123 or TN 123-1234 ID abcd & SonstWo (see below)
1312 DTEND;TZID=\"Mountain Time (US & Canada)\":20030623T100000
1313 DESCRIPTION:Viele Zeichen standen hier früher
1317 CREATED:20030618T230326Z
1318 LAST-MODIFIED:20030618T230335Z
1321 X-MICROSOFT-CDO-BUSYSTATUS:BUSY
1322 X-MICROSOFT-CDO-INSTTYPE:0
1323 X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
1324 X-MICROSOFT-CDO-ALLDAYEVENT:FALSE
1325 X-MICROSOFT-CDO-IMPORTANCE:1
1326 X-MICROSOFT-CDO-OWNERAPPTID:1022519251
1329 DESCRIPTION:REMINDER
1330 TRIGGER;RELATED=START:-PT00H15M00S
1335 "&23/6/2003 17:00-18:00 Updated: Dress Rehearsal for ABC01-15
1336 Desc: Viele Zeichen standen hier früher
1337 Location: 123 or TN 123-1234 ID abcd & SonstWo (see below)
1338 Organizer: MAILTO:bbb@bbbbb.com
1340 "&6/23/2003 17:00-18:00 Updated: Dress Rehearsal for ABC01-15
1341 Desc: Viele Zeichen standen hier früher
1342 Location: 123 or TN 123-1234 ID abcd & SonstWo (see below)
1343 Organizer: MAILTO:bbb@bbbbb.com
1346 ;; export 2004-10-28 block entries
1347 (icalendar-testsuite--test-export
1350 "-*- mode: text; fill-column: 256;-*-
1354 %%(diary-block 11 8 2004 11 10 2004) Nov 8-10 aa
1356 "DTSTART;VALUE=DATE:20041108
1357 DTEND;VALUE=DATE:20041111
1358 SUMMARY:Nov 8-10 aa")
1360 (icalendar-testsuite--test-export
1363 "%%(diary-block 12 13 2004 12 17 2004) Dec 13-17 bb"
1364 "DTSTART;VALUE=DATE:20041213
1365 DTEND;VALUE=DATE:20041218
1366 SUMMARY:Dec 13-17 bb")
1368 (icalendar-testsuite--test-export
1371 "%%(diary-block 2 3 2005 2 4 2005) Feb 3-4 cc"
1372 "DTSTART;VALUE=DATE:20050203
1373 DTEND;VALUE=DATE:20050205
1374 SUMMARY:Feb 3-4 cc")
1376 (icalendar-testsuite--test-export
1379 "%%(diary-block 4 24 2005 4 29 2005) April 24-29 dd"
1380 "DTSTART;VALUE=DATE:20050424
1381 DTEND;VALUE=DATE:20050430
1382 SUMMARY:April 24-29 dd
1384 (icalendar-testsuite--test-export
1387 "%%(diary-block 5 30 2005 6 1 2005) may 30 - June 1: ee"
1388 "DTSTART;VALUE=DATE:20050530
1389 DTEND;VALUE=DATE:20050602
1390 SUMMARY:may 30 - June 1: ee")
1392 (icalendar-testsuite--test-export
1395 "%%(diary-block 6 6 2005 6 8 2005) ff"
1396 "DTSTART;VALUE=DATE:20050606
1397 DTEND;VALUE=DATE:20050609
1400 ;; export 2004-10-28 anniversary entries
1401 (icalendar-testsuite--test-export
1407 %%(diary-anniversary 3 28 1991) aa birthday (%d years old)"
1408 "DTSTART;VALUE=DATE:19910328
1409 DTEND;VALUE=DATE:19910329
1410 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=03;BYMONTHDAY=28
1411 SUMMARY:aa birthday (%d years old)
1414 (icalendar-testsuite--test-export
1417 "%%(diary-anniversary 5 17 1957) bb birthday (%d years old)"
1418 "DTSTART;VALUE=DATE:19570517
1419 DTEND;VALUE=DATE:19570518
1420 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=05;BYMONTHDAY=17
1421 SUMMARY:bb birthday (%d years old)")
1423 (icalendar-testsuite--test-export
1426 "%%(diary-anniversary 6 8 1997) cc birthday (%d years old)"
1427 "DTSTART;VALUE=DATE:19970608
1428 DTEND;VALUE=DATE:19970609
1429 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=06;BYMONTHDAY=08
1430 SUMMARY:cc birthday (%d years old)")
1432 (icalendar-testsuite--test-export
1435 "%%(diary-anniversary 7 22 1983) dd (%d years ago...!)"
1436 "DTSTART;VALUE=DATE:19830722
1437 DTEND;VALUE=DATE:19830723
1438 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=07;BYMONTHDAY=22
1439 SUMMARY:dd (%d years ago...!)")
1441 (icalendar-testsuite--test-export
1444 "%%(diary-anniversary 8 1 1988) ee birthday (%d years old)"
1445 "DTSTART;VALUE=DATE:19880801
1446 DTEND;VALUE=DATE:19880802
1447 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=08;BYMONTHDAY=01
1448 SUMMARY:ee birthday (%d years old)")
1450 (icalendar-testsuite--test-export
1453 "%%(diary-anniversary 9 21 1957) ff birthday (%d years old)"
1454 "DTSTART;VALUE=DATE:19570921
1455 DTEND;VALUE=DATE:19570922
1456 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=09;BYMONTHDAY=21
1457 SUMMARY:ff birthday (%d years old)")
1462 ;; export 2004-10-28 monthly, weekly entries
1464 ;; (icalendar-testsuite--test-export
1467 ;; >>> ------------ monthly:
1469 ;; */27/* 10:00 blah blah"
1472 (icalendar-testsuite--test-export
1475 ">>> ------------ my week:
1478 "DTSTART;VALUE=DATE-TIME:20000103T130000
1479 DTEND;VALUE=DATE-TIME:20000103T140000
1480 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1483 (icalendar-testsuite--test-export
1487 "DTSTART;VALUE=DATE-TIME:20000103T150000
1488 DTEND;VALUE=DATE-TIME:20000103T160000
1489 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1493 (icalendar-testsuite--test-export
1496 "Monday 16:00-17:00 a2"
1497 "DTSTART;VALUE=DATE-TIME:20000103T160000
1498 DTEND;VALUE=DATE-TIME:20000103T170000
1499 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1502 (icalendar-testsuite--test-export
1505 "Tuesday 11:30-13:00 a3"
1506 "DTSTART;VALUE=DATE-TIME:20000104T113000
1507 DTEND;VALUE=DATE-TIME:20000104T130000
1508 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU
1511 (icalendar-testsuite--test-export
1515 "DTSTART;VALUE=DATE-TIME:20000104T150000
1516 DTEND;VALUE=DATE-TIME:20000104T160000
1517 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU
1520 (icalendar-testsuite--test-export
1523 "Wednesday 13:00 a5"
1524 "DTSTART;VALUE=DATE-TIME:20000105T130000
1525 DTEND;VALUE=DATE-TIME:20000105T140000
1526 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE
1529 (icalendar-testsuite--test-export
1532 "Wednesday 11:30-13:30 a6"
1533 "DTSTART;VALUE=DATE-TIME:20000105T113000
1534 DTEND;VALUE=DATE-TIME:20000105T133000
1535 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE
1538 (icalendar-testsuite--test-export
1541 "Wednesday 15:00 s1"
1542 "DTSTART;VALUE=DATE-TIME:20000105T150000
1543 DTEND;VALUE=DATE-TIME:20000105T160000
1544 RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE
1548 ;; export 2004-10-28 regular entries
1549 (icalendar-testsuite--test-export
1553 >>> regular diary entries:
1555 Oct 12 2004, 14:00 Tue: [2004-10-12] q1"
1556 "DTSTART;VALUE=DATE-TIME:20041012T140000
1557 DTEND;VALUE=DATE-TIME:20041012T150000
1558 SUMMARY:Tue: [2004-10-12] q1")
1561 (icalendar-testsuite--test-import
1566 :-//Mozilla.org/NONSGML Mozilla Calendar V1.0//EN
1569 :04979712-3902-11d9-93dd-8f9f4afe08da
1576 X-MOZILLA-ALARM-DEFAULT-LENGTH
1589 :6161a312-3902-11d9-b512-f764153bb28b
1596 X-MOZILLA-ALARM-DEFAULT-LENGTH
1607 :943a4d7e-3902-11d9-9ce7-c9addeadf928
1614 X-MOZILLA-ALARM-DEFAULT-LENGTH
1625 :fe53615e-3902-11d9-9dd8-9d38a155bf41
1632 X-MOZILLA-ALARM-DEFAULT-LENGTH
1634 X-MOZILLA-RECUR-DEFAULT-INTERVAL
1637 :FREQ=WEEKLY;INTERVAL=2;BYDAY=FR
1647 :87c928ee-3901-11d9-b21f-b45042155024
1649 :Rrrr/Cccccc ii Aaaaaaaa
1651 :Vvvvv Rrrr aaa Cccccc
1656 X-MOZILLA-ALARM-DEFAULT-LENGTH
1671 :e8f331ae-3902-11d9-9948-dfdcb66a2872
1678 X-MOZILLA-ALARM-DEFAULT-LENGTH
1681 :FREQ=WEEKLY;INTERVAL=1;BYDAY=MO
1696 "&23/11/2004 14:00-14:30 Jjjjj & Wwwww
1699 &23/11/2004 14:45-15:45 BB Aaaaaaaa Bbbbb
1702 &23/11/2004 11:00-12:00 Hhhhhhhh
1705 &%%(and (diary-cyclic 14 12 11 2004)) 14:00-18:30 MMM Aaaaaaaaa
1708 &%%(and (diary-block 19 11 2004 19 11 2004)) Rrrr/Cccccc ii Aaaaaaaa
1709 Desc: Vvvvv Rrrr aaa Cccccc
1712 &%%(and (diary-cyclic 7 1 11 2004)) Wwww aa hhhh
1715 "&11/23/2004 14:00-14:30 Jjjjj & Wwwww
1718 &11/23/2004 14:45-15:45 BB Aaaaaaaa Bbbbb
1721 &11/23/2004 11:00-12:00 Hhhhhhhh
1724 &%%(and (diary-cyclic 14 11 12 2004)) 14:00-18:30 MMM Aaaaaaaaa
1727 &%%(and (diary-block 11 19 2004 11 19 2004)) Rrrr/Cccccc ii Aaaaaaaa
1728 Desc: Vvvvv Rrrr aaa Cccccc
1731 &%%(and (diary-cyclic 7 11 1 2004)) Wwww aa hhhh
1736 (icalendar-testsuite--test-export
1737 "%%(diary-block 1 1 2004 4 1 2004) Urlaub"
1740 "DTSTART;VALUE=DATE:20040101
1741 DTEND;VALUE=DATE:20040105
1745 (icalendar-testsuite--test-export
1747 "5 11 2004 Bla Fasel"
1749 "DTSTART;VALUE=DATE:20041105
1750 DTEND;VALUE=DATE:20041106
1754 (icalendar-testsuite--test-export
1756 "2 Nov 2004 15:00-16:30 Zahnarzt"
1758 "DTSTART;VALUE=DATE-TIME:20041102T150000
1759 DTEND;VALUE=DATE-TIME:20041102T163000
1763 (icalendar-testsuite--test-import
1765 :b60d398e-1dd1-11b2-a159-cf8cb05139f4
1785 "&%%(and (diary-block 6 2 2005 6 2 2005)) Waitangi Day
1789 "&%%(and (diary-block 2 6 2005 2 6 2005)) Waitangi Day
1795 (icalendar-testsuite--test-import
1796 "DTSTART;VALUE=DATE:20050217
1797 SUMMARY:Hhhhhh Aaaaa ii Aaaaaaaa
1798 UID:6AFA7558-6994-11D9-8A3A-000A95A0E830-RID
1799 DTSTAMP:20050118T210335Z
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")
1806 (icalendar-testsuite--test-export
1808 "&%%(diary-cyclic 7 8 2 2005) 16:00-16:45 [WORK] Pppp"
1810 "DTSTART;VALUE=DATE-TIME:20050208T160000
1811 DTEND;VALUE=DATE-TIME:20050208T164500
1812 RRULE:FREQ=DAILY;INTERVAL=7
1817 (icalendar-testsuite--test-export
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
1824 DTEND;VALUE=DATE:19001102
1825 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=11;BYMONTHDAY=1
1826 SUMMARY:NNN Wwwwwwww Wwwww - Aaaaaa Pppppppp rrrrrr ddd oo Nnnnnnnn 30
1830 (defun icalendar-testsuite--run-cycle-tests ()
1831 "Perform cycling tests."
1832 (icalendar-testsuite--test-cycle
1833 "DTSTART;VALUE=DATE-TIME:20030919T090000
1834 DTEND;VALUE=DATE-TIME:20030919T113000
1838 (icalendar-testsuite--test-cycle
1839 "DTSTART;VALUE=DATE-TIME:20030919T090000
1840 DTEND;VALUE=DATE-TIME:20030919T113000
1842 DESCRIPTION:beschreibung!
1847 (icalendar-testsuite--test-cycle
1848 "DTSTART;VALUE=DATE:19190909
1849 DTEND;VALUE=DATE:19190910
1850 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=09;BYMONTHDAY=09
1851 SUMMARY:and diary-anniversary
1856 (provide 'icalendar-testsuite
)
1858 ;; arch-tag: 33a98396-90e9-49c8-b0e9-b606386d6e8c
1859 ;;; icalendar-testsuite.el ends here