libfsafe  0.1.1
eases writing fail-safe code (C++)
Defines
/home/ptr/dev/dev-libs/libfsafe/libfsafe/assert.hxx File Reference

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.

Detailed Description

Contains declarations of assertion macros.

Definition in file assert.hxx.


Define Documentation

#define ASSERT (   expr)
Value:
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.

Parameters:
exprCondition to be asserted.
Exceptions:
libfsafe::AssertionFailureif expr is false.
See also:
ASSERT_PRE
ASSERT_POST

Definition at line 26 of file assert.hxx.

#define ASSERT_POST (   expr)
Value:
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.

Parameters:
exprCondition to be asserted.
Exceptions:
libfsafe::PostconditionViolationif expr is false.
See also:
ASSERT_PRE
ASSERT

Definition at line 62 of file assert.hxx.

#define ASSERT_PRE (   expr)
Value:
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.

Parameters:
exprCondition to be asserted.
Exceptions:
libfsafe::PreconditionViolationif expr is false.
See also:
ASSERT
ASSERT_POST

Definition at line 45 of file assert.hxx.

 All Classes Files Defines