aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-03-23 00:21:28 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-03-23 00:21:28 +0100
commit43ee98219ce9b077109512785de629d416e8bd6f (patch)
treefeb2dad3c559c1211d0a632ca01090e45709db77
parentMinor cleanup. (diff)
downloadcalp-43ee98219ce9b077109512785de629d416e8bd6f.tar.gz
calp-43ee98219ce9b077109512785de629d416e8bd6f.tar.xz
Set up better test for recurring events.
-rwxr-xr-xmodule/test.scm77
-rw-r--r--testcal/repeating-event.ics28
-rw-r--r--testdata/recurrence/simple-daily.ics13
-rwxr-xr-xtests/recurring.scm56
4 files changed, 69 insertions, 105 deletions
diff --git a/module/test.scm b/module/test.scm
deleted file mode 100755
index 10c6c1a1..00000000
--- a/module/test.scm
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/usr/bin/guile -s
-!#
-
-(add-to-load-path (dirname (current-filename)))
-
-(use-modules (rnrs base) ; assert
- (srfi srfi-1)
- (srfi srfi-19)
- (srfi srfi-19 util)
- (srfi srfi-41)
- (vcalendar)
- (vcalendar output)
- (vcalendar recur))
-
-(define cal (make-vcomponent "../testcal/repeating-event.ics"))
-
-(define ev (car (children cal 'VEVENT)))
-
-(define ev-copy (copy-vcomponent ev))
-
-(assert (equal? (children ev)
- (children ev-copy)))
-
-(define (display-timespan ev)
- (format #t "~a ~a ~a -- ~a~%"
- (attr ev 'NEW_ATTR)
- (attr ev 'N)
- (time->string (attr ev "DTSTART"))
- (time->string (attr ev "DTEND"))))
-
-(display (attr ev 'N)) (newline)
-(display-timespan ev)
-(display (attr ev 'NEW_ATTR)) (newline)
-(newline)
-(define strm (generate-recurrence-set ev))
-(display (attr ev 'RRULE)) (newline)
-
-(if #f
- (begin
- (stream-for-each display-timespan (stream-take 20 strm))
-
- (newline)
-
- ;; (define strm (generate-recurrence-set ev))
- (display (attr ev 'RRULE)) (newline)
-
- ;; This makes the amount of events lookad at before have the same DTSTART,
- ;; which is the last from that set. The one's after that however are fine.
- (stream-for-each display-timespan (stream-take 40 strm))
- (newline)
- ;; This makes all the DTSTART be the last dtstart
- ;; (for-each display-timespan (stream->list (stream-take 20 strm)))
-
-;;; I believe that I might have something to do with the stream's cache.
-
- (newline)
-
- (display-timespan ev)
- (display (attr ev 'NEW_ATTR))
- (newline))
- (begin
- ;; These two acts as one large unit.
- ;; Something modifies the initial ev even though it shouldn't
- (display-timespan ev)
- (stream-for-each
- display-timespan
- (stream-take 20 (generate-recurrence-set (copy-vcomponent ev))))
- (newline)
- (display-timespan ev)
- (newline)
- (stream-for-each
- display-timespan
- (stream-take 40 (generate-recurrence-set (copy-vcomponent ev))))
- (newline)
- (display-timespan ev)
- ))
-
diff --git a/testcal/repeating-event.ics b/testcal/repeating-event.ics
deleted file mode 100644
index 2605d3e1..00000000
--- a/testcal/repeating-event.ics
+++ /dev/null
@@ -1,28 +0,0 @@
-BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//PIMUTILS.ORG//NONSGML khal / icalendar //EN
-BEGIN:VTIMEZONE
-TZID:Europe/Stockholm
-BEGIN:STANDARD
-DTSTART;VALUE=DATE-TIME:20181028T020000
-TZNAME:CET
-TZOFFSETFROM:+0200
-TZOFFSETTO:+0100
-END:STANDARD
-BEGIN:DAYLIGHT
-DTSTART;VALUE=DATE-TIME:20190331T030000
-TZNAME:CEST
-TZOFFSETFROM:+0100
-TZOFFSETTO:+0200
-END:DAYLIGHT
-END:VTIMEZONE
-BEGIN:VEVENT
-SUMMARY:Repeating event
-DTSTART;TZID=Europe/Stockholm;VALUE=DATE-TIME:20190302T160000
-DTEND;TZID=Europe/Stockholm;VALUE=DATE-TIME:20190302T170000
-DTSTAMP;VALUE=DATE-TIME:20190302T165849Z
-UID:USG7HSRFJSZ6YURWCNSH3UCKI2PHP19SWGBG
-SEQUENCE:0
-RRULE:FREQ=DAILY
-END:VEVENT
-END:VCALENDAR
diff --git a/testdata/recurrence/simple-daily.ics b/testdata/recurrence/simple-daily.ics
new file mode 100644
index 00000000..f6ccd661
--- /dev/null
+++ b/testdata/recurrence/simple-daily.ics
@@ -0,0 +1,13 @@
+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
+RRULE:FREQ=DAILY
+END:VEVENT
+END:VCALENDAR
diff --git a/tests/recurring.scm b/tests/recurring.scm
new file mode 100755
index 00000000..1fcef974
--- /dev/null
+++ b/tests/recurring.scm
@@ -0,0 +1,56 @@
+#!/usr/bin/guile -s
+!#
+
+(add-to-load-path (string-append (dirname (dirname (current-filename))) "/module"))
+
+(use-modules (srfi srfi-1)
+ (srfi srfi-19)
+ (srfi srfi-19 util)
+ (srfi srfi-41)
+ (srfi srfi-64) ; Testisg
+
+ (util)
+ (vcalendar)
+ (vcalendar output)
+ (vcalendar recur))
+
+(define (display-timespan ev)
+ (format #t "~a -- ~a~%"
+ (time->string (attr ev "DTSTART"))
+ (time->string (attr ev "DTEND"))))
+
+(define (tcal str)
+ (format #f "~a/testdata/recurrence/~a"
+ (dirname (dirname (current-filename)))
+ str))
+
+(test-begin "recurrence test")
+
+(define cal-1 (make-vcomponent (tcal "simple-daily.ics")))
+
+(let ((ev (car (children cal-1 'VEVENT))))
+ (format #t "~a~%" (attr ev 'RRULE))
+
+ (test-equal "Generate First"
+ (map (extract 'DTSTART)
+ (stream->list (stream-take 5 (generate-recurrence-set ev))))
+ (let* ((s0 (attr ev 'DTSTART))
+ (s1 (add-day s0))
+ (s2 (add-day s1))
+ (s3 (add-day s2))
+ (s4 (add-day s3)))
+ (list s0 s1 s2 s3 s4)))
+
+ ;; We run the exact same thing a secound time, since I had an error with
+ ;; that during development.
+ (test-equal "Generate Again"
+ (map (extract 'DTSTART)
+ (stream->list (stream-take 5 (generate-recurrence-set ev))))
+ (let* ((s0 (attr ev 'DTSTART))
+ (s1 (add-day s0))
+ (s2 (add-day s1))
+ (s3 (add-day s2))
+ (s4 (add-day s3)))
+ (list s0 s1 s2 s3 s4))) )
+
+(test-end "recurrence test")