Adds cocoapods for libraries.
Adds OCMockito and OCHamcrest libs.
This commit is contained in:
45
iOS/Pods/OCHamcrest/Source/Library/Collection/HCEvery.h
generated
Normal file
45
iOS/Pods/OCHamcrest/Source/Library/Collection/HCEvery.h
generated
Normal file
@@ -0,0 +1,45 @@
|
||||
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
||||
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
||||
|
||||
#import <OCHamcrest/HCDiagnosingMatcher.h>
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
* @abstract Matches if every item in a collection satisfies a nested matcher.
|
||||
*/
|
||||
@interface HCEvery : HCDiagnosingMatcher
|
||||
|
||||
@property (nonatomic, strong, readonly) id <HCMatcher> matcher;
|
||||
|
||||
- (instancetype)initWithMatcher:(id <HCMatcher>)matcher NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
FOUNDATION_EXPORT id HC_everyItem(id <HCMatcher> itemMatcher);
|
||||
|
||||
#ifndef HC_DISABLE_SHORT_SYNTAX
|
||||
/*!
|
||||
* @abstract Creates a matcher for collections that matches when the examined collection's items are
|
||||
* all matched by the specified matcher.
|
||||
* @param itemMatcher The matcher to apply to every item provided by the examined collection.
|
||||
* @discussion This matcher works on any collection that conforms to the NSFastEnumeration protocol,
|
||||
* performing a single pass.
|
||||
*
|
||||
* <b>Example</b><br />
|
||||
* <pre>assertThat(\@[\@"bar", \@"baz"], everyItem(startsWith(\@"ba")))</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_everyItem instead.
|
||||
*/
|
||||
static inline id everyItem(id <HCMatcher> itemMatcher)
|
||||
{
|
||||
return HC_everyItem(itemMatcher);
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
74
iOS/Pods/OCHamcrest/Source/Library/Collection/HCEvery.m
generated
Normal file
74
iOS/Pods/OCHamcrest/Source/Library/Collection/HCEvery.m
generated
Normal file
@@ -0,0 +1,74 @@
|
||||
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
||||
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
||||
|
||||
#import "HCEvery.h"
|
||||
|
||||
#import "HCRequireNonNilObject.h"
|
||||
|
||||
|
||||
@implementation HCEvery
|
||||
|
||||
- (instancetype)initWithMatcher:(id <HCMatcher>)matcher
|
||||
{
|
||||
HCRequireNonNilObject(matcher);
|
||||
|
||||
self = [super init];
|
||||
if (self)
|
||||
_matcher = matcher;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)matches:(id)collection describingMismatchTo:(id <HCDescription>)mismatchDescription
|
||||
{
|
||||
if (![collection conformsToProtocol:@protocol(NSFastEnumeration)])
|
||||
{
|
||||
[[mismatchDescription appendText:@"was non-collection "] appendDescriptionOf:collection];
|
||||
return NO;
|
||||
}
|
||||
|
||||
if ([collection count] == 0)
|
||||
{
|
||||
[mismatchDescription appendText:@"was empty"];
|
||||
return NO;
|
||||
}
|
||||
|
||||
for (id item in collection)
|
||||
{
|
||||
if (![self.matcher matches:item])
|
||||
{
|
||||
[self describeAllMismatchesInCollection:collection to:mismatchDescription];
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)describeAllMismatchesInCollection:(id)collection to:(id <HCDescription>)mismatchDescription
|
||||
{
|
||||
[mismatchDescription appendText:@"mismatches were: ["];
|
||||
BOOL isPastFirst = NO;
|
||||
for (id item in collection)
|
||||
{
|
||||
if (![self.matcher matches:item])
|
||||
{
|
||||
if (isPastFirst)
|
||||
[mismatchDescription appendText:@", "];
|
||||
[self.matcher describeMismatchOf:item to:mismatchDescription];
|
||||
isPastFirst = YES;
|
||||
}
|
||||
}
|
||||
[mismatchDescription appendText:@"]"];
|
||||
}
|
||||
|
||||
- (void)describeTo:(id <HCDescription>)description
|
||||
{
|
||||
[[description appendText:@"every item is "] appendDescriptionOf:self.matcher];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
id HC_everyItem(id <HCMatcher> itemMatcher)
|
||||
{
|
||||
return [[HCEvery alloc] initWithMatcher:itemMatcher];
|
||||
}
|
||||
63
iOS/Pods/OCHamcrest/Source/Library/Collection/HCHasCount.h
generated
Normal file
63
iOS/Pods/OCHamcrest/Source/Library/Collection/HCHasCount.h
generated
Normal file
@@ -0,0 +1,63 @@
|
||||
// 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 collection size satisfies a nested matcher.
|
||||
*/
|
||||
@interface HCHasCount : HCBaseMatcher
|
||||
|
||||
- (instancetype)initWithMatcher:(id <HCMatcher>)countMatcher NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
FOUNDATION_EXPORT id HC_hasCount(id <HCMatcher> countMatcher);
|
||||
|
||||
#ifndef HC_DISABLE_SHORT_SYNTAX
|
||||
/*!
|
||||
* @abstract Creates a matcher that matches when the examined object's <code>-count</code> method
|
||||
* returns a value that satisfies the specified matcher.
|
||||
* @param countMatcher A matcher for the count of an examined collection.
|
||||
* @discussion
|
||||
* <b>Example</b><br />
|
||||
* <pre>assertThat(\@[\@"foo", \@"bar"], hasCount(equalTo(@2)))</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_hasCount instead.
|
||||
*/
|
||||
static inline id hasCount(id <HCMatcher> countMatcher)
|
||||
{
|
||||
return HC_hasCount(countMatcher);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
FOUNDATION_EXPORT id HC_hasCountOf(NSUInteger count);
|
||||
|
||||
#ifndef HC_DISABLE_SHORT_SYNTAX
|
||||
/*!
|
||||
* @abstract Creates a matcher that matches when the examined object's <code>-count</code> method
|
||||
* returns a value that equals the specified value.
|
||||
* @param value Value to compare against as the expected count.
|
||||
* @discussion
|
||||
* <b>Example</b><br />
|
||||
* <pre>assertThat(\@[\@"foo", \@"bar"], hasCountOf(2))</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_hasCountOf instead.
|
||||
*/
|
||||
static inline id hasCountOf(NSUInteger value)
|
||||
{
|
||||
return HC_hasCountOf(value);
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
65
iOS/Pods/OCHamcrest/Source/Library/Collection/HCHasCount.m
generated
Normal file
65
iOS/Pods/OCHamcrest/Source/Library/Collection/HCHasCount.m
generated
Normal file
@@ -0,0 +1,65 @@
|
||||
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
||||
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
||||
|
||||
#import "HCHasCount.h"
|
||||
|
||||
#import "HCIsEqual.h"
|
||||
|
||||
|
||||
@interface HCHasCount ()
|
||||
@property (nonatomic, strong, readonly) id <HCMatcher> countMatcher;
|
||||
@end
|
||||
|
||||
@implementation HCHasCount
|
||||
|
||||
- (instancetype)initWithMatcher:(id <HCMatcher>)countMatcher
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
_countMatcher = countMatcher;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)matches:(nullable id)item
|
||||
{
|
||||
if (![self itemHasCount:item])
|
||||
return NO;
|
||||
|
||||
NSNumber *count = @([item count]);
|
||||
return [self.countMatcher matches:count];
|
||||
}
|
||||
|
||||
- (BOOL)itemHasCount:(id)item
|
||||
{
|
||||
return [item respondsToSelector:@selector(count)];
|
||||
}
|
||||
|
||||
- (void)describeMismatchOf:(nullable id)item to:(nullable id <HCDescription>)mismatchDescription
|
||||
{
|
||||
[mismatchDescription appendText:@"was "];
|
||||
if ([self itemHasCount:item])
|
||||
{
|
||||
[[[mismatchDescription appendText:@"count of "]
|
||||
appendDescriptionOf:@([item count])]
|
||||
appendText:@" with "];
|
||||
}
|
||||
[mismatchDescription appendDescriptionOf:item];
|
||||
}
|
||||
|
||||
- (void)describeTo:(id <HCDescription>)description
|
||||
{
|
||||
[[description appendText:@"a collection with count of "] appendDescriptionOf:self.countMatcher];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
id HC_hasCount(id <HCMatcher> countMatcher)
|
||||
{
|
||||
return [[HCHasCount alloc] initWithMatcher:countMatcher];
|
||||
}
|
||||
|
||||
id HC_hasCountOf(NSUInteger value)
|
||||
{
|
||||
return HC_hasCount(HC_equalTo(@(value)));
|
||||
}
|
||||
95
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsCollectionContaining.h
generated
Normal file
95
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsCollectionContaining.h
generated
Normal file
@@ -0,0 +1,95 @@
|
||||
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
||||
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
||||
|
||||
#import <OCHamcrest/HCDiagnosingMatcher.h>
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
* @abstract Matches if any item in a collection satisfies a nested matcher.
|
||||
*/
|
||||
@interface HCIsCollectionContaining : HCDiagnosingMatcher
|
||||
|
||||
- (instancetype)initWithMatcher:(id <HCMatcher>)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 <em>equalTo</em> matching.
|
||||
* @discussion This matcher works on any collection that conforms to the NSFastEnumeration protocol,
|
||||
* performing a single pass.
|
||||
*
|
||||
* If <em>itemMatcher</em> is not a matcher, it is implicitly wrapped in an <em>equalTo</em> matcher
|
||||
* to check for equality.
|
||||
*
|
||||
* <b>Example</b><br />
|
||||
* <pre>assertThat(\@[\@1, \@2, \@3], hasItem(equalTo(\@2)))</pre>
|
||||
*
|
||||
* <pre>assertThat(\@[\@1, \@2, \@3], hasItem(\@2))</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_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 <em>equalTo</em> matcher to check for equality.
|
||||
* @discussion This matcher works on any collection that conforms to the NSFastEnumeration protocol,
|
||||
* performing one pass for each matcher.
|
||||
*
|
||||
* <b>Example</b><br />
|
||||
* <pre>assertThat(\@[\@"foo", \@"bar", \@"baz"], hasItems(\@[endsWith(\@"z"), endsWith(\@"o")]))</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_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 <code>nil</code>.
|
||||
* Any argument that is not a matcher is implicitly wrapped in an <em>equalTo</em> matcher to check
|
||||
* for equality.
|
||||
* @discussion This matcher works on any collection that conforms to the NSFastEnumeration protocol,
|
||||
* performing one pass for each matcher.
|
||||
*
|
||||
* <b>Example</b><br />
|
||||
* <pre>assertThat(\@[\@"foo", \@"bar", \@"baz"], hasItems(endsWith(\@"z"), endsWith(\@"o"), 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_hasItems instead.
|
||||
*/
|
||||
#define hasItems(itemMatchers...) HC_hasItems(itemMatchers)
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
88
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsCollectionContaining.m
generated
Normal file
88
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsCollectionContaining.m
generated
Normal file
@@ -0,0 +1,88 @@
|
||||
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
||||
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
||||
|
||||
#import "HCIsCollectionContaining.h"
|
||||
|
||||
#import "HCAllOf.h"
|
||||
#import "HCCollect.h"
|
||||
#import "HCRequireNonNilObject.h"
|
||||
#import "HCWrapInMatcher.h"
|
||||
|
||||
|
||||
@interface HCIsCollectionContaining ()
|
||||
@property (nonatomic, strong, readonly) id <HCMatcher> elementMatcher;
|
||||
@end
|
||||
|
||||
@implementation HCIsCollectionContaining
|
||||
|
||||
- (instancetype)initWithMatcher:(id <HCMatcher>)elementMatcher
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
_elementMatcher = elementMatcher;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)matches:(id)collection describingMismatchTo:(id <HCDescription>)mismatchDescription
|
||||
{
|
||||
if (![collection conformsToProtocol:@protocol(NSFastEnumeration)])
|
||||
{
|
||||
[[mismatchDescription appendText:@"was non-collection "] appendDescriptionOf:collection];
|
||||
return NO;
|
||||
}
|
||||
|
||||
if ([collection count] == 0)
|
||||
{
|
||||
[mismatchDescription appendText:@"was empty"];
|
||||
return NO;
|
||||
}
|
||||
|
||||
for (id item in collection)
|
||||
if ([self.elementMatcher matches:item])
|
||||
return YES;
|
||||
|
||||
[mismatchDescription appendText:@"mismatches were: ["];
|
||||
BOOL isPastFirst = NO;
|
||||
for (id item in collection)
|
||||
{
|
||||
if (isPastFirst)
|
||||
[mismatchDescription appendText:@", "];
|
||||
[self.elementMatcher describeMismatchOf:item to:mismatchDescription];
|
||||
isPastFirst = YES;
|
||||
}
|
||||
[mismatchDescription appendText:@"]"];
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)describeTo:(id <HCDescription>)description
|
||||
{
|
||||
[[description appendText:@"a collection containing "]
|
||||
appendDescriptionOf:self.elementMatcher];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
id HC_hasItem(id itemMatcher)
|
||||
{
|
||||
HCRequireNonNilObject(itemMatcher);
|
||||
return [[HCIsCollectionContaining alloc] initWithMatcher:HCWrapInMatcher(itemMatcher)];
|
||||
}
|
||||
|
||||
id HC_hasItemsIn(NSArray *itemMatchers)
|
||||
{
|
||||
NSMutableArray *matchers = [[NSMutableArray alloc] init];
|
||||
for (id itemMatcher in itemMatchers)
|
||||
[matchers addObject:HC_hasItem(itemMatcher)];
|
||||
return HC_allOfIn(matchers);
|
||||
}
|
||||
|
||||
id HC_hasItems(id itemMatchers, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, itemMatchers);
|
||||
NSArray *array = HCCollectItems(itemMatchers, args);
|
||||
va_end(args);
|
||||
|
||||
return HC_hasItemsIn(array);
|
||||
}
|
||||
79
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsCollectionContainingInAnyOrder.h
generated
Normal file
79
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsCollectionContainingInAnyOrder.h
generated
Normal file
@@ -0,0 +1,79 @@
|
||||
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
||||
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
||||
|
||||
#import <OCHamcrest/HCDiagnosingMatcher.h>
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
* @abstract Matches if every item in a collection, in any order, satisfy a list of nested matchers.
|
||||
*/
|
||||
@interface HCIsCollectionContainingInAnyOrder : HCDiagnosingMatcher
|
||||
|
||||
- (instancetype)initWithMatchers:(NSArray<id <HCMatcher>> *)itemMatchers NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
FOUNDATION_EXPORT id HC_containsInAnyOrderIn(NSArray *itemMatchers);
|
||||
|
||||
#ifndef HC_DISABLE_SHORT_SYNTAX
|
||||
/*!
|
||||
* @abstract Creates an order-agnostic matcher for collections that matches when each item in the
|
||||
* examined collection satisfies one matcher anywhere in the specified list of matchers.
|
||||
* @param itemMatchers 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 This matcher works on any collection that conforms to the NSFastEnumeration protocol,
|
||||
* performing a single pass. For a positive match, the examined collection must be of the same
|
||||
* length as the specified list of matchers.
|
||||
*
|
||||
* Note: Each matcher in the specified list will only be used once during a given examination, so
|
||||
* be careful when specifying matchers that may be satisfied by more than one entry in an examined
|
||||
* collection.
|
||||
*
|
||||
* <b>Examples</b><br />
|
||||
* <pre>assertThat(\@[\@"foo", \@"bar"], containsInAnyOrderIn(\@[equalTo(\@"bar"), equalTo(\@"foo")]))</pre>
|
||||
* <pre>assertThat(\@[\@"foo", \@"bar"], containsInAnyOrderIn(@[\@"bar", \@"foo"]))</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_containsInAnyOrderIn instead.
|
||||
*/
|
||||
static inline id containsInAnyOrderIn(NSArray *itemMatchers)
|
||||
{
|
||||
return HC_containsInAnyOrderIn(itemMatchers);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
FOUNDATION_EXPORT id HC_containsInAnyOrder(id itemMatchers, ...) NS_REQUIRES_NIL_TERMINATION;
|
||||
|
||||
#ifndef HC_DISABLE_SHORT_SYNTAX
|
||||
/*!
|
||||
* @abstract Creates an order-agnostic matcher for collections that matches when each item in the
|
||||
* examined collection satisfies one matcher anywhere in the specified list of matchers.
|
||||
* @param itemMatchers... 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 This matcher works on any collection that conforms to the NSFastEnumeration protocol,
|
||||
* performing a single pass. For a positive match, the examined collection must be of the same
|
||||
* length as the specified list of matchers.
|
||||
*
|
||||
* Note: Each matcher in the specified list will only be used once during a given examination, so
|
||||
* be careful when specifying matchers that may be satisfied by more than one entry in an examined
|
||||
* collection.
|
||||
*
|
||||
* <b>Examples</b><br />
|
||||
* <pre>assertThat(\@[\@"foo", \@"bar"], containsInAnyOrder(equalTo(\@"bar"), equalTo(\@"foo"), nil))</pre>
|
||||
* <pre>assertThat(\@[\@"foo", \@"bar"], containsInAnyOrder(\@"bar", \@"foo", 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_containsInAnyOrder instead.
|
||||
*/
|
||||
#define containsInAnyOrder(itemMatchers...) HC_containsInAnyOrder(itemMatchers)
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
115
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsCollectionContainingInAnyOrder.m
generated
Normal file
115
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsCollectionContainingInAnyOrder.m
generated
Normal file
@@ -0,0 +1,115 @@
|
||||
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
||||
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
||||
|
||||
#import "HCIsCollectionContainingInAnyOrder.h"
|
||||
|
||||
#import "HCCollect.h"
|
||||
|
||||
|
||||
@interface HCMatchingInAnyOrder : NSObject
|
||||
@property (nonatomic, copy, readonly) NSMutableArray<id <HCMatcher>> *matchers;
|
||||
@property (nonatomic, strong, readonly) id <HCDescription> mismatchDescription;
|
||||
@end
|
||||
|
||||
@implementation HCMatchingInAnyOrder
|
||||
|
||||
- (instancetype)initWithMatchers:(NSArray<id <HCMatcher>> *)itemMatchers
|
||||
mismatchDescription:(id <HCDescription>)description
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
_matchers = [itemMatchers mutableCopy];
|
||||
_mismatchDescription = description;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)matches:(nullable id)item
|
||||
{
|
||||
NSUInteger index = 0;
|
||||
for (id <HCMatcher> matcher in self.matchers)
|
||||
{
|
||||
if ([matcher matches:item])
|
||||
{
|
||||
[self.matchers removeObjectAtIndex:index];
|
||||
return YES;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
[[self.mismatchDescription appendText:@"not matched: "]
|
||||
appendDescriptionOf:item];
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)isFinishedWith:(NSArray *)collection
|
||||
{
|
||||
if (self.matchers.count == 0)
|
||||
return YES;
|
||||
|
||||
[[[[self.mismatchDescription appendText:@"no item matches: "]
|
||||
appendList:self.matchers start:@"" separator:@", " end:@""]
|
||||
appendText:@" in "]
|
||||
appendList:collection start:@"[" separator:@", " end:@"]"];
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface HCIsCollectionContainingInAnyOrder ()
|
||||
@property (nonatomic, copy, readonly) NSArray<id <HCMatcher>> *matchers;
|
||||
@end
|
||||
|
||||
@implementation HCIsCollectionContainingInAnyOrder
|
||||
|
||||
- (instancetype)initWithMatchers:(NSArray<id <HCMatcher>> *)itemMatchers
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
_matchers = [itemMatchers copy];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)matches:(id)collection describingMismatchTo:(id <HCDescription>)mismatchDescription
|
||||
{
|
||||
if (![collection conformsToProtocol:@protocol(NSFastEnumeration)])
|
||||
{
|
||||
[[mismatchDescription appendText:@"was non-collection "] appendDescriptionOf:collection];
|
||||
return NO;
|
||||
}
|
||||
|
||||
HCMatchingInAnyOrder *matchSequence =
|
||||
[[HCMatchingInAnyOrder alloc] initWithMatchers:self.matchers
|
||||
mismatchDescription:mismatchDescription];
|
||||
for (id item in collection)
|
||||
if (![matchSequence matches:item])
|
||||
return NO;
|
||||
|
||||
return [matchSequence isFinishedWith:collection];
|
||||
}
|
||||
|
||||
- (void)describeTo:(id <HCDescription>)description
|
||||
{
|
||||
[[[description appendText:@"a collection over "]
|
||||
appendList:self.matchers start:@"[" separator:@", " end:@"]"]
|
||||
appendText:@" in any order"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
id HC_containsInAnyOrderIn(NSArray *itemMatchers)
|
||||
{
|
||||
return [[HCIsCollectionContainingInAnyOrder alloc] initWithMatchers:HCWrapIntoMatchers(itemMatchers)];
|
||||
}
|
||||
|
||||
id HC_containsInAnyOrder(id itemMatchers, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, itemMatchers);
|
||||
NSArray *array = HCCollectItems(itemMatchers, args);
|
||||
va_end(args);
|
||||
|
||||
return HC_containsInAnyOrderIn(array);
|
||||
}
|
||||
71
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsCollectionContainingInOrder.h
generated
Normal file
71
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsCollectionContainingInOrder.h
generated
Normal file
@@ -0,0 +1,71 @@
|
||||
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
||||
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
||||
|
||||
#import <OCHamcrest/HCDiagnosingMatcher.h>
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
* @abstract Matches if every item in a collection satisfies a list of nested matchers, in order.
|
||||
*/
|
||||
@interface HCIsCollectionContainingInOrder : HCDiagnosingMatcher
|
||||
|
||||
- (instancetype)initWithMatchers:(NSArray<id <HCMatcher>> *)itemMatchers NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
FOUNDATION_EXPORT id HC_containsIn(NSArray *itemMatchers);
|
||||
|
||||
#ifndef HC_DISABLE_SHORT_SYNTAX
|
||||
/*!
|
||||
* @abstract Creates a matcher for collections that matches when each item in the examined
|
||||
* collection satisfies the corresponding matcher in the specified list of matchers.
|
||||
* @param itemMatchers 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 This matcher works on any collection that conforms to the NSFastEnumeration protocol,
|
||||
* performing a single pass. For a positive match, the examined collection must be of the same
|
||||
* length as the specified list of matchers.
|
||||
*
|
||||
* <b>Examples</b><br />
|
||||
* <pre>assertThat(\@[\@"foo", \@"bar"], containsIn(\@[equalTo(\@"foo"), equalTo(\@"bar")]))</pre>
|
||||
* <pre>assertThat(\@[\@"foo", \@"bar"], containsIn(\@[\@"foo", \@"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_containsIn instead.)
|
||||
*/
|
||||
static inline id containsIn(NSArray *itemMatchers)
|
||||
{
|
||||
return HC_containsIn(itemMatchers);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
FOUNDATION_EXPORT id HC_contains(id itemMatchers, ...) NS_REQUIRES_NIL_TERMINATION;
|
||||
|
||||
#ifndef HC_DISABLE_SHORT_SYNTAX
|
||||
/*!
|
||||
* @abstract Creates a matcher for collections that matches when each item in the examined
|
||||
* collection satisfies the corresponding matcher in the specified list of matchers.
|
||||
* @param itemMatchers... 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 This matcher works on any collection that conforms to the NSFastEnumeration protocol,
|
||||
* performing a single pass. For a positive match, the examined collection must be of the same
|
||||
* length as the specified list of matchers.
|
||||
*
|
||||
* <b>Examples</b><br />
|
||||
* <pre>assertThat(\@[\@"foo", \@"bar"], contains(equalTo(\@"foo"), equalTo(\@"bar"), nil))</pre>
|
||||
* <pre>assertThat(\@[\@"foo", \@"bar"], contains(\@"foo", \@"bar", 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_contains instead.)
|
||||
*/
|
||||
#define contains(itemMatchers...) HC_contains(itemMatchers)
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
134
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsCollectionContainingInOrder.m
generated
Normal file
134
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsCollectionContainingInOrder.m
generated
Normal file
@@ -0,0 +1,134 @@
|
||||
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
||||
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
||||
|
||||
#import "HCIsCollectionContainingInOrder.h"
|
||||
|
||||
#import "HCCollect.h"
|
||||
|
||||
|
||||
@interface HCMatchSequence : NSObject
|
||||
@property (nonatomic, copy, readonly) NSArray<id <HCMatcher>> *matchers;
|
||||
@property (nonatomic, strong, readonly) id <HCDescription> mismatchDescription;
|
||||
@property (nonatomic, assign) NSUInteger nextMatchIndex;
|
||||
@end
|
||||
|
||||
@implementation HCMatchSequence
|
||||
|
||||
- (instancetype)initWithMatchers:(NSArray<id <HCMatcher>> *)itemMatchers
|
||||
mismatchDescription:(id <HCDescription>)description
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
_matchers = [itemMatchers copy];
|
||||
_mismatchDescription = description;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)matches:(nullable id)item
|
||||
{
|
||||
return [self isNotSurplus:item] && [self isMatched:item];
|
||||
}
|
||||
|
||||
- (BOOL)isFinished
|
||||
{
|
||||
if (self.nextMatchIndex < self.matchers.count)
|
||||
{
|
||||
[[self.mismatchDescription appendText:@"no item was "]
|
||||
appendDescriptionOf:self.matchers[self.nextMatchIndex]];
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)isMatched:(id)item
|
||||
{
|
||||
id <HCMatcher> matcher = self.matchers[self.nextMatchIndex];
|
||||
if (![matcher matches:item])
|
||||
{
|
||||
[self describeMismatchOfMatcher:matcher item:item];
|
||||
return NO;
|
||||
}
|
||||
++self.nextMatchIndex;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)isNotSurplus:(id)item
|
||||
{
|
||||
if (self.matchers.count <= self.nextMatchIndex)
|
||||
{
|
||||
[[self.mismatchDescription
|
||||
appendText:[NSString stringWithFormat:@"exceeded count of %lu with item ",
|
||||
(unsigned long)self.matchers.count]]
|
||||
appendDescriptionOf:item];
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)describeMismatchOfMatcher:(id <HCMatcher>)matcher item:(id)item
|
||||
{
|
||||
[self.mismatchDescription appendText:[NSString stringWithFormat:@"item %lu: ",
|
||||
(unsigned long)self.nextMatchIndex]];
|
||||
[matcher describeMismatchOf:item to:self.mismatchDescription];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface HCIsCollectionContainingInOrder ()
|
||||
@property (nonatomic, copy, readonly) NSArray<id <HCMatcher>> *matchers;
|
||||
@end
|
||||
|
||||
@implementation HCIsCollectionContainingInOrder
|
||||
|
||||
- (instancetype)initWithMatchers:(NSArray<id <HCMatcher>> *)itemMatchers
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
_matchers = [itemMatchers copy];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)matches:(id)collection describingMismatchTo:(id <HCDescription>)mismatchDescription
|
||||
{
|
||||
if (![collection conformsToProtocol:@protocol(NSFastEnumeration)])
|
||||
{
|
||||
[[mismatchDescription appendText:@"was non-collection "] appendDescriptionOf:collection];
|
||||
return NO;
|
||||
}
|
||||
|
||||
HCMatchSequence *matchSequence =
|
||||
[[HCMatchSequence alloc] initWithMatchers:self.matchers
|
||||
mismatchDescription:mismatchDescription];
|
||||
for (id item in collection)
|
||||
if (![matchSequence matches:item])
|
||||
return NO;
|
||||
|
||||
return [matchSequence isFinished];
|
||||
}
|
||||
|
||||
- (void)describeTo:(id <HCDescription>)description
|
||||
{
|
||||
[[description appendText:@"a collection containing "]
|
||||
appendList:self.matchers start:@"[" separator:@", " end:@"]"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
id HC_containsIn(NSArray *itemMatchers)
|
||||
{
|
||||
return [[HCIsCollectionContainingInOrder alloc] initWithMatchers:HCWrapIntoMatchers(itemMatchers)];
|
||||
}
|
||||
|
||||
id HC_contains(id itemMatchers, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, itemMatchers);
|
||||
NSArray *array = HCCollectItems(itemMatchers, args);
|
||||
va_end(args);
|
||||
|
||||
return HC_containsIn(array);
|
||||
}
|
||||
48
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsCollectionContainingInRelativeOrder.h
generated
Normal file
48
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsCollectionContainingInRelativeOrder.h
generated
Normal file
@@ -0,0 +1,48 @@
|
||||
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
||||
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
||||
|
||||
#import <OCHamcrest/HCDiagnosingMatcher.h>
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
* @abstract Matches if every item in a collection satisfies a list of nested matchers, in order.
|
||||
*/
|
||||
@interface HCIsCollectionContainingInRelativeOrder : HCDiagnosingMatcher
|
||||
|
||||
- (instancetype)initWithMatchers:(NSArray<id <HCMatcher>> *)itemMatchers NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
FOUNDATION_EXPORT id HC_containsInRelativeOrder(NSArray *itemMatchers);
|
||||
|
||||
#ifndef HC_DISABLE_SHORT_SYNTAX
|
||||
/*!
|
||||
* @abstract Creates a matcher for collections that matches when the examined collection contains
|
||||
* items satisfying the specified list of matchers, in the same relative order.
|
||||
* @param itemMatchers Array of matchers that must be satisfied by the items provided by the
|
||||
* examined collection in the same relative order.
|
||||
* @discussion This matcher works on any collection that conforms to the NSFastEnumeration protocol,
|
||||
* performing a single pass.
|
||||
*
|
||||
* Any element of <em>itemMatchers</em> that is not a matcher is implicitly wrapped in an
|
||||
* <em>equalTo</em> matcher to check for equality.
|
||||
*
|
||||
* <b>Examples</b><br />
|
||||
* <pre>assertThat(\@[\@1, \@2, \@3, \@4, \@5], containsInRelativeOrder(equalTo(\@2), equalTo(\@4)))</pre>
|
||||
* <pre>assertThat(\@[\@1, \@2, \@3, \@4, \@5], containsInRelativeOrder(\@2, \@4))</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_containsInRelativeOrder instead.
|
||||
*/
|
||||
static inline id containsInRelativeOrder(NSArray *itemMatchers)
|
||||
{
|
||||
return HC_containsInRelativeOrder(itemMatchers);
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
124
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsCollectionContainingInRelativeOrder.m
generated
Normal file
124
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsCollectionContainingInRelativeOrder.m
generated
Normal file
@@ -0,0 +1,124 @@
|
||||
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
||||
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
||||
|
||||
#import "HCIsCollectionContainingInRelativeOrder.h"
|
||||
|
||||
#import "HCCollect.h"
|
||||
|
||||
|
||||
static void HCRequireNonEmptyArray(NSArray *array)
|
||||
{
|
||||
if (!array.count)
|
||||
{
|
||||
@throw [NSException exceptionWithName:@"EmptyArray"
|
||||
reason:@"Must be non-empty array"
|
||||
userInfo:nil];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@interface HCMatchSequenceInRelativeOrder : NSObject
|
||||
@property (nonatomic, copy, readonly) NSArray<id <HCMatcher>> *matchers;
|
||||
@property (nonatomic, strong, readonly) id <HCDescription> mismatchDescription;
|
||||
@property (nonatomic, assign) NSUInteger nextMatchIndex;
|
||||
@property (nonatomic, strong) id lastMatchedItem;
|
||||
@end
|
||||
|
||||
@implementation HCMatchSequenceInRelativeOrder
|
||||
|
||||
- (instancetype)initWithMatchers:(NSArray<id <HCMatcher>> *)itemMatchers
|
||||
mismatchDescription:(id <HCDescription>)description
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
_matchers = [itemMatchers copy];
|
||||
_mismatchDescription = description;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)processItems:(NSArray *)sequence
|
||||
{
|
||||
for (id item in sequence)
|
||||
{
|
||||
if (self.nextMatchIndex < self.matchers.count)
|
||||
{
|
||||
id <HCMatcher> matcher = self.matchers[self.nextMatchIndex];
|
||||
if ([matcher matches:item])
|
||||
{
|
||||
self.lastMatchedItem = item;
|
||||
self.nextMatchIndex += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isFinished
|
||||
{
|
||||
if (self.nextMatchIndex < self.matchers.count)
|
||||
{
|
||||
[[self.mismatchDescription
|
||||
appendDescriptionOf:self.matchers[self.nextMatchIndex]]
|
||||
appendText:@" was not found"];
|
||||
if (self.lastMatchedItem != nil)
|
||||
{
|
||||
[[self.mismatchDescription
|
||||
appendText:@" after "]
|
||||
appendDescriptionOf:self.lastMatchedItem];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface HCIsCollectionContainingInRelativeOrder ()
|
||||
@property (nonatomic, copy, readonly) NSArray<id <HCMatcher>> *matchers;
|
||||
@end
|
||||
|
||||
@implementation HCIsCollectionContainingInRelativeOrder
|
||||
|
||||
- (instancetype)initWithMatchers:(NSArray<id <HCMatcher>> *)itemMatchers
|
||||
{
|
||||
HCRequireNonEmptyArray(itemMatchers);
|
||||
|
||||
self = [super init];
|
||||
if (self)
|
||||
_matchers = [itemMatchers copy];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)matches:(id)collection describingMismatchTo:(id <HCDescription>)mismatchDescription
|
||||
{
|
||||
if (![collection conformsToProtocol:@protocol(NSFastEnumeration)])
|
||||
{
|
||||
[[mismatchDescription appendText:@"was non-collection "] appendDescriptionOf:collection];
|
||||
return NO;
|
||||
}
|
||||
|
||||
HCMatchSequenceInRelativeOrder *matchSequenceInRelativeOrder =
|
||||
[[HCMatchSequenceInRelativeOrder alloc] initWithMatchers:self.matchers
|
||||
mismatchDescription:mismatchDescription];
|
||||
[matchSequenceInRelativeOrder processItems:collection];
|
||||
return [matchSequenceInRelativeOrder isFinished];
|
||||
}
|
||||
|
||||
- (void)describeTo:(id <HCDescription>)description
|
||||
{
|
||||
[[[description
|
||||
appendText:@"a collection containing "]
|
||||
appendList:self.matchers start:@"[" separator:@", " end:@"]"]
|
||||
appendText:@" in relative order"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
id HC_containsInRelativeOrder(NSArray *itemMatchers)
|
||||
{
|
||||
NSArray *matchers = HCWrapIntoMatchers(itemMatchers);
|
||||
return [[HCIsCollectionContainingInRelativeOrder alloc] initWithMatchers:matchers];
|
||||
}
|
||||
62
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsCollectionOnlyContaining.h
generated
Normal file
62
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsCollectionOnlyContaining.h
generated
Normal file
@@ -0,0 +1,62 @@
|
||||
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
||||
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
||||
|
||||
#import <OCHamcrest/HCEvery.h>
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
* @abstract Matches if every item in a collection satisfies any of the nested matchers.
|
||||
*/
|
||||
@interface HCIsCollectionOnlyContaining : HCEvery
|
||||
@end
|
||||
|
||||
FOUNDATION_EXPORT id HC_onlyContainsIn(NSArray *itemMatchers);
|
||||
|
||||
#ifndef HC_DISABLE_SHORT_SYNTAX
|
||||
/*!
|
||||
* @abstract Creates a matcher for collections that matches when each item of the examined
|
||||
* collection satisfies any of the specified matchers.
|
||||
* @param itemMatchers 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 This matcher works on any collection that conforms to the NSFastEnumeration protocol,
|
||||
* performing a single pass. Any matcher may match multiple elements.
|
||||
*
|
||||
* <b>Example</b><br />
|
||||
* <pre>assertThat(\@[\@"Jon", \@"John", \@"Bob"], onlyContainsIn(\@[startsWith(\@"Jo"), startsWith(\@("Bo")]))</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_onlyContainsIn instead.
|
||||
*/
|
||||
static inline id onlyContainsIn(NSArray *itemMatchers)
|
||||
{
|
||||
return HC_onlyContainsIn(itemMatchers);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
FOUNDATION_EXPORT id HC_onlyContains(id itemMatchers, ...) NS_REQUIRES_NIL_TERMINATION;
|
||||
|
||||
#ifndef HC_DISABLE_SHORT_SYNTAX
|
||||
/*!
|
||||
* @abstract Creates a matcher for collections that matches when each item of the examined
|
||||
* collection satisfies any of the specified matchers.
|
||||
* @param itemMatchers... 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 This matcher works on any collection that conforms to the NSFastEnumeration protocol,
|
||||
* performing a single pass. Any matcher may match multiple elements.
|
||||
*
|
||||
* <b>Example</b><br />
|
||||
* <pre>assertThat(\@[\@"Jon", \@"John", \@"Bob"], onlyContains(startsWith(\@"Jo"), startsWith(\@("Bo"), 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_onlyContains instead.
|
||||
*/
|
||||
#define onlyContains(itemMatchers...) HC_onlyContains(itemMatchers)
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
34
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsCollectionOnlyContaining.m
generated
Normal file
34
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsCollectionOnlyContaining.m
generated
Normal file
@@ -0,0 +1,34 @@
|
||||
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
||||
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
||||
|
||||
#import "HCIsCollectionOnlyContaining.h"
|
||||
|
||||
#import "HCAnyOf.h"
|
||||
#import "HCCollect.h"
|
||||
|
||||
|
||||
@implementation HCIsCollectionOnlyContaining
|
||||
|
||||
- (void)describeTo:(id <HCDescription>)description
|
||||
{
|
||||
[[description appendText:@"a collection containing items matching "]
|
||||
appendDescriptionOf:self.matcher];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
id HC_onlyContainsIn(NSArray *itemMatchers)
|
||||
{
|
||||
return [[HCIsCollectionOnlyContaining alloc] initWithMatcher:HC_anyOfIn(itemMatchers)];
|
||||
}
|
||||
|
||||
id HC_onlyContains(id itemMatchers, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, itemMatchers);
|
||||
NSArray *array = HCCollectItems(itemMatchers, args);
|
||||
va_end(args);
|
||||
|
||||
return HC_onlyContainsIn(array);
|
||||
}
|
||||
47
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsDictionaryContaining.h
generated
Normal file
47
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsDictionaryContaining.h
generated
Normal file
@@ -0,0 +1,47 @@
|
||||
// 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 satisfies the nested pair of matchers.
|
||||
*/
|
||||
@interface HCIsDictionaryContaining : HCBaseMatcher
|
||||
|
||||
- (instancetype)initWithKeyMatcher:(id <HCMatcher>)keyMatcher
|
||||
valueMatcher:(id <HCMatcher>)valueMatcher NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
FOUNDATION_EXPORT id HC_hasEntry(id keyMatcher, id valueMatcher);
|
||||
|
||||
#ifndef HC_DISABLE_SHORT_SYNTAX
|
||||
/*!
|
||||
* @abstract Creates a matcher for NSDictionaries that matches when the examined dictionary contains
|
||||
* at least one entry whose key satisfies the specified <code>keyMatcher</code> <b>and</b> whose
|
||||
* value satisfies the specified <code>valueMatcher</code>.
|
||||
* @param keyMatcher The matcher to satisfy for the key, or an expected value for <em>equalTo</em> matching.
|
||||
* @param valueMatcher The matcher to satisfy for the value, or an expected value for <em>equalTo</em> matching.
|
||||
* @discussion 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, hasEntry(equalTo(\@"foo"), equalTo(\@"bar")))</pre>
|
||||
* <pre>assertThat(myDictionary, hasEntry(\@"foo", \@"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_hasEntry instead.
|
||||
*/
|
||||
static inline id hasEntry(id keyMatcher, id valueMatcher)
|
||||
{
|
||||
return HC_hasEntry(keyMatcher, valueMatcher);
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
56
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsDictionaryContaining.m
generated
Normal file
56
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsDictionaryContaining.m
generated
Normal file
@@ -0,0 +1,56 @@
|
||||
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
||||
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
||||
|
||||
#import "HCIsDictionaryContaining.h"
|
||||
|
||||
#import "HCRequireNonNilObject.h"
|
||||
#import "HCWrapInMatcher.h"
|
||||
|
||||
|
||||
@interface HCIsDictionaryContaining ()
|
||||
@property (nonatomic, strong, readonly) id <HCMatcher> keyMatcher;
|
||||
@property (nonatomic, strong, readonly) id <HCMatcher> valueMatcher;
|
||||
@end
|
||||
|
||||
@implementation HCIsDictionaryContaining
|
||||
|
||||
- (instancetype)initWithKeyMatcher:(id <HCMatcher>)keyMatcher
|
||||
valueMatcher:(id <HCMatcher>)valueMatcher
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
_keyMatcher = keyMatcher;
|
||||
_valueMatcher = valueMatcher;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)matches:(id)dict
|
||||
{
|
||||
if ([dict isKindOfClass:[NSDictionary class]])
|
||||
for (id oneKey in dict)
|
||||
if ([self.keyMatcher matches:oneKey] && [self.valueMatcher matches:dict[oneKey]])
|
||||
return YES;
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)describeTo:(id <HCDescription>)description
|
||||
{
|
||||
[[[[[description appendText:@"a dictionary containing { "]
|
||||
appendDescriptionOf:self.keyMatcher]
|
||||
appendText:@" = "]
|
||||
appendDescriptionOf:self.valueMatcher]
|
||||
appendText:@"; }"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
id HC_hasEntry(id keyMatcher, id valueMatcher)
|
||||
{
|
||||
HCRequireNonNilObject(keyMatcher);
|
||||
HCRequireNonNilObject(valueMatcher);
|
||||
return [[HCIsDictionaryContaining alloc] initWithKeyMatcher:HCWrapInMatcher(keyMatcher)
|
||||
valueMatcher:HCWrapInMatcher(valueMatcher)];
|
||||
}
|
||||
68
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsDictionaryContainingEntries.h
generated
Normal file
68
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsDictionaryContainingEntries.h
generated
Normal file
@@ -0,0 +1,68 @@
|
||||
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
||||
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
||||
|
||||
#import <OCHamcrest/HCDiagnosingMatcher.h>
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
* @abstract Matches if dictionary contains entries that satisfy the list of keys and value
|
||||
* matchers.
|
||||
*/
|
||||
@interface HCIsDictionaryContainingEntries : HCDiagnosingMatcher
|
||||
|
||||
- (instancetype)initWithKeys:(NSArray *)keys
|
||||
valueMatchers:(NSArray<id <HCMatcher>> *)valueMatchers NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
FOUNDATION_EXPORT id HC_hasEntriesIn(NSDictionary *valueMatchersForKeys);
|
||||
|
||||
#ifndef HC_DISABLE_SHORT_SYNTAX
|
||||
/*!
|
||||
* @abstract Creates a matcher for NSDictionaries that matches when the examined dictionary contains
|
||||
* entries satisfying a dictionary of keys and their value matchers.
|
||||
* @param valueMatchersForKeys A dictionary of keys (not matchers) and their value matchers. Any
|
||||
* value argument that is not a matcher is implicitly wrapped in an <em>equalTo</em> matcher to
|
||||
* check for equality.
|
||||
* @discussion
|
||||
* <b>Examples</b><br />
|
||||
* <pre>assertThat(personDict, hasEntriesIn(\@{\@"firstName": equalTo(\@"Jon"), \@"lastName": equalTo(\@"Reid")}))</pre>
|
||||
* <pre>assertThat(personDict, hasEntriesIn(\@{\@"firstName": \@"Jon", \@"lastName": \@"Reid"}))</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_hasEntryIn instead.
|
||||
*/
|
||||
static inline id hasEntriesIn(NSDictionary *valueMatchersForKeys)
|
||||
{
|
||||
return HC_hasEntriesIn(valueMatchersForKeys);
|
||||
}
|
||||
#endif
|
||||
|
||||
FOUNDATION_EXPORT id HC_hasEntries(id keysAndValueMatchers, ...) NS_REQUIRES_NIL_TERMINATION;
|
||||
|
||||
#ifndef HC_DISABLE_SHORT_SYNTAX
|
||||
/*!
|
||||
* @abstract Creates a matcher for NSDictionaries that matches when the examined dictionary contains
|
||||
* entries satisfying a list of alternating keys and their value matchers.
|
||||
* @param keysAndValueMatchers... A key (not a matcher) to look up, followed by a value matcher or
|
||||
* an expected value for <em>equalTo</em> matching, in a comma-separated list ending
|
||||
* with <code>nil</code>
|
||||
* @discussion Note that the keys must be actual keys, not matchers. Any value 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(personDict, hasEntries(\@"firstName", equalTo(\@"Jon"), \@"lastName", equalTo(\@"Reid"), nil))</pre>
|
||||
* <pre>assertThat(personDict, hasEntries(\@"firstName", \@"Jon", \@"lastName", \@"Reid", 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_hasEntry instead.
|
||||
*/
|
||||
#define hasEntries(keysAndValueMatchers...) HC_hasEntries(keysAndValueMatchers)
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
132
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsDictionaryContainingEntries.m
generated
Normal file
132
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsDictionaryContainingEntries.m
generated
Normal file
@@ -0,0 +1,132 @@
|
||||
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
||||
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
||||
|
||||
#import "HCIsDictionaryContainingEntries.h"
|
||||
|
||||
#import "HCWrapInMatcher.h"
|
||||
|
||||
|
||||
@interface HCIsDictionaryContainingEntries ()
|
||||
@property (nonatomic, copy, readonly) NSArray *keys;
|
||||
@property (nonatomic, copy, readonly) NSArray<id <HCMatcher>> *valueMatchers;
|
||||
@end
|
||||
|
||||
@implementation HCIsDictionaryContainingEntries
|
||||
|
||||
- (instancetype)initWithKeys:(NSArray *)keys
|
||||
valueMatchers:(NSArray<id <HCMatcher>> *)valueMatchers
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
_keys = [keys copy];
|
||||
_valueMatchers = [valueMatchers copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)matches:(id)dict describingMismatchTo:(id <HCDescription>)mismatchDescription
|
||||
{
|
||||
if (![dict isKindOfClass:[NSDictionary class]])
|
||||
{
|
||||
[[mismatchDescription appendText:@"was non-dictionary "] appendDescriptionOf:dict];
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSUInteger count = self.keys.count;
|
||||
for (NSUInteger index = 0; index < count; ++index)
|
||||
{
|
||||
id key = self.keys[index];
|
||||
if (dict[key] == nil)
|
||||
{
|
||||
[[[[mismatchDescription appendText:@"no "]
|
||||
appendDescriptionOf:key]
|
||||
appendText:@" key in "]
|
||||
appendDescriptionOf:dict];
|
||||
return NO;
|
||||
}
|
||||
|
||||
id valueMatcher = self.valueMatchers[index];
|
||||
id actualValue = dict[key];
|
||||
|
||||
if (![valueMatcher matches:actualValue])
|
||||
{
|
||||
[[[[mismatchDescription appendText:@"value for "]
|
||||
appendDescriptionOf:key]
|
||||
appendText:@" was "]
|
||||
appendDescriptionOf:actualValue];
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)describeKeyValueAtIndex:(NSUInteger)index to:(id <HCDescription>)description
|
||||
{
|
||||
[[[[description appendDescriptionOf:self.keys[index]]
|
||||
appendText:@" = "]
|
||||
appendDescriptionOf:self.valueMatchers[index]]
|
||||
appendText:@"; "];
|
||||
}
|
||||
|
||||
- (void)describeTo:(id <HCDescription>)description
|
||||
{
|
||||
[description appendText:@"a dictionary containing { "];
|
||||
NSUInteger count = [self.keys count];
|
||||
NSUInteger index = 0;
|
||||
for (; index < count - 1; ++index)
|
||||
[self describeKeyValueAtIndex:index to:description];
|
||||
[self describeKeyValueAtIndex:index to:description];
|
||||
[description appendText:@"}"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
static void requirePairedObject(id obj)
|
||||
{
|
||||
if (obj == nil)
|
||||
{
|
||||
@throw [NSException exceptionWithName:@"NilObject"
|
||||
reason:@"HC_hasEntries keys and value matchers must be paired"
|
||||
userInfo:nil];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
id HC_hasEntriesIn(NSDictionary *valueMatchersForKeys)
|
||||
{
|
||||
NSArray *keys = valueMatchersForKeys.allKeys;
|
||||
NSMutableArray<id <HCMatcher>> *valueMatchers = [[NSMutableArray alloc] init];
|
||||
for (id key in keys)
|
||||
[valueMatchers addObject:HCWrapInMatcher(valueMatchersForKeys[key])];
|
||||
|
||||
return [[HCIsDictionaryContainingEntries alloc] initWithKeys:keys
|
||||
valueMatchers:valueMatchers];
|
||||
}
|
||||
|
||||
id HC_hasEntries(id keysAndValueMatchers, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, keysAndValueMatchers);
|
||||
|
||||
id key = keysAndValueMatchers;
|
||||
id valueMatcher = va_arg(args, id);
|
||||
requirePairedObject(valueMatcher);
|
||||
NSMutableArray *keys = [NSMutableArray arrayWithObject:key];
|
||||
NSMutableArray<id <HCMatcher>> *valueMatchers = [NSMutableArray arrayWithObject:HCWrapInMatcher(valueMatcher)];
|
||||
|
||||
key = va_arg(args, id);
|
||||
while (key != nil)
|
||||
{
|
||||
[keys addObject:key];
|
||||
valueMatcher = va_arg(args, id);
|
||||
requirePairedObject(valueMatcher);
|
||||
[valueMatchers addObject:HCWrapInMatcher(valueMatcher)];
|
||||
key = va_arg(args, id);
|
||||
}
|
||||
|
||||
return [[HCIsDictionaryContainingEntries alloc] initWithKeys:keys
|
||||
valueMatchers:valueMatchers];
|
||||
}
|
||||
44
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsDictionaryContainingKey.h
generated
Normal file
44
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsDictionaryContainingKey.h
generated
Normal file
@@ -0,0 +1,44 @@
|
||||
// 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 key satisfying the nested matcher.
|
||||
*/
|
||||
@interface HCIsDictionaryContainingKey : HCBaseMatcher
|
||||
|
||||
- (instancetype)initWithKeyMatcher:(id <HCMatcher>)keyMatcher NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
FOUNDATION_EXPORT id HC_hasKey(id keyMatcher);
|
||||
|
||||
#ifndef HC_DISABLE_SHORT_SYNTAX
|
||||
/*!
|
||||
* @abstract Creates a matcher for NSDictionaries that matches when the examined dictionary contains
|
||||
* at least key that satisfies the specified matcher.
|
||||
* @param keyMatcher The matcher to satisfy for the key, or an expected value for <em>equalTo</em> matching.
|
||||
* @discussion 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, hasEntry(equalTo(\@"foo")))</pre>
|
||||
* <pre>assertThat(myDictionary, hasEntry(\@"foo"))</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_hasKey instead.
|
||||
*/
|
||||
static inline id hasKey(id keyMatcher)
|
||||
{
|
||||
return HC_hasKey(keyMatcher);
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
46
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsDictionaryContainingKey.m
generated
Normal file
46
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsDictionaryContainingKey.m
generated
Normal file
@@ -0,0 +1,46 @@
|
||||
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
||||
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
||||
|
||||
#import "HCIsDictionaryContainingKey.h"
|
||||
|
||||
#import "HCRequireNonNilObject.h"
|
||||
#import "HCWrapInMatcher.h"
|
||||
|
||||
|
||||
@interface HCIsDictionaryContainingKey ()
|
||||
@property (nonatomic, strong, readonly) id <HCMatcher> keyMatcher;
|
||||
@end
|
||||
|
||||
@implementation HCIsDictionaryContainingKey
|
||||
|
||||
- (instancetype)initWithKeyMatcher:(id <HCMatcher>)keyMatcher
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
_keyMatcher = keyMatcher;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)matches:(id)dict
|
||||
{
|
||||
if ([dict isKindOfClass:[NSDictionary class]])
|
||||
for (id oneKey in dict)
|
||||
if ([self.keyMatcher matches:oneKey])
|
||||
return YES;
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)describeTo:(id <HCDescription>)description
|
||||
{
|
||||
[[description appendText:@"a dictionary containing key "]
|
||||
appendDescriptionOf:self.keyMatcher];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
id HC_hasKey(id keyMatcher)
|
||||
{
|
||||
HCRequireNonNilObject(keyMatcher);
|
||||
return [[HCIsDictionaryContainingKey alloc] initWithKeyMatcher:HCWrapInMatcher(keyMatcher)];
|
||||
}
|
||||
46
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsDictionaryContainingValue.h
generated
Normal file
46
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsDictionaryContainingValue.h
generated
Normal file
@@ -0,0 +1,46 @@
|
||||
// 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
|
||||
46
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsDictionaryContainingValue.m
generated
Normal file
46
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsDictionaryContainingValue.m
generated
Normal file
@@ -0,0 +1,46 @@
|
||||
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
||||
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
||||
|
||||
#import "HCIsDictionaryContainingValue.h"
|
||||
|
||||
#import "HCRequireNonNilObject.h"
|
||||
#import "HCWrapInMatcher.h"
|
||||
|
||||
|
||||
@interface HCIsDictionaryContainingValue ()
|
||||
@property (nonatomic, strong, readonly) id <HCMatcher> valueMatcher;
|
||||
@end
|
||||
|
||||
@implementation HCIsDictionaryContainingValue
|
||||
|
||||
- (instancetype)initWithValueMatcher:(id <HCMatcher>)valueMatcher
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
_valueMatcher = valueMatcher;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)matches:(id)dict
|
||||
{
|
||||
if ([dict respondsToSelector:@selector(allValues)])
|
||||
for (id oneValue in [dict allValues])
|
||||
if ([self.valueMatcher matches:oneValue])
|
||||
return YES;
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)describeTo:(id <HCDescription>)description
|
||||
{
|
||||
[[description appendText:@"a dictionary containing value "]
|
||||
appendDescriptionOf:self.valueMatcher];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
id HC_hasValue(id valueMatcher)
|
||||
{
|
||||
HCRequireNonNilObject(valueMatcher);
|
||||
return [[HCIsDictionaryContainingValue alloc] initWithValueMatcher:HCWrapInMatcher(valueMatcher)];
|
||||
}
|
||||
39
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsEmptyCollection.h
generated
Normal file
39
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsEmptyCollection.h
generated
Normal file
@@ -0,0 +1,39 @@
|
||||
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
||||
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
||||
|
||||
#import <OCHamcrest/HCHasCount.h>
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*!
|
||||
* @abstract Matches empty collections.
|
||||
*/
|
||||
@interface HCIsEmptyCollection : HCHasCount
|
||||
|
||||
- (instancetype)init;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
FOUNDATION_EXPORT id HC_isEmpty(void);
|
||||
|
||||
#ifndef HC_DISABLE_SHORT_SYNTAX
|
||||
/*!
|
||||
* @abstract Creates a matcher that matches any examined object whose <code>-count</code> method
|
||||
* returns zero.
|
||||
*
|
||||
* <b>Example</b><br />
|
||||
* <pre>assertThat(\@[], isEmpty())</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_isEmpty instead.
|
||||
*/
|
||||
static inline id isEmpty(void)
|
||||
{
|
||||
return HC_isEmpty();
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
33
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsEmptyCollection.m
generated
Normal file
33
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsEmptyCollection.m
generated
Normal file
@@ -0,0 +1,33 @@
|
||||
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
||||
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
||||
|
||||
#import "HCIsEmptyCollection.h"
|
||||
|
||||
#import "HCIsEqual.h"
|
||||
|
||||
|
||||
@implementation HCIsEmptyCollection
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super initWithMatcher:HC_equalTo(@0)];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)describeMismatchOf:(nullable id)item to:(nullable id <HCDescription>)mismatchDescription
|
||||
{
|
||||
[[mismatchDescription appendText:@"was "] appendDescriptionOf:item];
|
||||
}
|
||||
|
||||
- (void)describeTo:(id <HCDescription>)description
|
||||
{
|
||||
[description appendText:@"empty collection"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
FOUNDATION_EXPORT id HC_isEmpty(void)
|
||||
{
|
||||
return [[HCIsEmptyCollection alloc] init];
|
||||
}
|
||||
43
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsIn.h
generated
Normal file
43
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsIn.h
generated
Normal file
@@ -0,0 +1,43 @@
|
||||
// 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 examined object is contained within the nested collection.
|
||||
*/
|
||||
@interface HCIsIn : HCBaseMatcher
|
||||
|
||||
- (instancetype)initWithCollection:(id)collection NS_DESIGNATED_INITIALIZER;
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
FOUNDATION_EXPORT id HC_isIn(id aCollection);
|
||||
|
||||
#ifndef HC_DISABLE_SHORT_SYNTAX
|
||||
/*!
|
||||
* @abstract Creates a matcher that matches when the examined object is found within the specified
|
||||
* collection.
|
||||
* @param aCollection The collection to search.
|
||||
* @discussion Invokes <code>-containsObject:</code> on <em>aCollection</em> to determine if the
|
||||
* examined object is an element of the collection.
|
||||
*
|
||||
* <b>Example</b><br />
|
||||
* <pre>assertThat(\@"foo", isIn(\@@[\@"bar", \@"foo"]))</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_isIn instead.
|
||||
*/
|
||||
static inline id isIn(id aCollection)
|
||||
{
|
||||
return HC_isIn(aCollection);
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
45
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsIn.m
generated
Normal file
45
iOS/Pods/OCHamcrest/Source/Library/Collection/HCIsIn.m
generated
Normal file
@@ -0,0 +1,45 @@
|
||||
// OCHamcrest by Jon Reid, https://qualitycoding.org/
|
||||
// Copyright 2019 hamcrest.org. See LICENSE.txt
|
||||
|
||||
#import "HCIsIn.h"
|
||||
|
||||
|
||||
@interface HCIsIn ()
|
||||
@property (nonatomic, strong, readonly) id collection;
|
||||
@end
|
||||
|
||||
@implementation HCIsIn
|
||||
|
||||
- (instancetype)initWithCollection:(id)collection
|
||||
{
|
||||
if (![collection respondsToSelector:@selector(containsObject:)])
|
||||
{
|
||||
@throw [NSException exceptionWithName:@"NotAContainer"
|
||||
reason:@"Object must respond to -containsObject:"
|
||||
userInfo:nil];
|
||||
}
|
||||
|
||||
self = [super init];
|
||||
if (self)
|
||||
_collection = collection;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)matches:(nullable id)item
|
||||
{
|
||||
return [self.collection containsObject:item];
|
||||
}
|
||||
|
||||
- (void)describeTo:(id <HCDescription>)description
|
||||
{
|
||||
[[description appendText:@"one of "]
|
||||
appendList:self.collection start:@"{" separator:@", " end:@"}"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
id HC_isIn(id aCollection)
|
||||
{
|
||||
return [[HCIsIn alloc] initWithCollection:aCollection];
|
||||
}
|
||||
Reference in New Issue
Block a user