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
-// for functions returning any of unsigned {int,long} or size_t
-inline void
-assertEquals(int expected,
- unsigned actual,
- CppUnit::SourceLine sourceLine,
- const std::string& message)
-{
- assertEquals(unsigned(expected), actual, sourceLine, message);
-}
+// for functions returning size_t
+WX_CPPUNIT_ASSERT_EQUALS(int, size_t);
-inline void
-assertEquals(int expected,
- unsigned long actual,
- CppUnit::SourceLine sourceLine,
- const std::string& message)
-{
- assertEquals((unsigned long)expected, actual, sourceLine, message);
-}
+// 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__
-// we also need this one to resolve ambiguity in the tests comparing unsigned
-// short (e.g. wxDateTime_t returned by several wxDateTime methods) with
-// 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);
-}
+WX_CPPUNIT_ASSERT_EQUALS(int, int);
+WX_CPPUNIT_ASSERT_EQUALS(size_t, size_t);
-// this one is useful for wxTextCtrl functions which return longs
-inline void
-assertEquals(int expected,
- long actual,
- CppUnit::SourceLine sourceLine,
- const std::string& message)
-{
- assertEquals((long)expected, actual, sourceLine, message);
-}
+#endif // VC6
CPPUNIT_NS_END
static const struct FileNameTest
{
- wxString original;
+ const char *original;
int flags;
- wxString expected;
+ const char *expected;
wxPathFormat fmt;
} tests[] =
{
// test wxPATH_NORM_TILDE
// 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, 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
{ "Foo", wxPATH_NORM_CASE, "Foo", wxPATH_UNIX },
"c:\\users\\zeitlin", wxPATH_DOS },
// test wxPATH_NORM_ABSOLUTE
- { "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/", wxPATH_NORM_ABSOLUTE, "CWD/a/b/", wxPATH_UNIX },
+ { "a/b/c.ext", wxPATH_NORM_ABSOLUTE, "CWD/a/b/c.ext", wxPATH_UNIX },
{ "/a", wxPATH_NORM_ABSOLUTE, "/a", wxPATH_UNIX },
// test giving no flags at all to Normalize()
);
// 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) );
}
}
addr->Hostname(gs_serverHost);
addr->Service("www");
- ptr.reset(addr);
+ ptr = wxSockAddressPtr(addr);
}
return ptr;
sock->Write(httpGetRoot.ToAscii(), httpGetRoot.length());
- ptr.reset(sock);
+ ptr = wxSocketClientPtr(sock);
return ptr;
}
CPPUNIT_ASSERT_EQUAL( ',', *wxStrpbrk(strWX.c_str(), s.mb_str()) );
CPPUNIT_ASSERT_EQUAL( L',', *wxStrpbrk(strWX.c_str(), s.wc_str()) );
- CPPUNIT_ASSERT_EQUAL( (const char *)NULL, wxStrpbrk(strWX, "xyz") );
- CPPUNIT_ASSERT_EQUAL( (const wchar_t *)NULL, wxStrpbrk(strWX.c_str(), L"xyz") );
+ CPPUNIT_ASSERT_EQUAL( (char *)NULL, wxStrpbrk(strWX, "xyz") );
+ CPPUNIT_ASSERT_EQUAL( (wchar_t *)NULL, wxStrpbrk(strWX.c_str(), L"xyz") );
}
// to it should fail
struct StringConversionData
{
- const char *str;
- const wchar_t *wcs;
+ StringConversionData(const char *str_, const wchar_t *wcs_, int flags_ = 0)
+ : str(str_), wcs(wcs_), flags(flags_)
+ {
+ }
+
+ const char * const str;
+ const wchar_t * const wcs;
enum
{
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
//
static const StringConversionData utf7data[] =
{
// normal fragments
- { "+AKM-", L"\xa3" },
- { "+AOk-t+AOk-", L"\xe9t\xe9" },
+ StringConversionData("+AKM-", L"\xa3"),
+ StringConversionData("+AOk-t+AOk-", L"\xe9t\xe9"),
// 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
- { "+-", L"+" },
- { "+--", L"+-" },
+ StringConversionData("+-", L"+"),
+ StringConversionData("+--", L"+-"),
// the following are invalid UTF-7 sequences
- { "\xa3", NULL },
- { "+", NULL },
- { "+~", NULL },
- { "a+", NULL },
+ StringConversionData("\xa3", NULL),
+ StringConversionData("+", NULL),
+ StringConversionData("+~", NULL),
+ StringConversionData("a+", NULL),
};
for ( size_t n = 0; n < WXSIZEOF(utf7data); n++ )
static const StringConversionData utf8data[] =
{
#ifdef wxHAVE_U_ESCAPE
- { "\xc2\xa3", L"\u00a3" },
+ StringConversionData("\xc2\xa3", L"\u00a3"),
#endif
- { "\xc2", NULL },
+ StringConversionData("\xc2", NULL),
};
wxCSConv conv(_T("utf-8"));
static const StringConversionData utf16data[] =
{
#ifdef wxHAVE_U_ESCAPE
- { "\x04\x1f\x04\x40\x04\x38\x04\x32\x04\x35\x04\x42\0\0",
- L"\u041f\u0440\u0438\u0432\u0435\u0442" },
- { "\x01\0\0b\x01\0\0a\x01\0\0r\0\0", L"\u0100b\u0100a\u0100r" },
+ StringConversionData(
+ "\x04\x1f\x04\x40\x04\x38\x04\x32\x04\x35\x04\x42\0\0",
+ L"\u041f\u0440\u0438\u0432\u0435\u0442"),
+ StringConversionData(
+ "\x01\0\0b\x01\0\0a\x01\0\0r\0\0",
+ L"\u0100b\u0100a\u0100r"),
#endif
- { "\0f\0o\0o\0\0", L"foo" },
+ StringConversionData("\0f\0o\0o\0\0", L"foo"),
};
wxCSConv conv(wxFONTENCODING_UTF16BE);
static const StringConversionData utf32data[] =
{
#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",
- L"\u041f\u0440\u0438\u0432\u0435\u0442" },
+ L"\u041f\u0440\u0438\u0432\u0435\u0442"),
#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);