Skip to content

Commit

Permalink
Removed redundancy in verify methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
erikdoe committed Apr 30, 2014
1 parent cf31817 commit 1668016
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 27 deletions.
5 changes: 5 additions & 0 deletions Source/Changes.txt
@@ -1,6 +1,11 @@
Listing of notable changes by release. More detail is usually found in the Git
commit messages and/or the pull requests.

OCMock 3.0.M2 (not yet released)

* Failures without location are now thrown as OCMockTestFailure exception,
not as NSInternalInconsistencyException


OCMock 3.0.M1 (2014-04-26)

Expand Down
10 changes: 7 additions & 3 deletions Source/OCMock/OCMFunctions.m
Expand Up @@ -69,13 +69,17 @@ void OCMReportFailure(OCMLocation *loc, NSString *description)
}
[testCase failWithException:exception];
}
else
else if(loc != nil)
{
NSLog(@"%@:%lu %@", [loc file], (unsigned long)[loc line], description);
NSString *reason = [NSString stringWithFormat:@"%@:%lu %@", [loc file], (unsigned long)[loc line], description];
NSException *exception = [NSException exceptionWithName:@"OCMockTestFailure" reason:reason userInfo:nil];
[exception raise];
[[NSException exceptionWithName:@"OCMockTestFailure" reason:reason userInfo:nil] raise];

}
else
{
NSLog(@"%@", description);
[[NSException exceptionWithName:@"OCMockTestFailure" reason:description userInfo:nil] raise];
}

}
15 changes: 1 addition & 14 deletions Source/OCMock/OCMockObject.m
Expand Up @@ -139,20 +139,7 @@ - (id)reject

- (void)verify
{
if([expectations count] == 1)
{
[NSException raise:NSInternalInconsistencyException format:@"%@: expected method was not invoked: %@",
[self description], [[expectations objectAtIndex:0] description]];
}
if([expectations count] > 0)
{
[NSException raise:NSInternalInconsistencyException format:@"%@ : %@ expected methods were not invoked: %@",
[self description], @([expectations count]), [self _recorderDescriptions:YES]];
}
if([exceptions count] > 0)
{
[[exceptions objectAtIndex:0] raise];
}
[self verifyAtLocation:nil];
}

- (void)verifyAtLocation:(OCMLocation *)location
Expand Down
11 changes: 1 addition & 10 deletions Source/OCMock/OCObserverMockObject.m
Expand Up @@ -62,16 +62,7 @@ - (id)expect

- (void)verify
{
if([recorders count] == 1)
{
[NSException raise:NSInternalInconsistencyException format:@"%@: expected notification was not observed: %@",
[self description], [[recorders lastObject] description]];
}
if([recorders count] > 0)
{
[NSException raise:NSInternalInconsistencyException format:@"%@ : %@ expected notifications were not observed.",
[self description], @([recorders count])];
}
[self verifyAtLocation:nil];
}

- (void)verifyAtLocation:(OCMLocation *)location
Expand Down

0 comments on commit 1668016

Please sign in to comment.