aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/sxml/sxml-namespaced-util.scm
blob: bc29e21dec50afd3874812c99f02fe0c8d2899f3 (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
(define-module (test sxml-namespaced-util)
  :use-module (srfi srfi-64)
  :use-module (sxml namespaced)
  :use-module (sxml namespaced util))

(define ns (gensym "xmlns-"))

(test-equal "XML Hash key"
  (cons 'a ns)
  (xml-element-hash-key ((xml 'a ns))))

(test-group "Find element"
  (let ((el ((xml ns 'a))))
    (test-eq "Found element is the source element"
      el
      (find-child
       el
       (xml-element-children
        ((xml ns 'b)
         el ((xml ns 'a)))))))
  ;; TODO Test "find" failure
  )

(test-group "Element Match"
 (test-assert "Positive element match"
   (element-matches? ((xml 'a ns))
                     (list
                      ((xml 'a ns)
                       "Content here"))))
 (test-assert "Negative element match"
   (not (element-matches? ((xml 'a ns))
                          (list
                           ((xml 'b ns)
                            "Content here"))))))

'((sxml namespaced util))