qxLib
Macros
assert.h File Reference
#include <qx/algo/predicates.h>
#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_EXPECT(condition, ...)
 Verifies that condition is true. 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_NO_ENTRY   !QX_TEXT("No entry")
 Use this as a condition in any macro above to indicate that this part of your code must never be executed.
 
#define QX_NOT_IMPLEMENTED   !QX_TEXT("Not implemented")
 Use this as a condition in any macro above to indicate that this part of your code is not ready yet.
 
#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 237 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 255 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 291 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 351 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 371 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 273 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 310 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 330 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:255
#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:411

Definition at line 411 of file assert.h.