Make check_{neq|eq} output more explicit
As the panic message mentions __a and __b, use these explicitly in the error message and equate them to concrete values. Do not use parenthesis to show the computed value as these can be mistaken for functions.
This commit is contained in:
parent
4234171e92
commit
6f1bf3ebf9
50
debug.hpp
50
debug.hpp
@ -63,33 +63,35 @@
|
|||||||
#define check_soft(C) _check_meta((C), { ; }, { ; })
|
#define check_soft(C) _check_meta((C), { ; }, { ; })
|
||||||
|
|
||||||
|
|
||||||
#define check_eq(A,B) do { \
|
#define check_eq(A,B) do { \
|
||||||
const auto __a = (A); \
|
const auto __a = (A); \
|
||||||
const auto __b = (B); \
|
const auto __b = (B); \
|
||||||
_check_meta (almost_equal (__a, __b), \
|
_check_meta (almost_equal (__a, __b), \
|
||||||
{ ; }, \
|
{ ; }, \
|
||||||
{ \
|
{ \
|
||||||
std::ostringstream os; \
|
std::ostringstream os; \
|
||||||
os << "expected equality.\n" \
|
os << "expected equality.\n" \
|
||||||
<< #A << '(' << __a << ")" \
|
<< "__a: " << #A << " is " << __a << ")" \
|
||||||
<< "\n != \n" \
|
<< "\n != \n" \
|
||||||
<< #B << '(' << __b << ")"; \
|
<< "__b: " << #B << " is " << __b << ")"; \
|
||||||
panic (os.str ()); \
|
panic (os.str ()); \
|
||||||
}); \
|
}); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
#define check_neq(A,B) do { \
|
#define check_neq(A,B) do { \
|
||||||
const auto __a = (A); \
|
const auto __a = (A); \
|
||||||
const auto __b = (B); \
|
const auto __b = (B); \
|
||||||
_check_meta (!almost_equal (__a, __b), \
|
_check_meta (!almost_equal (__a, __b), \
|
||||||
{ ; }, \
|
{ ; }, \
|
||||||
{ \
|
{ \
|
||||||
std::ostringstream os; \
|
std::ostringstream os; \
|
||||||
os << "unexepected equality.\n" \
|
os << "unexpected equality.\n" \
|
||||||
<< __a << "\n ==\n" << __b; \
|
<< "__a: " << #A << " is " << __a << ")" \
|
||||||
panic (os.str ()); \
|
<< "\n == \n" \
|
||||||
}); \
|
<< "__b: " << #B << " is " << __b << ")"; \
|
||||||
|
panic (os.str ()); \
|
||||||
|
}); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user