From 2c64172825efe341a0cad13d74b3387700bd8c02 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 12 Mar 2014 22:20:50 +0000 Subject: [PATCH] Reset the system last error value before checking it in wxLog test. Explicitly set the last error indicator to 0 before checking that wxLogSysError() logs it correctly as it wasn't always set to 0 otherwise. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76123 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- tests/log/logtest.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/log/logtest.cpp b/tests/log/logtest.cpp index 55988504a1..f991621865 100644 --- a/tests/log/logtest.cpp +++ b/tests/log/logtest.cpp @@ -23,6 +23,12 @@ #include "wx/scopeguard.h" +#ifdef __WINDOWS__ + #include "wx/msw/wrapwin.h" +#else + #include +#endif + #if WXWIN_COMPATIBILITY_2_8 // we override deprecated DoLog() and DoLogString() in this test, suppress // warnings about it @@ -348,11 +354,13 @@ void LogTestCase::SysError() 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__ + // Try to ensure that the system error is 0. +#ifdef __WINDOWS__ + ::SetLastError(0); +#else + errno = 0; +#endif + wxLogSysError("Success"); CPPUNIT_ASSERT( m_log->GetLog(wxLOG_Error).StartsWith("Success (", &s) ); WX_ASSERT_MESSAGE( ("Error message is \"(%s\"", s), s.StartsWith("error 0") ); @@ -361,7 +369,6 @@ void LogTestCase::SysError() 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__ } void LogTestCase::NoWarnings()