@@ -40,7 +40,8 @@ class TestNSXMLDocument : XCTestCase {
40
40
// ("test_validation_failure", test_validation_failure),
41
41
( " test_dtd " , test_dtd) ,
42
42
( " test_documentWithDTD " , test_documentWithDTD) ,
43
- ( " test_dtd_attributes " , test_dtd_attributes)
43
+ ( " test_dtd_attributes " , test_dtd_attributes) ,
44
+ ( " test_documentWithEncodingSetDoesntCrash " , test_documentWithEncodingSetDoesntCrash)
44
45
]
45
46
#else // On Linux, currently the tests that rely on NSError are segfaulting in swift_dynamicCast
46
47
return [
@@ -60,7 +61,8 @@ class TestNSXMLDocument : XCTestCase {
60
61
// ("test_validation_failure", test_validation_failure),
61
62
( " test_dtd " , test_dtd) ,
62
63
// ("test_documentWithDTD", test_documentWithDTD),
63
- ( " test_dtd_attributes " , test_dtd_attributes)
64
+ ( " test_dtd_attributes " , test_dtd_attributes) ,
65
+ ( " test_documentWithEncodingSetDoesntCrash " , test_documentWithEncodingSetDoesntCrash)
64
66
]
65
67
#endif
66
68
}
@@ -406,4 +408,16 @@ class TestNSXMLDocument : XCTestCase {
406
408
let attrDecl = dtd. attributeDeclaration ( forName: " print " , elementName: " foo " ) !
407
409
XCTAssert ( attrDecl. dtdKind == . enumerationAttribute)
408
410
}
411
+
412
+ func test_documentWithEncodingSetDoesntCrash( ) throws {
413
+ weak var weakDoc : XMLDocument ? = nil
414
+ func makeSureDocumentIsAllocatedAndFreed( ) {
415
+ let doc = XMLDocument ( rootElement: XMLElement ( name: " test " ) )
416
+ doc. characterEncoding = " UTF-8 "
417
+ weakDoc = doc
418
+ }
419
+ makeSureDocumentIsAllocatedAndFreed ( )
420
+ XCTAssertNil ( weakDoc, " document not freed even through it should have " )
421
+ }
422
+
409
423
}
0 commit comments