Skip to content

Commit

Permalink
check: adding test for issue #280
Browse files Browse the repository at this point in the history
  • Loading branch information
drmohundro committed Aug 5, 2024
1 parent 7226ebc commit 5ebc266
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Tests/SWXMLHashTests/XMLParsingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class XMLParsingTests: XCTestCase {
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-11-17</publish_date>
<foo />
<description>After the collapse of a nanotechnology society in England, the young survivors lay the foundation for a new society.</description>
</book>
</catalog>
Expand Down Expand Up @@ -86,6 +87,20 @@ class XMLParsingTests: XCTestCase {
XCTAssertEqual(xml!["root"]["catalog"]["book"][1]["author"].element?.text, "Ralls, Kim")
}

func testForBugReported() {
let testXml = """
<event><detail><archive /></detail></event>
"""

let parser = XMLHash.parse(testXml)

XCTAssertNotNil(parser["event"]["detail"]["archive"].element)
XCTAssertNil(parser["event"]["detail"]["notThere"].element)

// XCTAssertNotNil(xml!["root"]["catalog"]["book"][2]["foo"].element)
// XCTAssertNil(xml!["root"]["catalog"]["book"][1]["foo"].element)
}

func testShouldBeAbleToParseElementGroupsByIndex() {
XCTAssertEqual(try xml!["root"]["catalog"]["book"].byIndex(1)["author"].element?.text, "Ralls, Kim")
}
Expand Down

0 comments on commit 5ebc266

Please sign in to comment.