45 lines
1.7 KiB
Objective-C
45 lines
1.7 KiB
Objective-C
// OCMockito by Jon Reid, https://qualitycoding.org/
|
|
// Copyright 2020 Quality Coding, Inc. See LICENSE.txt
|
|
|
|
@protocol HCMatcher;
|
|
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
/*!
|
|
* @abstract Ability to specify OCHamcrest matchers for non-object arguments.
|
|
*/
|
|
@protocol MKTNonObjectArgumentMatching
|
|
|
|
/*!
|
|
* @abstract Specifies OCHamcrest matcher for a specific argument of a method.
|
|
* @discussion For methods arguments that take objects, just pass the matcher directly as a method
|
|
* call. But for arguments that take non-objects, pass in a dummy value to satisfy the compiler, but
|
|
* call this to override it with the given matcher. Upon verification, the actual argument received
|
|
* will be converted to an object before being checked by the matcher.
|
|
*
|
|
* The argument index is 0-based, so the first argument of a method has index 0.
|
|
*
|
|
* Examples:
|
|
* <pre>[[given([mockFetchedResultsController performFetch:NULL]) withMatcher:anything()] willReturn:\@YES];</pre>
|
|
* This stubs <code>performFetch:</code> to return <code>YES</code> for any NSError ** argument.
|
|
*
|
|
* <pre>[[verify(mockArray) withMatcher:greaterThan(@5]) forArgument:0] removeObjectAtIndex:0];</pre>
|
|
* This verifies that <code>removeObjectAtIndex:</code> was called with an index greater than 5.
|
|
*/
|
|
- (id)withMatcher:(id <HCMatcher>)matcher forArgument:(NSUInteger)index;
|
|
|
|
/*!
|
|
* @abstract Specifies OCHamcrest matcher for the first argument of a method.
|
|
* @discussion Equivalent to <code>withMatcher:matcher forArgument:0</code>.
|
|
*
|
|
* Example:
|
|
* <pre>[[verify(mockArray) withMatcher:greaterThan(\@5)] removeObjectAtIndex:0];</pre>
|
|
* This verifies that <code>removeObjectAtIndex:</code> was called with an index greater than 5.
|
|
*/
|
|
- (id)withMatcher:(id <HCMatcher>)matcher;
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|