File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Tests/NimbleTests/Matchers Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -182,6 +182,29 @@ final class EqualTest: XCTestCase { // swiftlint:disable:this type_body_length
182182 expect { 1 as NSNumber } . to ( equal ( 1 as NSNumber ) )
183183 }
184184
185+ func testCustomNSObjectEquality( ) {
186+ final class SomeObject : NSObject {
187+ let id : Int
188+
189+ init ( id: Int ) {
190+ self . id = id
191+ }
192+
193+ override func isEqual( _ object: Any ? ) -> Bool {
194+ guard let rhs = object as? SomeObject else {
195+ return false
196+ }
197+
198+ return self . id == rhs. id
199+ }
200+ }
201+
202+ expect ( SomeObject ( id: 1 ) ) . to ( equal ( SomeObject ( id: 1 ) ) )
203+ let obj1 = SomeObject ( id: 1 )
204+ expect ( obj1) . to ( equal ( obj1) )
205+ expect ( SomeObject ( id: 1 ) ) . toNot ( equal ( SomeObject ( id: 2 ) ) )
206+ }
207+
185208 func testOperatorEquality( ) {
186209 expect ( " foo " ) == " foo "
187210 expect ( " foo " ) != " bar "
You can’t perform that action at this time.
0 commit comments