diff --git a/tc/base/assert_defs.h b/tc/base/assert_defs.h index e87050c..5813f4b 100644 --- a/tc/base/assert_defs.h +++ b/tc/base/assert_defs.h @@ -14,11 +14,17 @@ #include "fundamental.h" #include #include - #include - #define _CHECKS + #ifndef _CHECKS + #define _CHECKS + #endif + #ifndef IF_TC_CHECKS - #define IF_TC_CHECKS(...) __VA_ARGS__ + #ifdef _CHECKS + #define IF_TC_CHECKS(...) __VA_ARGS__ + #else + #define IF_TC_CHECKS(...) + #endif #endif #ifndef IF_TC_DEBUG #ifdef _DEBUG @@ -27,9 +33,14 @@ #define IF_TC_DEBUG(...) #endif #endif + #ifndef _ASSERT - #include - #define _ASSERT(...) assert(TC_FWD(__VA_ARGS__)) + #ifdef NDEBUG + #define _ASSERT(...) IF_TC_CHECKS(TC_FWD(__VA_ARGS__) ? (void)0 : std::abort()) + #else + #include + #define _ASSERT(...) IF_TC_CHECKS(assert(TC_FWD(__VA_ARGS__))) + #endif #endif #ifndef TRYASSERT #define TRYASSERT _ASSERT @@ -59,14 +70,14 @@ #define _ASSERTENOTIFY _ASSERTE #endif #ifndef _ASSERTEQUAL - #define _ASSERTEQUAL(a, b) assert((a)==(b)) + #define _ASSERTEQUAL(a, b) _ASSERT((a)==(b)) #endif #ifndef _ASSERTDEBUGEQUAL #define _ASSERTDEBUGEQUAL(a, b) IF_TC_DEBUG(_ASSERTEQUAL(a, b)) #endif #ifndef _ASSERTANYOF #include - #define _ASSERTANYOF(expr, values) [](auto const& e, auto const&... val) noexcept { assert( ((e == val) || ...) ); }(expr, BOOST_PP_SEQ_ENUM(values)) + #define _ASSERTANYOF(expr, values) [](auto const& e, auto const&... val) noexcept { _ASSERT( ((e == val) || ...) ); }(expr, BOOST_PP_SEQ_ENUM(values)) #endif #ifndef _ASSERTDEBUGANYOF #define _ASSERTDEBUGANYOF(expr, values) IF_TC_DEBUG(_ASSERTANYOF(expr, values)) @@ -75,7 +86,7 @@ #define _ASSERTINITIALIZED( expr ) tc::discard(expr) #endif #ifndef _ASSERTPRINT - #define _ASSERTPRINT( cond, ... ) assert( cond ) + #define _ASSERTPRINT( cond, ... ) _ASSERT( cond ) #endif #ifndef VERIFYEQUAL #include diff --git a/tc/range/concat_adaptor.t.cpp b/tc/range/concat_adaptor.t.cpp index eb92ceb..5cb800a 100644 --- a/tc/range/concat_adaptor.t.cpp +++ b/tc/range/concat_adaptor.t.cpp @@ -76,7 +76,7 @@ UNITTESTDEF(concat_index_test) { tc::vector vecn; - _ASSERTEQUAL(tc::break_, tc::for_each( + VERIFYEQUAL(tc::break_, tc::for_each( tc::filter( tc::reverse( tc::concat(