65 lines
2.1 KiB
Objective-C
65 lines
2.1 KiB
Objective-C
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
|
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
|
|
|
#import <OCHamcrest/HCDiagnosingMatcher.h>
|
|
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
/*!
|
|
* @abstract Calculates the logical conjunction of multiple matchers.
|
|
* @discussion Evaluation is shortcut, so subsequent matchers are not called if an earlier matcher
|
|
* returns <code>NO</code>.
|
|
*/
|
|
@interface HCAllOf : HCDiagnosingMatcher
|
|
|
|
- (instancetype)initWithMatchers:(NSArray<id <HCMatcher>> *)matchers NS_DESIGNATED_INITIALIZER;
|
|
- (instancetype)init NS_UNAVAILABLE;
|
|
|
|
@end
|
|
|
|
|
|
FOUNDATION_EXPORT id HC_allOfIn(NSArray<id <HCMatcher>> *matchers);
|
|
|
|
#ifndef HC_DISABLE_SHORT_SYNTAX
|
|
/*!
|
|
* @abstract Creates a matcher that matches when the examined object matches <b>all</b> of the
|
|
* specified matchers.
|
|
* @param matchers An array of matchers. Any element that is not a matcher is implicitly wrapped in
|
|
* an <em>equalTo</em> matcher to check for equality.
|
|
* @discussion
|
|
* <b>Example</b><br />
|
|
* <pre>assertThat(\@"myValue", allOfIn(\@[startsWith(\@"my"), containsSubstring(\@"Val")]))</pre>
|
|
*
|
|
* <b>Name Clash</b><br />
|
|
* In the event of a name clash, <code>#define HC_DISABLE_SHORT_SYNTAX</code> and use the synonym
|
|
* HC_allOfIn instead.
|
|
*/
|
|
static inline id allOfIn(NSArray *matchers)
|
|
{
|
|
return HC_allOfIn(matchers);
|
|
}
|
|
#endif
|
|
|
|
|
|
FOUNDATION_EXPORT id HC_allOf(id matchers, ...) NS_REQUIRES_NIL_TERMINATION;
|
|
|
|
#ifndef HC_DISABLE_SHORT_SYNTAX
|
|
/*!
|
|
* @abstract Creates a matcher that matches when the examined object matches <b>all</b> of the
|
|
* specified matchers.
|
|
* @param matchers... A comma-separated list of matchers ending with <code>nil</code>. Any argument
|
|
* that is not a matcher is implicitly wrapped in an <em>equalTo</em> matcher to check for equality.
|
|
* @discussion
|
|
* <b>Example</b><br />
|
|
* <pre>assertThat(\@"myValue", allOf(startsWith(\@"my"), containsSubstring(\@"Val"), nil))</pre>
|
|
*
|
|
* <b>Name Clash</b><br />
|
|
* In the event of a name clash, <code>#define HC_DISABLE_SHORT_SYNTAX</code> and use the synonym
|
|
* HC_allOf instead.
|
|
*/
|
|
#define allOf(matchers...) HC_allOf(matchers)
|
|
#endif
|
|
|
|
NS_ASSUME_NONNULL_END
|