aboutsummaryrefslogtreecommitdiff
path: root/tests
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 /tests
parentMinor cleanup. (diff)
downloadcalp-43ee98219ce9b077109512785de629d416e8bd6f.tar.gz
calp-43ee98219ce9b077109512785de629d416e8bd6f.tar.xz
Set up better test for recurring events.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/recurring.scm56
1 files changed, 56 insertions, 0 deletions
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")