Skip to content

Commit

Permalink
Merge pull request #524 from ikesyo/simplify-equal-for-array-of-optional
Browse files Browse the repository at this point in the history
Simplify `equal` matcher for `[T?]`
  • Loading branch information
ikesyo authored May 10, 2018
2 parents 08f7a5d + fe10f81 commit d47a10f
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions Sources/Nimble/Matchers/Equal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,8 @@ public func equal<T: Equatable>(_ expectedValue: [T?]) -> Predicate<[T?]> {
)
}

let doesNotMatch = PredicateResult(
status: .doesNotMatch,
message: msg
)

if expectedValue.count != actualValue.count {
return doesNotMatch
}

for (index, item) in actualValue.enumerated() {
let otherItem = expectedValue[index]
if item == nil && otherItem == nil {
continue
} else if item == nil && otherItem != nil {
return doesNotMatch
} else if item != nil && otherItem == nil {
return doesNotMatch
} else if item! != otherItem! {
return doesNotMatch
}
}

return PredicateResult(
status: .matches,
message: msg
)
let matches = expectedValue == actualValue
return PredicateResult(bool: matches, message: msg)
}
}

Expand Down

0 comments on commit d47a10f

Please sign in to comment.