ZeroErr
载入中...
搜索中...
未找到
assert.h 文件参考
#include "zeroerr/internal/config.h"
#include "zeroerr/format.h"
#include "zeroerr/internal/debugbreak.h"
#include "zeroerr/internal/decomposition.h"
#include "zeroerr/print.h"
#include <cstdint>
#include <exception>
assert.h 的引用(Include)关系图:
此图展示该文件被哪些文件直接或间接地引用了:

浏览该文件的源代码.

类

struct  zeroerr::assert_info
 This is a one-byte assert info struct, which is used to collect the meta info of an assertion 更多...
struct  zeroerr::AssertionData
 AssertionData is a struct that contains all the information of an assertion. It will be thrown as an exception when the assertion failed. 更多...
struct  zeroerr::detail::context_helper< T, true >
struct  zeroerr::detail::context_helper< T, false >

命名空间

namespace  ZEROERR_CLANG_SUPPRESS_WARNING_POP
namespace  zeroerr
namespace  zeroerr::detail

宏定义

#define ZEROERR_G_CONTEXT_SCOPE(x)
#define ZEROERR_PRINT_ASSERT_DEFAULT_PRINTER(cond, level, ...)
 Default printer for assertion messages
#define ZEROERR_PRINT_ASSERT(cond, level, pattern, ...)
#define ZEROERR_ASSERT_EXP(cond, level, expect_throw, is_false, ...)
#define ZEROERR_ASSERT_CMP(lhs, op, rhs, level, expect_throw, is_false, ...)
#define ZEROERR_CHECK_LEVEL   ZEROERR_WARN
#define ZEROERR_CHECK(cond, ...)
#define ZEROERR_CHECK_NOT(cond, ...)
#define ZEROERR_CHECK_THROWS(cond, ...)
#define ZEROERR_REQUIRE(cond, ...)
#define ZEROERR_REQUIRE_NOT(cond, ...)
#define ZEROERR_REQUIRE_THROWS(cond, ...)
#define ZEROERR_ASSERT(cond, ...)
#define ZEROERR_ASSERT_NOT(cond, ...)
#define ZEROERR_ASSERT_THROWS(cond, ...)
#define CHECK(...)
#define CHECK_NOT(...)
#define CHECK_THROWS(...)
#define REQUIRE(...)
#define REQUIRE_NOT(...)
#define REQUIRE_THROWS(...)
#define ASSERT(...)
#define ASSERT_NOT(...)
#define ASSERT_THROWS(...)
#define ZEROERR_CHECK_EQ(lhs, rhs, ...)
#define ZEROERR_CHECK_NE(lhs, rhs, ...)
#define ZEROERR_CHECK_LT(lhs, rhs, ...)
#define ZEROERR_CHECK_LE(lhs, rhs, ...)
#define ZEROERR_CHECK_GT(lhs, rhs, ...)
#define ZEROERR_CHECK_GE(lhs, rhs, ...)
#define ZEROERR_REQUIRE_EQ(lhs, rhs, ...)
#define ZEROERR_REQUIRE_NE(lhs, rhs, ...)
#define ZEROERR_REQUIRE_LT(lhs, rhs, ...)
#define ZEROERR_REQUIRE_LE(lhs, rhs, ...)
#define ZEROERR_REQUIRE_GT(lhs, rhs, ...)
#define ZEROERR_REQUIRE_GE(lhs, rhs, ...)
#define ZEROERR_ASSERT_EQ(lhs, rhs, ...)
#define ZEROERR_ASSERT_NE(lhs, rhs, ...)
#define ZEROERR_ASSERT_LT(lhs, rhs, ...)
#define ZEROERR_ASSERT_LE(lhs, rhs, ...)
#define ZEROERR_ASSERT_GT(lhs, rhs, ...)
#define ZEROERR_ASSERT_GE(lhs, rhs, ...)
#define CHECK_EQ(...)
#define CHECK_NE(...)
#define CHECK_LT(...)
#define CHECK_LE(...)
#define CHECK_GT(...)
#define CHECK_GE(...)
#define REQUIRE_EQ(...)
#define REQUIRE_NE(...)
#define REQUIRE_LT(...)
#define REQUIRE_LE(...)
#define REQUIRE_GT(...)
#define REQUIRE_GE(...)
#define ASSERT_EQ(...)
#define ASSERT_NE(...)
#define ASSERT_LT(...)
#define ASSERT_LE(...)
#define ASSERT_GT(...)
#define ASSERT_GE(...)

