Turi Create  4.0
Logging Assertions

Assertions. More...

Macros

#define __CHECK(condition)
 
#define ASSERT_TRUE(cond)   EXPECT_TRUE(cond)
 
#define ASSERT_FALSE(cond)   EXPECT_FALSE(cond)
 
#define __CHECK_EQ(val1, val2)   __CHECK_OP(==, val1, val2)
 
#define __CHECK_NE(val1, val2)   __CHECK_OP(!=, val1, val2)
 
#define __CHECK_LE(val1, val2)   __CHECK_OP(<=, val1, val2)
 
#define __CHECK_LT(val1, val2)   __CHECK_OP(< , val1, val2)
 
#define __CHECK_GE(val1, val2)   __CHECK_OP(>=, val1, val2)
 
#define __CHECK_GT(val1, val2)   __CHECK_OP(> , val1, val2)
 
#define __CHECK_DELTA(val1, val2, delta)
 
#define DASSERT_TRUE(cond)   ASSERT_TRUE(cond)
 
#define DASSERT_FALSE(cond)   ASSERT_FALSE(cond)
 
#define __DCHECK_EQ(val1, val2)   __CHECK_EQ(val1, val2)
 
#define __DCHECK_NE(val1, val2)   __CHECK_NE(val1, val2)
 
#define __DCHECK_LE(val1, val2)   __CHECK_LE(val1, val2)
 
#define __DCHECK_LT(val1, val2)   __CHECK_LT(val1, val2)
 
#define __DCHECK_GE(val1, val2)   __CHECK_GE(val1, val2)
 
#define __DCHECK_GT(val1, val2)   __CHECK_GT(val1, val2)
 
#define __DCHECK_DELTA(val1, val2, delta)   __CHECK_DELTA(val1, val2, delta)
 

Detailed Description

Assertions.

Macro Definition Documentation

◆ __CHECK

#define __CHECK (   condition)
Value:
do { \
if (UNLIKELY(!(condition))) { \
auto throw_error = [&]() GL_GCC_ONLY(GL_COLD_NOINLINE_ERROR) { \
std::ostringstream ss; \
ss << "Check failed (" << __FILE__ << ":" << __LINE__ \
<< "): " << #condition << std::endl; \
logstream(LOG_ERROR) << ss.str(); \
__print_back_trace(); \
LOGGED_TURI_LOGGER_FAIL_METHOD(ss.str()); \
}; \
throw_error(); \
TURI_BUILTIN_UNREACHABLE(); \
} \
} while (0)
#define LOG_ERROR
Definition: logger.hpp:97
#define GL_COLD_NOINLINE_ERROR

CHECK dies with a fatal error if condition is not true. It is not controlled by NDEBUG, so the check will be executed regardless of compilation mode.

Definition at line 199 of file assertions.hpp.

◆ __CHECK_DELTA

#define __CHECK_DELTA (   val1,
  val2,
  delta 
)
Value:
do { \
const double _CHECK_OP_v1_ = val1; \
const double _CHECK_OP_v2_ = val2; \
const double _CHECK_OP_delta_ = delta; \
if (__builtin_expect( \
!(std::abs((_CHECK_OP_v1_) - (_CHECK_OP_v2_)) <= _CHECK_OP_delta_),\
0)) { \
auto throw_error = [&]() GL_GCC_ONLY(GL_COLD_NOINLINE_ERROR) { \
std::ostringstream ss; \
ss << "Assertion failed: (" << __FILE__ << ":" << __LINE__ << "): " \
<< "abs(" << #val1 << " - " << #val2 << ") <= " << #delta << ". [" \
<< "abs(" << _CHECK_OP_v2_ << " - " << _CHECK_OP_v1_ << ") > " \
<< _CHECK_OP_delta_ << "]" << std::endl; \
logstream(LOG_ERROR) << ss.str(); \
__print_back_trace(); \
LOGGED_TURI_LOGGER_FAIL_METHOD(ss.str()); \
}; \
throw_error(); \
TURI_BUILTIN_UNREACHABLE(); \
} \
} while (0)
#define LOG_ERROR
Definition: logger.hpp:97
#define GL_COLD_NOINLINE_ERROR

Expects |val1 - val2| <= delta difference, dies with a fatal error otherwise. Mainly meant for floating point values. ASSERT_DELTA and EXPECT_DELTA

Definition at line 260 of file assertions.hpp.

◆ __CHECK_EQ

#define __CHECK_EQ (   val1,
  val2 
)    __CHECK_OP(==, val1, val2)

Expects val1 == val2, dies with a fatal error otherwise. Synonyms are ASSERT_EQ and EXPECT_EQ.

