test-sxml-dom.lisp
 1 ;;;; -*- mode: lisp -*-
2 ;;;;
3 ;;;; $Id: test-sxml-dom.lisp,v 1.1.1.1 2004/06/07 18:49:59 scaekenberghe Exp $
4 ;;;;
5 ;;;; Unit and functional tests for sxml-dom.lisp
6 ;;;;
7 ;;;; Copyright (C) 2002, 2004 Sven Van Caekenberghe, Beta Nine BVBA.
8 ;;;;
9 ;;;; You are granted the rights to distribute and use this software
10 ;;;; as governed by the terms of the Lisp Lesser General Public License
11 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
12
13 (in-package :s-xml)
14
15 (assert
16 (equal (with-input-from-string (stream " <foo/>")
17 (parse-xml stream :output-type :sxml))
18 '(:|foo|)))
19
20 (assert
21 (equal (parse-xml-string "<tag1><tag2 att1='one'/>this is some text</tag1>"
22 :output-type :sxml)
23 '(:|tag1|
24 (:|tag2| (:@ (:|att1| "one")))
25 "this is some text")))
26
27 (assert
28 (equal (parse-xml-string "<TAG>&lt;foo&gt;</TAG>"
29 :output-type :sxml)
30 '(:TAG "<foo>")))
31
32 (assert
33 (equal (parse-xml-string
34 "<P><INDEX ITEM='one'/> This is some <B>bold</B> text, with a leading &amp; trailing space </P>"
35 :output-type :sxml)
36 '(:p
37 (:index (:@ (:item "one")))
38 " This is some "
39 (:b "bold")
40 " text, with a leading & trailing space ")))
41
42 (assert
43 (consp (parse-xml-file (merge-pathnames "xhtml-page.xml" *load-pathname*)
44 :output-type :sxml)))
45
46 (assert
47 (consp (parse-xml-file (merge-pathnames "ant-build-file.xml" *load-pathname*)
48 :output-type :sxml)))
49
50 (assert
51 (consp (parse-xml-file (merge-pathnames "plist.xml" *load-pathname*)
52 :output-type :sxml)))
53
54 (assert
55 (string-equal (print-xml-string '(:|foo|) :input-type :sxml)
56 "<foo/>"))
57
58 (assert
59 (string-equal (print-xml-string '(:|foo| (:@ (:|bar| "1"))) :input-type :sxml)
60 "<foo bar=\"1\"/>"))
61
62 (assert
63 (string-equal (print-xml-string '(:foo "some text") :input-type :sxml)
64 "<FOO>some text</FOO>"))
65
66 (assert
67 (string-equal (print-xml-string '(:|foo| (:|bar|)) :input-type :sxml)
68 "<foo><bar/></foo>"))
69
70 ;;;; eof