Files
MonsterCards/iOS/Pods/OCHamcrest/Source/Library/Logical/HCAnyOf.m
Tom Hicks c3031fbc39 Adds cocoapods for libraries.
Adds OCMockito and OCHamcrest libs.
2020-09-05 22:06:51 -07:00

53 lines
1.0 KiB
Objective-C

// OCHamcrest by Jon Reid, https://qualitycoding.org/
// Copyright 2019 hamcrest.org. See LICENSE.txt
#import "HCAnyOf.h"
#import "HCCollect.h"
@interface HCAnyOf ()
@property (nonatomic, copy, readonly) NSArray<id <HCMatcher>> *matchers;
@end
@implementation HCAnyOf
- (instancetype)initWithMatchers:(NSArray<id <HCMatcher>> *)matchers
{
self = [super init];
if (self)
_matchers = [matchers copy];
return self;
}
- (BOOL)matches:(nullable id)item
{
for (id <HCMatcher> oneMatcher in self.matchers)
if ([oneMatcher matches:item])
return YES;
return NO;
}
- (void)describeTo:(id <HCDescription>)description
{
[description appendList:self.matchers start:@"(" separator:@" or " end:@")"];
}
@end
id HC_anyOfIn(NSArray *matchers)
{
return [[HCAnyOf alloc] initWithMatchers:HCWrapIntoMatchers(matchers)];
}
id HC_anyOf(id matchers, ...)
{
va_list args;
va_start(args, matchers);
NSArray *array = HCCollectItems(matchers, args);
va_end(args);
return HC_anyOfIn(array);
}