From b2eabfe86603fe932b61c513577a8e1b7d0fb815 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Jan 2009 16:04:22 +0000 Subject: [PATCH] abstract VC6 workaround inside a WX_CPPUNIT_ALLOW_EQUALS_TO_INT() macro git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57833 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/cppunit.h | 53 +++-- tests/datetime/datetimetest.cpp | 2 + tests/streams/bstream.h | 2 + tests/test_vc7_test.vcproj | 355 +++++++++++++++++++++++++++++++- 4 files changed, 380 insertions(+), 32 deletions(-) diff --git a/include/wx/cppunit.h b/include/wx/cppunit.h index b11bebf5a9..81dcbe2ef2 100644 --- a/include/wx/cppunit.h +++ b/include/wx/cppunit.h @@ -56,7 +56,6 @@ #include "wx/afterstd.h" #include "wx/string.h" -#include "wx/filefn.h" // for wxFileOffset /////////////////////////////////////////////////////////////////////////////// @@ -106,6 +105,10 @@ assertEquals(const wchar_t *expected, assertEquals(wxString(expected), actual, sourceLine, message); } +CPPUNIT_NS_END + +// define an assertEquals() overload for the given types, this is a helper and +// shouldn't be used directly because of VC6 complications, see below #define WX_CPPUNIT_ASSERT_EQUALS(T1, T2) \ inline void \ assertEquals(T1 expected, \ @@ -122,28 +125,34 @@ assertEquals(const wchar_t *expected, } \ } -// and another to be able to specify (usually literal) ints as expected values -// for functions returning size_t/short/long/wxFileOffset -WX_CPPUNIT_ASSERT_EQUALS(int, long) -WX_CPPUNIT_ASSERT_EQUALS(int, short) -WX_CPPUNIT_ASSERT_EQUALS(int, size_t) -WX_CPPUNIT_ASSERT_EQUALS(int, wxFileOffset) - -// special section with VC6 workarounds: due to incorrect resolution of -// overloaded/template functions in this compiler (it basically doesn't use the -// template version at all if any overloaded function matches partially even if -// none of them matches fully) we also need -#ifdef __VISUALC6__ - -WX_CPPUNIT_ASSERT_EQUALS(int, int) -WX_CPPUNIT_ASSERT_EQUALS(long, long) -WX_CPPUNIT_ASSERT_EQUALS(short, short) -WX_CPPUNIT_ASSERT_EQUALS(size_t, size_t) -WX_CPPUNIT_ASSERT_EQUALS(wxFileOffset, wxFileOffset) - -#endif // VC6 +// this macro allows us to specify (usually literal) ints as expected values +// for functions returning integral types different from "int" +// +// FIXME-VC6: due to incorrect resolution of overloaded/template functions in +// this compiler (it basically doesn't use the template version at +// all if any overloaded function matches partially even if none of +// them matches fully) we also need to provide extra overloads -CPPUNIT_NS_END +#ifdef __VISUALC6__ + #define WX_CPPUNIT_ALLOW_EQUALS_TO_INT(T) \ + CPPUNIT_NS_BEGIN \ + WX_CPPUNIT_ASSERT_EQUALS(int, T) \ + WX_CPPUNIT_ASSERT_EQUALS(T, T) \ + CPPUNIT_NS_END + + CPPUNIT_NS_BEGIN + WX_CPPUNIT_ASSERT_EQUALS(int, int) + CPPUNIT_NS_END +#else // !VC6 + #define WX_CPPUNIT_ALLOW_EQUALS_TO_INT(T) \ + CPPUNIT_NS_BEGIN \ + WX_CPPUNIT_ASSERT_EQUALS(int, T) \ + CPPUNIT_NS_END +#endif // VC6/!VC6 + +WX_CPPUNIT_ALLOW_EQUALS_TO_INT(long) +WX_CPPUNIT_ALLOW_EQUALS_TO_INT(short) +WX_CPPUNIT_ALLOW_EQUALS_TO_INT(size_t) // Use this macro to compare a wxArrayString with the pipe-separated elements // of the given string diff --git a/tests/datetime/datetimetest.cpp b/tests/datetime/datetimetest.cpp index 033707b17c..70dd191b99 100644 --- a/tests/datetime/datetimetest.cpp +++ b/tests/datetime/datetimetest.cpp @@ -32,6 +32,8 @@ static std::ostream& operator<<(std::ostream& ostr, const wxDateTime& dt) return ostr; } +WX_CPPUNIT_ALLOW_EQUALS_TO_INT(wxDateTime::wxDateTime_t) + // to test Today() meaningfully we must be able to change the system date which // is not usually the case, but if we're under Win32 we can try it -- define // the macro below to do it diff --git a/tests/streams/bstream.h b/tests/streams/bstream.h index 9b46aa90c8..36394c56f3 100644 --- a/tests/streams/bstream.h +++ b/tests/streams/bstream.h @@ -29,6 +29,8 @@ STREAM_IMPLEMENT_SUB_REGISTRATION_ROUTINE( Name ) +WX_CPPUNIT_ALLOW_EQUALS_TO_INT(wxFileOffset) + /////////////////////////////////////////////////////////////////////////////// // Template class that implements a test for all base stream functions. // diff --git a/tests/test_vc7_test.vcproj b/tests/test_vc7_test.vcproj index 6dafda7a87..46ce94b7e8 100644 --- a/tests/test_vc7_test.vcproj +++ b/tests/test_vc7_test.vcproj @@ -1,11 +1,4 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -632,155 +683,439 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - -- 2.45.2