Skip to content
Permalink
Browse files

Add XCTAssertAsserts

XCTAssertAsserts is for testing if NSAssert or NSParameterAssert is called.
It is a no-op if NS_BLOCK_ASSERTIONS is defined.
Update project to match "Xcode" standard with regards to having assertions off in release.
  • Loading branch information...
dmaclach authored and thomasvl committed May 20, 2019
1 parent 6aa9324 commit 80704a61eab151018384000d4e83f7f512ee55f5
@@ -1407,6 +1407,7 @@
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
@@ -823,6 +823,7 @@
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
@@ -350,6 +350,22 @@
})
#endif // XCTAssertNotEqualCStrings

/*!
* @define XCTAssertAsserts(expression, ...)
* Generates a failure when ((\a expression) does not assert.
* If NS_BLOCK_ASSERTIONS is enabled, this test will always pass.
* @param expression An expression.
* @param ... An optional supplementary description of the failure. A literal NSString, optionally
with string format specifiers. This parameter can be completely omitted.
*/
#ifndef NS_BLOCK_ASSERTIONS
#define XCTAssertAsserts(expression, ...) \
_XCTPrimitiveAssertThrowsSpecificNamed(self, expression, @#expression, NSException, \
NSInternalInconsistencyException, __VA_ARGS__)
#else
#define XCTAssertAsserts(expression, ...)
#endif

#else // GTM_USING_XCTEST

// Generates a failure when a1 != noErr
@@ -80,3 +80,18 @@ - (void)testZZZCheck {
}

@end

@interface GTMSenTestCase : GTMTestCase
@end

@implementation GTMSenTestCase
- (void)funcThatAsserts {
NSAssert(nil, @"Should be nil");
}

- (void)testXCTAssertAsserts {
XCTAssertAsserts([self funcThatAsserts]);
}

@end

0 comments on commit 80704a6

Please sign in to comment.
You can’t perform that action at this time.