qxLib
Macros
assert.h File Reference
#include <qx/category.h>
#include <qx/logger/logger.h>
#include <exception>

Go to the source code of this file.

Macros

#define QX_ASSERT(condition, ...)
 Verifies that condition is true. More...
 
#define QX_ASSERT_NO_ENTRY(...)    _QX_ASSERT_NO_ENTRY(QX_ASSERT_BEFORE_DEBUG_BREAK, QX_ASSERT_DEBUG_BREAK, QX_ASSERT_AFTER_DEBUG_BREAK, ##__VA_ARGS__)
 Fails unconditionally if this code should not be executed. More...
 
#define QX_ASSERT_NOT_IMPLEMENTED(...)
 Fails unconditionally if this code should not be executed with "Not implemented" message. More...
 
#define QX_EXPECT(condition, ...)
 Verifies that condition is true. More...
 
#define QX_EXPECT_NO_ENTRY(...)    _QX_ASSERT_NO_ENTRY(QX_EXPECT_BEFORE_DEBUG_BREAK, QX_EXPECT_DEBUG_BREAK, QX_EXPECT_AFTER_DEBUG_BREAK, ##__VA_ARGS__)
 Fails unconditionally if this code should not be executed. More...
 
#define QX_EXPECT_NOT_IMPLEMENTED(...)
 Fails unconditionally if this code should not be executed with "Not implemented" message. More...
 
#define QX_EXPECT_CONTINUE(condition, ...)
 Verifies that condition is true and continues loop if false. More...
 
#define QX_EXPECT_BREAK(condition, ...)
 Verifies that condition is true and break loop if false. More...
 
#define QX_EXPECT_RETURN(condition, return_value, ...)
 Verifies that condition is true and "return return_value;" if false. More...
 
#define QX_EXPECT_RETURN_VOID(condition, ...)
 Verifies that condition is true and "return;" if false. More...
 
#define QX_EXPECT_CO_RETURN(condition, return_value, ...)
 Verifies that condition is true and "co_return return_value;" if false. More...
 
#define QX_EXPECT_CO_RETURN_VOID(condition, ...)
 Verifies that condition is true and "co_return;" if false. More...
 
#define QX_PREDICATE_HIT_ONCE()
 Predicate to add to a condition in any EXPECT macro. When added, a macro will only hit once. More...
 

Detailed Description

Author
Khrapov
Date
29.10.2020

Definition in file assert.h.

Macro Definition Documentation

◆ QX_ASSERT

