Skip to content

Commit

Permalink
Merge pull request #180 from sdefresne/fixes/OCMEqualTypesAllowingOpa…
Browse files Browse the repository at this point in the history
…queStructsInternal

Fix OCMEqualTypesAllowingOpaqueStructsInternal when type2 is opaque
  • Loading branch information
erikdoe committed Apr 2, 2015
2 parents 92b970a + 065270d commit fc3f81f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Source/OCMock/OCMFunctions.m
Expand Up @@ -103,7 +103,7 @@ static BOOL OCMEqualTypesAllowingOpaqueStructsInternal(const char *type1, const
BOOL type1Opaque = (type1Equals == NULL || (type1End < type1Equals) || type1Equals[1] == endChar);
BOOL type2Opaque = (type2Equals == NULL || (type2End < type2Equals) || type2Equals[1] == endChar);
const char *type1NameEnd = (type1Equals == NULL || (type1End < type1Equals)) ? type1End : type1Equals;
const char *type2NameEnd = (type1Equals == NULL || (type2End < type2Equals)) ? type2End : type2Equals;
const char *type2NameEnd = (type2Equals == NULL || (type2End < type2Equals)) ? type2End : type2Equals;
intptr_t type1NameLen = type1NameEnd - type1;
intptr_t type2NameLen = type2NameEnd - type2;

Expand Down
8 changes: 8 additions & 0 deletions Source/OCMockTests/OCMockObjectTests.m
Expand Up @@ -492,8 +492,16 @@ - (void)testOpaqueStructComparison
"::DefaultDeleter<GURL> >={scoped_ptr_impl<GURL, base::DefaultDeleter<GURL"
"> >={Data=^{GURL}}}}}";

const char *type3 =
"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]);
}

- (void)testReturnsStubbedNilReturnValue
Expand Down

0 comments on commit fc3f81f

Please sign in to comment.