Skip to content

Commit ce042e1

Browse files
committed
add event test
1 parent bf7e22c commit ce042e1

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
; Copyright (c) Rich Hickey. All rights reserved.
2+
; The use and distribution terms for this software are covered by the
3+
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
4+
; which can be found in the file epl-v10.html at the root of this distribution.
5+
; By using this software in any fashion, you are agreeing to be bound by
6+
; the terms of this license.
7+
; You must not remove this notice, or any other, from this software.
8+
9+
(ns ^{:doc "Tests for event seqs."}
10+
clojure.data.xml.test-event
11+
(:require [clojure.test :refer :all]
12+
[clojure.data.xml :refer :all]
13+
[clojure.data.xml.event :as event])
14+
(:import
15+
[java.io StringReader]
16+
[clojure.data.xml.event StartElementEvent CharsEvent EndElementEvent]))
17+
18+
(deftest test-end-element-info
19+
(let [ev (vec (event-seq (StringReader. "<a><b>123</b></a>") {}))]
20+
(is (= 5 (count ev)))
21+
(is (= [StartElementEvent StartElementEvent CharsEvent EndElementEvent EndElementEvent]
22+
(map type ev)))
23+
(let [ee (last ev)]
24+
(is (= :a (:tag ee)))
25+
(is (= {:line-number 1, :column-number 14, :character-offset 13} (:location-info ee))))))
26+
27+
(comment
28+
(run-tests)
29+
)

0 commit comments

Comments
 (0)