Skip to content

Commit

Permalink
Fix for the Guard Malloc issue reported in #362.
Browse files Browse the repository at this point in the history
  • Loading branch information
erikdoe committed Nov 4, 2018
1 parent bc40df6 commit 662bbeb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Source/OCMockTests/OCMockObjectClassMethodMockingTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -261,28 +261,32 @@ - (void)testStopMockingDisposesMetaClass
{
id mock = [[OCClassMockObject alloc] initWithClass:[TestClassWithClassMethods class]];

const char *createdSubclassName = object_getClassName([TestClassWithClassMethods class]);
char *createdSubclassName = strdup(object_getClassName([TestClassWithClassMethods class]));
XCTAssertNotNil(objc_lookUpClass(createdSubclassName));

[mock stopMocking];
XCTAssertNil(objc_lookUpClass(createdSubclassName));
free(createdSubclassName);
}

- (void)testSecondClassMockDisposesFirstMetaClass
{
id mock1 = [[OCClassMockObject alloc] initWithClass:[TestClassWithClassMethods class]];
const char *createdSubclassName1 = object_getClassName([TestClassWithClassMethods class]);
char *createdSubclassName1 = strdup(object_getClassName([TestClassWithClassMethods class]));
XCTAssertNotNil(objc_lookUpClass(createdSubclassName1));

id mock2 = [[OCClassMockObject alloc] initWithClass:[TestClassWithClassMethods class]];
const char *createdSubclassName2 = object_getClassName([TestClassWithClassMethods class]);
char *createdSubclassName2 = strdup(object_getClassName([TestClassWithClassMethods class]));
XCTAssertNotNil(objc_lookUpClass(createdSubclassName2));

[mock1 stopMocking];
[mock2 stopMocking];

XCTAssertNil(objc_lookUpClass(createdSubclassName1));
XCTAssertNil(objc_lookUpClass(createdSubclassName2));

free(createdSubclassName1);
free(createdSubclassName2);
}

- (void)testForwardToRealObject
Expand Down

0 comments on commit 662bbeb

Please sign in to comment.