-
Notifications
You must be signed in to change notification settings - Fork 609
Open
Labels
Description
- (void)testMockView {
UIViewController *controller = [[UIViewController alloc] init];
UIViewController *controller2 = [[UIViewController alloc] init];
id mockController2 = OCMPartialMock(controller2);
[controller addChildViewController:mockController2];
}
will crash with libGuardMalloc turned on. I'm guessing that the problem is that addChildViewController: is directly instance variables with its knowledge of UIViewController using offsets relative to self which in this case is a mock and not the controller itself. This ends up being a weird looking crash that is a pain to diagnose, and could end up "working" but corrupting the heap in weird and wonderful ways.
The problem can be avoided by not passing in the mock object. Should we be issuing a warning where partial mocks are being used instead of the object that they are mocking (I'm thinking -[OCMPartialMockObject handleUnRecordedInvocation:])
Reactions are currently unavailable