forked from JohnSundell/Plot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
XMLTests.swift
58 lines (49 loc) · 1.5 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
47
48
49
50
51
52
53
54
55
56
57
58
/**
* 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>")
}
}
extension XMLTests {
static var allTests: Linux.TestList<XMLTests> {
[
("testEmptyXML", testEmptyXML),
("testSingleElement", testSingleElement),
("testSelfClosingElement", testSelfClosingElement),
("testElementWithAttribute", testElementWithAttribute),
("testElementWithChildren", testElementWithChildren)
]
}
}