added a macro for comparison size_t variables with literal constants, this is less ugly than explicitly casting the arguments to size_t; use it to fix base64 compilation under 64 bit platforms

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47633 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-07-21 23:41:07 +00:00
parent 8b51786f6e
commit d2001a563b
2 changed files with 10 additions and 8 deletions

View File

@@ -28,13 +28,13 @@
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#pragma warn -8022 #pragma warn -8022
#endif #endif
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Set the default format for the errors, which can be used by an IDE to jump // Set the default format for the errors, which can be used by an IDE to jump
// to the error location. This default gets overridden by the cppunit headers // to the error location. This default gets overridden by the cppunit headers
// for some compilers (e.g. VC++). // for some compilers (e.g. VC++).
#ifndef CPPUNIT_COMPILER_LOCATION_FORMAT #ifndef CPPUNIT_COMPILER_LOCATION_FORMAT
#define CPPUNIT_COMPILER_LOCATION_FORMAT "%p:%l:" #define CPPUNIT_COMPILER_LOCATION_FORMAT "%p:%l:"
#endif #endif
@@ -80,6 +80,8 @@
// Use this macro to compare a wxString with a literal string. // Use this macro to compare a wxString with a literal string.
#define WX_ASSERT_STR_EQUAL(p, s) CPPUNIT_ASSERT_EQUAL(wxString(p), s) #define WX_ASSERT_STR_EQUAL(p, s) CPPUNIT_ASSERT_EQUAL(wxString(p), s)
// Use this macro to compare a size_t with a literal integer
#define WX_ASSERT_SIZET_EQUAL(n, m) CPPUNIT_ASSERT_EQUAL(((size_t)n), m)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// stream inserter for wxString // stream inserter for wxString

View File

@@ -59,7 +59,7 @@ static void generateRandomData(void* buff, size_t len)
static void generateGibberish(void* buff, size_t len) static void generateGibberish(void* buff, size_t len)
{ {
static const unsigned char cb64[] = static const unsigned char cb64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
unsigned char *cbuff = (unsigned char *)buff; unsigned char *cbuff = (unsigned char *)buff;
@@ -129,7 +129,7 @@ void Base64TestCase::EncodeDecodeEmpty()
CPPUNIT_ASSERT(resultmt.empty()); CPPUNIT_ASSERT(resultmt.empty());
bufmt = wxBase64Decode(resultmt); bufmt = wxBase64Decode(resultmt);
CPPUNIT_ASSERT_EQUAL(0u, bufmt.GetDataLen()); WX_ASSERT_SIZET_EQUAL(0, bufmt.GetDataLen());
} }
void Base64TestCase::EncodeDecodeA() void Base64TestCase::EncodeDecodeA()
@@ -138,7 +138,7 @@ void Base64TestCase::EncodeDecodeA()
CPPUNIT_ASSERT_EQUAL(wxString("QQ=="), str); CPPUNIT_ASSERT_EQUAL(wxString("QQ=="), str);
wxMemoryBuffer buf = wxBase64Decode(str); wxMemoryBuffer buf = wxBase64Decode(str);
CPPUNIT_ASSERT_EQUAL(1u, buf.GetDataLen()); WX_ASSERT_SIZET_EQUAL(1, buf.GetDataLen());
CPPUNIT_ASSERT_EQUAL('A', *(char *)buf.GetData()); CPPUNIT_ASSERT_EQUAL('A', *(char *)buf.GetData());
} }
@@ -148,7 +148,7 @@ void Base64TestCase::EncodeDecodeAB()
CPPUNIT_ASSERT_EQUAL(wxString("QUI="), str); CPPUNIT_ASSERT_EQUAL(wxString("QUI="), str);
wxMemoryBuffer buf = wxBase64Decode(str); wxMemoryBuffer buf = wxBase64Decode(str);
CPPUNIT_ASSERT_EQUAL(2u, buf.GetDataLen()); WX_ASSERT_SIZET_EQUAL(2, buf.GetDataLen());
CPPUNIT_ASSERT_EQUAL('A', buf[0]); CPPUNIT_ASSERT_EQUAL('A', buf[0]);
CPPUNIT_ASSERT_EQUAL('B', buf[1]); CPPUNIT_ASSERT_EQUAL('B', buf[1]);
} }
@@ -159,7 +159,7 @@ void Base64TestCase::EncodeDecodeABC()
CPPUNIT_ASSERT_EQUAL(wxString("QUJD"), str); CPPUNIT_ASSERT_EQUAL(wxString("QUJD"), str);
wxMemoryBuffer buf = wxBase64Decode(str); wxMemoryBuffer buf = wxBase64Decode(str);
CPPUNIT_ASSERT_EQUAL(3u, buf.GetDataLen()); WX_ASSERT_SIZET_EQUAL(3, buf.GetDataLen());
CPPUNIT_ASSERT_EQUAL('A', buf[0]); CPPUNIT_ASSERT_EQUAL('A', buf[0]);
CPPUNIT_ASSERT_EQUAL('B', buf[1]); CPPUNIT_ASSERT_EQUAL('B', buf[1]);
CPPUNIT_ASSERT_EQUAL('C', buf[2]); CPPUNIT_ASSERT_EQUAL('C', buf[2]);
@@ -171,7 +171,7 @@ void Base64TestCase::EncodeDecodeABCD()
CPPUNIT_ASSERT_EQUAL(wxString("QUJDRA=="), str); CPPUNIT_ASSERT_EQUAL(wxString("QUJDRA=="), str);
wxMemoryBuffer buf = wxBase64Decode(str); wxMemoryBuffer buf = wxBase64Decode(str);
CPPUNIT_ASSERT_EQUAL(4u, buf.GetDataLen()); WX_ASSERT_SIZET_EQUAL(4, buf.GetDataLen());
CPPUNIT_ASSERT_EQUAL('A', buf[0]); CPPUNIT_ASSERT_EQUAL('A', buf[0]);
CPPUNIT_ASSERT_EQUAL('B', buf[1]); CPPUNIT_ASSERT_EQUAL('B', buf[1]);
CPPUNIT_ASSERT_EQUAL('C', buf[2]); CPPUNIT_ASSERT_EQUAL('C', buf[2]);