main
1//
2// Licensed under the terms in License.txt
3//
4// Copyright 2010 Allen Ding. All rights reserved.
5//
6
7#import "KWBeZeroMatcher.h"
8#import "KWFormatter.h"
9#import "KWValue.h"
10
11@implementation KWBeZeroMatcher
12
13#pragma mark -
14#pragma mark Getting Matcher Strings
15
16+ (NSArray *)matcherStrings {
17 return @[@"beZero"];
18}
19
20#pragma mark -
21#pragma mark Matching
22
23- (BOOL)evaluate {
24 if (![self.subject respondsToSelector:@selector(boolValue)])
25 [NSException raise:@"KWMatcherException" format:@"subject does not respond to -numberValue"];
26
27 return [[self.subject numberValue] isEqualToNumber:@0];
28}
29
30#pragma mark -
31#pragma mark Getting Failure Messages
32
33- (NSString *)failureMessageForShould {
34 return [NSString stringWithFormat:@"expected subject to be zero, got %@",
35 [KWFormatter formatObject:self.subject]];
36}
37
38- (NSString *)failureMessageForShouldNot {
39 return [NSString stringWithFormat:@"expected subject not to be zero"];
40}
41
42#pragma mark -
43#pragma mark Configuring Matchers
44
45- (void)beZero {
46}
47
48@end