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... | |
#define | SIPLASPLAS_STATICASSERT_EQ(expr, expect) |
Defines an static equal to assertion. More... | |
#define | SIPLASPLAS_STATICASSERT_NE(expr, expect) |
Defines an static not equal to assertion. More... | |
#define | SIPLASPLAS_STATICASSERT_BT(expr, expect) |
Defines an static bigger than assertion. More... | |
#define | SIPLASPLAS_STATICASSERT_LT(expr, expect) |
Defines an static less than assertion. More... | |
#define | SIPLASPLAS_STATICASSERT_BE(expr, expect) |
Defines an static bigger or equal to assertion. More... | |
#define | SIPLASPLAS_STATICASSERT_LE(expr, expect) |
Defines an static less or equal to assertion. More... | |
#define | SIPLASPLAS_STATICASSERT_TRUE(expression) |
Defines an static true assertion. More... | |
#define | SIPLASPLAS_STATICASSERT_FALSE(expression) |
Defines an static 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 | ( | ... | ) |
Defines a false assertion.
The assertion success if the expression evaluates to false. Fails otherwise.
... | Assertion boolean expression |
#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 | ( | ... | ) |
Defines a true assertion.
The assertion success if the expression evaluates to true. Fails otherwise.
... | Assertion boolean expression |
#define SIPLASPLAS_STATICASSERT_BE | ( | expr, | |
expect | |||
) |
Defines an static bigger or equal to assertion.
Compilation fails if the first operand (expression) is not bigger or equal to the second (expected). The comparison (operator>=
) must be a constant expression.
#define SIPLASPLAS_STATICASSERT_BT | ( | expr, | |
expect | |||
) |
Defines an static bigger than assertion.
Compilation fails if the first operand (expression) is not bigger than the second (expected). The bigger than comparison (operator>
) must be a constant expression.
#define SIPLASPLAS_STATICASSERT_EQ | ( | expr, | |
expect | |||
) |
Defines an static equal to assertion.
Compilation fails if the first operand (expression) is not equal to the second (expected). The equality comparison (operator==
) must be a constant expression.
#define SIPLASPLAS_STATICASSERT_FALSE | ( | expression | ) |
Defines an static false assertion.
Compilation fails if the expression does not evauate to false. The expression must be a constant expression.
#define SIPLASPLAS_STATICASSERT_LE | ( | expr, | |
expect | |||
) |
Defines an static less or equal to assertion.
Compilation fails if the first operand (expression) is not less or equal to the second (expected). The comparison (operator<=
) must be a constant expression.
#define SIPLASPLAS_STATICASSERT_LT | ( | expr, | |
expect | |||
) |
Defines an static less than assertion.
Compilation fails if the first operand (expression) is not less than the second (expected). The less than comparison (operator<
) must be a constant expression.
#define SIPLASPLAS_STATICASSERT_NE | ( | expr, | |
expect | |||
) |
Defines an static not equal to assertion.
Compilation fails if the first operand (expression) is equal to the second (expected). The inequality comparison (operator!=
) must be a constant expression.
#define SIPLASPLAS_STATICASSERT_TRUE | ( | expression | ) |
Defines an static true assertion.
Compilation fails if the expression does not evauate to true. The expression must be a constant expression.