From 712654d4c023a2ab13190c6905d313e0ba897965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 2 Oct 2023 19:26:40 +0200 Subject: Rewrite test running system. --- tests/unit/vcomponent/param.scm | 69 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tests/unit/vcomponent/param.scm (limited to 'tests/unit/vcomponent/param.scm') diff --git a/tests/unit/vcomponent/param.scm b/tests/unit/vcomponent/param.scm new file mode 100644 index 00000000..9611fd8a --- /dev/null +++ b/tests/unit/vcomponent/param.scm @@ -0,0 +1,69 @@ +;;; Commentary: +;; Checks that parameters (1) are correctly parsed and stored. +;; (1): 'A', and 'B' in the line "KEY;A=1;B=2:Some text" +;;; Code: + +(define-module (test param) + :use-module (srfi srfi-64) + :use-module (srfi srfi-64 test-error) + :use-module (srfi srfi-88) + :use-module ((vcomponent base) + :select (param prop* parameters prop vline?)) + :use-module ((vcomponent formats ical parse) + :select (parse-calendar)) + :use-module ((vcomponent) :select (vcomponent properties set-properties)) + :use-module ((hnh util) :select (sort* set!)) + :use-module ((ice-9 ports) :select (call-with-input-string)) + :use-module ((vcomponent formats xcal output) + :select (vcomponent->sxcal)) + ) + +;; TODO clean up this whole test + +;; TODO possibly change parsing + +(define v + (car + (call-with-input-string + "BEGIN:DUMMY +X-KEY;A=1;B=2:Some text +END:DUMMY" + parse-calendar))) + +(test-equal '("1") (param (prop* v 'X-KEY) 'A)) + +(test-equal '("2") (param (prop* v 'X-KEY) 'B)) + +(test-equal #f (param (prop* v 'X-KEY) 'C)) + + +(test-group "Properties" + (let ((p (properties v))) + (test-assert (list? p)) + (test-eqv 1 (length p)) + (test-eq 'X-KEY (caar p)) + (test-assert (vline? (cadar p))))) + + + +;; TODO possibly move this. +;; Checks that a warning is properly raised for +;; unkonwn keys (without an X-prefix) +(test-error "Ensure parse-calendar warns on unknown keys" + 'warning + (call-with-input-string + "BEGIN:DUMMY +KEY:Some Text +END:DUMMY" + parse-calendar)) + +;; Similar thing happens for sxcal, but during serialization instead +(let ((component (set-properties (vcomponent type: 'DUMMY) + (cons 'KEY "Anything")))) + + (test-error + 'warning + (vcomponent->sxcal component))) + +'((vcomponent base) + (vcomponent formats xcal output)) -- cgit v1.2.3