libfsafe
0.1.1
eases writing fail-safe code (C++)
|
Contains declarations of assertion macros. More...
#include <libsex/utility.hxx>
#include <libfsafe/AssertionFailure.hxx>
#include <libfsafe/PreconditionViolation.hxx>
#include <libfsafe/PostconditionViolation.hxx>
Go to the source code of this file.
Defines | |
#define | ASSERT(expr) |
General assertion macro. | |
#define | ASSERT_PRE(expr) |
Macro to assert a precondition. | |
#define | ASSERT_POST(expr) |
Macro to assert a postcondition. |
Contains declarations of assertion macros.
Definition in file assert.hxx.
#define ASSERT | ( | expr | ) |
if (!(expr)) { \
throw libsex::formatted<libfsafe::AssertionFailure>(__FILE__, __LINE__, #expr); \
}
General assertion macro.
There are assertion macros for specific purposes. This one should only be used for internal checks.
expr | Condition to be asserted. |
libfsafe::AssertionFailure | if expr is false. |
Definition at line 26 of file assert.hxx.
#define ASSERT_POST | ( | expr | ) |
if (!(expr)) { \
throw libsex::formatted<libfsafe::PostconditionViolation>(__FILE__, __LINE__, #expr); \
}
Macro to assert a postcondition.
To be used to ensure that the result of a function/method is correct, i.e. the callee fulfilled its part of the contract.
expr | Condition to be asserted. |
libfsafe::PostconditionViolation | if expr is false. |
Definition at line 62 of file assert.hxx.
#define ASSERT_PRE | ( | expr | ) |
if (!(expr)) { \
throw libsex::formatted<libfsafe::PreconditionViolation>(__FILE__, __LINE__, #expr); \
}
Macro to assert a precondition.
To be used to ensure that a method/function is called the right way (e.g. parameter values, internal state).
In other words, assert that the callee fulfilled its part of the contract.
expr | Condition to be asserted. |
libfsafe::PreconditionViolation | if expr is false. |
Definition at line 45 of file assert.hxx.