You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One thing that I currently use pretty often (especially for networking code) is:
if (!AssertTrue(a > 3)) {
// Handle the failed assertion in releasereturn;
}
This allows crashing in debug builds during testing but handling it without crashing for users in release builds.
It looks very similar to:
if (!ASSERT_VAL(a > 3))
but ASSERT_VAL returns the value of a, not the result of the whole expression a > 3.
Obviously it's possible to do
if (ASSERT_VAL(a > 3) <= 3)
but that makes it complicated and error-prone.
Would it be possible to return the result of the whole expression from ASSERT, or to create a variant of the macro (e.g. ASSERT_THAT) that returns the result?