枚举

enum class  zeroerr::assert_level : uint8_t { zeroerr::ZEROERR_WARN_l , zeroerr::ZEROERR_ERROR_l , zeroerr::ZEROERR_FATAL_l }
enum class  zeroerr::assert_throw : uint8_t { zeroerr::no_throw , zeroerr::throws , zeroerr::throws_as }
enum class  zeroerr::assert_cmp : uint8_t {
  zeroerr::eq , zeroerr::ne , zeroerr::gt , zeroerr::ge ,
  zeroerr::lt , zeroerr::le
}

变量

constexpr bool ZEROERR_CLANG_SUPPRESS_WARNING_POP::_ZEROERR_TEST_CONTEXT = false

宏定义说明

◆ ASSERT

#define ASSERT ( ...)
值:
#define ZEROERR_ASSERT(cond,...)
定义 assert.h:163
#define ZEROERR_SUPPRESS_VARIADIC_MACRO_POP
定义 config.h:316
#define ZEROERR_EXPAND(x)
定义 config.h:131
#define ZEROERR_SUPPRESS_VARIADIC_MACRO
定义 config.h:312

◆ ASSERT_EQ

#define ASSERT_EQ ( ...)
值:
#define ZEROERR_ASSERT_EQ(lhs, rhs,...)
定义 assert.h:191

◆ ASSERT_GE

#define ASSERT_GE ( ...)
值:
#define ZEROERR_ASSERT_GE(lhs, rhs,...)
定义 assert.h:196

◆ ASSERT_GT

#define ASSERT_GT ( ...)
值:
#define ZEROERR_ASSERT_GT(lhs, rhs,...)
定义 assert.h:195

◆ ASSERT_LE

#define ASSERT_LE ( ...)
值:
#define ZEROERR_ASSERT_LE(lhs, rhs,...)
定义 assert.h:194

◆ ASSERT_LT

#define ASSERT_LT ( ...)
值:
#define ZEROERR_ASSERT_LT(lhs, rhs,...)
定义 assert.h:193

◆ ASSERT_NE

#define ASSERT_NE ( ...)
值:
#define ZEROERR_ASSERT_NE(lhs, rhs,...)
定义 assert.h:192

◆ ASSERT_NOT

#define ASSERT_NOT ( ...)
值:

◆ ASSERT_THROWS

#define ASSERT_THROWS ( ...)
值:

◆ CHECK

#define CHECK ( ...)
值:

◆ CHECK_EQ

#define CHECK_EQ ( ...)
值:
#define ZEROERR_CHECK_EQ(lhs, rhs,...)
定义 assert.h:177

◆ CHECK_GE

#define CHECK_GE ( ...)
值:
#define ZEROERR_CHECK_GE(lhs, rhs,...)
定义 assert.h:182

◆ CHECK_GT

#define CHECK_GT ( ...)
值:
#define ZEROERR_CHECK_GT(lhs, rhs,...)
定义 assert.h:181

◆ CHECK_LE

#define CHECK_LE ( ...)
值:
#define ZEROERR_CHECK_LE(lhs, rhs,...)
定义 assert.h:180

◆ CHECK_LT

#define CHECK_LT ( ...)
值:
#define ZEROERR_CHECK_LT(lhs, rhs,...)
定义 assert.h:179

◆ CHECK_NE

