forked from JohnSundell/Plot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXMLTests.swift
46 lines (38 loc) · 1.11 KB
/
XMLTests.swift
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
/**
* Plot
* Copyright (c) John Sundell 2019
* MIT license, see LICENSE file for details
*/
import XCTest
import Plot
final class XMLTests: XCTestCase {
func testEmptyXML() {
assertEqualXMLContent(XML(), "")
}
func testSingleElement() {
let xml = XML(.element(named: "hello", text: "world!"))
assertEqualXMLContent(xml, "<hello>world!</hello>")
}
func testSelfClosingElement() {
let xml = XML(.selfClosedElement(named: "element"))
assertEqualXMLContent(xml, "<element/>")
}
func testElementWithAttribute() {
let xml = XML(.element(
named: "element",
nodes: [
.attribute(named: "attribute", value: "value")
]
))
assertEqualXMLContent(xml, #"<element attribute="value"></element>"#)
}
func testElementWithChildren() {
let xml = XML(
.element(named: "parent", nodes: [
.selfClosedElement(named: "a"),
.selfClosedElement(named: "b")
])
)
assertEqualXMLContent(xml, "<parent><a/><b/></parent>")
}
}