Skip to content

Commit a6eccbe

Browse files
committed
Parity: XMLDTD.init()
Implement it to create an empty .DTDKind node, as it does on Darwin.
1 parent ccca1c3 commit a6eccbe

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Foundation/XMLDTD.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ open class XMLDTD : XMLNode {
2626
}
2727

2828
public init() {
29-
NSUnimplemented()
29+
super.init(kind: .DTDKind, options: [])
3030
}
3131

3232
public convenience init(contentsOf url: URL, options mask: XMLNode.Options = []) throws {

TestFoundation/TestXMLDocument.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,17 @@ class TestXMLDocument : LoopbackServerTest {
620620
_ = XMLNode()
621621
}
622622

623+
func test_creatingAnEmptyDTD() {
624+
let dtd = XMLDTD()
625+
XCTAssertEqual(dtd.publicID, "")
626+
XCTAssertEqual(dtd.systemID, "")
627+
XCTAssertEqual(dtd.children ?? [], [])
628+
629+
let plistDTDUrl = "https://www.apple.com/DTDs/PropertyList-1.0.dtd"
630+
dtd.systemID = plistDTDUrl
631+
XCTAssertEqual(dtd.systemID, plistDTDUrl)
632+
}
633+
623634
static var allTests: [(String, (TestXMLDocument) -> () throws -> Void)] {
624635
return [
625636
("test_basicCreation", test_basicCreation),
@@ -653,6 +664,7 @@ class TestXMLDocument : LoopbackServerTest {
653664
("test_nodeKinds", test_nodeKinds),
654665
("test_sr10776_documentName", test_sr10776_documentName),
655666
("test_creatingAnEmptyDocumentAndNode", test_creatingAnEmptyDocumentAndNode),
667+
("test_creatingAnEmptyDTD", test_creatingAnEmptyDTD),
656668
]
657669
}
658670
}

0 commit comments

Comments
 (0)