I am trying to write a test for a method in which the result depends on the return value of NSDate timeIntervalSinceNow. I would like to specify the return value in my tests so that I can test certain scenarios.
It is very hard for me to get this OCMock object returning what I need. Here is my code:
id mock = [OCMockObject mockForClass:[NSDate class]]; NSTimeInterval t = 20.0; [[[mock stub] andReturnValue:OCMOCK_VALUE(t)] timeIntervalSinceNow]; STAssertEquals([mock timeIntervalSinceNow], 20.0, @"Should be eql.");
This generates an "error: expected specifier-classifier-list before the error" typeof ".
Any thoughts? I'm new to ObjC, so any other tips related to it are really appreciated.
Thanks.
source share