really fix VC6 compilation of all testsi (without breaking VC9)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56656 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-11-03 00:31:16 +00:00
parent 8112fbf0d7
commit 527587d347
5 changed files with 69 additions and 68 deletions

View File

@@ -105,47 +105,36 @@ assertEquals(const wchar_t *expected,
assertEquals(wxString(expected), actual, sourceLine, message); assertEquals(wxString(expected), actual, sourceLine, message);
} }
#define WX_CPPUNIT_ASSERT_EQUALS(T1, T2) \
inline void \
assertEquals(T1 expected, \
T2 actual, \
CppUnit::SourceLine sourceLine, \
const std::string& message) \
{ \
if ( !assertion_traits<T1>::equal(expected,actual) ) \
{ \
Asserter::failNotEqual( assertion_traits<T1>::toString(expected), \
assertion_traits<T2>::toString(actual), \
sourceLine, \
message ); \
} \
}
// and another to be able to specify (usually literal) ints as expected values // and another to be able to specify (usually literal) ints as expected values
// for functions returning any of unsigned {int,long} or size_t // for functions returning size_t
inline void WX_CPPUNIT_ASSERT_EQUALS(int, size_t);
assertEquals(int expected,
unsigned actual,
CppUnit::SourceLine sourceLine,
const std::string& message)
{
assertEquals(unsigned(expected), actual, sourceLine, message);
}
inline void // special section with VC6 workarounds: due to incorrect resolution of
assertEquals(int expected, // overloaded/template functions in this compiler (it basically doesn't use the
unsigned long actual, // template version at all if any overloaded function matches partially even if
CppUnit::SourceLine sourceLine, // none of them matches fully) we also need
const std::string& message) #ifdef __VISUALC6__
{
assertEquals((unsigned long)expected, actual, sourceLine, message);
}
// we also need this one to resolve ambiguity in the tests comparing unsigned WX_CPPUNIT_ASSERT_EQUALS(int, int);
// short (e.g. wxDateTime_t returned by several wxDateTime methods) with WX_CPPUNIT_ASSERT_EQUALS(size_t, size_t);
// literal integer constants
inline void
assertEquals(int expected,
unsigned short actual,
CppUnit::SourceLine sourceLine,
const std::string& message)
{
assertEquals((unsigned short)expected, actual, sourceLine, message);
}
// this one is useful for wxTextCtrl functions which return longs #endif // VC6
inline void
assertEquals(int expected,
long actual,
CppUnit::SourceLine sourceLine,
const std::string& message)
{
assertEquals((long)expected, actual, sourceLine, message);
}
CPPUNIT_NS_END CPPUNIT_NS_END

View File

@@ -292,9 +292,9 @@ void FileNameTestCase::TestNormalize()
static const struct FileNameTest static const struct FileNameTest
{ {
wxString original; const char *original;
int flags; int flags;
wxString expected; const char *expected;
wxPathFormat fmt; wxPathFormat fmt;
} tests[] = } tests[] =
{ {
@@ -311,8 +311,8 @@ void FileNameTestCase::TestNormalize()
// test wxPATH_NORM_TILDE // test wxPATH_NORM_TILDE
// NB: do the tilde expansion also under Windows to test if it works there too // NB: do the tilde expansion also under Windows to test if it works there too
{ "/a/b/~", wxPATH_NORM_TILDE, "/a/b/~", wxPATH_UNIX }, { "/a/b/~", wxPATH_NORM_TILDE, "/a/b/~", wxPATH_UNIX },
{ "/~/a/b", wxPATH_NORM_TILDE, home + "a/b", wxPATH_UNIX }, { "/~/a/b", wxPATH_NORM_TILDE, "HOME/a/b", wxPATH_UNIX },
{ "~/a/b", wxPATH_NORM_TILDE, home + "a/b", wxPATH_UNIX }, { "~/a/b", wxPATH_NORM_TILDE, "HOME/a/b", wxPATH_UNIX },
// test wxPATH_NORM_CASE // test wxPATH_NORM_CASE
{ "Foo", wxPATH_NORM_CASE, "Foo", wxPATH_UNIX }, { "Foo", wxPATH_NORM_CASE, "Foo", wxPATH_UNIX },
@@ -325,8 +325,8 @@ void FileNameTestCase::TestNormalize()
"c:\\users\\zeitlin", wxPATH_DOS }, "c:\\users\\zeitlin", wxPATH_DOS },
// test wxPATH_NORM_ABSOLUTE // test wxPATH_NORM_ABSOLUTE
{ "a/b/", wxPATH_NORM_ABSOLUTE, cwd + "a/b/", wxPATH_UNIX }, { "a/b/", wxPATH_NORM_ABSOLUTE, "CWD/a/b/", wxPATH_UNIX },
{ "a/b/c.ext", wxPATH_NORM_ABSOLUTE, cwd + "a/b/c.ext", wxPATH_UNIX }, { "a/b/c.ext", wxPATH_NORM_ABSOLUTE, "CWD/a/b/c.ext", wxPATH_UNIX },
{ "/a", wxPATH_NORM_ABSOLUTE, "/a", wxPATH_UNIX }, { "/a", wxPATH_NORM_ABSOLUTE, "/a", wxPATH_UNIX },
// test giving no flags at all to Normalize() // test giving no flags at all to Normalize()
@@ -364,6 +364,9 @@ void FileNameTestCase::TestNormalize()
); );
// compare result with expected string // compare result with expected string
wxString expected(tests[i].expected);
expected.Replace(_T("HOME/"), home);
expected.Replace(_T("CWD/"), cwd);
CPPUNIT_ASSERT_EQUAL( fnt.expected, fn.GetFullPath(fnt.fmt) ); CPPUNIT_ASSERT_EQUAL( fnt.expected, fn.GetFullPath(fnt.fmt) );
} }
} }

