aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-12-30 16:34:23 +0100
committerHugo Hörnquist <hugo@hornquist.se>2019-12-30 16:34:23 +0100
commitf0318ef98f77e5d55db36523c5438be2c2cfc078 (patch)
tree0322a9931d2aa8fc4cc882252edeb9948284de83 /tests
parentAdd throw-handler to test runner. (diff)
downloadcalp-f0318ef98f77e5d55db36523c5438be2c2cfc078.tar.gz
calp-f0318ef98f77e5d55db36523c5438be2c2cfc078.tar.xz
Fix recurrence tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/recurring.scm63
1 files changed, 36 insertions, 27 deletions
diff --git a/tests/recurring.scm b/tests/recurring.scm
index 8f1bbd1b..134b9922 100644
--- a/tests/recurring.scm
+++ b/tests/recurring.scm
@@ -1,42 +1,51 @@
-(((srfi srfi-41) stream-take stream-map)
+(((srfi srfi-41) stream-take stream-map stream->list)
((srfi srfi-1) find)
+ ((srfi srfi-19) date->time-utc time-utc->date)
((srfi srfi-19 util) day-stream)
((guile) make-struct/no-tail)
((vcomponent base) children extract type attr)
((vcomponent) parse-calendar)
((vcomponent recurrence) generate-recurrence-set))
-(define cal-1
+;;; Test that basic recurrence works
+
+(define ev
(call-with-input-string
- "BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-Manual baby!
-BEGIN:VEVENT
-SUMMARY:Repeating event
-DTSTART;20190302T160000
-DTEND;VALUE=DATE-TIME:20190302T170000
-DTSTAMP;VALUE=DATE-TIME:20190302T165849Z
-UID:USG7HSRFJSZ6YURWCNSH3UCKI2PHP19SWGBG
-SEQUENCE:0
+ "BEGIN:VEVENT
+DTSTART;20190302
RRULE:FREQ=DAILY
-END:VEVENT
-END:VCALENDAR"
+END:VEVENT"
parse-calendar))
-(let ((ev (find (lambda (e) (eq? 'VEVENT (type e))) (children cal-1))))
- (test-assert "Generate Recurrence set" (generate-recurrence-set ev))
+(test-assert "Generate at all"
+ (stream->list (stream-take 5 (generate-recurrence-set ev))))
+
+(test-equal "Generate First"
+ (stream->list
+ (stream-take
+ 5 (stream-map (extract 'DTSTART)
+ (generate-recurrence-set ev))))
+ (stream->list
+ (stream-take
+ 5 (stream-map date->time-utc
+ (day-stream
+ (time-utc->date (attr ev 'DTSTART)))))))
- (test-equal "Generate First"
- (stream-take 5 (stream-map (extract 'DTSTART)
- (generate-recurrence-set ev)))
- (stream-take 5 (day-stream (attr ev 'DTSTART))))
+;; We run the exact same thing a secound time, since I had an error with
+;; that during development.
- ;; We run the exact same thing a secound time, since I had an error with
- ;; that during development.
+(test-equal "Generate Again"
+ (stream->list
+ (stream-take
+ 5 (stream-map (extract 'DTSTART)
+ (generate-recurrence-set ev))))
+ (stream->list
+ (stream-take
+ 5 (stream-map date->time-utc
+ (day-stream
+ (time-utc->date (attr ev 'DTSTART)))))))
- ;; (test-equal "Generate Again"
- ;; (stream-take 5 (stream-map (extract 'DTSTART)
- ;; (generate-recurrence-set ev)))
- ;; (stream-take 5 (day-stream (attr ev 'DTSTART))))
- )
+;;; TODO, also test:
+;;; - limited repetition
+;;; - weird rules