-
Notifications
You must be signed in to change notification settings - Fork 607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle using nil as argument for andReturn in ObjC++ code. #404
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,15 +18,24 @@ | |
#import "OCMBoxedReturnValueProvider.h" | ||
|
||
@interface OCMBoxedReturnValueProvider(Private) | ||
- (BOOL)isMethodReturnType:(const char *)returnType compatibleWithValueType:(const char *)valueType; | ||
- (BOOL)isMethodReturnType:(const char *)returnType compatibleWithValueType:(const char *)valueType value:(const char*)value valueSize:(size_t)valueSize; | ||
@end | ||
|
||
@interface OCMBoxedReturnValueProviderTests : XCTestCase | ||
|
||
{ | ||
char value; | ||
size_t valueSize; | ||
} | ||
@end | ||
|
||
@implementation OCMBoxedReturnValueProviderTests | ||
|
||
- (void)setUp { | ||
[super setUp]; | ||
value = 'A'; | ||
valueSize = 1; | ||
} | ||
|
||
- (void)testCorrectEqualityForCppProperty | ||
{ | ||
// see https://github.com/erikdoe/ocmock/issues/96 | ||
|
@@ -53,12 +62,12 @@ - (void)testCorrectEqualityForCppProperty | |
"r^{GURL}"; | ||
|
||
OCMBoxedReturnValueProvider *boxed = [OCMBoxedReturnValueProvider new]; | ||
XCTAssertTrue([boxed isMethodReturnType:type1 compatibleWithValueType:type2]); | ||
XCTAssertTrue([boxed isMethodReturnType:type1 compatibleWithValueType:type3]); | ||
XCTAssertTrue([boxed isMethodReturnType:type2 compatibleWithValueType:type1]); | ||
XCTAssertTrue([boxed isMethodReturnType:type2 compatibleWithValueType:type3]); | ||
XCTAssertTrue([boxed isMethodReturnType:type3 compatibleWithValueType:type1]); | ||
XCTAssertTrue([boxed isMethodReturnType:type3 compatibleWithValueType:type2]); | ||
XCTAssertTrue([boxed isMethodReturnType:type1 compatibleWithValueType:type2 value:&value valueSize:valueSize]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed these tests to pass |
||
XCTAssertTrue([boxed isMethodReturnType:type1 compatibleWithValueType:type3 value:&value valueSize:valueSize]); | ||
XCTAssertTrue([boxed isMethodReturnType:type2 compatibleWithValueType:type1 value:&value valueSize:valueSize]); | ||
XCTAssertTrue([boxed isMethodReturnType:type2 compatibleWithValueType:type3 value:&value valueSize:valueSize]); | ||
XCTAssertTrue([boxed isMethodReturnType:type3 compatibleWithValueType:type1 value:&value valueSize:valueSize]); | ||
XCTAssertTrue([boxed isMethodReturnType:type3 compatibleWithValueType:type2 value:&value valueSize:valueSize]); | ||
} | ||
|
||
|
||
|
@@ -78,7 +87,7 @@ - (void)testCorrectEqualityForCppReturnTypesWithVtables | |
"ar> >={__rep=(?={__long=QQ*}{__short=(?=Cc)[23c]}{__raw=[3Q]})}}}}"; | ||
|
||
OCMBoxedReturnValueProvider *boxed = [OCMBoxedReturnValueProvider new]; | ||
XCTAssertTrue([boxed isMethodReturnType:type1 compatibleWithValueType:type2]); | ||
XCTAssertTrue([boxed isMethodReturnType:type1 compatibleWithValueType:type2 value:&value valueSize:valueSize]); | ||
} | ||
|
||
|
||
|
@@ -89,7 +98,7 @@ - (void)testCorrectEqualityForStructureWithUnknownName | |
const char *type2 = "{CLLocationCoordinate2D=dd}"; | ||
|
||
OCMBoxedReturnValueProvider *boxed = [OCMBoxedReturnValueProvider new]; | ||
XCTAssertTrue([boxed isMethodReturnType:type1 compatibleWithValueType:type2]); | ||
XCTAssertTrue([boxed isMethodReturnType:type1 compatibleWithValueType:type2 value:&value valueSize:valueSize]); | ||
|
||
} | ||
|
||
|
@@ -115,7 +124,7 @@ - (void)testCorrectEqualityForStructureWithoutName | |
"pressed_pair<GURL *, std::__1::default_delete<GURL> >=^{GURL}}}}"; | ||
|
||
OCMBoxedReturnValueProvider *boxed = [OCMBoxedReturnValueProvider new]; | ||
XCTAssertTrue([boxed isMethodReturnType:type1 compatibleWithValueType:type2]); | ||
XCTAssertTrue([boxed isMethodReturnType:type1 compatibleWithValueType:type2 value:&value valueSize:valueSize]); | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2020 Erik Doernenburg and contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
* not use these files except in compliance with the License. You may obtain | ||
* a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
#import <XCTest/XCTest.h> | ||
#import <OCMock/OCMock.h> | ||
|
||
#if !defined(__cplusplus) | ||
#error This file must be compiled with C++ | ||
#endif | ||
|
||
#if !__has_feature(cxx_nullptr) | ||
#error This file must be compiled with a version of C++ that supports nullptr | ||
#endif | ||
|
||
@interface OCMCPlusPlus11Tests : XCTestCase | ||
@end | ||
|
||
|
||
@implementation OCMCPlusPlus11Tests | ||
|
||
- (void)testSetsUpStubReturningNilForIdReturnType | ||
{ | ||
id mock = OCMPartialMock([NSArray arrayWithObject:@"Foo"]); | ||
|
||
OCMExpect([mock lastObject]).andReturn(nil); | ||
XCTAssertNil([mock lastObject], @"Should have returned stubbed value"); | ||
|
||
OCMExpect([mock lastObject]).andReturn(Nil); | ||
XCTAssertNil([mock lastObject], @"Should have returned stubbed value"); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2020 Erik Doernenburg and contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
* not use these files except in compliance with the License. You may obtain | ||
* a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
#import <XCTest/XCTest.h> | ||
#import <OCMock/OCMock.h> | ||
|
||
#if !defined(__cplusplus) | ||
#error This file must be compiled with C++ | ||
#endif | ||
|
||
#if __has_feature(cxx_nullptr) | ||
#error This file must be compiled with a version of C++ (98) that doesn't support nullptr | ||
#endif | ||
|
||
@interface OCMCPlusPlus98Tests : XCTestCase | ||
@end | ||
|
||
|
||
@implementation OCMCPlusPlus98Tests | ||
|
||
- (void)testSetsUpStubReturningNilForIdReturnType | ||
{ | ||
id mock = OCMPartialMock([NSArray arrayWithObject:@"Foo"]); | ||
|
||
OCMExpect([mock lastObject]).andReturn(nil); | ||
XCTAssertNil([mock lastObject], @"Should have returned stubbed value"); | ||
|
||
OCMExpect([mock lastObject]).andReturn(Nil); | ||
XCTAssertNil([mock lastObject], @"Should have returned stubbed value"); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change breaks the build for me. When I change the file type back to Objective-C it works. The error is:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh.. that is probably an accidental mod when I changed the file to objc++ before I broke the tests out into their own files. No need to pull that across. Apologies.