no message
This commit is contained in:
1 parent
2b564cb203
commit
03436011a4
204 files changed
+12793
-37
No files matched your search
@@ -0,0 +1,38 @@
|
||||
#import "EXPMatchers+match.h"
|
||||
#import "EXPMatcherHelpers.h"
|
||||
|
||||
EXPMatcherImplementationBegin(match, (NSString *expected)) {
|
||||
BOOL actualIsNil = (actual == nil);
|
||||
BOOL expectedIsNil = (expected == nil);
|
||||
|
||||
__block NSRegularExpression *regex = nil;
|
||||
__block NSError *regexError = nil;
|
||||
|
||||
prerequisite (^BOOL {
|
||||
BOOL nilInput = (actualIsNil || expectedIsNil);
|
||||
if (!nilInput) {
|
||||
regex = [NSRegularExpression regularExpressionWithPattern:expected options:0 error:®exError];
|
||||
}
|
||||
return !nilInput && regex;
|
||||
});
|
||||
|
||||
match(^BOOL {
|
||||
NSRange range = [regex rangeOfFirstMatchInString:actual options:0 range:NSMakeRange(0, [actual length])];
|
||||
return !NSEqualRanges(range, NSMakeRange(NSNotFound, 0));
|
||||
});
|
||||
|
||||
failureMessageForTo(^NSString *{
|
||||
if (actualIsNil) return @"the object is nil/null";
|
||||
if (expectedIsNil) return @"the expression is nil/null";
|
||||
if (regexError) return [NSString stringWithFormat:@"unable to create regular expression from given parameter: %@", [regexError localizedDescription]];
|
||||
return [NSString stringWithFormat:@"expected: %@ to match to %@", EXPDescribeObject(actual), expected];
|
||||
});
|
||||
|
||||
failureMessageForNotTo(^NSString *{
|
||||
if (actualIsNil) return @"the object is nil/null";
|
||||
if (expectedIsNil) return @"the expression is nil/null";
|
||||
if (regexError) return [NSString stringWithFormat:@"unable to create regular expression from given parameter: %@", [regexError localizedDescription]];
|
||||
return [NSString stringWithFormat:@"expected: %@ not to match to %@", EXPDescribeObject(actual), expected];
|
||||
});
|
||||
}
|
||||
EXPMatcherImplementationEnd
|
||||
Reference in new issue
Block a user