Permalink
Browse files

Added tests demonstrating that the assert macros don’t cause extra si…

…de-effects.
  • Loading branch information...
1 parent f8f0f8e commit 6bc64fb19bd02e7bcb00a6ba013dcc93a7261d24 @robrix committed May 18, 2010
Showing with 24 additions and 1 deletion.
  1. +2 −0 RXAssertions.xcodeproj/project.pbxproj
  2. +22 −1 RXAssertionsTests.m
@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
+ D415F64311A28E060027AAD8 /* RXAssertionsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D442A48D106FD99700944F07 /* RXAssertionsTests.m */; };
D442A493106FD9BF00944F07 /* libRXAssertions.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC07E0554694100DB518D /* libRXAssertions.a */; };
D472095311581618003F9546 /* RXMockObjectTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D472095211581618003F9546 /* RXMockObjectTests.m */; };
D4C03B4A1063445800925A75 /* RXAssertions.h in Headers */ = {isa = PBXBuildFile; fileRef = D4C03B471063445800925A75 /* RXAssertions.h */; };
@@ -197,6 +198,7 @@
files = (
D472095311581618003F9546 /* RXMockObjectTests.m in Sources */,
D4CE0C55116FB8E400FE6B86 /* RXAssertionHelperTests.m in Sources */,
+ D415F64311A28E060027AAD8 /* RXAssertionsTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
@@ -4,11 +4,22 @@
#import "RXAssertions.h"
-@interface RXAssertionsTests : SenTestCase
+@interface RXAssertionsTests : SenTestCase {
+ NSUInteger incrementedValue;
+}
@end
@implementation RXAssertionsTests
+-(void)setUp {
+ incrementedValue = 0;
+}
+
+-(NSUInteger)incrementedValue {
+ return incrementedValue++;
+}
+
+#if RX_DEMONSTRATE_TEST_FAILURES
-(void)testDemonstrateFailures {
BOOL condition = NO;
RXAssert(condition);
@@ -25,7 +36,9 @@ -(void)testDemonstrateFailures {
object = nil;
RXAssertNotNil(object);
}
+#endif
+#if RX_DEMONSTRATE_TEST_FAILURES && RX_DEMONSTRATE_TEST_FAILURE_MESSAGES
-(void)testCanAddOptionalFailureMessages {
BOOL condition = NO;
RXAssert(condition, @"This is a demonstration of an %@ failure", @"RXAssert");
@@ -42,5 +55,13 @@ -(void)testCanAddOptionalFailureMessages {
object = nil;
RXAssertNotNil(object, @"This is a demonstration of an %@ failure.", @"RXAssertNotNil");
}
+#endif
+
+-(void)testDoesNotCauseExtraSideEffects {
+ RXAssert([self incrementedValue] == 0);
+ RXAssertFalse([self incrementedValue] == 0);
+ RXAssertEquals([self incrementedValue], 2);
+ RXAssertEquals([self incrementedValue], 3);
+}
@end

0 comments on commit 6bc64fb

Please sign in to comment.