added some extra comparison operators to fix Sun CC 5.0 compilation to wxLongLongWx
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7651 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -3,8 +3,6 @@
|
|||||||
// Purpose: declaration of wxLongLong class - best implementation of a 64
|
// Purpose: declaration of wxLongLong class - best implementation of a 64
|
||||||
// bit integer for the current platform.
|
// bit integer for the current platform.
|
||||||
// Author: Jeffrey C. Ollie <jeff@ollie.clive.ia.us>, Vadim Zeitlin
|
// Author: Jeffrey C. Ollie <jeff@ollie.clive.ia.us>, Vadim Zeitlin
|
||||||
// Remarks: this class is not public in wxWindows 2.0! It is intentionally
|
|
||||||
// not documented and is for private use only.
|
|
||||||
// Modified by:
|
// Modified by:
|
||||||
// Created: 10.02.99
|
// Created: 10.02.99
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
@@ -459,6 +457,17 @@ public:
|
|||||||
bool operator>=(const wxLongLongWx& ll) const
|
bool operator>=(const wxLongLongWx& ll) const
|
||||||
{ return *this > ll || *this == ll; }
|
{ return *this > ll || *this == ll; }
|
||||||
|
|
||||||
|
bool operator<(long l) const { return *this < wxLongLongWx(l); }
|
||||||
|
bool operator>(long l) const { return *this > wxLongLongWx(l); }
|
||||||
|
bool operator==(long l) const
|
||||||
|
{
|
||||||
|
return l >= 0 ? (m_hi == 0 && m_lo == (unsigned long)l)
|
||||||
|
: (m_hi == -1 && m_lo == (unsigned long)l);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator<=(long l) const { return *this < l || *this == l; }
|
||||||
|
bool operator>=(long l) const { return *this > l || *this == l; }
|
||||||
|
|
||||||
// multiplication
|
// multiplication
|
||||||
wxLongLongWx operator*(const wxLongLongWx& ll) const;
|
wxLongLongWx operator*(const wxLongLongWx& ll) const;
|
||||||
wxLongLongWx& operator*=(const wxLongLongWx& ll);
|
wxLongLongWx& operator*=(const wxLongLongWx& ll);
|
||||||
|
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
//#define TEST_ARRAYS
|
//#define TEST_ARRAYS
|
||||||
//#define TEST_CMDLINE
|
//#define TEST_CMDLINE
|
||||||
#define TEST_DATETIME
|
//#define TEST_DATETIME
|
||||||
//#define TEST_DIR
|
//#define TEST_DIR
|
||||||
//#define TEST_DLLLOADER
|
//#define TEST_DLLLOADER
|
||||||
//#define TEST_EXECUTE
|
//#define TEST_EXECUTE
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
//#define TEST_HASH
|
//#define TEST_HASH
|
||||||
//#define TEST_LIST
|
//#define TEST_LIST
|
||||||
//#define TEST_LOG
|
//#define TEST_LOG
|
||||||
//#define TEST_LONGLONG
|
#define TEST_LONGLONG
|
||||||
//#define TEST_MIME
|
//#define TEST_MIME
|
||||||
//#define TEST_INFO_FUNCTIONS
|
//#define TEST_INFO_FUNCTIONS
|
||||||
//#define TEST_SOCKETS
|
//#define TEST_SOCKETS
|
||||||
@@ -950,28 +950,16 @@ static void TestBitOperations()
|
|||||||
{
|
{
|
||||||
puts("*** Testing wxLongLong bit operation ***\n");
|
puts("*** Testing wxLongLong bit operation ***\n");
|
||||||
|
|
||||||
wxLongLong a, c;
|
wxLongLong ll;
|
||||||
size_t nTested = 0;
|
size_t nTested = 0;
|
||||||
for ( size_t n = 0; n < 100000; n++ )
|
for ( size_t n = 0; n < 100000; n++ )
|
||||||
{
|
{
|
||||||
a = RAND_LL();
|
ll = RAND_LL();
|
||||||
|
|
||||||
#if wxUSE_LONGLONG_NATIVE
|
#if wxUSE_LONGLONG_NATIVE
|
||||||
for ( size_t n = 0; n < 33; n++ )
|
for ( size_t n = 0; n < 33; n++ )
|
||||||
{
|
{
|
||||||
wxLongLongNative b(a.GetHi(), a.GetLo());
|
|
||||||
|
|
||||||
b >>= n;
|
|
||||||
c = a >> n;
|
|
||||||
|
|
||||||
wxASSERT_MSG( b == c, "bit shift failure" );
|
|
||||||
|
|
||||||
b = wxLongLongNative(a.GetHi(), a.GetLo()) << n;
|
|
||||||
c = a << n;
|
|
||||||
|
|
||||||
wxASSERT_MSG( b == c, "bit shift failure" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // !wxUSE_LONGLONG_NATIVE
|
#else // !wxUSE_LONGLONG_NATIVE
|
||||||
puts("Can't do it without native long long type, test skipped.");
|
puts("Can't do it without native long long type, test skipped.");
|
||||||
|
|
||||||
@@ -990,6 +978,55 @@ static void TestBitOperations()
|
|||||||
puts(" done!");
|
puts(" done!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void TestLongLongComparison()
|
||||||
|
{
|
||||||
|
puts("*** Testing wxLongLong comparison ***\n");
|
||||||
|
|
||||||
|
static const long testLongs[] =
|
||||||
|
{
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
-1,
|
||||||
|
LONG_MAX,
|
||||||
|
LONG_MIN,
|
||||||
|
0x1234,
|
||||||
|
-0x1234
|
||||||
|
};
|
||||||
|
|
||||||
|
static const long ls[2] =
|
||||||
|
{
|
||||||
|
0x1234,
|
||||||
|
-0x1234,
|
||||||
|
};
|
||||||
|
|
||||||
|
wxLongLongWx lls[2];
|
||||||
|
lls[0] = ls[0];
|
||||||
|
lls[1] = ls[1];
|
||||||
|
|
||||||
|
for ( size_t n = 0; n < WXSIZEOF(testLongs); n++ )
|
||||||
|
{
|
||||||
|
bool res;
|
||||||
|
|
||||||
|
for ( size_t m = 0; m < WXSIZEOF(lls); m++ )
|
||||||
|
{
|
||||||
|
res = lls[m] > testLongs[n];
|
||||||
|
printf("0x%lx > 0x%lx is %s (%s)\n",
|
||||||
|
ls[m], testLongs[n], res ? "true" : "false",
|
||||||
|
res == (ls[m] > testLongs[n]) ? "ok" : "ERROR");
|
||||||
|
|
||||||
|
res = lls[m] < testLongs[n];
|
||||||
|
printf("0x%lx < 0x%lx is %s (%s)\n",
|
||||||
|
ls[m], testLongs[n], res ? "true" : "false",
|
||||||
|
res == (ls[m] < testLongs[n]) ? "ok" : "ERROR");
|
||||||
|
|
||||||
|
res = lls[m] == testLongs[n];
|
||||||
|
printf("0x%lx == 0x%lx is %s (%s)\n",
|
||||||
|
ls[m], testLongs[n], res ? "true" : "false",
|
||||||
|
res == (ls[m] == testLongs[n]) ? "ok" : "ERROR");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#undef MAKE_LL
|
#undef MAKE_LL
|
||||||
#undef RAND_LL
|
#undef RAND_LL
|
||||||
|
|
||||||
@@ -3409,14 +3446,15 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
TestSpeed();
|
TestSpeed();
|
||||||
}
|
}
|
||||||
TestMultiplication();
|
|
||||||
if ( 0 )
|
if ( 0 )
|
||||||
{
|
{
|
||||||
|
TestMultiplication();
|
||||||
TestDivision();
|
TestDivision();
|
||||||
TestAddition();
|
TestAddition();
|
||||||
TestLongLongConversion();
|
TestLongLongConversion();
|
||||||
TestBitOperations();
|
TestBitOperations();
|
||||||
}
|
}
|
||||||
|
TestLongLongComparison();
|
||||||
#endif // TEST_LONGLONG
|
#endif // TEST_LONGLONG
|
||||||
|
|
||||||
#ifdef TEST_HASH
|
#ifdef TEST_HASH
|
||||||
|
Reference in New Issue
Block a user