In my example I try to wrap the struct in an NSValue and pass that as the return value for the mock. Then when the object I'm testing calls into the mock the return value gets munged. So either I'm incorrectly wrapping the value or I'm incorrectly creating it.
Here's my define for wrapping the struct:
Code:
#define OCMOCK_STRUCT(atype, variable) [NSValue value:&variable withObjCType:@encode(atype)]
Here's the code that sets the expectation:
Code:
CLLocationCoordinate2D ulLL = (CLLocationCoordinate2D){1.0f,1.0f};
CLLocationCoordinate2D lrLL = (CLLocationCoordinate2D){2.0f,2.0f};
[[[(id)aMap expect] andReturn:OCMOCK_STRUCT(CLLocationCoordinate2D, ulLL)] pixelToLatLong:(CGPoint){0,0}];
[[[(id)aMap expect] andReturn:OCMOCK_STRUCT(CLLocationCoordinate2D, lrLL)] pixelToLatLong:(CGPoint){320,460}];//lower right point
When I call into my mock I get garbage in the mock return values. Help?