claw 1.9.0
 
Loading...
Searching...
No Matches
assert.hpp File Reference

Some assert macros to strengthen you code. More...

#include <cstdlib>
#include <iostream>
#include <sstream>
Include dependency graph for assert.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  claw
 This is the main namespace.
 

Macros

#define CLAW_ASSERT(b, s)
 Print a message on std::cerr and stop the program if a condition is not true.
 
#define CLAW_FAIL(s)
 Print a message on std::cerr and stop the program.
 
#define CLAW_PRECOND(b)
 Abort the program if a precondition is not true.
 
#define CLAW_POSTCOND(b)
 Abort the program if a postcondition is not true.
 

Functions

void claw::debug_assert (const char *file, const char *func, unsigned int line, bool b, const std::string &s)
 The method used by CLAW_ASSERT macro. Souldn't be used elsewhere.
 

Detailed Description

Some assert macros to strengthen you code.

Author
Julien Jorge

Definition in file assert.hpp.

Macro Definition Documentation

◆ CLAW_ASSERT

#define CLAW_ASSERT ( b,
s )
Value:
claw::debug_assert(__FILE__, __FUNCTION__, __LINE__, (b), (s))
void debug_assert(const char *file, const char *func, unsigned int line, bool b, const std::string &s)
The method used by CLAW_ASSERT macro. Souldn't be used elsewhere.
Definition assert.hpp:72

Print a message on std::cerr and stop the program if a condition is not true.

Parameters
bCondition to verify.
sAn error message.

Definition at line 88 of file assert.hpp.

◆ CLAW_FAIL

#define CLAW_FAIL ( s)
Value:
claw::debug_assert(__FILE__, __FUNCTION__, __LINE__, false, (s))

Print a message on std::cerr and stop the program.

Parameters
sAn error message.

Definition at line 91 of file assert.hpp.

◆ CLAW_POSTCOND

#define CLAW_POSTCOND ( b)
Value:
CLAW_ASSERT(b, "postcondition failed: " #b)
#define CLAW_ASSERT(b, s)
Print a message on std::cerr and stop the program if a condition is not true.
Definition assert.hpp:88

Abort the program if a postcondition is not true.

Parameters
bCondition to verify.

Definition at line 96 of file assert.hpp.

◆ CLAW_PRECOND

#define CLAW_PRECOND ( b)
Value:
CLAW_ASSERT(b, "precondition failed: " #b)

Abort the program if a precondition is not true.

Parameters
bCondition to verify.

Definition at line 94 of file assert.hpp.