Definition at line 283 of file assertions.hpp.

◆ __CHECK_GE

#define __CHECK_GE (   val1,
  val2 
)    __CHECK_OP(>=, val1, val2)

Expects val1 >= val2, dies with a fatal error otherwise. Synonyms are ASSERT_GE and EXPECT_GE

Definition at line 287 of file assertions.hpp.

◆ __CHECK_GT

#define __CHECK_GT (   val1,
  val2 
)    __CHECK_OP(> , val1, val2)

Expects val1 > val2, dies with a fatal error otherwise. Synonyms are ASSERT_GT and EXPECT_GT

Definition at line 288 of file assertions.hpp.

◆ __CHECK_LE

#define __CHECK_LE (   val1,
  val2 
)    __CHECK_OP(<=, val1, val2)

Expects val1 <= val2, dies with a fatal error otherwise. Synonyms are ASSERT_LE and EXPECT_LE

Definition at line 285 of file assertions.hpp.

◆ __CHECK_LT

#define __CHECK_LT (   val1,
  val2 
)    __CHECK_OP(< , val1, val2)

Expects val1 < val2, dies with a fatal error otherwise. Synonyms are ASSERT_LT and EXPECT_LT

Definition at line 286 of file assertions.hpp.

◆ __CHECK_NE

#define __CHECK_NE (   val1,
  val2 
)    __CHECK_OP(!=, val1, val2)

Expects val1 != val2, dies with a fatal error otherwise. Synonyms are ASSERT_NE and EXPECT_NE

Definition at line 284 of file assertions.hpp.

◆ __DCHECK_DELTA

#define __DCHECK_DELTA (   val1,
  val2,
  delta 
)    __CHECK_DELTA(val1, val2, delta)

Like __CHECK_DELTA but is compiled away by NDEBUG. Synonyms are DASSERT_DELTA.

Definition at line 358 of file assertions.hpp.

◆ __DCHECK_EQ

#define __DCHECK_EQ (   val1,
  val2 
)    __CHECK_EQ(val1, val2)

Like __CHECK_EQ but is compiled away by NDEBUG. Synonyms are DASSERT_EQ.

Definition at line 357 of file assertions.hpp.

◆ __DCHECK_GE

#define __DCHECK_GE (   val1,
  val2 
)    __CHECK_GE(val1, val2)

Like __CHECK_GE but is compiled away by NDEBUG. Synonyms are DASSERT_GE.

Definition at line 362 of file assertions.hpp.

◆ __DCHECK_GT

#define __DCHECK_GT (   val1,
  val2 
)    __CHECK_GT(val1, val2)

Like __CHECK_GT but is compiled away by NDEBUG. Synonyms are DASSERT_GT.

Definition at line 363 of file assertions.hpp.

◆ __DCHECK_LE

#define __DCHECK_LE (   val1,
  val2 
)    __CHECK_LE(val1, val2)

Like __CHECK_LE but is compiled away by NDEBUG. Synonyms are DASSERT_LE.

Definition at line 360 of file assertions.hpp.

◆ __DCHECK_LT

#define __DCHECK_LT (   val1,
  val2 
)    __CHECK_LT(val1, val2)

Like __CHECK_LT but is compiled away by NDEBUG. Synonyms are DASSERT_LT.

Definition at line 361 of file assertions.hpp.

◆ __DCHECK_NE

#define __DCHECK_NE (   val1,
  val2 
)    __CHECK_NE(val1, val2)

Like __CHECK_NE but is compiled away by NDEBUG. Synonyms are DASSERT_NE.

Definition at line 359 of file assertions.hpp.

◆ ASSERT_FALSE

#define ASSERT_FALSE (   cond)    EXPECT_FALSE(cond)

Expects val to evaluate to false, dies with a fatal error otherwise. Synonyms are EXPECT_FALSE

Definition at line 310 of file assertions.hpp.

◆ ASSERT_TRUE

#define ASSERT_TRUE (   cond)    EXPECT_TRUE(cond)

Expects val to evaluate to true, dies with a fatal error otherwise. Synonyms are EXPECT_TRUE

Definition at line 309 of file assertions.hpp.

◆ DASSERT_FALSE

#define DASSERT_FALSE (   cond)    ASSERT_FALSE(cond)

Like ASSERT_FALSE but is compiled away by NDEBUG.

Definition at line 365 of file assertions.hpp.

◆ DASSERT_TRUE

#define DASSERT_TRUE (   cond)    ASSERT_TRUE(cond)

Like ASSERT_TRUE but is compiled away by NDEBUG.

Definition at line 364 of file assertions.hpp.