Skip to content

Commit

Permalink
Fixing an issue with stubs returning BOOL on 64bit iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
stigi committed Dec 31, 2013
1 parent 9fe6aee commit 45eb99c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Source/OCMockito/NSInvocation+TKAdditions.m
Expand Up @@ -185,6 +185,11 @@ void MKTSetReturnValueForInvocation(NSInvocation *invocation, id returnValue)
long long value = [returnValue longLongValue];
[invocation setReturnValue:&value];
}
else if(strcmp(returnType, @encode(BOOL)) == 0)
{
BOOL value = [returnValue boolValue];
[invocation setReturnValue:&value];
}
else if (strcmp(returnType, @encode(unsigned char)) == 0)
{
unsigned char value = [returnValue unsignedCharValue];
Expand Down
7 changes: 7 additions & 0 deletions Source/Tests/StubProtocolTest.m
Expand Up @@ -25,6 +25,7 @@ @protocol ReturningProtocol <NSObject>
- (id)methodReturningObject;
- (id)methodReturningObjectWithArg:(id)arg;
- (id)methodReturningObjectWithIntArg:(int)arg;
- (BOOL)methodReturningBOOL;
- (short)methodReturningShort;

@end
Expand Down Expand Up @@ -89,6 +90,12 @@ - (void)testShouldSupportShortcutForSpecifyingMatcherForFirstArgument
assertThat([mockProtocol methodReturningObjectWithIntArg:2], is(@"FOO"));
}

- (void)testStubbedMethod_ShouldReturnGivenBool
{
[given([mockProtocol methodReturningBOOL]) willReturnBool:YES];
assertThatBool([mockProtocol methodReturningBOOL], equalToBool(YES));
}

- (void)testStubbedMethod_ShouldReturnGivenShort
{
[given([mockProtocol methodReturningShort]) willReturnShort:42];
Expand Down

0 comments on commit 45eb99c

Please sign in to comment.