]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/log/logtest.cpp
Don't pass spin text control messages processed at wx level to Windows.
[wxWidgets.git] / tests / log / logtest.cpp
index 644a18f89f189ca701090d67770e32e50b3fa90b..4ee9b2b38faa0443bc24a82a56742ea48859cc58 100644 (file)
@@ -19,6 +19,7 @@
 
 #ifndef WX_PRECOMP
     #include "wx/log.h"
 
 #ifndef WX_PRECOMP
     #include "wx/log.h"
+    #include "wx/filefn.h"
 #endif // WX_PRECOMP
 
 #include "wx/scopeguard.h"
 #endif // WX_PRECOMP
 
 #include "wx/scopeguard.h"
@@ -168,6 +169,7 @@ private:
         CPPUNIT_TEST( CompatLogger );
         CPPUNIT_TEST( CompatLogger2 );
 #endif // WXWIN_COMPATIBILITY_2_8
         CPPUNIT_TEST( CompatLogger );
         CPPUNIT_TEST( CompatLogger2 );
 #endif // WXWIN_COMPATIBILITY_2_8
+        CPPUNIT_TEST( SysError );
     CPPUNIT_TEST_SUITE_END();
 
     void Functions();
     CPPUNIT_TEST_SUITE_END();
 
     void Functions();
@@ -180,6 +182,7 @@ private:
     void CompatLogger();
     void CompatLogger2();
 #endif // WXWIN_COMPATIBILITY_2_8
     void CompatLogger();
     void CompatLogger2();
 #endif // WXWIN_COMPATIBILITY_2_8
+    void SysError();
 
     TestLog *m_log;
     wxLog *m_logOld;
 
     TestLog *m_log;
     wxLog *m_logOld;
@@ -191,7 +194,7 @@ private:
 // register in the unnamed registry so that these tests are run by default
 CPPUNIT_TEST_SUITE_REGISTRATION( LogTestCase );
 
 // register in the unnamed registry so that these tests are run by default
 CPPUNIT_TEST_SUITE_REGISTRATION( LogTestCase );
 
-// also include in it's own registry so that these tests can be run alone
+// also include in its own registry so that these tests can be run alone
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( LogTestCase, "LogTestCase" );
 
 void LogTestCase::setUp()
 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( LogTestCase, "LogTestCase" );
 
 void LogTestCase::setUp()
@@ -335,3 +338,28 @@ void LogTestCase::CompatLogger2()
 }
 
 #endif // WXWIN_COMPATIBILITY_2_8
 }
 
 #endif // WXWIN_COMPATIBILITY_2_8
+
+void LogTestCase::SysError()
+{
+    wxString s;
+
+    wxLogSysError(17, "Error");
+    CPPUNIT_ASSERT( m_log->GetLog(wxLOG_Error).StartsWith("Error (", &s) );
+    WX_ASSERT_MESSAGE( ("Error message is \"(%s\"", s), s.StartsWith("error 17") );
+
+    // The last error code seems to be set somewhere in MinGW CRT as its value
+    // is just not what we expect (ERROR_INVALID_PARAMETER instead of 0 and 0
+    // instead of ERROR_FILE_NOT_FOUND) so exclude the tests which rely on last
+    // error being preserved for this compiler.
+#ifndef __MINGW32__
+    wxLogSysError("Success");
+    CPPUNIT_ASSERT( m_log->GetLog(wxLOG_Error).StartsWith("Success (", &s) );
+    WX_ASSERT_MESSAGE( ("Error message is \"(%s\"", s), s.StartsWith("error 0") );
+
+    wxOpen("no-such-file", 0, 0);
+    wxLogSysError("Not found");
+    CPPUNIT_ASSERT( m_log->GetLog(wxLOG_Error).StartsWith("Not found (", &s) );
+    WX_ASSERT_MESSAGE( ("Error message is \"(%s\"", s), s.StartsWith("error 2") );
+#endif // __MINGW32__
+}
+