View File

@@ -79,7 +79,7 @@ wxSockAddressPtr SocketTestCase::GetServer() const
addr->Hostname(gs_serverHost); addr->Hostname(gs_serverHost);
addr->Service("www"); addr->Service("www");
ptr.reset(addr); ptr = wxSockAddressPtr(addr);
} }
return ptr; return ptr;
@@ -104,7 +104,7 @@ wxSocketClientPtr SocketTestCase::GetHTTPSocket(int flags) const
sock->Write(httpGetRoot.ToAscii(), httpGetRoot.length()); sock->Write(httpGetRoot.ToAscii(), httpGetRoot.length());
ptr.reset(sock); ptr = wxSocketClientPtr(sock);
return ptr; return ptr;
} }

View File

@@ -205,7 +205,7 @@ void CrtTestCase::Strpbrk()
CPPUNIT_ASSERT_EQUAL( ',', *wxStrpbrk(strWX.c_str(), s.mb_str()) ); CPPUNIT_ASSERT_EQUAL( ',', *wxStrpbrk(strWX.c_str(), s.mb_str()) );
CPPUNIT_ASSERT_EQUAL( L',', *wxStrpbrk(strWX.c_str(), s.wc_str()) ); CPPUNIT_ASSERT_EQUAL( L',', *wxStrpbrk(strWX.c_str(), s.wc_str()) );
CPPUNIT_ASSERT_EQUAL( (const char *)NULL, wxStrpbrk(strWX, "xyz") ); CPPUNIT_ASSERT_EQUAL( (char *)NULL, wxStrpbrk(strWX, "xyz") );
CPPUNIT_ASSERT_EQUAL( (const wchar_t *)NULL, wxStrpbrk(strWX.c_str(), L"xyz") ); CPPUNIT_ASSERT_EQUAL( (wchar_t *)NULL, wxStrpbrk(strWX.c_str(), L"xyz") );
} }

View File

