Give more information if wxFont unit tests fail

Use INFO() to provide extra information instead of the ugly
WX_ASSERT_MESSAGE().
This commit is contained in:
Vadim Zeitlin 2022-04-17 21:23:17 +02:00
parent 6afd2e8f87
commit 61e24f6be0

View File

@ -263,14 +263,13 @@ TEST_CASE("wxFont::GetSet", "[font][getters]")
static const char *knownGoodFaceName = "Monospace";
#endif
WX_ASSERT_MESSAGE
(
("failed to set face name \"%s\" for test font #%u\n"
"(this failure is harmless if this face name is not "
"available on this system)", knownGoodFaceName, n),
test.SetFaceName(knownGoodFaceName)
);
CHECK( test.IsOk() );
INFO("Testing font #" << n);
{
INFO("setting face name to " << knownGoodFaceName);
CHECK( test.SetFaceName(knownGoodFaceName) );
CHECK( test.IsOk() );
}
// test Get/SetFamily()
@ -364,10 +363,12 @@ TEST_CASE("wxFont::NativeFontInfo", "[font][fontinfo]")
wxFont temp;
CHECK( temp.SetNativeFontInfo(nid) );
CHECK( temp.IsOk() );
WX_ASSERT_MESSAGE(
("Test #%u failed\ndump of test font: \"%s\"\ndump of temp font: \"%s\"", \
n, DumpFont(&test), DumpFont(&temp)),
temp == test );
INFO("Testing font #" << n);
INFO("original font user description: " << DumpFont(&test));
INFO("the other font description: " << DumpFont(&temp));
CHECK( temp == test );
}
// test that clearly invalid font info strings do not work
@ -409,22 +410,25 @@ TEST_CASE("wxFont::NativeFontInfoUserDesc", "[font][fontinfo]")
const wxFont *pf = GetTestFonts(numFonts);
for ( unsigned n = 0; n < numFonts; n++ )
{
INFO("Testing font #" << n);
wxFont test(*pf++);
const wxString& niud = test.GetNativeFontInfoUserDesc();
CHECK( !niud.empty() );
// documented to be never empty
INFO("original font user description: " << niud);
wxFont temp2;
CHECK( temp2.SetNativeFontInfoUserDesc(niud) );
CHECK( temp2.IsOk() );
INFO("the other font description: " << niud);
#ifdef __WXGTK__
// Pango saves/restores all font info in the user-friendly string:
WX_ASSERT_MESSAGE(
("Test #%u failed; native info user desc was \"%s\" for test and \"%s\" for temp2", \
n, niud, temp2.GetNativeFontInfoUserDesc()),
temp2 == test );
CHECK( temp2 == test );
#else
// NOTE: as documented GetNativeFontInfoUserDesc/SetNativeFontInfoUserDesc
// are not granted to save/restore all font info.