]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/font/fonttest.cpp
removed the now unnecessary WX_CPPUNIT_ALLOW_EQUALS_TO_INT(wxFileOffset)
[wxWidgets.git] / tests / font / fonttest.cpp
index 4167cd8ad51f681bc7a207fc3ca26c632e042222..c8a60f0f4efa9e4a79b89af2bc9646cc7efae610 100644 (file)
@@ -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.