siplasplas
A library for C++ reflection and introspection
|
Assertion utilities. More...
Classes | |
class | cpp::AssertException |
Represents an assertion error. More... | |
class | cpp::AssertExpression |
Implements a siplasplas assertion. More... | |
class | cpp::DummyAssertExpression |
Represents an assert expression when SIPLASPLAS_ASSERT() macros are disabled. More... | |
Macros | |
#define | SIPLASPLAS_ASSERT(...) |
Defines an assertion expression. More... | |
#define | SIPLASPLAS_ASSERT_COMP_IMPL(a, b, op, wording) |
Implements a comparison assertion. More... | |
#define | SIPLASPLAS_ASSERT_EQ(a, b) |
Defines an equal to assertion. More... | |
#define | SIPLASPLAS_ASSERT_NE(a, b) |
Defines a not equal to assertion. More... | |
#define | SIPLASPLAS_ASSERT_BT(a, b) |
Defines a bigger than assertion. More... | |
#define | SIPLASPLAS_ASSERT_LT(a, b) |
Defines a less than assertion. More... | |
#define | SIPLASPLAS_ASSERT_BE(a, b) |
Defines a bigger or equal assertion. More... | |
#define | SIPLASPLAS_ASSERT_LE(a, b) |
Defines a less or equal assertion. More... | |
#define | SIPLASPLAS_ASSERT_TRUE(...) |
Defines a true assertion. More... | |
#define | SIPLASPLAS_ASSERT_FALSE(...) |
Defines a false assertion. More... | |
Assertion utilities.
#define SIPLASPLAS_ASSERT | ( | ... | ) |
Defines an assertion expression.
When NDEBUG
is not defined, this macro is defined to instance a cpp::AssertExpression object. Else it instances a cpp::DummyAssertExpression object which does nothing.
__VA_ARGS__ | Parameters for the underlying assertion expression constructor. See cpp::AssertExpression and cpp::DummyAssertExpression. |
#define SIPLASPLAS_ASSERT_BE | ( | a, | |
b | |||
) |
Defines a bigger or equal assertion.
The assertion success if a
is bigger or equal to b
. Fails otherwise. The comparison is done by means of operator>=(a, b)
.
a | First value to compare. |
b | Second value to compare. |
Compared values must be printable by the fmt library. This can be achieved by implementing operator<<(std::ostream&, const T&)
#define SIPLASPLAS_ASSERT_BT | ( | a, | |
b | |||
) |
Defines a bigger than assertion.
The assertion success if a
is bigger than b
. Fails otherwise. The comparison is done by means of operator>(a, b)
.
a | First value to compare. |
b | Second value to compare. |
Compared values must be printable by the fmt library. This can be achieved by implementing operator<<(std::ostream&, const T&)
#define SIPLASPLAS_ASSERT_COMP_IMPL | ( | a, | |
b, | |||
op, | |||
wording | |||
) |
Implements a comparison assertion.
This macro builds a detailed assertion expression for expressions that compare two values using an specific comparison operator. The resulting diagnostic message is of the form:
So for an example assertion like this:
returns a diagnostic like the following:
This macro is used by siplasplas to implement comparison assertion macros for different comparison operators.
Compared values must be printable by the fmt library. This can be achieved by implementing operator<<(std::ostream&, const T&)
#define SIPLASPLAS_ASSERT_EQ | ( | a, | |
b | |||
) |
Defines an equal to assertion.
The assertion success if a
and b
are equal. Fails otherwise. Equality is tested using operator==(a, b)
.
a | First value to compare. |
b | Second value to compare. |
Compared values must be printable by the fmt library. This can be achieved by implementing operator<<(std::ostream&, const T&)
#define SIPLASPLAS_ASSERT_FALSE | ( | ... | ) |
#define SIPLASPLAS_ASSERT_LE | ( | a, | |
b | |||
) |
Defines a less or equal assertion.
The assertion success if a
is less or equal to b
. Fails otherwise. Comparison is done by means of operator<=(a, b)
.
a | First value to compare. |
b | Second value to compare. |
Compared values must be printable by the fmt library. This can be achieved by implementing operator<<(std::ostream&, const T&)
#define SIPLASPLAS_ASSERT_LT | ( | a, | |
b | |||
) |
Defines a less than assertion.
The assertion success if a
is less than b
. Fails otherwise. Comparison is done by means of operator<(a, b)
.
a | First value to compare. |
b | Second value to compare. |
Compared values must be printable by the fmt library. This can be achieved by implementing operator<<(std::ostream&, const T&)
#define SIPLASPLAS_ASSERT_NE | ( | a, | |
b | |||
) |
Defines a not equal to assertion.
The assertion success if a
and b
are not equal. Fails otherwise. Inequality is tested using operator!=(a, b)
.
a | First value to compare. |
b | Second value to compare. |
Compared values must be printable by the fmt library. This can be achieved by implementing operator<<(std::ostream&, const T&)
#define SIPLASPLAS_ASSERT_TRUE | ( | ... | ) |