7 #include "internal_macros.h"
13 typedef void(AbortHandlerT)();
15 inline AbortHandlerT*& GetAbortHandler() {
16 static AbortHandlerT* handler = &std::abort;
20 BENCHMARK_NORETURN inline void CallAbortHandler() {
22 std::abort(); // fallback to enforce noreturn
25 // CheckHandler is the class constructed by failing CHECK macros. CheckHandler
26 // will log information about the failures and abort when it is destructed.
29 CheckHandler(const char* check, const char* file, const char* func, int line)
30 : log_(GetErrorLogInstance()) {
31 log_ << file << ":" << line << ": " << func << ": Check `" << check
35 LogType& GetLog() { return log_; }
37 BENCHMARK_NORETURN ~CheckHandler() BENCHMARK_NOEXCEPT_OP(false) {
42 CheckHandler& operator=(const CheckHandler&) = delete;
43 CheckHandler(const CheckHandler&) = delete;
44 CheckHandler() = delete;
50 } // end namespace internal
51 } // end namespace benchmark
53 // The CHECK macro returns a std::ostream object that can have extra information
57 (b ? ::benchmark::internal::GetNullLogInstance() \
58 : ::benchmark::internal::CheckHandler(#b, __FILE__, __func__, __LINE__) \
61 #define CHECK(b) ::benchmark::internal::GetNullLogInstance()
64 #define CHECK_EQ(a, b) CHECK((a) == (b))
65 #define CHECK_NE(a, b) CHECK((a) != (b))
66 #define CHECK_GE(a, b) CHECK((a) >= (b))
67 #define CHECK_LE(a, b) CHECK((a) <= (b))
68 #define CHECK_GT(a, b) CHECK((a) > (b))
69 #define CHECK_LT(a, b) CHECK((a) < (b))