Adds cocoapods for libraries.

Adds OCMockito and OCHamcrest libs.
This commit is contained in:
2020-09-05 22:06:51 -07:00
parent af47156557
commit c3031fbc39
364 changed files with 17147 additions and 1 deletions

View 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);
}