Skip to content

Commit

Permalink
Fixed crash when comparing literals to mocked protocols jonreid#131
Browse files Browse the repository at this point in the history
  • Loading branch information
jonreid committed Sep 8, 2016
1 parent 41349dd commit 977d899
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ OCMockito now requires OCHamcrest v5.4.0 or higher.

- Prevent argument captor from capturing values twice.
- Prevent over-releasing mock object that is stubbed as return value for copy method.
- Fixed crash when comparing literals to mocked protocols.


Version 3.0.2
Expand Down
7 changes: 7 additions & 0 deletions Source/OCMockito/Mocking/MKTProtocolMock.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,11 @@ - (BOOL)respondsToSelector:(SEL)aSelector
return [self methodSignatureForSelector:aSelector] != nil;
}

#pragma mark Support being called as isEqual: argument

- (BOOL)isNSArray__ { return NO; }
- (BOOL)isNSDictionary__ { return NO; }
- (BOOL)isNSNumber__ { return NO; }
- (BOOL)isNSString__ { return NO; }

@end
28 changes: 28 additions & 0 deletions Source/Tests/MKTProtocolMockTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,32 @@ - (void)testShouldNotRespondToUnrelatedSelector
XCTAssertFalse([mockImplementer respondsToSelector:@selector(objectAtIndex:)]);
}

- (void)testArray_ShouldBeAbleToCompareToMock
{
id obj = @[];

XCTAssertFalse([obj isEqual:mockImplementer]);
}

- (void)testDictionary_ShouldBeAbleToCompareToMock
{
id obj = @{};

XCTAssertFalse([obj isEqual:mockImplementer]);
}

- (void)testNumber_ShouldBeAbleToCompareToMock
{
id obj = @0;

XCTAssertFalse([obj isEqual:mockImplementer]);
}

- (void)testString_ShouldBeAbleToCompareToMock
{
id obj = @"";

XCTAssertFalse([obj isEqual:mockImplementer]);
}

@end

0 comments on commit 977d899

Please sign in to comment.