Details
-
Improvement
-
Status: Closed
-
Major - P3
-
Resolution: Fixed
-
None
-
None
Description
Even if we do extension BsonValue: Equatable {...} (which we may as well, because all of our BSON types will always be Equatable too) we can't actually make arbitrary BsonValues comparable via == because of restrictions preventing protocols from conforming to themselves, == only can only be applied to two instances of a concrete type conforming to Equatable, and not just instances of possibly different types that are both Equatable.
However, we can provide a convenience method that takes in two arbitrary {{BsonValue}}s and compares whether they are equal. To implement that we can do something like
switch left, right { |
case let l as Int, let r as Int: return l == r |
case let l as Double, let r as Double: return l == r |
// ... all the other bson types
|
}
|
We could additionally write a custom Nimble matcher that uses this, so we could do something like expect(doc["a"]).to(bsonEqual(doc["b"])).
Attachments
Issue Links
- has to be done before
-
SWIFT-241 Replace pre-existing test code to use the new bsonEqual Nimble matcher
-
- Closed
-