문제

My MessageSerializer class has a method whose signature looks like this:

- (Message *)deserialize:(const void *)buffer length:(NSUInteger)length;

Can I use OCMockito to stub it? Where serializer is my mock serializer, the compiler approves of all these following forms in my test method:

[given([serializer deserialize:[data bytes] length:[data length]]) willReturn:message];
[given([serializer deserialize:(__bridge const void *)anything() length:[data length]]) willReturn:message];
[given([serializer deserialize: CFBridgingRetain(anything()) length:[data length]]) willReturn:message];

... but none of them cause the mock to return "message" to the class under test when deserialize:length: is called.

도움이 되었습니까?

해결책

OCMockito doesn't support const void * parameters at this time. I'd recommend making a hand-rolled stub.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top