aboutsummaryrefslogtreecommitdiff
path: root/tests/test/xcal.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-03-07 15:31:00 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-03-07 20:29:14 +0100
commitf7716ac1a87649cad96242f2d5bf0a987d7f430c (patch)
treeb4b84951ef468fd644c42e9e0fee535d879f0387 /tests/test/xcal.scm
parentCleanup in (hnh util path). (diff)
downloadcalp-f7716ac1a87649cad96242f2d5bf0a987d7f430c.tar.gz
calp-f7716ac1a87649cad96242f2d5bf0a987d7f430c.tar.xz
Add new tests.
Diffstat (limited to 'tests/test/xcal.scm')
-rw-r--r--tests/test/xcal.scm58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/test/xcal.scm b/tests/test/xcal.scm
new file mode 100644
index 00000000..48d43c59
--- /dev/null
+++ b/tests/test/xcal.scm
@@ -0,0 +1,58 @@
+;;; Commentary:
+;; Basic tests of xcal convertion.
+;; Currently only checks that events survive a round trip.
+;;; Code:
+
+(define-module (test xcal)
+ :use-module (srfi srfi-64)
+ :use-module (srfi srfi-88)
+ :use-module ((vcomponent formats xcal parse)
+ :select (sxcal->vcomponent))
+ :use-module ((vcomponent formats xcal output)
+ :select (vcomponent->sxcal))
+ :use-module ((vcomponent formats ical parse)
+ :select (parse-calendar))
+ :use-module ((hnh util) :select (->))
+ :use-module ((vcomponent base)
+ :select (parameters prop* children)))
+
+;;; Some different types, same parameters
+
+(define ev
+ (call-with-input-string
+ "BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//calparse-test
+BEGIN:VEVENT
+SUMMARY:Test event
+DTSTART;TZID=Europe/Stockholm:20200625T133000
+DTEND:20200625T143000Z
+DTSTAMP:20200609T131418Z
+UID:1
+SEQUENCE:0
+CREATED:20200609T081725Z
+DESCRIPTION:Short description
+LAST-MODIFIED:20200609T081725Z
+STATUS;X-TEST-PARAM=10:CONFIRMED
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR"
+ parse-calendar))
+
+(define twice-converted
+ (-> ev vcomponent->sxcal sxcal->vcomponent))
+
+;;; NOTE both these tests may fail since neither properties nor parameters are ordered sorted.
+
+(test-equal
+ "c->x & c->x->c->x"
+ (vcomponent->sxcal ev)
+ (vcomponent->sxcal twice-converted))
+
+(test-equal
+ "xcal parameters"
+ '((X-TEST-PARAM "10"))
+ (parameters
+ (prop* (car (children twice-converted)) 'STATUS)))
+
+