Sha256: a68f578fec0a231b59d28e3507ee1c45ee60c21c69845afe0d3fb3634006fac2
Contents?: true
Size: 1.38 KB
Versions: 8
Compression:
Stored size: 1.38 KB
Contents
#import "EXPMatchers+haveCountOf.h" EXPMatcherImplementationBegin(haveCountOf, (NSUInteger expected)) { BOOL actualIsStringy = [actual isKindOfClass:[NSString class]] || [actual isKindOfClass:[NSAttributedString class]]; BOOL actualIsCompatible = actualIsStringy || [actual respondsToSelector:@selector(count)]; prerequisite(^BOOL{ return actualIsCompatible; }); NSUInteger (^count)(id) = ^(id actual) { if(actualIsStringy) { return [actual length]; } else { return [actual count]; } }; match(^BOOL{ if(actualIsCompatible) { return count(actual) == expected; } return NO; }); failureMessageForTo(^NSString *{ if(!actualIsCompatible) return [NSString stringWithFormat:@"%@ is not an instance of NSString, NSAttributedString, NSArray, NSSet, NSOrderedSet, or NSDictionary", EXPDescribeObject(actual)]; return [NSString stringWithFormat:@"expected %@ to have a count of %zi but got %zi", EXPDescribeObject(actual), expected, count(actual)]; }); failureMessageForNotTo(^NSString *{ if(!actualIsCompatible) return [NSString stringWithFormat:@"%@ is not an instance of NSString, NSAttributedString, NSArray, NSSet, NSOrderedSet, or NSDictionary", EXPDescribeObject(actual)]; return [NSString stringWithFormat:@"expected %@ not to have a count of %zi", EXPDescribeObject(actual), expected]; }); } EXPMatcherImplementationEnd
Version data entries
8 entries across 8 versions & 2 rubygems