#define CHECK_NE ( ...)
值:
#define ZEROERR_CHECK_NE(lhs, rhs,...)
定义 assert.h:178

◆ CHECK_NOT

#define CHECK_NOT ( ...)
值:

◆ CHECK_THROWS

#define CHECK_THROWS ( ...)
值:

◆ REQUIRE

#define REQUIRE ( ...)
值:

◆ REQUIRE_EQ

#define REQUIRE_EQ ( ...)
值:
#define ZEROERR_REQUIRE_EQ(lhs, rhs,...)
定义 assert.h:184

◆ REQUIRE_GE

#define REQUIRE_GE ( ...)
值:
#define ZEROERR_REQUIRE_GE(lhs, rhs,...)
定义 assert.h:189

◆ REQUIRE_GT

#define REQUIRE_GT ( ...)
值:
#define ZEROERR_REQUIRE_GT(lhs, rhs,...)
定义 assert.h:188

◆ REQUIRE_LE

#define REQUIRE_LE ( ...)
值:
#define ZEROERR_REQUIRE_LE(lhs, rhs,...)
定义 assert.h:187

◆ REQUIRE_LT

#define REQUIRE_LT ( ...)
值:
#define ZEROERR_REQUIRE_LT(lhs, rhs,...)
定义 assert.h:186

◆ REQUIRE_NE

#define REQUIRE_NE ( ...)
值:
#define ZEROERR_REQUIRE_NE(lhs, rhs,...)
定义 assert.h:185

◆ REQUIRE_NOT

#define REQUIRE_NOT ( ...)
值:

◆ REQUIRE_THROWS

#define REQUIRE_THROWS ( ...)
值:

◆ ZEROERR_ASSERT

#define ZEROERR_ASSERT ( cond,
... )
值:
ZEROERR_EXPAND(ZEROERR_ASSERT_EXP(cond, ZEROERR_FATAL, no_throw, false, __VA_ARGS__))
#define ZEROERR_ASSERT_EXP(cond, level, expect_throw, is_false,...)
定义 assert.h:63
#define ZEROERR_FATAL(...)
定义 log.h:39

◆ ZEROERR_ASSERT_CMP

#define ZEROERR_ASSERT_CMP ( lhs,
op,
rhs,
level,
expect_throw,
is_false,
... )
值:
zeroerr::assert_info info{zeroerr::assert_level::ZEROERR_CAT(level, _l), \
zeroerr::assert_throw::expect_throw, is_false}; \
\
print.isQuoted = false; \
zeroerr::AssertionData assertion_data(__FILE__, __LINE__, #lhs " " #op " " #rhs, info); \
try { \
ZEROERR_SUPPRESS_COMPARE \
assertion_data.setResult(zeroerr::detail::makeComparisonLhs((lhs), print) op (rhs)); \
} catch (const std::exception& e) { \
assertion_data.setException(e); \
} \
zeroerr::detail::context_helper< \
decltype(_ZEROERR_TEST_CONTEXT), \
std::is_same<decltype(_ZEROERR_TEST_CONTEXT), \
const bool>::value>::setContext(assertion_data, _ZEROERR_TEST_CONTEXT); \
ZEROERR_PRINT_ASSERT(assertion_data.passed == false, level, "" __VA_ARGS__); \
if (false) debug_break(); \
assertion_data(); \
ZEROERR_FUNC_SCOPE_RET(assertion_data.passed); \
} \
#define ZEROERR_FUNC_SCOPE_RET(v)
定义 config.h:124
#define ZEROERR_SUPPRESS_COMPARE_POP
定义 config.h:331
#define ZEROERR_FUNC_SCOPE_END
定义 config.h:123
#define ZEROERR_FUNC_SCOPE_BEGIN
定义 config.h:122
constexpr bool _ZEROERR_TEST_CONTEXT
定义 assert.h:225
ComparisonLhs< L > makeComparisonLhs(const L &lhs, Printer &printer)
定义 decomposition.h:124
AssertionData is a struct that contains all the information of an assertion. It will be thrown as an ...
定义 assert.h:250
A functor class Printer for printing a value of any type.
定义 print.h:87
bool isQuoted
定义 print.h:131
This is a one-byte assert info struct, which is used to collect the meta info of an assertion
定义 assert.h:239

