// 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()
{
// 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 );
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
#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.