#define QX_ASSERT (   condition,
  ... 
)
Value:
_QX_ASSERT( \
QX_ASSERT_BEFORE_DEBUG_BREAK, \
QX_ASSERT_DEBUG_BREAK, \
QX_ASSERT_AFTER_DEBUG_BREAK, \
condition, \
##__VA_ARGS__)

Verifies that condition is true.

ASSERT macros generate fatal failures and abort the program execution

Parameters
condition- condition to check. if false, assert fails
...- "category + format string + format arguments" or "category + format string" or "format string + format arguments" or "format string" or "category"

Definition at line 253 of file assert.h.

◆ QX_ASSERT_NO_ENTRY

#define QX_ASSERT_NO_ENTRY (   ...)     _QX_ASSERT_NO_ENTRY(QX_ASSERT_BEFORE_DEBUG_BREAK, QX_ASSERT_DEBUG_BREAK, QX_ASSERT_AFTER_DEBUG_BREAK, ##__VA_ARGS__)

Fails unconditionally if this code should not be executed.

ASSERT macros generate fatal failures and abort the program execution

Parameters
...- nothing or "category"

Definition at line 266 of file assert.h.

◆ QX_ASSERT_NOT_IMPLEMENTED

#define QX_ASSERT_NOT_IMPLEMENTED (   ...)
Value:
_QX_ASSERT_NOT_IMPLEMENTED( \
QX_ASSERT_BEFORE_DEBUG_BREAK, \
QX_ASSERT_DEBUG_BREAK, \
QX_ASSERT_AFTER_DEBUG_BREAK, \
##__VA_ARGS__)

Fails unconditionally if this code should not be executed with "Not implemented" message.

ASSERT macros generate fatal failures and abort the program execution

Parameters
...- nothing or "category"

Definition at line 274 of file assert.h.

◆ QX_EXPECT

#define QX_EXPECT (   condition,
  ... 
)
Value:
_QX_ASSERT( \
QX_EXPECT_BEFORE_DEBUG_BREAK, \
QX_EXPECT_DEBUG_BREAK, \
QX_EXPECT_AFTER_DEBUG_BREAK, \
condition, \
##__VA_ARGS__)

Verifies that condition is true.

EXPECT macros generate nonfatal failures and allow to continue running

Parameters
condition- condition to check. if false, assert fails
...- "category + format string + format arguments" or "category + format string" or "format string + format arguments" or "format string" or "category"

Definition at line 291 of file assert.h.

◆ QX_EXPECT_BREAK

#define QX_EXPECT_BREAK (   condition,
  ... 
)
Value:
_QX_ASSERT_BREAK( \
QX_EXPECT_BEFORE_DEBUG_BREAK, \
QX_EXPECT_DEBUG_BREAK, \
QX_EXPECT_AFTER_DEBUG_BREAK, \
condition, \
##__VA_ARGS__)

Verifies that condition is true and break loop if false.

EXPECT macros generate nonfatal failures and allow to continue running

Parameters
condition- condition to check. if false, assert fails
...- "category + format string + format arguments" or "category + format string" or "format string + format arguments" or "format string" or "category"

Definition at line 347 of file assert.h.

◆ QX_EXPECT_CO_RETURN

#define QX_EXPECT_CO_RETURN (   condition,
  return_value,
  ... 
)
Value:
_QX_ASSERT_RETURN( \
QX_EXPECT_BEFORE_DEBUG_BREAK, \
QX_EXPECT_DEBUG_BREAK, \
QX_EXPECT_AFTER_DEBUG_BREAK, \
co_return, \
condition, \
return_value, \
##__VA_ARGS__)

Verifies that condition is true and "co_return return_value;" if false.

EXPECT macros generate nonfatal failures and allow to continue running

Parameters
condition- condition to check. if false, assert fails
return_value- return value. use empty argument, if return type is void
...- "category + format string + format arguments" or "category + format string" or "format string + format arguments" or "format string" or "category"

Definition at line 407 of file assert.h.

◆ QX_EXPECT_CO_RETURN_VOID

#define QX_EXPECT_CO_RETURN_VOID (   condition,
  ... 
)
Value:
_QX_ASSERT_RETURN( \
QX_EXPECT_BEFORE_DEBUG_BREAK, \
QX_EXPECT_DEBUG_BREAK, \
QX_EXPECT_AFTER_DEBUG_BREAK, \
co_return, \
condition, \
, \
##__VA_ARGS__)

Verifies that condition is true and "co_return;" if false.

EXPECT macros generate nonfatal failures and allow to continue running

Parameters
condition- condition to check. if false, assert fails
...- "category + format string + format arguments" or "category + format string" or "format string + format arguments" or "format string" or "category"

Definition at line 427 of file assert.h.

◆ QX_EXPECT_CONTINUE

#define QX_EXPECT_CONTINUE (   condition,
  ... 
)
Value:
_QX_ASSERT_CONTINUE( \
QX_EXPECT_BEFORE_DEBUG_BREAK, \
QX_EXPECT_DEBUG_BREAK, \
QX_EXPECT_AFTER_DEBUG_BREAK, \
condition, \
##__VA_ARGS__)

Verifies that condition is true and continues loop if false.

EXPECT macros generate nonfatal failures and allow to continue running

Parameters
condition- condition to check. if false, assert fails
...- "category + format string + format arguments" or "category + format string" or "format string + format arguments" or "format string" or "category"

Definition at line 329 of file assert.h.

◆ QX_EXPECT_NO_ENTRY

#define QX_EXPECT_NO_ENTRY (   ...)     _QX_ASSERT_NO_ENTRY(QX_EXPECT_BEFORE_DEBUG_BREAK, QX_EXPECT_DEBUG_BREAK, QX_EXPECT_AFTER_DEBUG_BREAK, ##__VA_ARGS__)

Fails unconditionally if this code should not be executed.

EXPECT macros generate nonfatal failures and allow to continue running

Parameters
...- nothing or "category"

Definition at line 304 of file assert.h.

◆ QX_EXPECT_NOT_IMPLEMENTED

#define QX_EXPECT_NOT_IMPLEMENTED (   ...)
Value:
_QX_ASSERT_NOT_IMPLEMENTED( \
QX_EXPECT_BEFORE_DEBUG_BREAK, \
QX_EXPECT_DEBUG_BREAK, \
QX_EXPECT_AFTER_DEBUG_BREAK, \
##__VA_ARGS__)

Fails unconditionally if this code should not be executed with "Not implemented" message.

EXPECT macros generate nonfatal failures and allow to continue running

Parameters
...- nothing or "category"

Definition at line 312 of file assert.h.

◆ QX_EXPECT_RETURN

#define QX_EXPECT_RETURN (   condition,
  return_value,
  ... 
)
Value:
_QX_ASSERT_RETURN( \
QX_EXPECT_BEFORE_DEBUG_BREAK, \
QX_EXPECT_DEBUG_BREAK, \
QX_EXPECT_AFTER_DEBUG_BREAK, \
return, \
condition, \
return_value, \
##__VA_ARGS__)

Verifies that condition is true and "return return_value;" if false.

EXPECT macros generate nonfatal failures and allow to continue running

Parameters
condition- condition to check. if false, assert fails
return_value- return value. use empty argument, if return type is void
...- "category + format string + format arguments" or "category + format string" or "format string + format arguments" or "format string" or "category"

Definition at line 366 of file assert.h.

◆ QX_EXPECT_RETURN_VOID

#define QX_EXPECT_RETURN_VOID (   condition,
  ... 
)
Value:
_QX_ASSERT_RETURN( \
QX_EXPECT_BEFORE_DEBUG_BREAK, \
QX_EXPECT_DEBUG_BREAK, \
QX_EXPECT_AFTER_DEBUG_BREAK, \
return, \
condition, \
, \
##__VA_ARGS__)

Verifies that condition is true and "return;" if false.

EXPECT macros generate nonfatal failures and allow to continue running

Parameters
condition- condition to check. if false, assert fails
...- "category + format string + format arguments" or "category + format string" or "format string + format arguments" or "format string" or "category"

Definition at line 386 of file assert.h.

◆ QX_PREDICATE_HIT_ONCE

#define QX_PREDICATE_HIT_ONCE ( )
Value:
[]() \
{ \
static bool h = false; \
return qx::details::hit_once(h); \
}()

Predicate to add to a condition in any EXPECT macro. When added, a macro will only hit once.

Note
It must be after the actual condition.
QX_EXPECT((a > b || b == 0) || QX_PREDICATE_HIT_ONCE());
#define QX_EXPECT(condition,...)
Verifies that condition is true.
Definition: assert.h:291
#define QX_PREDICATE_HIT_ONCE()
Predicate to add to a condition in any EXPECT macro. When added, a macro will only hit once.
Definition: assert.h:457

Definition at line 457 of file assert.h.