STXXL
1.4-dev
|
There are quite a bunch of macros for testing assertions. You must be careful to pick the right one depending on when and what you want to assert on.
To check specific conditions at compile time use STXXL_STATIC_ASSERT.
Assertions in unit tests must use the following macros to ensure that the condition is also checked in release builds (where a plain "assert()"
is void). These CHECK
function should NOT be used to test return values, since we try to throw exceptions instead of aborting the program.
Sometimes one also wants to check that a specific expression throws an exception. This checking can be done automatically using a try { } catch {}
by using STXXL_CHECK_THROW.
For the usual assertions, that should be removed in production code for performance, we use the standard "assert()"
function.
However, there is also STXXL_ASSERT(), which can be used as a replacement for assert()
, when compiler warnings about unused variables or typedefs occur. The issue is that assert() completely removes the code, whereas STXXL_ASSERT() keeps the code encloses it inside if(0)
.