// OCHamcrest by Jon Reid, https://qualitycoding.org/ // Copyright 2019 hamcrest.org. See LICENSE.txt #import NS_ASSUME_NONNULL_BEGIN /*! * @abstract Matches if any item in a collection satisfies a nested matcher. */ @interface HCIsCollectionContaining : HCDiagnosingMatcher - (instancetype)initWithMatcher:(id )elementMatcher NS_DESIGNATED_INITIALIZER; - (instancetype)init NS_UNAVAILABLE; @end FOUNDATION_EXPORT id HC_hasItem(id itemMatcher); #ifndef HC_DISABLE_SHORT_SYNTAX /*! * @abstract hasItem(itemMatcher) - * Creates a matcher for collections that matches when at least one item in the examined collection * satisfies the specified matcher. * @param itemMatcher The matcher to apply to collection elements, or an expected value * for equalTo matching. * @discussion This matcher works on any collection that conforms to the NSFastEnumeration protocol, * performing a single pass. * * If itemMatcher is not a matcher, it is implicitly wrapped in an equalTo matcher * to check for equality. * * Example
*
assertThat(\@[\@1, \@2, \@3], hasItem(equalTo(\@2)))
* *
assertThat(\@[\@1, \@2, \@3], hasItem(\@2))
* * Name Clash
* In the event of a name clash, #define HC_DISABLE_SHORT_SYNTAX and use the synonym * HC_hasItem instead. */ #define hasItem HC_hasItem #endif FOUNDATION_EXPORT id HC_hasItemsIn(NSArray *itemMatchers); #ifndef HC_DISABLE_SHORT_SYNTAX /*! * @abstract Creates a matcher for collections that matches when all specified matchers are * satisfied by any item in the examined collection. * @param itemMatchers An array of matchers. Any element that is not a matcher is implicitly wrapped * in an equalTo matcher to check for equality. * @discussion This matcher works on any collection that conforms to the NSFastEnumeration protocol, * performing one pass for each matcher. * * Example
*
assertThat(\@[\@"foo", \@"bar", \@"baz"], hasItems(\@[endsWith(\@"z"), endsWith(\@"o")]))
* * Name Clash
* In the event of a name clash, #define HC_DISABLE_SHORT_SYNTAX and use the synonym * HC_hasItemsIn instead. */ static inline id hasItemsIn(NSArray *itemMatchers) { return HC_hasItemsIn(itemMatchers); } #endif FOUNDATION_EXPORT id HC_hasItems(id itemMatchers, ...) NS_REQUIRES_NIL_TERMINATION; #ifndef HC_DISABLE_SHORT_SYNTAX /*! * @abstract Creates a matcher for collections that matches when all specified matchers are * satisfied by any item in the examined collection. * @param itemMatchers... A comma-separated list of matchers ending with nil. * Any argument that is not a matcher is implicitly wrapped in an equalTo matcher to check * for equality. * @discussion This matcher works on any collection that conforms to the NSFastEnumeration protocol, * performing one pass for each matcher. * * Example
*
assertThat(\@[\@"foo", \@"bar", \@"baz"], hasItems(endsWith(\@"z"), endsWith(\@"o"), nil))
* * Name Clash
* In the event of a name clash, #define HC_DISABLE_SHORT_SYNTAX and use the synonym * HC_hasItems instead. */ #define hasItems(itemMatchers...) HC_hasItems(itemMatchers) #endif NS_ASSUME_NONNULL_END