diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-03-07 15:31:00 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-03-07 20:29:14 +0100 |
commit | f7716ac1a87649cad96242f2d5bf0a987d7f430c (patch) | |
tree | b4b84951ef468fd644c42e9e0fee535d879f0387 /tests/test/param.scm | |
parent | Cleanup in (hnh util path). (diff) | |
download | calp-f7716ac1a87649cad96242f2d5bf0a987d7f430c.tar.gz calp-f7716ac1a87649cad96242f2d5bf0a987d7f430c.tar.xz |
Add new tests.
Diffstat (limited to 'tests/test/param.scm')
-rw-r--r-- | tests/test/param.scm | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/test/param.scm b/tests/test/param.scm new file mode 100644 index 00000000..8b8a010d --- /dev/null +++ b/tests/test/param.scm @@ -0,0 +1,57 @@ +;;; 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-88) + :use-module ((vcomponent base) + :select (param prop* parameters prop)) + :use-module ((vcomponent formats ical parse) + :select (parse-calendar)) + :use-module ((vcomponent) :select (make-vcomponent)) + :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)) + ) + +(define v + (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-equal + '(A B) + (sort* (map car (parameters (prop* v 'X-KEY))) + string<? + symbol->string)) + + +;; TODO possibly move this. +;; Checks that a warning is properly raised for +;; unkonwn keys (without an X-prefix) +(test-error + 'warning + (call-with-input-string + "BEGIN:DUMMY +KEY:Some Text +END:DUMMY")) + +;; Similar thing happens for sxcal, but during serialization instead +(let ((component (make-vcomponent 'DUMMY))) + (set! (prop component 'KEY) "Anything") + (test-error + 'warning + (vcomponent->sxcal component))) + + |