main
 1//
 2// Licensed under the terms in License.txt
 3//
 4// Copyright 2010 Allen Ding. All rights reserved.
 5//
 6
 7#import "KWBeIdenticalToMatcher.h"
 8#import "KWFormatter.h"
 9
10@interface KWBeIdenticalToMatcher()
11
12#pragma mark -
13#pragma mark Properties
14
15@property (nonatomic, readwrite, retain) id otherSubject;
16
17@end
18
19@implementation KWBeIdenticalToMatcher
20
21#pragma mark -
22#pragma mark Initializing
23
24- (void)dealloc {
25    [otherSubject release];
26    [super dealloc];
27}
28
29#pragma mark -
30#pragma mark Properties
31
32@synthesize otherSubject;
33
34#pragma mark -
35#pragma mark Getting Matcher Strings
36
37+ (NSArray *)matcherStrings {
38    return @[@"beIdenticalTo:"];
39}
40
41#pragma mark -
42#pragma mark Matching
43
44- (BOOL)evaluate {
45    return self.subject == self.otherSubject;
46}
47
48#pragma mark -
49#pragma mark Getting Failure Messages
50
51- (NSString *)failureMessageForShould {
52    return [NSString stringWithFormat:@"expected subject to be identical to %@ (%p), got %@ (%p)",
53                                      [KWFormatter formatObject:self.otherSubject],
54                                      self.otherSubject,
55                                      [KWFormatter formatObject:self.subject],
56                                      self.subject];
57}
58
59- (NSString *)failureMessageForShouldNot {
60    return [NSString stringWithFormat:@"expected subject not to be identical to %@ (%p)",
61                                      [KWFormatter formatObject:self.otherSubject],
62                                      self.otherSubject];
63}
64
65- (NSString *)description
66{
67  return [NSString stringWithFormat:@"be identical to %@", self.otherSubject];
68}
69
70#pragma mark -
71#pragma mark Configuring Matchers
72
73- (void)beIdenticalTo:(id)anObject {
74    self.otherSubject = anObject;
75}
76
77@end