OCMockito anything() for primitive types

故事扮演 提交于 2020-01-04 02:22:07

问题


For method signature

- (void)insertValue:(NSUInteger)value;

I'm trying to see if insertValue for any value never gets called.

[verifyCount(test, never()) insertValue:0];

Since compiler complains anything() primitive types, how do I test this?


回答1:


It's just like https://stackoverflow.com/a/20524472/246895

[[verifyCount(test, never()) withMatcher:anything()]
    insertValue:0];

OCMockito does all argument checking using OCHamcrest matchers. Normally, OCMockito turns a primitive argument into an NSNumber, then wraps it in an implicit OCHamcrest equalTo matcher. But -withMatcher: and -withMatcher:forArgument replace the implicit matcher.



来源:https://stackoverflow.com/questions/20562059/ocmockito-anything-for-primitive-types

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!