OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
DefensiveProgramming.h
Go to the documentation of this file.
1#pragma once
2#include <cassert>
3
4#ifdef _DEBUG
5#define ASSERT(condition){ \
6 if (!(condition)) \
7 { \
8 assert(false); \
9 } \
10 }
11#else
12#define ASSERT(condition)
13#endif // _DEBUG
14
15 // Checks the invariant method of a class.
16 // Method shall be protected and inline.
17 // Should be executed before and after a method is executed.
18#define INVARIANT ASSERT(invariant())
19
20#define POST(condition){ \
21 ASSERT(condition); \
22 INVARIANT; \
23}
24
25#define PRE(condition){ \
26 INVARIANT; \
27 ASSERT(condition); \
28}