Skip to content

Commit e724ba0

Browse files
committed
XMLParser: Add a test for SR-9758.
1 parent f753b1c commit e724ba0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

TestFoundation/TestXMLParser.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class TestXMLParser : XCTestCase {
6565
("test_withData", test_withData),
6666
("test_withDataEncodings", test_withDataEncodings),
6767
("test_withDataOptions", test_withDataOptions),
68+
("test_sr9758_abortParsing", test_sr9758_abortParsing),
6869
]
6970
}
7071

@@ -141,4 +142,16 @@ class TestXMLParser : XCTestCase {
141142
XCTAssertTrue(res)
142143
}
143144

145+
func test_sr9758_abortParsing() {
146+
class Delegate: NSObject, XMLParserDelegate {
147+
func parserDidStartDocument(_ parser: XMLParser) { parser.abortParsing() }
148+
}
149+
let xml = TestXMLParser.xmlUnderTest(encoding: .utf8)
150+
let parser = XMLParser(data: xml.data(using: .utf8)!)
151+
let delegate = Delegate()
152+
parser.delegate = delegate
153+
XCTAssertFalse(parser.parse())
154+
XCTAssertNotNil(parser.parserError)
155+
}
156+
144157
}

0 commit comments

Comments
 (0)