From 92e41a7477822d563408248c9c58f6c7d5a42767 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 12 Dec 2020 18:13:25 +0100 Subject: [PATCH] Improve reporting test failures due to assert failures Show the condition which failed for wxASSERT() (as opposed to wxASSERT_MSG()), as otherwise the error message didn't show any information at all, making diagnosing the problem impossible. Also show the assert location, as this can be useful too and there doesn't seem to be any reason not to do it. --- tests/test.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test.cpp b/tests/test.cpp index f2b0d84ef7..76a99d1134 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -171,7 +171,13 @@ static void TestAssertHandler(const wxString& file, CATCH_TRANSLATE_EXCEPTION(TestAssertFailure& e) { - return e.m_msg.ToStdString(wxConvUTF8); + wxString desc = e.m_msg; + if ( desc.empty() ) + desc.Printf(wxASCII_STR("Condition \"%s\" failed"), e.m_cond); + + desc += wxString::Format(wxASCII_STR(" in %s() at %s:%d"), e.m_func, e.m_file, e.m_line); + + return desc.ToStdString(wxConvUTF8); } #endif // wxDEBUG_LEVEL