From fe360d4d01fa1cdb0bb7ada8dbb772f6be9c76d4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 6 Aug 2026 22:15:55 +0200 Subject: [PATCH] Handle invalid wxColour better in unit test assertions Show invalid colour as "invalid" instead of "" and don't trigger a wx assertion when comparing with it. --- tests/asserthelper.cpp | 2 +- tests/graphics/colour.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/asserthelper.cpp b/tests/asserthelper.cpp index 9b04e7b38d..60fb05ef96 100644 --- a/tests/asserthelper.cpp +++ b/tests/asserthelper.cpp @@ -13,7 +13,7 @@ std::ostream& operator<<(std::ostream& os, const wxColour& c) { - os << c.GetAsString(wxC2S_HTML_SYNTAX); + os << (c.IsOk() ? c.GetAsString(wxC2S_HTML_SYNTAX) : "invalid"); return os; } diff --git a/tests/graphics/colour.cpp b/tests/graphics/colour.cpp index 0dabeaf3e9..3701b779d6 100644 --- a/tests/graphics/colour.cpp +++ b/tests/graphics/colour.cpp @@ -34,6 +34,9 @@ public: bool match(const wxColour& c) const override { + if ( !c.IsOk() ) + return false; + return c.Red() == m_red && c.Green() == m_green && c.Blue() == m_blue; }