| 1 |
#include <cstdio> |
| 2 |
|
| 3 |
#if __cplusplus >= 201103L |
| 4 |
#define BL_NOEXCEPT noexcept |
| 5 |
#else |
| 6 |
#define BL_NOEXCEPT throw() |
| 7 |
#endif |
| 8 |
|
| 9 |
#if defined __has_builtin |
| 10 |
# if __has_builtin (__builtin_LINE) |
| 11 |
# define VERIFY_LINE __builtin_LINE () |
| 12 |
# endif |
| 13 |
#endif |
| 14 |
#if !defined VERIFY_LINE |
| 15 |
# define VERIFY_LINE __LINE__ |
| 16 |
#endif |
| 17 |
|
| 18 |
/* I'm not a huge fan of macros but in the interest of keeping the code that |
| 19 |
isn't being tested as simple as possible, we use them. */ |
| 20 |
|
| 21 |
#define VERIFY(EXPR) \ |
| 22 |
do { \ |
| 23 |
if (!(EXPR)) \ |
| 24 |
{ \ |
| 25 |
std::printf("VERIFY ln: %d `" #EXPR "` evaluated to false\n", \ |
| 26 |
VERIFY_LINE); \ |
| 27 |
inner_ok = false; \ |
| 28 |
goto end; \ |
| 29 |
} \ |
| 30 |
} while (false) |
| 31 |
|
| 32 |
#define VERIFY_NON_TARGET(EXPR) \ |
| 33 |
do { \ |
| 34 |
if (!(EXPR)) \ |
| 35 |
{ \ |
| 36 |
std::printf("VERIFY ln: %d `" #EXPR "` evaluated to false\n", \ |
| 37 |
VERIFY_LINE); \ |
| 38 |
return false; \ |
| 39 |
} \ |
| 40 |
} while (false) |