◆ ZEROERR_ASSERT_EQ

#define ZEROERR_ASSERT_EQ ( lhs,
rhs,
... )
值:
ZEROERR_ASSERT_CMP(lhs, ==, rhs, ZEROERR_FATAL, no_throw, false, __VA_ARGS__)
#define ZEROERR_ASSERT_CMP(lhs, op, rhs, level, expect_throw, is_false,...)
定义 assert.h:86

◆ ZEROERR_ASSERT_EXP

#define ZEROERR_ASSERT_EXP ( cond,
level,
expect_throw,
is_false,
... )
值:
zeroerr::assert_info info{zeroerr::assert_level::ZEROERR_CAT(level, _l), \
zeroerr::assert_throw::expect_throw, is_false}; \
\
zeroerr::AssertionData assertion_data(__FILE__, __LINE__, #cond, info); \
try { \
assertion_data.setResult(zeroerr::ExpressionDecomposer() << cond); \
} catch (const std::exception& e) { \
assertion_data.setException(e); \
} \
zeroerr::detail::context_helper< \
decltype(_ZEROERR_TEST_CONTEXT), \
std::is_same<decltype(_ZEROERR_TEST_CONTEXT), \
const bool>::value>::setContext(assertion_data, _ZEROERR_TEST_CONTEXT); \
ZEROERR_PRINT_ASSERT(assertion_data.passed == false, level, "" __VA_ARGS__); \
if (false) debug_break(); \
assertion_data(); \
ZEROERR_FUNC_SCOPE_RET(assertion_data.passed); \
} \
定义 decomposition.h:207

◆ ZEROERR_ASSERT_GE

#define ZEROERR_ASSERT_GE ( lhs,
rhs,
... )
值:
ZEROERR_ASSERT_CMP(lhs, >=, rhs, ZEROERR_FATAL, no_throw, false, __VA_ARGS__)

◆ ZEROERR_ASSERT_GT

#define ZEROERR_ASSERT_GT ( lhs,
rhs,
... )
值:
ZEROERR_ASSERT_CMP(lhs, >, rhs, ZEROERR_FATAL, no_throw, false, __VA_ARGS__)

◆ ZEROERR_ASSERT_LE

#define ZEROERR_ASSERT_LE ( lhs,
rhs,
... )
值:
ZEROERR_ASSERT_CMP(lhs, <=, rhs, ZEROERR_FATAL, no_throw, false, __VA_ARGS__)

◆ ZEROERR_ASSERT_LT

#define ZEROERR_ASSERT_LT ( lhs,
rhs,
... )
值:
ZEROERR_ASSERT_CMP(lhs, <, rhs, ZEROERR_FATAL, no_throw, false, __VA_ARGS__)

◆ ZEROERR_ASSERT_NE

#define ZEROERR_ASSERT_NE ( lhs,
rhs,
... )
值:
ZEROERR_ASSERT_CMP(lhs, !=, rhs, ZEROERR_FATAL, no_throw, false, __VA_ARGS__)

◆ ZEROERR_ASSERT_NOT

#define ZEROERR_ASSERT_NOT ( cond,
... )
值:
ZEROERR_EXPAND(ZEROERR_ASSERT_EXP(cond, ZEROERR_FATAL, no_throw, true, __VA_ARGS__))

◆ ZEROERR_ASSERT_THROWS

#define ZEROERR_ASSERT_THROWS ( cond,
... )
值:
ZEROERR_EXPAND(ZEROERR_ASSERT_EXP(cond, ZEROERR_FATAL, throws, false, __VA_ARGS__))

