Skip to content

Commit 5fb434e

Browse files
committed
XMLNode: Modify the tests for stringValue.
To confirm that SR-10759 is resolved.
1 parent e1071a9 commit 5fb434e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

TestFoundation/TestXMLDocument.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,26 @@ class TestXMLDocument : LoopbackServerTest {
199199
func test_stringValue() {
200200
let element = XMLElement(name: "root")
201201
let foo = XMLElement(name: "foo")
202+
let text = XMLNode.text(withStringValue:"<text>") as! XMLNode
203+
let comment = XMLNode.comment(withStringValue:"<comment>") as! XMLNode
204+
foo.addChild(text)
205+
foo.addChild(comment)
202206
element.addChild(foo)
207+
208+
XCTAssertEqual(text.stringValue, "<text>")
209+
XCTAssertEqual(comment.stringValue, "<comment>")
210+
XCTAssertEqual(foo.stringValue, "<text><comment>") // Same with Darwin
211+
XCTAssertEqual(element.stringValue, "<text><comment>") // Same with Darwin
212+
213+
// Confirm that SR-10759 is resolved.
214+
// https://bugs.swift.org/browse/SR-10759
215+
text.stringValue = "<modified text>"
216+
comment.stringValue = "<modified comment>"
217+
XCTAssertEqual(text.stringValue, "<modified text>")
218+
XCTAssertEqual(comment.stringValue, "<modified comment>")
219+
220+
XCTAssertEqual(element.stringValue, "<modified text><modified comment>")
221+
XCTAssertEqual(element.xmlString, "<root><foo>&lt;modified text&gt;<!--<modified comment>--></foo></root>")
203222

204223
element.stringValue = "Hello!<evil/>"
205224
XCTAssertEqual(element.xmlString, "<root>Hello!&lt;evil/&gt;</root>")

0 commit comments

Comments
 (0)