简体   繁体   中英

Can OCMockito stub a method that takes a `const void *` parameter?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM