diff --git a/tests/testprec.h b/tests/testprec.h index 38e2ce14e0..0eaf103cfc 100644 --- a/tests/testprec.h +++ b/tests/testprec.h @@ -55,6 +55,31 @@ #define wxDEFAULT_MANTISSA_SIZE_3 #endif +// Many tests use wide characters or wide strings inside Catch macros, which +// requires converting them to string if the check fails. This falls back to +// std::ostream::operator<() by default, which never worked correctly, as there +// never was any overload for wchar_t and so it used something else, but in C++ +// 20 this overload is explicitly deleted, so it results in compile-time error. +// +// Hence define this specialization to allow compiling such comparisons. +namespace Catch +{ + +template <> +struct StringMaker +{ + static std::string convert(wchar_t wc) + { + if ( wc < 0x7f ) + return std::string(static_cast(wc), 1); + + return wxString::Format("U+%06X", wc).ToStdString(); + } +}; + +} // namespace Catch + + // thrown when assert fails in debug build class TestAssertFailure {