blob: caf2d33c2d1c6ac491293b2e185417aae1cdafb0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
(define-module (test create)
:use-module ((srfi srfi-1) :select (every))
:use-module (srfi srfi-64)
:use-module (srfi srfi-88)
:use-module ((vcomponent create)
:select (vcomponent
with-parameters
as-list))
:use-module ((vcomponent)
:select (children properties type prop prop* param vline?)))
;; vevent, vcalendar, vtimezone, standard, and daylight all trivial
;; and therefore not tested
(test-group "Empty component"
(let ((ev (vcomponent 'TEST)))
(test-equal 'TEST (type ev))
(test-equal '() (children ev))
(test-equal '() (properties ev))))
(test-group "Component with properties, but no children"
(let ((ev (vcomponent 'TEST
prop: "value")))
(test-equal '(PROP) (map car (properties ev)))
(test-equal "value" (prop ev 'PROP))))
(test-group "Component with children, but no properties"
(let* ((child (vcomponent 'CHILD))
(ev (vcomponent 'TEST
(list child))))
(test-equal '() (properties ev))
(test-equal 1 (length (children ev)))
; (test-eq child (car (children ev)))
))
(test-group "Component with both children and properties"
(let* ((child (vcomponent 'CHILD))
(ev (vcomponent 'TEST
prop: "VALUE"
(list child))))
(test-equal '(PROP) (map car (properties ev)))
(test-equal "VALUE" (prop ev 'PROP))
(test-equal 1 (length (children ev)))
; (test-eq child (car (children ev)))
))
(test-group "Component with no children, where last elements value is a list"
(let ((ev (vcomponent 'TEST prop: (list 1 2 3))))
(test-equal '() (children ev))
(test-equal '(PROP) (map car (properties ev)))
(test-equal '(1 2 3) (prop ev 'PROP))))
(test-group "With parameters"
(let ((ev (vcomponent 'TEST
prop: (with-parameters param: 1 2))))
(test-equal 2 (prop ev 'PROP))
(test-equal '(1) (param (prop* ev 'PROP) 'PARAM))))
(test-group "As list"
(let ((ev (vcomponent 'TEST
prop: (as-list (list 1 2 3)))))
(test-equal '(1 2 3) (prop ev 'PROP))
(test-equal 3 (length (prop* ev 'PROP)))
(test-assert (every vline? (prop* ev 'PROP)))))
;; (test-group "Parameters and lists" )
'((vcomponent create))
|