I'm trying to test for equality among Realm objects in unit tests. However, I'm unable to get objects to return true for their equality.
According to the Realm docs here, I should be able to do that:
let expectedUser = User()
expectedUser.email = "help@realm.io"
XCTAssertEqual(testRealm.objects(User.self).first!,
expectedUser,
"User was not properly updated from server.")
However, I get the following test failure with the following code:
Realm Model
class Blurb: Object {
dynamic var text = ""
}
Test
func testRealmEquality() {
let a = Blurb()
a.text = "asdf"
let b = Blurb()
b.text = "asdf"
XCTAssertEqual(a, b)
}
XCTAssertEqual failed: ("Optional(Blurb {
text = asdf;
})") is not equal to ("Optional(Blurb {
text = asdf;
})")
Aucun commentaire:
Enregistrer un commentaire