Skip to content

Commit 3026c5e

Browse files
committed
XMLNode: Add a test for XMLNode.Kind.
1 parent e660c63 commit 3026c5e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

TestFoundation/TestXMLDocument.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class TestXMLDocument : LoopbackServerTest {
3838
("test_removeNamespace", test_removeNamespace),
3939
("test_optionPreserveAll", test_optionPreserveAll),
4040
("test_rootElementRetainsDocument", test_rootElementRetainsDocument),
41+
("test_nodeKinds", test_nodeKinds),
4142
]
4243
}
4344

@@ -550,6 +551,21 @@ class TestXMLDocument : LoopbackServerTest {
550551

551552
XCTAssertEqual(try? test(), "plans")
552553
}
554+
555+
func test_nodeKinds() {
556+
XCTAssertEqual(XMLDocument(rootElement: nil).kind, .document)
557+
XCTAssertEqual(XMLElement(name: "prefix:localName").kind, .element)
558+
XCTAssertEqual((XMLNode.attribute(withName: "name", stringValue: "value") as? XMLNode)?.kind, .attribute)
559+
XCTAssertEqual((XMLNode.namespace(withName: "namespace", stringValue: "http://example.com/") as? XMLNode)?.kind, .namespace)
560+
XCTAssertEqual((XMLNode.processingInstruction(withName: "name", stringValue: "value") as? XMLNode)?.kind, .processingInstruction)
561+
XCTAssertEqual((XMLNode.comment(withStringValue: "comment") as? XMLNode)?.kind, .comment)
562+
XCTAssertEqual((XMLNode.text(withStringValue: "text") as? XMLNode)?.kind, .text)
563+
XCTAssertEqual((try? XMLDTD(data:#"<!ENTITY a "A">"#.data(using: .utf8)!))?.kind, .DTDKind)
564+
XCTAssertEqual(XMLDTDNode(xmlString: #"<!ENTITY b "B">"#)?.kind, .entityDeclaration)
565+
XCTAssertEqual(XMLDTDNode(xmlString: "<!ATTLIST A B CDATA #IMPLIED>")?.kind, .attributeDeclaration)
566+
XCTAssertEqual(XMLDTDNode(xmlString: "<!ELEMENT E EMPTY>")?.kind, .elementDeclaration)
567+
XCTAssertEqual(XMLDTDNode(xmlString: #"<!NOTATION f SYSTEM "F">"#)?.kind, .notationDeclaration)
568+
}
553569
}
554570

555571
fileprivate extension XMLNode {

0 commit comments

Comments
 (0)