X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/14a83cbf361d8bd14aad290a87df7d00bbd6656a..4e42fe49f2ce998daf49876b3ae89e8e00234d2e:/tests/font/fonttest.cpp?ds=sidebyside diff --git a/tests/font/fonttest.cpp b/tests/font/fonttest.cpp index 4167cd8ad5..c8a60f0f4e 100644 --- a/tests/font/fonttest.cpp +++ b/tests/font/fonttest.cpp @@ -51,6 +51,27 @@ CPPUNIT_TEST_SUITE_REGISTRATION( FontTestCase ); // also include in it's own registry so that these tests can be run alone CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FontTestCase, "FontTestCase" ); +wxString DumpFont(const wxFont *font) +{ + // dumps the internal properties of a wxFont in the same order they + // are checked by wxFontBase::operator==() + + wxASSERT(font->IsOk()); + + wxString s; + s.Printf(wxS("%d-%d;%d-%d-%d-%d-%d-%s-%d"), + font->GetPointSize(), + font->GetPixelSize().x, + font->GetPixelSize().y, + font->GetFamily(), + font->GetStyle(), + font->GetWeight(), + font->GetUnderlined() ? 1 : 0, + font->GetFaceName(), + font->GetEncoding()); + + return s; +} void FontTestCase::GetSet() { @@ -85,11 +106,14 @@ void FontTestCase::GetSet() // test Get/SetFamily() - test.SetFamily( wxFONTFAMILY_MODERN ); + test.SetFamily( wxFONTFAMILY_ROMAN ); CPPUNIT_ASSERT( test.IsOk() ); - CPPUNIT_ASSERT_EQUAL( wxFONTFAMILY_MODERN, test.GetFamily() ); + CPPUNIT_ASSERT( wxFONTFAMILY_ROMAN == test.GetFamily() || + wxFONTFAMILY_UNKNOWN == test.GetFamily() ); + // note that there is always the possibility that GetFamily() returns + // wxFONTFAMILY_UNKNOWN so that we consider it as a valid return value + - // test Get/SetEncoding() //test.SetEncoding( wxFONTENCODING_KOI8 ); @@ -106,7 +130,10 @@ void FontTestCase::GetSet() wxFont temp; CPPUNIT_ASSERT( temp.SetNativeFontInfo(nid) ); CPPUNIT_ASSERT( temp.IsOk() ); - CPPUNIT_ASSERT( temp == test ); + WX_ASSERT_MESSAGE( + ("Test #%lu failed\ndump of test font: \"%s\"\ndump of temp font: \"%s\"", \ + n, DumpFont(&test), DumpFont(&temp)), + temp == test ); // test Get/SetNativeFontInfoUserDesc @@ -121,7 +148,10 @@ void FontTestCase::GetSet() #ifdef __WXGTK__ // Pango saves/restores all font info in the user-friendly string: - CPPUNIT_ASSERT( temp2 == test ); + WX_ASSERT_MESSAGE( + ("Test #%lu failed; native info user desc was \"%s\" for test and \"%s\" for temp2", \ + n, niud, temp2.GetNativeFontInfoUserDesc()), + temp2 == test ); #else // NOTE: as documented GetNativeFontInfoUserDesc/SetNativeFontInfoUserDesc // are not granted to save/restore all font info.