diff options
| author | Ulf Jasper | 2010-08-08 19:42:47 +0200 |
|---|---|---|
| committer | Ulf Jasper | 2010-08-08 19:42:47 +0200 |
| commit | 81ee941084fdb35b93a500f6e763e5b0d1c3ab1b (patch) | |
| tree | 482efd7d55cb5e283aa5c9001a243b1a2d0831be | |
| parent | cd21226da41a652bbf21557307bf7e4904fa1524 (diff) | |
| download | emacs-81ee941084fdb35b93a500f6e763e5b0d1c3ab1b.tar.gz emacs-81ee941084fdb35b93a500f6e763e5b0d1c3ab1b.zip | |
Fixed bug#6766 (icalendar.el)
lisp/ChangeLog:
* calendar/icalendar.el (icalendar-uid-format): Doc fix.
(icalendar--split-value): Fixed splitting regexp. (Bug#6766)
(icalendar--get-weekday-numbers): New
(icalendar--create-uid, icalendar-export-region)
(icalendar--parse-summary-and-rest): Code formatting.
(icalendar--convert-recurring-to-diary): Handle multiple byday
values in weekly rules. (Bug#6766)
test/ChangeLog:
* icalendar-testsuite.el (icalendar-testsuite-run): Added internal tests.
(icalendar-testsuite--trim, icalendar-testsuite--compare-strings)
(icalendar-testsuite--run-internal-tests): New.
(icalendar-testsuite--test-convert-ordinary-to-ical)
(icalendar-testsuite--test-convert-block-to-ical)
(icalendar-testsuite--test-convert-anniversary-to-ical)
(icalendar-testsuite--test-parse-vtimezone)
(icalendar-testsuite--do-test-export): Code formatting.
(icalendar-testsuite--test-parse-vtimezone): Doc fix.
(icalendar-testsuite--do-test-import)
(icalendar-testsuite--do-test-cycle): Use icalendar-testsuite--compare-strings
(icalendar-testsuite--run-import-tests): Comment added.
(icalendar-testsuite--run-import-tests)
(icalendar-testsuite--run-real-world-tests): Fixed expected results.
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/calendar/icalendar.el | 111 | ||||
| -rw-r--r-- | test/ChangeLog | 17 | ||||
| -rw-r--r-- | test/icalendar-testsuite.el | 206 |
4 files changed, 260 insertions, 84 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 701a9cc52c8..50aa73ad37b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2010-08-08 Ulf Jasper <ulf.jasper@web.de> | ||
| 2 | |||
| 3 | * calendar/icalendar.el (icalendar-uid-format): Doc fix. | ||
| 4 | (icalendar--split-value): Fixed splitting regexp. (Bug#6766) | ||
| 5 | (icalendar--get-weekday-numbers): New | ||
| 6 | (icalendar--create-uid, icalendar-export-region) | ||
| 7 | (icalendar--parse-summary-and-rest): Code formatting. | ||
| 8 | (icalendar--convert-recurring-to-diary): Handle multiple byday | ||
| 9 | values in weekly rules. (Bug#6766) | ||
| 10 | |||
| 1 | 2010-08-08 Jay Belanger <jay.p.belanger@gmail.com> | 11 | 2010-08-08 Jay Belanger <jay.p.belanger@gmail.com> |
| 2 | 12 | ||
| 3 | * calc/calc.el (calc-trail-mode,calc-refresh): Use `face' property | 13 | * calc/calc.el (calc-trail-mode,calc-refresh): Use `face' property |
diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el index a07402aa031..2dcf75758c0 100644 --- a/lisp/calendar/icalendar.el +++ b/lisp/calendar/icalendar.el | |||
| @@ -212,15 +212,15 @@ if nil they are ignored." | |||
| 212 | 212 | ||
| 213 | (defcustom icalendar-uid-format | 213 | (defcustom icalendar-uid-format |
| 214 | "emacs%t%c" | 214 | "emacs%t%c" |
| 215 | "Format of unique ID code (UID) for each iCalendar object. | 215 | "Format of unique ID code (UID) for each iCalendar object. |
| 216 | The following specifiers are available: | 216 | The following specifiers are available: |
| 217 | %c COUNTER, an integer value that is increased each time a uid is | 217 | %c COUNTER, an integer value that is increased each time a uid is |
| 218 | generated. This may be necessary for systems which do not | 218 | generated. This may be necessary for systems which do not |
| 219 | provide time-resolution finer than a second. | 219 | provide time-resolution finer than a second. |
| 220 | %h HASH, a hash value of the diary entry, | 220 | %h HASH, a hash value of the diary entry, |
| 221 | %s DTSTART, the start date (excluding time) of the diary entry, | 221 | %s DTSTART, the start date (excluding time) of the diary entry, |
| 222 | %t TIMESTAMP, a unique creation timestamp, | 222 | %t TIMESTAMP, a unique creation timestamp, |
| 223 | %u USERNAME, the user-login-name. | 223 | %u USERNAME, the variable `user-login-name'. |
| 224 | 224 | ||
| 225 | For example, a value of \"%s_%h@mydomain.com\" will generate a | 225 | For example, a value of \"%s_%h@mydomain.com\" will generate a |
| 226 | UID code for each entry composed of the time of the event, a hash | 226 | UID code for each entry composed of the time of the event, a hash |
| @@ -427,7 +427,7 @@ children." | |||
| 427 | (goto-char (point-min)) | 427 | (goto-char (point-min)) |
| 428 | (while | 428 | (while |
| 429 | (re-search-forward | 429 | (re-search-forward |
| 430 | "\\([A-Za-z0-9-]+\\)=\\(\\([^;,:]+\\)\\|\"\\([^\"]+\\)\"\\);?" | 430 | "\\([A-Za-z0-9-]+\\)=\\(\\([^;:]+\\)\\|\"\\([^\"]+\\)\"\\);?" |
| 431 | nil t) | 431 | nil t) |
| 432 | (setq param-name (intern (match-string 1))) | 432 | (setq param-name (intern (match-string 1))) |
| 433 | (setq param-value (match-string 2)) | 433 | (setq param-value (match-string 2)) |
| @@ -744,6 +744,20 @@ Note that this silently ignores seconds." | |||
| 744 | ;; Error: | 744 | ;; Error: |
| 745 | -1)) | 745 | -1)) |
| 746 | 746 | ||
| 747 | (defun icalendar--get-weekday-numbers (abbrevweekdays) | ||
| 748 | "Return the list of numbers for the comma-separated ABBREVWEEKDAYS." | ||
| 749 | (when abbrevweekdays | ||
| 750 | (let* ((num -1) | ||
| 751 | (weekday-alist (mapcar (lambda (day) | ||
| 752 | (progn | ||
| 753 | (setq num (1+ num)) | ||
| 754 | (cons (downcase day) num))) | ||
| 755 | icalendar--weekday-array))) | ||
| 756 | (delq nil | ||
| 757 | (mapcar (lambda (abbrevday) | ||
| 758 | (cdr (assoc abbrevday weekday-alist))) | ||
| 759 | (split-string (downcase abbrevweekdays) ",")))))) | ||
| 760 | |||
| 747 | (defun icalendar--get-weekday-abbrev (weekday) | 761 | (defun icalendar--get-weekday-abbrev (weekday) |
| 748 | "Return the abbreviated WEEKDAY." | 762 | "Return the abbreviated WEEKDAY." |
| 749 | (catch 'found | 763 | (catch 'found |
| @@ -912,21 +926,21 @@ current iCalendar object, as a string. Increase | |||
| 912 | `icalendar--uid-count'. Returns the UID string." | 926 | `icalendar--uid-count'. Returns the UID string." |
| 913 | (let ((uid icalendar-uid-format)) | 927 | (let ((uid icalendar-uid-format)) |
| 914 | 928 | ||
| 915 | (setq uid (replace-regexp-in-string | 929 | (setq uid (replace-regexp-in-string |
| 916 | "%c" | 930 | "%c" |
| 917 | (format "%d" icalendar--uid-count) | 931 | (format "%d" icalendar--uid-count) |
| 918 | uid t t)) | 932 | uid t t)) |
| 919 | (setq icalendar--uid-count (1+ icalendar--uid-count)) | 933 | (setq icalendar--uid-count (1+ icalendar--uid-count)) |
| 920 | (setq uid (replace-regexp-in-string | 934 | (setq uid (replace-regexp-in-string |
| 921 | "%t" | 935 | "%t" |
| 922 | (format "%d%d%d" (car (current-time)) | 936 | (format "%d%d%d" (car (current-time)) |
| 923 | (cadr (current-time)) | 937 | (cadr (current-time)) |
| 924 | (car (cddr (current-time)))) | 938 | (car (cddr (current-time)))) |
| 925 | uid t t)) | 939 | uid t t)) |
| 926 | (setq uid (replace-regexp-in-string | 940 | (setq uid (replace-regexp-in-string |
| 927 | "%h" | 941 | "%h" |
| 928 | (format "%d" (abs (sxhash entry-full))) uid t t)) | 942 | (format "%d" (abs (sxhash entry-full))) uid t t)) |
| 929 | (setq uid (replace-regexp-in-string | 943 | (setq uid (replace-regexp-in-string |
| 930 | "%u" (or user-login-name "UNKNOWN_USER") uid t t)) | 944 | "%u" (or user-login-name "UNKNOWN_USER") uid t t)) |
| 931 | (let ((dtstart (if (string-match "^DTSTART[^:]*:\\([0-9]*\\)" contents) | 945 | (let ((dtstart (if (string-match "^DTSTART[^:]*:\\([0-9]*\\)" contents) |
| 932 | (substring contents (match-beginning 1) (match-end 1)) | 946 | (substring contents (match-beginning 1) (match-end 1)) |
| @@ -1008,7 +1022,7 @@ FExport diary data into iCalendar file: ") | |||
| 1008 | (if url | 1022 | (if url |
| 1009 | (setq contents (concat contents "\nURL:" url)))) | 1023 | (setq contents (concat contents "\nURL:" url)))) |
| 1010 | 1024 | ||
| 1011 | (setq header (concat "\nBEGIN:VEVENT\nUID:" | 1025 | (setq header (concat "\nBEGIN:VEVENT\nUID:" |
| 1012 | (icalendar--create-uid entry-full contents))) | 1026 | (icalendar--create-uid entry-full contents))) |
| 1013 | (setq result (concat result header contents "\nEND:VEVENT"))) | 1027 | (setq result (concat result header contents "\nEND:VEVENT"))) |
| 1014 | ;; handle errors | 1028 | ;; handle errors |
| @@ -1126,7 +1140,7 @@ Returns an alist." | |||
| 1126 | (list "%u" | 1140 | (list "%u" |
| 1127 | (concat "\\(" icalendar-import-format-url "\\)??")))) | 1141 | (concat "\\(" icalendar-import-format-url "\\)??")))) |
| 1128 | ;; Need the \' regexp in order to detect multi-line items | 1142 | ;; Need the \' regexp in order to detect multi-line items |
| 1129 | (setq s (concat "\\`" | 1143 | (setq s (concat "\\`" |
| 1130 | (icalendar--rris "%s" "\\(.*?\\)" s nil t) | 1144 | (icalendar--rris "%s" "\\(.*?\\)" s nil t) |
| 1131 | "\\'")) | 1145 | "\\'")) |
| 1132 | (if (string-match s summary-and-rest) | 1146 | (if (string-match s summary-and-rest) |
| @@ -2057,39 +2071,47 @@ END-T is the event's end time in diary format." | |||
| 2057 | )) | 2071 | )) |
| 2058 | ) | 2072 | ) |
| 2059 | (cond ((string-equal frequency "WEEKLY") | 2073 | (cond ((string-equal frequency "WEEKLY") |
| 2060 | (if (not start-t) | 2074 | (let* ((byday (cadr (assoc 'BYDAY rrule-props))) |
| 2061 | (progn | 2075 | (weekdays |
| 2062 | ;; weekly and all-day | 2076 | (icalendar--get-weekday-numbers byday)) |
| 2063 | (icalendar--dmsg "weekly all-day") | 2077 | (weekday-clause |
| 2064 | (if until | 2078 | (when (> (length weekdays) 1) |
| 2065 | (setq result | 2079 | (format "(memq (calendar-day-of-week date) '%s) " |
| 2066 | (format | 2080 | weekdays)))) |
| 2067 | (concat "%%%%(and " | 2081 | (if (not start-t) |
| 2068 | "(diary-cyclic %d %s) " | 2082 | (progn |
| 2069 | "(diary-block %s %s))") | 2083 | ;; weekly and all-day |
| 2070 | (* interval 7) | 2084 | (icalendar--dmsg "weekly all-day") |
| 2071 | dtstart-conv | 2085 | (if until |
| 2072 | dtstart-conv | 2086 | (setq result |
| 2073 | (if count until-1-conv until-conv) | 2087 | (format |
| 2074 | )) | 2088 | (concat "%%%%(and " |
| 2075 | (setq result | 2089 | "%s" |
| 2076 | (format "%%%%(and (diary-cyclic %d %s))" | 2090 | "(diary-block %s %s))") |
| 2077 | (* interval 7) | 2091 | (or weekday-clause |
| 2078 | dtstart-conv)))) | 2092 | (format "(diary-cyclic %d %s) " |
| 2079 | ;; weekly and not all-day | 2093 | (* interval 7) |
| 2080 | (let* ((byday (cadr (assoc 'BYDAY rrule-props))) | 2094 | dtstart-conv)) |
| 2081 | (weekday | 2095 | (if count until-1-conv until-conv) |
| 2082 | (icalendar--get-weekday-number byday))) | 2096 | )) |
| 2097 | (setq result | ||
| 2098 | (format "%%%%(and %s(diary-cyclic %d %s))" | ||
| 2099 | (or weekday-clause "") | ||
| 2100 | (if weekday-clause 1 (* interval 7)) | ||
| 2101 | dtstart-conv)))) | ||
| 2102 | ;; weekly and not all-day | ||
| 2083 | (icalendar--dmsg "weekly not-all-day") | 2103 | (icalendar--dmsg "weekly not-all-day") |
| 2084 | (if until | 2104 | (if until |
| 2085 | (setq result | 2105 | (setq result |
| 2086 | (format | 2106 | (format |
| 2087 | (concat "%%%%(and " | 2107 | (concat "%%%%(and " |
| 2088 | "(diary-cyclic %d %s) " | 2108 | "%s" |
| 2089 | "(diary-block %s %s)) " | 2109 | "(diary-block %s %s)) " |
| 2090 | "%s%s%s") | 2110 | "%s%s%s") |
| 2091 | (* interval 7) | 2111 | (or weekday-clause |
| 2092 | dtstart-conv | 2112 | (format "(diary-cyclic %d %s) " |
| 2113 | (* interval 7) | ||
| 2114 | dtstart-conv)) | ||
| 2093 | dtstart-conv | 2115 | dtstart-conv |
| 2094 | until-conv | 2116 | until-conv |
| 2095 | (or start-t "") | 2117 | (or start-t "") |
| @@ -2100,10 +2122,11 @@ END-T is the event's end time in diary format." | |||
| 2100 | ;; DTEND;VALUE=DATE-TIME:20030919T113000 | 2122 | ;; DTEND;VALUE=DATE-TIME:20030919T113000 |
| 2101 | (setq result | 2123 | (setq result |
| 2102 | (format | 2124 | (format |
| 2103 | "%%%%(and (diary-cyclic %s %s)) %s%s%s" | 2125 | "%%%%(and %s(diary-cyclic %d %s)) %s%s%s" |
| 2104 | (* interval 7) | 2126 | (or weekday-clause "") |
| 2105 | dtstart-conv | 2127 | (if weekday-clause 1 (* interval 7)) |
| 2106 | (or start-t "") | 2128 | dtstart-conv |
| 2129 | (or start-t "") | ||
| 2107 | (if end-t "-" "") (or end-t ""))))))) | 2130 | (if end-t "-" "") (or end-t ""))))))) |
| 2108 | ;; yearly | 2131 | ;; yearly |
| 2109 | ((string-equal frequency "YEARLY") | 2132 | ((string-equal frequency "YEARLY") |
diff --git a/test/ChangeLog b/test/ChangeLog index c23b46a0715..a226e88d883 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,3 +1,20 @@ | |||
| 1 | 2010-08-08 Ulf Jasper <ulf.jasper@web.de> | ||
| 2 | |||
| 3 | * icalendar-testsuite.el (icalendar-testsuite-run): Added internal tests. | ||
| 4 | (icalendar-testsuite--trim, icalendar-testsuite--compare-strings) | ||
| 5 | (icalendar-testsuite--run-internal-tests): New. | ||
| 6 | (icalendar-testsuite--test-convert-ordinary-to-ical) | ||
| 7 | (icalendar-testsuite--test-convert-block-to-ical) | ||
| 8 | (icalendar-testsuite--test-convert-anniversary-to-ical) | ||
| 9 | (icalendar-testsuite--test-parse-vtimezone) | ||
| 10 | (icalendar-testsuite--do-test-export): Code formatting. | ||
| 11 | (icalendar-testsuite--test-parse-vtimezone): Doc fix. | ||
| 12 | (icalendar-testsuite--do-test-import) | ||
| 13 | (icalendar-testsuite--do-test-cycle): Use icalendar-testsuite--compare-strings | ||
| 14 | (icalendar-testsuite--run-import-tests): Comment added. | ||
| 15 | (icalendar-testsuite--run-import-tests) | ||
| 16 | (icalendar-testsuite--run-real-world-tests): Fixed expected results. | ||
| 17 | |||
| 1 | 2010-06-25 Chong Yidong <cyd@stupidchicken.com> | 18 | 2010-06-25 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 19 | ||
| 3 | * redisplay-testsuite.el (test-redisplay-3): New test. | 20 | * redisplay-testsuite.el (test-redisplay-3): New test. |
diff --git a/test/icalendar-testsuite.el b/test/icalendar-testsuite.el index 012f586c342..351bd528bcb 100644 --- a/test/icalendar-testsuite.el +++ b/test/icalendar-testsuite.el | |||
| @@ -33,6 +33,7 @@ | |||
| 33 | (defun icalendar-testsuite-run () | 33 | (defun icalendar-testsuite-run () |
| 34 | "Run icalendar test suite." | 34 | "Run icalendar test suite." |
| 35 | (interactive) | 35 | (interactive) |
| 36 | (icalendar-testsuite--run-internal-tests) | ||
| 36 | (icalendar-testsuite--run-function-tests) | 37 | (icalendar-testsuite--run-function-tests) |
| 37 | (icalendar-testsuite--run-import-tests) | 38 | (icalendar-testsuite--run-import-tests) |
| 38 | (icalendar-testsuite--run-export-tests) | 39 | (icalendar-testsuite--run-export-tests) |
| @@ -41,6 +42,44 @@ | |||
| 41 | (message "All icalendar tests finished successfully.")) | 42 | (message "All icalendar tests finished successfully.")) |
| 42 | 43 | ||
| 43 | ;; ====================================================================== | 44 | ;; ====================================================================== |
| 45 | ;; internal | ||
| 46 | ;; ====================================================================== | ||
| 47 | (defun icalendar-testsuite--trim (string) | ||
| 48 | "Remove leading and trailing whitespace from STRING." | ||
| 49 | (replace-regexp-in-string "[ \t\n]+\\'" "" | ||
| 50 | (replace-regexp-in-string "\\`[ \t\n]+" "" string))) | ||
| 51 | |||
| 52 | (defun icalendar-testsuite--compare-strings (str1 str2) | ||
| 53 | "Compare strings STR1 and STR2. | ||
| 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)) | ||
| 59 | (len (length str2))) | ||
| 60 | (if (numberp result) | ||
| 61 | (if (> result 0) | ||
| 62 | (concat "..." (substring str2 (- result 1) | ||
| 63 | (min len (+ (- result 1) 3))) "...") | ||
| 64 | (concat "..." (substring str2 (- (+ result 1)) | ||
| 65 | (min len (+ (- (+ result 1)) 3))) "...")) | ||
| 66 | t))) | ||
| 67 | |||
| 68 | (defun icalendar-testsuite--run-internal-tests () | ||
| 69 | "Run icalendar-testsuite internal tests." | ||
| 70 | (assert (equal t (icalendar-testsuite--compare-strings " abcde" "abcde "))) | ||
| 71 | (assert | ||
| 72 | (string= "...def..." | ||
| 73 | (icalendar-testsuite--compare-strings "abcxe" "abcdefghijklmn"))) | ||
| 74 | (assert (string= "...xe..." | ||
| 75 | (icalendar-testsuite--compare-strings "abcde" "abcxe"))) | ||
| 76 | (assert (string= "...ddd..." | ||
| 77 | (icalendar-testsuite--compare-strings "abc" "abcdddddd"))) | ||
| 78 | (assert (string= "......" | ||
| 79 | (icalendar-testsuite--compare-strings "abcdefghij" "abc")))) | ||
| 80 | |||
| 81 | |||
| 82 | ;; ====================================================================== | ||
| 44 | ;; Test methods for functions | 83 | ;; Test methods for functions |
| 45 | ;; ====================================================================== | 84 | ;; ====================================================================== |
| 46 | (defun icalendar-testsuite--run-function-tests () | 85 | (defun icalendar-testsuite--run-function-tests () |
| @@ -260,7 +299,7 @@ END:VEVENT | |||
| 260 | (assert (string= "subject" (cadr result))) | 299 | (assert (string= "subject" (cadr result))) |
| 261 | 300 | ||
| 262 | ;; with time | 301 | ;; with time |
| 263 | (setq result (icalendar--convert-ordinary-to-ical | 302 | (setq result (icalendar--convert-ordinary-to-ical |
| 264 | "&?" "&2010 2 15 12:34-23:45 s")) | 303 | "&?" "&2010 2 15 12:34-23:45 s")) |
| 265 | (assert (= 2 (length result))) | 304 | (assert (= 2 (length result))) |
| 266 | (assert (string= (concat "\nDTSTART;VALUE=DATE-TIME:20100215T123400" | 305 | (assert (string= (concat "\nDTSTART;VALUE=DATE-TIME:20100215T123400" |
| @@ -269,7 +308,7 @@ END:VEVENT | |||
| 269 | (assert (string= "s" (cadr result))) | 308 | (assert (string= "s" (cadr result))) |
| 270 | 309 | ||
| 271 | ;; with time, again -- test bug#5549 | 310 | ;; with time, again -- test bug#5549 |
| 272 | (setq result (icalendar--convert-ordinary-to-ical | 311 | (setq result (icalendar--convert-ordinary-to-ical |
| 273 | "x?" "x2010 2 15 0:34-1:45 s")) | 312 | "x?" "x2010 2 15 0:34-1:45 s")) |
| 274 | (assert (= 2 (length result))) | 313 | (assert (= 2 (length result))) |
| 275 | (assert (string= (concat "\nDTSTART;VALUE=DATE-TIME:20100215T003400" | 314 | (assert (string= (concat "\nDTSTART;VALUE=DATE-TIME:20100215T003400" |
| @@ -312,7 +351,7 @@ END:VEVENT | |||
| 312 | "Test method for `icalendar--convert-block-to-ical'." | 351 | "Test method for `icalendar--convert-block-to-ical'." |
| 313 | (let* ((calendar-date-style 'iso) | 352 | (let* ((calendar-date-style 'iso) |
| 314 | result) | 353 | result) |
| 315 | (setq result (icalendar--convert-block-to-ical | 354 | (setq result (icalendar--convert-block-to-ical |
| 316 | "" "%%(diary-block 2004 7 19 2004 8 27) Sommerferien")) | 355 | "" "%%(diary-block 2004 7 19 2004 8 27) Sommerferien")) |
| 317 | (assert (= 2 (length result))) | 356 | (assert (= 2 (length result))) |
| 318 | (assert (string= (concat | 357 | (assert (string= (concat |
| @@ -325,7 +364,7 @@ END:VEVENT | |||
| 325 | "Test method for `icalendar--convert-cyclic-to-ical'." | 364 | "Test method for `icalendar--convert-cyclic-to-ical'." |
| 326 | (let* ((calendar-date-style 'iso) | 365 | (let* ((calendar-date-style 'iso) |
| 327 | result) | 366 | result) |
| 328 | (setq result (icalendar--convert-block-to-ical | 367 | (setq result (icalendar--convert-block-to-ical |
| 329 | "" "%%(diary-block 2004 7 19 2004 8 27) Sommerferien")) | 368 | "" "%%(diary-block 2004 7 19 2004 8 27) Sommerferien")) |
| 330 | (assert (= 2 (length result))) | 369 | (assert (= 2 (length result))) |
| 331 | (assert (string= (concat | 370 | (assert (string= (concat |
| @@ -338,7 +377,7 @@ END:VEVENT | |||
| 338 | "Test method for `icalendar--convert-anniversary-to-ical'." | 377 | "Test method for `icalendar--convert-anniversary-to-ical'." |
| 339 | (let* ((calendar-date-style 'iso) | 378 | (let* ((calendar-date-style 'iso) |
| 340 | result) | 379 | result) |
| 341 | (setq result (icalendar--convert-anniversary-to-ical | 380 | (setq result (icalendar--convert-anniversary-to-ical |
| 342 | "" "%%(diary-anniversary 1964 6 30) g")) | 381 | "" "%%(diary-anniversary 1964 6 30) g")) |
| 343 | (assert (= 2 (length result))) | 382 | (assert (= 2 (length result))) |
| 344 | (assert (string= (concat | 383 | (assert (string= (concat |
| @@ -386,6 +425,7 @@ END:VEVENT | |||
| 386 | )) | 425 | )) |
| 387 | 426 | ||
| 388 | (defun icalendar-testsuite--test-parse-vtimezone () | 427 | (defun icalendar-testsuite--test-parse-vtimezone () |
| 428 | "Test method for `icalendar--parse-vtimezone'." | ||
| 389 | (let (vtimezone result) | 429 | (let (vtimezone result) |
| 390 | (setq vtimezone (icalendar-testsuite--get-ical-event "BEGIN:VTIMEZONE | 430 | (setq vtimezone (icalendar-testsuite--get-ical-event "BEGIN:VTIMEZONE |
| 391 | TZID:thename | 431 | TZID:thename |
| @@ -406,7 +446,8 @@ END:VTIMEZONE | |||
| 406 | (setq result (icalendar--parse-vtimezone vtimezone)) | 446 | (setq result (icalendar--parse-vtimezone vtimezone)) |
| 407 | (assert (string= "thename" (car result))) | 447 | (assert (string= "thename" (car result))) |
| 408 | (message (cdr result)) | 448 | (message (cdr result)) |
| 409 | (assert (string= "STD-02:00DST-03:00,M3.5.0/03:00:00,M10.5.0/04:00:00" (cdr result))) | 449 | (assert (string= "STD-02:00DST-03:00,M3.5.0/03:00:00,M10.5.0/04:00:00" |
| 450 | (cdr result))) | ||
| 410 | (setq vtimezone (icalendar-testsuite--get-ical-event "BEGIN:VTIMEZONE | 451 | (setq vtimezone (icalendar-testsuite--get-ical-event "BEGIN:VTIMEZONE |
| 411 | TZID:anothername | 452 | TZID:anothername |
| 412 | BEGIN:STANDARD | 453 | BEGIN:STANDARD |
| @@ -457,7 +498,7 @@ and ISO style input data must use english month names." | |||
| 457 | (icalendar-testsuite--do-test-export input-iso expected-output))) | 498 | (icalendar-testsuite--do-test-export input-iso expected-output))) |
| 458 | (when input-european | 499 | (when input-european |
| 459 | (let ((calendar-month-name-array | 500 | (let ((calendar-month-name-array |
| 460 | ["Januar" "Februar" "März" "April" "Mai" "Juni" "Juli" "August" | 501 | ["Januar" "Februar" "März" "April" "Mai" "Juni" "Juli" "August" |
| 461 | "September" "Oktober" "November" "Dezember"]) | 502 | "September" "Oktober" "November" "Dezember"]) |
| 462 | (calendar-day-name-array | 503 | (calendar-day-name-array |
| 463 | ["Sonntag" "Montag" "Dienstag" "Mittwoch" "Donnerstag" "Freitag" | 504 | ["Sonntag" "Montag" "Dienstag" "Mittwoch" "Donnerstag" "Freitag" |
| @@ -511,12 +552,18 @@ END:VCALENDAR | |||
| 511 | \\s-*$" | 552 | \\s-*$" |
| 512 | nil t))) | 553 | nil t))) |
| 513 | (error | 554 | (error |
| 514 | "Export test failed! Input: `%s'\nFound:\n\n%s\n\nbut expected\n\n%s" | 555 | "Export test failed! Input: `%s'\nFound:\n\n%s\n\nbut expected\n\n%s\n%s" |
| 515 | input | 556 | input |
| 516 | (or (and (match-beginning 1) | 557 | (or (and (match-beginning 1) |
| 517 | (buffer-substring-no-properties (match-beginning 1) (match-end 1))) | 558 | (buffer-substring-no-properties (match-beginning 1) |
| 559 | (match-end 1))) | ||
| 560 | "<nil>") | ||
| 561 | (or expected-output "<nil>") | ||
| 562 | (icalendar-testsuite--compare-strings (or (and (match-beginning 1) | ||
| 563 | (buffer-substring-no-properties (match-beginning 1) | ||
| 564 | (match-end 1))) | ||
| 518 | "<nil>") | 565 | "<nil>") |
| 519 | (or expected-output "<nil>")))) | 566 | (or expected-output "<nil>"))))) |
| 520 | (kill-buffer (find-buffer-visiting temp-file)) | 567 | (kill-buffer (find-buffer-visiting temp-file)) |
| 521 | (delete-file temp-file))) | 568 | (delete-file temp-file))) |
| 522 | 569 | ||
| @@ -571,11 +618,13 @@ Argument EXPECTED-OUTPUT expected diary string." | |||
| 571 | (icalendar-import-buffer temp-file t t) | 618 | (icalendar-import-buffer temp-file t t) |
| 572 | (save-excursion | 619 | (save-excursion |
| 573 | (find-file temp-file) | 620 | (find-file temp-file) |
| 574 | (let ((result (buffer-substring-no-properties (point-min) (point-max)))) | 621 | (let* ((result (buffer-substring-no-properties (point-min) (point-max))) |
| 575 | (unless (string-match (concat "^\\s-*" expected-output "\\s-*$") | 622 | (difference |
| 576 | result) | 623 | (icalendar-testsuite--compare-strings result |
| 577 | (error "Import test failed! Found `%s'\nbut expected `%s'" result | 624 | expected-output))) |
| 578 | expected-output))) | 625 | (if (stringp difference) |
| 626 | (error "Import test failed! Found\n`%s'\nbut expected\n`%s'\n%s'" | ||
| 627 | result expected-output difference))) | ||
| 579 | (kill-buffer (find-buffer-visiting temp-file)) | 628 | (kill-buffer (find-buffer-visiting temp-file)) |
| 580 | (delete-file temp-file)))) | 629 | (delete-file temp-file)))) |
| 581 | 630 | ||
| @@ -626,9 +675,12 @@ Argument INPUT icalendar event string." | |||
| 626 | (when (re-search-forward "\nUID:.*\n" nil t) | 675 | (when (re-search-forward "\nUID:.*\n" nil t) |
| 627 | (replace-match "\n")) | 676 | (replace-match "\n")) |
| 628 | (let ((cycled (buffer-substring-no-properties (point-min) (point-max)))) | 677 | (let ((cycled (buffer-substring-no-properties (point-min) (point-max)))) |
| 629 | (unless (string-equal org-input cycled) | 678 | (let ((difference (icalendar-testsuite--compare-strings cycled |
| 630 | (error "Import test failed! Found `%s'\nbut expected `%s'" cycled | 679 | org-input))) |
| 631 | org-input)))) | 680 | (if (stringp difference) |
| 681 | (error "Import test failed! Found\n`%s'\nbut expected\n`%s'\n%s'" | ||
| 682 | cycled org-input difference))) | ||
| 683 | )) | ||
| 632 | 684 | ||
| 633 | ;; clean up -- Note this is done only if test is passed | 685 | ;; clean up -- Note this is done only if test is passed |
| 634 | (kill-buffer (find-buffer-visiting temp-diary)) | 686 | (kill-buffer (find-buffer-visiting temp-diary)) |
| @@ -660,6 +712,7 @@ DTSTART;VALUE=DATE-TIME:20030919" | |||
| 660 | "&9/19/2003 non-recurring allday") | 712 | "&9/19/2003 non-recurring allday") |
| 661 | 713 | ||
| 662 | (icalendar-testsuite--test-import | 714 | (icalendar-testsuite--test-import |
| 715 | ;; do not remove the trailing blank after "long"! | ||
| 663 | "SUMMARY:long | 716 | "SUMMARY:long |
| 664 | summary | 717 | summary |
| 665 | DTSTART;VALUE=DATE:20030919" | 718 | DTSTART;VALUE=DATE:20030919" |
| @@ -678,9 +731,17 @@ DTSTART;VALUE=DATE:20040719 | |||
| 678 | DTEND;VALUE=DATE:20040828 | 731 | DTEND;VALUE=DATE:20040828 |
| 679 | DTSTAMP:20031103T011641Z | 732 | DTSTAMP:20031103T011641Z |
| 680 | " | 733 | " |
| 681 | "&%%(and (diary-block 2004 7 19 2004 8 27)) Sommerferien" | 734 | "&%%(and (diary-block 2004 7 19 2004 8 27)) Sommerferien |
| 682 | "&%%(and (diary-block 19 7 2004 27 8 2004)) Sommerferien" | 735 | Status: TENTATIVE |
| 683 | "&%%(and (diary-block 7 19 2004 8 27 2004)) Sommerferien") | 736 | Class: PRIVATE |
| 737 | " | ||
| 738 | "&%%(and (diary-block 19 7 2004 27 8 2004)) Sommerferien | ||
| 739 | Status: TENTATIVE | ||
| 740 | Class: PRIVATE | ||
| 741 | " | ||
| 742 | "&%%(and (diary-block 7 19 2004 8 27 2004)) Sommerferien | ||
| 743 | Status: TENTATIVE | ||
| 744 | Class: PRIVATE") | ||
| 684 | 745 | ||
| 685 | (icalendar-testsuite--test-import | 746 | (icalendar-testsuite--test-import |
| 686 | "UID | 747 | "UID |
| @@ -702,9 +763,15 @@ DTSTAMP | |||
| 702 | LAST-MODIFIED | 763 | LAST-MODIFIED |
| 703 | :20041118T013640Z | 764 | :20041118T013640Z |
| 704 | " | 765 | " |
| 705 | "&2004/11/23 14:00-14:30 folded summary" | 766 | "&2004/11/23 14:00-14:30 folded summary |
| 706 | "&23/11/2004 14:00-14:30 folded summary" | 767 | Status: TENTATIVE |
| 707 | "&11/23/2004 14:00-14:30 folded summary") | 768 | Class: PRIVATE" |
| 769 | "&23/11/2004 14:00-14:30 folded summary | ||
| 770 | Status: TENTATIVE | ||
| 771 | Class: PRIVATE" | ||
| 772 | "&11/23/2004 14:00-14:30 folded summary | ||
| 773 | Status: TENTATIVE | ||
| 774 | Class: PRIVATE") | ||
| 708 | (icalendar-testsuite--test-import | 775 | (icalendar-testsuite--test-import |
| 709 | "UID | 776 | "UID |
| 710 | :6161a312-3902-11d9-b512-f764153bb28b | 777 | :6161a312-3902-11d9-b512-f764153bb28b |
| @@ -723,9 +790,15 @@ DTEND | |||
| 723 | DTSTAMP | 790 | DTSTAMP |
| 724 | :20041118T013641Z | 791 | :20041118T013641Z |
| 725 | " | 792 | " |
| 726 | "&2004/11/23 14:45-15:45 another example" | 793 | "&2004/11/23 14:45-15:45 another example |
| 727 | "&23/11/2004 14:45-15:45 another example" | 794 | Status: TENTATIVE |
| 728 | "&11/23/2004 14:45-15:45 another example") | 795 | Class: PRIVATE" |
| 796 | "&23/11/2004 14:45-15:45 another example | ||
| 797 | Status: TENTATIVE | ||
| 798 | Class: PRIVATE" | ||
| 799 | "&11/23/2004 14:45-15:45 another example | ||
| 800 | Status: TENTATIVE | ||
| 801 | Class: PRIVATE") | ||
| 729 | 802 | ||
| 730 | (icalendar-testsuite--test-import | 803 | (icalendar-testsuite--test-import |
| 731 | "SUMMARY:rrule daily | 804 | "SUMMARY:rrule daily |
| @@ -890,10 +963,55 @@ CLASS:PUBLIC | |||
| 890 | SEQUENCE:1 | 963 | SEQUENCE:1 |
| 891 | CREATED:20041127T183329 | 964 | CREATED:20041127T183329 |
| 892 | " | 965 | " |
| 893 | "&%%(and (diary-cyclic 1 2001 12 21) (diary-block 2001 12 21 2001 12 29)) Urlaub" | 966 | "&%%(and (diary-cyclic 1 2001 12 21) (diary-block 2001 12 21 2001 12 29)) Urlaub |
| 894 | "&%%(and (diary-cyclic 1 21 12 2001) (diary-block 21 12 2001 29 12 2001)) Urlaub" | 967 | Class: PUBLIC" |
| 895 | "&%%(and (diary-cyclic 1 12 21 2001) (diary-block 12 21 2001 12 29 2001)) Urlaub") | 968 | "&%%(and (diary-cyclic 1 21 12 2001) (diary-block 21 12 2001 29 12 2001)) Urlaub |
| 896 | ) | 969 | Class: PUBLIC" |
| 970 | "&%%(and (diary-cyclic 1 12 21 2001) (diary-block 12 21 2001 12 29 2001)) Urlaub | ||
| 971 | Class: PUBLIC") | ||
| 972 | |||
| 973 | ;;bug#6766 -- multiple byday values in a weekly rrule | ||
| 974 | (icalendar-testsuite--test-import | ||
| 975 | "CLASS:PUBLIC | ||
| 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 | ||
| 980 | SEQUENCE:1 | ||
| 981 | STATUS:CONFIRMED | ||
| 982 | SUMMARY:Scrum | ||
| 983 | TRANSP:OPAQUE | ||
| 984 | UID:8814e3f9-7482-408f-996c-3bfe486a1262 | ||
| 985 | END:VEVENT | ||
| 986 | BEGIN:VEVENT | ||
| 987 | CLASS:PUBLIC | ||
| 988 | DTSTAMP:20100525T141214Z | ||
| 989 | DTSTART;VALUE=DATE:20100422 | ||
| 990 | DTEND;VALUE=DATE:20100423 | ||
| 991 | RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU,TH | ||
| 992 | SEQUENCE:1 | ||
| 993 | SUMMARY:Tues + Thurs thinking | ||
| 994 | TRANSP:OPAQUE | ||
| 995 | UID:8814e3f9-7482-408f-996c-3bfe486a1263 | ||
| 996 | " | ||
| 997 | "&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 2010 4 21)) 11:30-12:00 Scrum | ||
| 998 | Status: CONFIRMED | ||
| 999 | Class: PUBLIC | ||
| 1000 | &%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 2010 4 22)) Tues + Thurs thinking | ||
| 1001 | Class: PUBLIC" | ||
| 1002 | |||
| 1003 | "&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 21 4 2010)) 11:30-12:00 Scrum | ||
| 1004 | Status: CONFIRMED | ||
| 1005 | Class: PUBLIC | ||
| 1006 | &%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 22 4 2010)) Tues + Thurs thinking | ||
| 1007 | Class: PUBLIC" | ||
| 1008 | |||
| 1009 | "&%%(and (memq (calendar-day-of-week date) '(1 3 4 5)) (diary-cyclic 1 4 21 2010)) 11:30-12:00 Scrum | ||
| 1010 | Status: CONFIRMED | ||
| 1011 | Class: PUBLIC | ||
| 1012 | &%%(and (memq (calendar-day-of-week date) '(2 4)) (diary-cyclic 1 4 22 2010)) Tues + Thurs thinking | ||
| 1013 | Class: PUBLIC") | ||
| 1014 | ) | ||
| 897 | 1015 | ||
| 898 | ;; ====================================================================== | 1016 | ;; ====================================================================== |
| 899 | ;; Export tests | 1017 | ;; Export tests |
| @@ -1104,11 +1222,13 @@ END:VCALENDAR" | |||
| 1104 | "&9/5/2003 10:30-15:30 On-Site Interview | 1222 | "&9/5/2003 10:30-15:30 On-Site Interview |
| 1105 | Desc: 10:30am - Blah | 1223 | Desc: 10:30am - Blah |
| 1106 | Location: Cccc | 1224 | Location: Cccc |
| 1107 | Organizer: MAILTO:aaaaaaa@aaaaaaa.com" | 1225 | Organizer: MAILTO:aaaaaaa@aaaaaaa.com |
| 1226 | Status: CONFIRMED" | ||
| 1108 | "&5/9/2003 10:30-15:30 On-Site Interview | 1227 | "&5/9/2003 10:30-15:30 On-Site Interview |
| 1109 | Desc: 10:30am - Blah | 1228 | Desc: 10:30am - Blah |
| 1110 | Location: Cccc | 1229 | Location: Cccc |
| 1111 | Organizer: MAILTO:aaaaaaa@aaaaaaa.com") | 1230 | Organizer: MAILTO:aaaaaaa@aaaaaaa.com |
| 1231 | Status: CONFIRMED") | ||
| 1112 | 1232 | ||
| 1113 | ;; 2003-06-18 a | 1233 | ;; 2003-06-18 a |
| 1114 | (icalendar-testsuite--test-import | 1234 | (icalendar-testsuite--test-import |
| @@ -1146,11 +1266,13 @@ END:VALARM" | |||
| 1146 | "&23/6/2003 11:00-12:00 Dress Rehearsal for XXXX-XXXX | 1266 | "&23/6/2003 11:00-12:00 Dress Rehearsal for XXXX-XXXX |
| 1147 | Desc: 753 Zeichen hier radiert | 1267 | Desc: 753 Zeichen hier radiert |
| 1148 | Location: 555 or TN 555-5555 ID 5555 & NochWas (see below) | 1268 | Location: 555 or TN 555-5555 ID 5555 & NochWas (see below) |
| 1149 | Organizer: MAILTO:xxx@xxxxx.com" | 1269 | Organizer: MAILTO:xxx@xxxxx.com |
| 1270 | Status: CONFIRMED" | ||
| 1150 | "&6/23/2003 11:00-12:00 Dress Rehearsal for XXXX-XXXX | 1271 | "&6/23/2003 11:00-12:00 Dress Rehearsal for XXXX-XXXX |
| 1151 | Desc: 753 Zeichen hier radiert | 1272 | Desc: 753 Zeichen hier radiert |
| 1152 | Location: 555 or TN 555-5555 ID 5555 & NochWas (see below) | 1273 | Location: 555 or TN 555-5555 ID 5555 & NochWas (see below) |
| 1153 | Organizer: MAILTO:xxx@xxxxx.com") | 1274 | Organizer: MAILTO:xxx@xxxxx.com |
| 1275 | Status: CONFIRMED") | ||
| 1154 | 1276 | ||
| 1155 | ;; 2003-06-18 b -- uses timezone | 1277 | ;; 2003-06-18 b -- uses timezone |
| 1156 | (icalendar-testsuite--test-import | 1278 | (icalendar-testsuite--test-import |
| @@ -1188,7 +1310,7 @@ ORGANIZER;CN=\"ABCD,TECHTRAINING | |||
| 1188 | \(A-Americas,exgen1)\":MAILTO:bbb@bbbbb.com | 1310 | \(A-Americas,exgen1)\":MAILTO:bbb@bbbbb.com |
| 1189 | LOCATION:123 or TN 123-1234 ID abcd & SonstWo (see below) | 1311 | LOCATION:123 or TN 123-1234 ID abcd & SonstWo (see below) |
| 1190 | DTEND;TZID=\"Mountain Time (US & Canada)\":20030623T100000 | 1312 | DTEND;TZID=\"Mountain Time (US & Canada)\":20030623T100000 |
| 1191 | DESCRIPTION:Viele Zeichen standen hier früher | 1313 | DESCRIPTION:Viele Zeichen standen hier früher |
| 1192 | SEQUENCE:0 | 1314 | SEQUENCE:0 |
| 1193 | PRIORITY:5 | 1315 | PRIORITY:5 |
| 1194 | CLASS: | 1316 | CLASS: |
| @@ -1211,12 +1333,12 @@ END:VEVENT | |||
| 1211 | END:VCALENDAR" | 1333 | END:VCALENDAR" |
| 1212 | nil | 1334 | nil |
| 1213 | "&23/6/2003 17:00-18:00 Updated: Dress Rehearsal for ABC01-15 | 1335 | "&23/6/2003 17:00-18:00 Updated: Dress Rehearsal for ABC01-15 |
| 1214 | Desc: Viele Zeichen standen hier früher | 1336 | Desc: Viele Zeichen standen hier früher |
| 1215 | Location: 123 or TN 123-1234 ID abcd & SonstWo (see below) | 1337 | Location: 123 or TN 123-1234 ID abcd & SonstWo (see below) |
| 1216 | Organizer: MAILTO:bbb@bbbbb.com | 1338 | Organizer: MAILTO:bbb@bbbbb.com |
| 1217 | Status: CONFIRMED" | 1339 | Status: CONFIRMED" |
| 1218 | "&6/23/2003 17:00-18:00 Updated: Dress Rehearsal for ABC01-15 | 1340 | "&6/23/2003 17:00-18:00 Updated: Dress Rehearsal for ABC01-15 |
| 1219 | Desc: Viele Zeichen standen hier früher | 1341 | Desc: Viele Zeichen standen hier früher |
| 1220 | Location: 123 or TN 123-1234 ID abcd & SonstWo (see below) | 1342 | Location: 123 or TN 123-1234 ID abcd & SonstWo (see below) |
| 1221 | Organizer: MAILTO:bbb@bbbbb.com | 1343 | Organizer: MAILTO:bbb@bbbbb.com |
| 1222 | Status: CONFIRMED") | 1344 | Status: CONFIRMED") |
| @@ -1661,9 +1783,13 @@ DTSTAMP | |||
| 1661 | :20050128T011209Z" | 1783 | :20050128T011209Z" |
| 1662 | nil | 1784 | nil |
| 1663 | "&%%(and (diary-block 6 2 2005 6 2 2005)) Waitangi Day | 1785 | "&%%(and (diary-block 6 2 2005 6 2 2005)) Waitangi Day |
| 1664 | Desc: abcdef" | 1786 | Desc: abcdef |
| 1787 | Status: CONFIRMED | ||
| 1788 | Class: PRIVATE" | ||
| 1665 | "&%%(and (diary-block 2 6 2005 2 6 2005)) Waitangi Day | 1789 | "&%%(and (diary-block 2 6 2005 2 6 2005)) Waitangi Day |
| 1666 | Desc: abcdef") | 1790 | Desc: abcdef |
| 1791 | Status: CONFIRMED | ||
| 1792 | Class: PRIVATE") | ||
| 1667 | 1793 | ||
| 1668 | ;; 2005-03-01 lt | 1794 | ;; 2005-03-01 lt |
| 1669 | (icalendar-testsuite--test-import | 1795 | (icalendar-testsuite--test-import |