Skip to content

Commit

Permalink
Add SASSERT_EQ and VERIFY_EQ
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobR authored and NikolajBjorner committed Aug 1, 2022
1 parent 79ee543 commit d2fe174
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/util/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ bool is_debug_enabled(const char * tag);
#define CASSERT(TAG, COND) DEBUG_CODE(if (assertions_enabled() && is_debug_enabled(TAG) && !(COND)) { notify_assertion_violation(__FILE__, __LINE__, #COND); INVOKE_DEBUGGER(); })
#define XASSERT(COND, EXTRA_CODE) DEBUG_CODE(if (assertions_enabled() && !(COND)) { notify_assertion_violation(__FILE__, __LINE__, #COND); { EXTRA_CODE } INVOKE_DEBUGGER(); })

#define SASSERT_EQ(LHS, RHS) \
DEBUG_CODE(if (assertions_enabled() && !((LHS) == (RHS))) { \
notify_assertion_violation(__FILE__, __LINE__, #LHS " == " #RHS); \
std::cerr << "LHS value: " << (LHS) << "\nRHS value: " << (RHS) << "\n"; \
INVOKE_DEBUGGER(); \
})

#ifdef Z3DEBUG
# define UNREACHABLE() DEBUG_CODE(notify_assertion_violation(__FILE__, __LINE__, "UNEXPECTED CODE WAS REACHED."); INVOKE_DEBUGGER();)
#else
Expand All @@ -78,7 +85,14 @@ bool is_debug_enabled(const char * tag);
#define VERIFY(_x_) if (!(_x_)) { \
notify_assertion_violation(__FILE__, __LINE__, "Failed to verify: " #_x_ "\n"); \
exit(ERR_UNREACHABLE); \
}
}

#define VERIFY_EQ(LHS, RHS) \
if (!((LHS) == (RHS))) { \
notify_assertion_violation(__FILE__, __LINE__, "Failed to verify: " #LHS " == " #RHS "\n"); \
std::cerr << "LHS value: " << (LHS) << "\nRHS value: " << (RHS) << "\n"; \
exit(ERR_UNREACHABLE); \
}

#define ENSURE(_x_) VERIFY(_x_)

Expand Down

0 comments on commit d2fe174

Please sign in to comment.