diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2023-12-01 23:13:32 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2023-12-01 23:15:01 +0100 |
commit | 1a18c30f06b97392414a8a69f04b52918bdfe554 (patch) | |
tree | 421fdb303abf4adb3476debaa7287484076a4a84 /tests/unit/formats/run.scm | |
parent | Properly specify as-list and with-parameters interaction. (diff) | |
download | calp-1a18c30f06b97392414a8a69f04b52918bdfe554.tar.gz calp-1a18c30f06b97392414a8a69f04b52918bdfe554.tar.xz |
Repair format tests.
The test have been really broken for a while, since the return type of
`parameters` changed somewhere along the line.
The serializers are now updated to the new API, and the tests updated to
compare components correctly!
Diffstat (limited to 'tests/unit/formats/run.scm')
-rw-r--r-- | tests/unit/formats/run.scm | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/tests/unit/formats/run.scm b/tests/unit/formats/run.scm index 775a1cdc..860ccae9 100644 --- a/tests/unit/formats/run.scm +++ b/tests/unit/formats/run.scm @@ -1,4 +1,5 @@ (define-module (test formats run) + :use-module (srfi srfi-1) :use-module (srfi srfi-64) :use-module (srfi srfi-88) :use-module ((hnh util) :select (->)) @@ -11,6 +12,7 @@ :use-module ((vcomponent formats ical) :prefix #{ics:}#) :use-module ((vcomponent formats xcal) :prefix #{xcs:}#) :use-module ((vcomponent formats sxcal) :prefix #{sxcs:}#) + :use-module ((vcomponent) :select (vcomponent-equal?)) :use-module (sxml namespaced) :use-module ((calp namespaces) :select (xcal)) :use-module (hnh test xmllint) @@ -32,15 +34,18 @@ version: "2.0" (list (vevent - attach: (with-parameters fmttype: "text/plain" - encoding: "BASE64" - value: "BINARY" - (-> "\n" - (string->bytevector - (make-transcoder (utf-8-codec))))) + attach: + (as-list + ;; TODO this creates a vline with a vline as its value + (list (with-parameters fmttype: "text/plain" + encoding: "BASE64" + value: "BINARY" + (-> "\n" + (string->bytevector + (make-transcoder (utf-8-codec))))))) ;; categories: '("a" "b") class: 'PUBLIC - comment: "A comment" + comment: (as-list (list "A comment")) description: "Descrition of the event" description: (with-parameters language: "sv" "Beskrivning av händelsen") ;; geo: (geo y: 10 x: 20) @@ -67,22 +72,32 @@ ;; Assert serialize is set + ;; String representation of pre-vetted representation of the format + ;; (e.g. target.ics) (define target (call-with-input-file (path-append (dirname (current-filename)) reference) read-string)) + ;; The reference component (defined above), + ;; serialized into the target format (define serialized-component (call-with-output-string (lambda (port) (serialize ev port)))) + ;; Check that the serialization suceeded (test-equal (string-append "serialise " name) target serialized-component) + ;; If a parser is given, check that re-parsing the serialized component + ;; returns the original component. (when parse - (test-equal (string-append "parse " name) - (list ev) - (call-with-input-string serialized-component parse)))) + (test-group (string-append "parse " name) + ;; List since parse always returns lists. + (for-each (lambda (target parsed) + (test-assert (vcomponent-equal? target parsed))) + (list ev) + (call-with-input-string serialized-component parse))))) @@ -91,11 +106,6 @@ ;;; to ensure that all implementations are compatible. ;;; However, reflowing data for better diffs is acceptable. -;;; TODO remove this. -;;; iCalendar disabled since the internal vcomponent format isn't yet -;;; fully defined. -(test-skip "iCalendar") - (test-group "iCalendar" (run-test "iCalendar" "target.ics" @@ -111,7 +121,9 @@ (namespaced-sxml->sxml ((@@ (vcomponent formats sxcal) serialize/object) ev) `((,xcal . xcal))) - p)))) + p)) + ;; TODO parse + )) (test-group "xCalendar" (run-test @@ -120,7 +132,9 @@ (-> (call-with-output-string (lambda (port) (xcs:serialize ev port))) xmllint - (display p))))) + (display p))) + ;; TODO parse + )) @@ -129,6 +143,8 @@ (vcomponent formats xcal parse) (vcomponent formats xcal types) + (vcomponent formats sxcal) + (vcomponent formats ical) (vcomponent formats ical output) (vcomponent formats ical parse) |