Skip to content

Commit

Permalink
Added unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
orchetect committed Dec 16, 2023
1 parent f3abd52 commit 7fe6bef
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Tests/OTCoreTests/Extensions/Foundation/XMLElement Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,27 @@ final class Extensions_Foundation_XMLElement_Tests: XMLTestCase {
XCTAssertEqual(element.child(at: 1)?.name, "child2")
}

func testRemoveChildren_WherePredicate() {
let element = XMLElement(name: "testname")

let child1 = XMLElement(name: "child1", attributes: [("value", "123")])
let child2 = XMLElement(name: "child2", attributes: [("value", "456")])
let child3 = XMLElement(name: "child3", attributes: [("value", "789")])
element.addChild(child1)
element.addChild(child2)
element.addChild(child3)

XCTAssertEqual(element.childCount, 3)

element.removeChildren { child in
[1, 3].contains(child.name!.suffix(1).int!)
}

XCTAssertEqual(element.childCount, 1)

XCTAssertEqual(element.child(at: 0), child2)
}

func testXMLElement_InitNameAttributes() {
let element = XMLElement(name: "testname", attributes: [
("key1", "value1"),
Expand Down

0 comments on commit 7fe6bef

Please sign in to comment.