Skip to content

Commit

Permalink
Tests: prefer XCTAssertEqual over XCTAssertTrue
Browse files Browse the repository at this point in the history
Use the `XCTAssertEqual` check for the equality over an inline equal
check. This allows the message to describe both sides of the comparison
and helps identify the issue more easily.
  • Loading branch information
compnerd committed Sep 8, 2024
1 parent c820f72 commit 83062fa
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Tests/Foundation/TestXMLDocument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ class TestXMLDocument : LoopbackServerTest {
XCTAssert(element.name! == "D:propfind")
XCTAssert(element.rootDocument == nil)
if let namespace = element.namespaces?.first {
XCTAssert(namespace.prefix == "D")
XCTAssert(namespace.stringValue == "DAV:")
XCTAssertEqual(namespace.prefix, "D")
XCTAssertEqual(namespace.stringValue, "DAV:")
} else {
XCTFail("Namespace was not parsed correctly")
}

if let child = element.elements(forName: "D:prop").first {
XCTAssert(child.localName == "prop")
XCTAssert(child.prefix == "D")
XCTAssert(child.name == "D:prop")
XCTAssertEqual(child.localName, "prop")
XCTAssertEqual(child.prefix, "D")
XCTAssertEqual(child.name, "D:prop")
} else {
XCTFail("Child element was not parsed correctly!")
}
Expand Down Expand Up @@ -484,8 +484,8 @@ class TestXMLDocument : LoopbackServerTest {
let elementDecl = XMLDTDNode(kind: .elementDeclaration)
elementDecl.name = "MyElement"
elementDecl.stringValue = "(#PCDATA | array)*"
XCTAssert(elementDecl.stringValue == "(#PCDATA | array)*", elementDecl.stringValue ?? "nil string value")
XCTAssert(elementDecl.name == "MyElement")
XCTAssertEqual(elementDecl.stringValue, "(#PCDATA | array)*")
XCTAssertEqual(elementDecl.name, "MyElement")
}

func test_documentWithDTD() throws {
Expand Down Expand Up @@ -562,9 +562,9 @@ class TestXMLDocument : LoopbackServerTest {
XCTAssert(newNS.name == "F")

let root = doc.rootElement()!
XCTAssert(root.localName == "propfind")
XCTAssert(root.name == "D:propfind")
XCTAssert(root.prefix == "D")
XCTAssertEqual(root.localName, "propfind")
XCTAssertEqual(root.name, "D:propfind")
XCTAssertEqual(root.prefix, "D")
let node = doc.findFirstChild(named: "prop")
XCTAssert(node != nil, "failed to find existing node")
XCTAssert(node?.localName == "prop")
Expand Down

0 comments on commit 83062fa

Please sign in to comment.