@@ -27,8 +27,13 @@
// to it should fail // to it should fail
struct StringConversionData struct StringConversionData
{ {
const char *str; StringConversionData(const char *str_, const wchar_t *wcs_, int flags_ = 0)
const wchar_t *wcs; : str(str_), wcs(wcs_), flags(flags_)
{
}
const char * const str;
const wchar_t * const wcs;
enum enum
{ {
@@ -36,7 +41,7 @@ struct StringConversionData
ONLY_MB2WC = 1 // only test str -> wcs conversion ONLY_MB2WC = 1 // only test str -> wcs conversion
}; };
int flags; const int flags;
// test that the conversion between str and wcs (subject to flags) succeeds // test that the conversion between str and wcs (subject to flags) succeeds
// //
@@ -281,21 +286,22 @@ void UnicodeTestCase::ConversionUTF7()
static const StringConversionData utf7data[] = static const StringConversionData utf7data[] =
{ {
// normal fragments // normal fragments
{ "+AKM-", L"\xa3" }, StringConversionData("+AKM-", L"\xa3"),
{ "+AOk-t+AOk-", L"\xe9t\xe9" }, StringConversionData("+AOk-t+AOk-", L"\xe9t\xe9"),
// this one is an alternative valid encoding of the same string // this one is an alternative valid encoding of the same string
{ "+AOk-t+AOk", L"\xe9t\xe9", StringConversionData::ONLY_MB2WC }, StringConversionData("+AOk-t+AOk", L"\xe9t\xe9",
StringConversionData::ONLY_MB2WC),
// some special cases // some special cases
{ "+-", L"+" }, StringConversionData("+-", L"+"),
{ "+--", L"+-" }, StringConversionData("+--", L"+-"),
// the following are invalid UTF-7 sequences // the following are invalid UTF-7 sequences
{ "\xa3", NULL }, StringConversionData("\xa3", NULL),
{ "+", NULL }, StringConversionData("+", NULL),
{ "+~", NULL }, StringConversionData("+~", NULL),
{ "a+", NULL }, StringConversionData("a+", NULL),
}; };
for ( size_t n = 0; n < WXSIZEOF(utf7data); n++ ) for ( size_t n = 0; n < WXSIZEOF(utf7data); n++ )
@@ -322,9 +328,9 @@ void UnicodeTestCase::ConversionUTF8()
static const StringConversionData utf8data[] = static const StringConversionData utf8data[] =
{ {
#ifdef wxHAVE_U_ESCAPE #ifdef wxHAVE_U_ESCAPE
{ "\xc2\xa3", L"\u00a3" }, StringConversionData("\xc2\xa3", L"\u00a3"),
#endif #endif
{ "\xc2", NULL }, StringConversionData("\xc2", NULL),
}; };
wxCSConv conv(_T("utf-8")); wxCSConv conv(_T("utf-8"));
@@ -341,11 +347,14 @@ void UnicodeTestCase::ConversionUTF16()
static const StringConversionData utf16data[] = static const StringConversionData utf16data[] =
{ {
#ifdef wxHAVE_U_ESCAPE #ifdef wxHAVE_U_ESCAPE
{ "\x04\x1f\x04\x40\x04\x38\x04\x32\x04\x35\x04\x42\0\0", StringConversionData(
L"\u041f\u0440\u0438\u0432\u0435\u0442" }, "\x04\x1f\x04\x40\x04\x38\x04\x32\x04\x35\x04\x42\0\0",
{ "\x01\0\0b\x01\0\0a\x01\0\0r\0\0", L"\u0100b\u0100a\u0100r" }, L"\u041f\u0440\u0438\u0432\u0435\u0442"),
StringConversionData(
"\x01\0\0b\x01\0\0a\x01\0\0r\0\0",
L"\u0100b\u0100a\u0100r"),
#endif #endif
{ "\0f\0o\0o\0\0", L"foo" }, StringConversionData("\0f\0o\0o\0\0", L"foo"),
}; };
wxCSConv conv(wxFONTENCODING_UTF16BE); wxCSConv conv(wxFONTENCODING_UTF16BE);
@@ -368,11 +377,11 @@ void UnicodeTestCase::ConversionUTF32()
static const StringConversionData utf32data[] = static const StringConversionData utf32data[] =
{ {
#ifdef wxHAVE_U_ESCAPE #ifdef wxHAVE_U_ESCAPE
{ StringConversionData(
"\0\0\x04\x1f\0\0\x04\x40\0\0\x04\x38\0\0\x04\x32\0\0\x04\x35\0\0\x04\x42\0\0\0\0", "\0\0\x04\x1f\0\0\x04\x40\0\0\x04\x38\0\0\x04\x32\0\0\x04\x35\0\0\x04\x42\0\0\0\0",
L"\u041f\u0440\u0438\u0432\u0435\u0442" }, L"\u041f\u0440\u0438\u0432\u0435\u0442"),
#endif #endif
{ "\0\0\0f\0\0\0o\0\0\0o\0\0\0\0", L"foo" }, StringConversionData("\0\0\0f\0\0\0o\0\0\0o\0\0\0\0", L"foo"),
}; };
wxCSConv conv(wxFONTENCODING_UTF32BE); wxCSConv conv(wxFONTENCODING_UTF32BE);