Pregunta

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.

¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top