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

46 lines
1.0 KiB
Objective-C

// 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];
}