Sha256: 5027605dd20241e6b247f72829610143ac2fd4b2bcafaab7e3002d57ac23f583
Contents?: true
Size: 1.47 KB
Versions: 8
Compression:
Stored size: 1.47 KB
Contents
#import "EXPMatchers+contain.h" EXPMatcherImplementationBegin(_contain, (id expected)) { BOOL actualIsCompatible = [actual isKindOfClass:[NSString class]] || [actual conformsToProtocol:@protocol(NSFastEnumeration)]; BOOL expectedIsNil = (expected == nil); prerequisite(^BOOL{ return actualIsCompatible && !expectedIsNil; }); match(^BOOL{ if(actualIsCompatible) { if([actual isKindOfClass:[NSString class]]) { return [(NSString *)actual rangeOfString:[expected description]].location != NSNotFound; } else { for (id object in actual) { if ([object isEqual:expected]) { return YES; } } } } return NO; }); failureMessageForTo(^NSString *{ if(!actualIsCompatible) return [NSString stringWithFormat:@"%@ is not an instance of NSString or NSFastEnumeration", EXPDescribeObject(actual)]; if(expectedIsNil) return @"the expected value is nil/null"; return [NSString stringWithFormat:@"expected %@ to contain %@", EXPDescribeObject(actual), EXPDescribeObject(expected)]; }); failureMessageForNotTo(^NSString *{ if(!actualIsCompatible) return [NSString stringWithFormat:@"%@ is not an instance of NSString or NSFastEnumeration", EXPDescribeObject(actual)]; if(expectedIsNil) return @"the expected value is nil/null"; return [NSString stringWithFormat:@"expected %@ not to contain %@", EXPDescribeObject(actual), EXPDescribeObject(expected)]; }); } EXPMatcherImplementationEnd
Version data entries
8 entries across 8 versions & 2 rubygems