KWBeIdenticalToMatcher.m 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // Licensed under the terms in License.txt
  3. //
  4. // Copyright 2010 Allen Ding. All rights reserved.
  5. //
  6. #import "KWBeIdenticalToMatcher.h"
  7. #import "KWFormatter.h"
  8. @interface KWBeIdenticalToMatcher()
  9. #pragma mark - Properties
  10. @property (nonatomic, readwrite, strong) id otherSubject;
  11. @end
  12. @implementation KWBeIdenticalToMatcher
  13. #pragma mark - Getting Matcher Strings
  14. + (NSArray *)matcherStrings {
  15. return @[@"beIdenticalTo:"];
  16. }
  17. #pragma mark - Matching
  18. - (BOOL)evaluate {
  19. return self.subject == self.otherSubject;
  20. }
  21. #pragma mark - Getting Failure Messages
  22. - (NSString *)failureMessageForShould {
  23. return [NSString stringWithFormat:@"expected subject to be identical to %@ (%p), got %@ (%p)",
  24. [KWFormatter formatObject:self.otherSubject],
  25. self.otherSubject,
  26. [KWFormatter formatObject:self.subject],
  27. self.subject];
  28. }
  29. - (NSString *)failureMessageForShouldNot {
  30. return [NSString stringWithFormat:@"expected subject not to be identical to %@ (%p)",
  31. [KWFormatter formatObject:self.otherSubject],
  32. self.otherSubject];
  33. }
  34. - (NSString *)description {
  35. return [NSString stringWithFormat:@"be identical to %@", self.otherSubject];
  36. }
  37. #pragma mark - Configuring Matchers
  38. - (void)beIdenticalTo:(id)anObject {
  39. self.otherSubject = anObject;
  40. }
  41. @end