◆ ZEROERR_CHECK

#define ZEROERR_CHECK ( cond,
... )
值:
ZEROERR_EXPAND(ZEROERR_ASSERT_EXP(cond, ZEROERR_CHECK_LEVEL, no_throw, false, __VA_ARGS__))
#define ZEROERR_CHECK_LEVEL
定义 assert.h:155

◆ ZEROERR_CHECK_EQ

#define ZEROERR_CHECK_EQ ( lhs,
rhs,
... )
值:
ZEROERR_ASSERT_CMP(lhs, ==, rhs, ZEROERR_CHECK_LEVEL, no_throw, false, __VA_ARGS__)

◆ ZEROERR_CHECK_GE

#define ZEROERR_CHECK_GE ( lhs,
rhs,
... )
值:
ZEROERR_ASSERT_CMP(lhs, >=, rhs, ZEROERR_CHECK_LEVEL, no_throw, false, __VA_ARGS__)

◆ ZEROERR_CHECK_GT

#define ZEROERR_CHECK_GT ( lhs,
rhs,
... )
值:
ZEROERR_ASSERT_CMP(lhs, >, rhs, ZEROERR_CHECK_LEVEL, no_throw, false, __VA_ARGS__)

◆ ZEROERR_CHECK_LE

#define ZEROERR_CHECK_LE ( lhs,
rhs,
... )
值:
ZEROERR_ASSERT_CMP(lhs, <=, rhs, ZEROERR_CHECK_LEVEL, no_throw, false, __VA_ARGS__)

◆ ZEROERR_CHECK_LEVEL

#define ZEROERR_CHECK_LEVEL   ZEROERR_WARN

◆ ZEROERR_CHECK_LT

#define ZEROERR_CHECK_LT ( lhs,
rhs,
... )
值:
ZEROERR_ASSERT_CMP(lhs, <, rhs, ZEROERR_CHECK_LEVEL, no_throw, false, __VA_ARGS__)

◆ ZEROERR_CHECK_NE

#define ZEROERR_CHECK_NE ( lhs,
rhs,
... )
值:
ZEROERR_ASSERT_CMP(lhs, !=, rhs, ZEROERR_CHECK_LEVEL, no_throw, false, __VA_ARGS__)

◆ ZEROERR_CHECK_NOT

#define ZEROERR_CHECK_NOT ( cond,
... )
值:
ZEROERR_EXPAND(ZEROERR_ASSERT_EXP(cond, ZEROERR_CHECK_LEVEL, no_throw, true, __VA_ARGS__))

◆ ZEROERR_CHECK_THROWS

#define ZEROERR_CHECK_THROWS ( cond,
... )
值:
ZEROERR_EXPAND(ZEROERR_ASSERT_EXP(cond, ZEROERR_CHECK_LEVEL, throws, false, __VA_ARGS__))

◆ ZEROERR_G_CONTEXT_SCOPE

#define ZEROERR_G_CONTEXT_SCOPE ( x)

◆ ZEROERR_PRINT_ASSERT

