yahelpers
Enhanced debugging functionality for the ya ecosystem
Loading...
Searching...
No Matches
Macros
Assertion macros

Macros for runtime-assertion. More...

Macros

#define ASSERT_DEFAULT   0
 Print timestamp of the assert and abort on error.
 
#define ASSERT_NO_ABORT   1
 Specifies whether the assert will abort on error.
 
#define ASSERT_NO_TIMESTAMP   2
 Specifies whether the assert will print a timestamp on error.
 
#define ASSERT_FOR_TESTS   4
 Specifies whether the assert is CMocka-compatible.
 
#define ASSERT(cond, opts)
 Prints a debug message if the condition cond is failed.
 

Detailed Description

Macros for runtime-assertion.

Macro Definition Documentation

◆ ASSERT

#define ASSERT (   cond,
  opts 
)
Value:
do { \
if (!(cond)) { \
if ((opts) & ASSERT_NO_TIMESTAMP) { \
LOG_DEBUG("ASSERT " #cond " failed !!!"); \
} else { \
time_t assert_time = time(NULL); \
LOG_DEBUG("[% ld ] ASSERT " #cond " failed !!!"); \
} \
if ((opts) & ASSERT_FOR_TESTS) { \
assert((cond)); \
} else if (!((opts) & ASSERT_NO_ABORT)) { \
abort(); \
} \
} \
} while (0)
#define ASSERT_NO_TIMESTAMP
Specifies whether the assert will print a timestamp on error.
Definition assert.h:31
#define ASSERT_NO_ABORT
Specifies whether the assert will abort on error.
Definition assert.h:28
#define ASSERT_FOR_TESTS
Specifies whether the assert is CMocka-compatible.
Definition assert.h:34

Prints a debug message if the condition cond is failed.

Parameters
condThe condition which is checked
optsThe option flags
See also
ASSERT_DEFAULT
ASSERT_NO_ABORT
ASSERT_NO_TIMESTAMP
ASSERT_FOR_TESTS

◆ ASSERT_DEFAULT

#define ASSERT_DEFAULT   0

Print timestamp of the assert and abort on error.

◆ ASSERT_FOR_TESTS

#define ASSERT_FOR_TESTS   4

Specifies whether the assert is CMocka-compatible.

◆ ASSERT_NO_ABORT

#define ASSERT_NO_ABORT   1

Specifies whether the assert will abort on error.

◆ ASSERT_NO_TIMESTAMP

#define ASSERT_NO_TIMESTAMP   2

Specifies whether the assert will print a timestamp on error.