Permalink
Browse files

Merge pull request #243 from sharplet/pointer-value-macro

Add thePointerValue() macro
  • Loading branch information...
2 parents 0216268 + d52076d commit f5ee8cf5399aa4efb373c5e6da9fedb3fa8f1feb Marin Usalj committed Mar 25, 2013
Showing with 19 additions and 0 deletions.
  1. +3 −0 Classes/KiwiMacros.h
  2. +16 −0 Tests/KWEqualMatcherTest.m
@@ -60,6 +60,9 @@
})
#endif // #if defined(__GNUC__)
+// Allows for comparision of pointer values in expectations
+#define thePointerValue(expr) [NSValue valueWithPointer:(expr)]
+
// Example group declarations.
#define SPEC_BEGIN(name) \
\
@@ -58,6 +58,22 @@ - (void)testItShouldMatchKiwiBoxedValuesWithNumberBoxedValues {
STAssertTrue([matcher evaluate], @"expected positive match");
}
+- (void)testItShouldMatchEqualPointerValues
+{
+ int subject = 123;
+ id matcher = [KWEqualMatcher matcherWithSubject:thePointerValue(&subject)];
+ [matcher equal:thePointerValue(&subject)];
+ STAssertTrue([matcher evaluate], @"expected positive match");
+}
+
+- (void)testItShouldNotMatchUnequalPointerValues
+{
+ int subject = 123;
+ id matcher = [KWEqualMatcher matcherWithSubject:thePointerValue(&subject)];
+ [matcher equal:thePointerValue(NULL)];
+ STAssertFalse([matcher evaluate], @"expected negative match");
+}
+
- (void)testItShouldHaveHumanReadableDescription
{
id matcher = [KWEqualMatcher matcherWithSubject:theValue(123)];

0 comments on commit f5ee8cf

Please sign in to comment.