#define ZEROERR_PRINT_ASSERT ( cond,
level,
pattern,
... )
值:
ZEROERR_PRINT_ASSERT_DEFAULT_PRINTER(cond, level, " Assertion Failed:\n{msg}" pattern, \
assertion_data.log(), ##__VA_ARGS__)
#define ZEROERR_PRINT_ASSERT_DEFAULT_PRINTER(cond, level,...)
Default printer for assertion messages
定义 assert.h:35

◆ ZEROERR_PRINT_ASSERT_DEFAULT_PRINTER

#define ZEROERR_PRINT_ASSERT_DEFAULT_PRINTER ( cond,
level,
... )
值:
do { \
if (cond) { \
switch (zeroerr::assert_level::ZEROERR_CAT(level, _l)) { \
zeroerr::getStderrPrinter().os << zeroerr::FgYellow << "WARN" << zeroerr::Reset; \
break; \
zeroerr::getStderrPrinter().os << zeroerr::FgRed << "ERROR" << zeroerr::Reset; \
break; \
zeroerr::getStderrPrinter().os << zeroerr::FgMagenta << "FATAL" << zeroerr::Reset; \
break; \
} \
zeroerr::getStderrPrinter().os << zeroerr::format(__VA_ARGS__) << '\n'; \
} \
} while (0)
const char * FgMagenta
定义 color.cpp:47
ZEROERR_DIAGNOSTIC_NOINLINE zeroerr::String format(const char *fmt, T &&... args)
Format a string with arguments
定义 format.h:27
@ ZEROERR_FATAL_l
定义 assert.h:231
@ ZEROERR_ERROR_l
定义 assert.h:231
@ ZEROERR_WARN_l
定义 assert.h:231
const char * FgRed
定义 color.cpp:43
const char * FgYellow
定义 color.cpp:45
const char * Reset
定义 color.cpp:34

Default printer for assertion messages

This macro defines the default printer for assertion messages. It prints the assertion message in different colors based on the assertion level.

The macro can be overridden by defining ZEROERR_PRINT_ASSERT_DEFAULT_PRINTER before including this header. (Or undefine it and implement your own printer.)

◆ ZEROERR_REQUIRE

#define ZEROERR_REQUIRE ( cond,
... )
值:
ZEROERR_EXPAND(ZEROERR_ASSERT_EXP(cond, ZEROERR_ERROR, no_throw, false, __VA_ARGS__))
#define ZEROERR_ERROR(...)
定义 log.h:38

◆ ZEROERR_REQUIRE_EQ

#define ZEROERR_REQUIRE_EQ ( lhs,
rhs,
... )
值:
ZEROERR_ASSERT_CMP(lhs, ==, rhs, ZEROERR_ERROR, no_throw, false, __VA_ARGS__)

◆ ZEROERR_REQUIRE_GE

#define ZEROERR_REQUIRE_GE ( lhs,
rhs,
... )
值:
ZEROERR_ASSERT_CMP(lhs, >=, rhs, ZEROERR_ERROR, no_throw, false, __VA_ARGS__)

◆ ZEROERR_REQUIRE_GT

#define ZEROERR_REQUIRE_GT ( lhs,
rhs,
... )
值:
ZEROERR_ASSERT_CMP(lhs, >, rhs, ZEROERR_ERROR, no_throw, false, __VA_ARGS__)

◆ ZEROERR_REQUIRE_LE

#define ZEROERR_REQUIRE_LE ( lhs,
rhs,
... )
值:
ZEROERR_ASSERT_CMP(lhs, <=, rhs, ZEROERR_ERROR, no_throw, false, __VA_ARGS__)

◆ ZEROERR_REQUIRE_LT

#define ZEROERR_REQUIRE_LT ( lhs,
rhs,
... )
值:
ZEROERR_ASSERT_CMP(lhs, <, rhs, ZEROERR_ERROR, no_throw, false, __VA_ARGS__)

◆ ZEROERR_REQUIRE_NE

#define ZEROERR_REQUIRE_NE ( lhs,
rhs,
... )
值:
ZEROERR_ASSERT_CMP(lhs, !=, rhs, ZEROERR_ERROR, no_throw, false, __VA_ARGS__)

◆ ZEROERR_REQUIRE_NOT

#define ZEROERR_REQUIRE_NOT ( cond,
... )
值:
ZEROERR_EXPAND(ZEROERR_ASSERT_EXP(cond, ZEROERR_ERROR, no_throw, true, __VA_ARGS__))

◆ ZEROERR_REQUIRE_THROWS

#define ZEROERR_REQUIRE_THROWS ( cond,
... )
值:
ZEROERR_EXPAND(ZEROERR_ASSERT_EXP(cond, ZEROERR_ERROR, throws, false, __VA_ARGS__))