47 lines
1.4 KiB
Objective-C
47 lines
1.4 KiB
Objective-C
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
|
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
|
|
|
#import <OCHamcrest/HCBaseMatcher.h>
|
|
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
/*!
|
|
* @abstract Matches if any entry in a dictionary has a value satisfying the nested matcher.
|
|
*/
|
|
@interface HCIsDictionaryContainingValue : HCBaseMatcher
|
|
|
|
- (instancetype)initWithValueMatcher:(id <HCMatcher>)valueMatcher NS_DESIGNATED_INITIALIZER;
|
|
- (instancetype)init NS_UNAVAILABLE;
|
|
|
|
@end
|
|
|
|
|
|
FOUNDATION_EXPORT id HC_hasValue(id valueMatcher);
|
|
|
|
#ifndef HC_DISABLE_SHORT_SYNTAX
|
|
/*!
|
|
* @abstract Creates a matcher for NSDictionaries that matches when the examined dictionary contains
|
|
* at least value that satisfies the specified matcher.
|
|
* @param valueMatcher The matcher to satisfy for the value, or an expected value for <em>equalTo</em> matching.
|
|
* @discussion This matcher works on any collection that has an <code>-allValues</code> method.
|
|
*
|
|
* Any argument that is not a matcher is implicitly wrapped in an <em>equalTo</em> matcher to check
|
|
* for equality.
|
|
*
|
|
* <b>Examples</b><br />
|
|
* <pre>assertThat(myDictionary, hasValue(equalTo(\@"bar")))</pre>
|
|
* <pre>assertThat(myDictionary, hasValue(\@"bar"))</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_hasValue instead.
|
|
*/
|
|
static inline id hasValue(id valueMatcher)
|
|
{
|
|
return HC_hasValue(valueMatcher);
|
|
}
|
|
#endif
|
|
|
|
NS_ASSUME_NONNULL_END
|