Skip to content

Commit

Permalink
Updating assertEqualUnordered
Browse files Browse the repository at this point in the history
  • Loading branch information
LuizZak committed Jul 20, 2024
1 parent 184971e commit e9005bb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Sources/TestCommons/Assertions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public func assertEqualUnordered<T>(

if lhs.count != rhs.count {
XCTFail(
"lhs.count != rhs.count (\(lhs.count) != \(rhs.count)) lhs: \(lhs) rhs: \(rhs) \(message())",
"\(message()) lhs.count != rhs.count (\(lhs.count) != \(rhs.count)) lhs: \(lhs) rhs: \(rhs)".trimmingCharacters(in: .whitespaces),
file: file,
line: line
)
Expand All @@ -25,7 +25,7 @@ public func assertEqualUnordered<T>(

let signal: (String) -> Void = {
XCTFail(
"lhs != rhs (\(lhs) != \(rhs)) \($0)",
"\($0) lhs != rhs (\(lhs) != \(rhs))".trimmingCharacters(in: .whitespaces),
file: file,
line: line
)
Expand All @@ -36,12 +36,12 @@ public func assertEqualUnordered<T>(
if let nextIndex = remaining.firstIndex(where: { compare($0, item) }) {
remaining.remove(at: nextIndex)
} else {
return signal(message())
return signal("Found unmatched rhs element \(item) \(message())")
}
}

if !remaining.isEmpty {
signal(message())
signal("Found unmatched lhs elements \(remaining) \(message())")
}
}

Expand Down

0 comments on commit e9005bb

Please sign in to comment.