]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/longlong/longlongtest.cpp
PCH less build fix
[wxWidgets.git] / tests / longlong / longlongtest.cpp
index 93ef09515074c2cd48870c7161426012c132b98c..a9142a6fb5dba21cd896c7ea448ed7dc8c9929ff 100644 (file)
@@ -11,7 +11,7 @@
 // headers
 // ----------------------------------------------------------------------------
 
-#include "wx/wxprec.h"
+#include "testprec.h"
 
 #ifdef __BORLANDC__
     #pragma hdrstop
@@ -24,7 +24,7 @@
 #include "wx/longlong.h"
 #include "wx/timer.h"
 
-#include "wx/cppunit.h"
+#if wxUSE_LONGLONG
 
 // ----------------------------------------------------------------------------
 // helpers for testing
@@ -68,6 +68,7 @@ private:
         CPPUNIT_TEST( Division );
         CPPUNIT_TEST( BitOperations );
         CPPUNIT_TEST( ToString );
+        CPPUNIT_TEST( LoHi );
     CPPUNIT_TEST_SUITE_END();
 
     void Conversion();
@@ -77,6 +78,7 @@ private:
     void Division();
     void BitOperations();
     void ToString();
+    void LoHi();
 
     DECLARE_NO_COPY_CLASS(LongLongTestCase)
 };
@@ -235,37 +237,37 @@ void LongLongTestCase::Division()
 
 void LongLongTestCase::BitOperations()
 {
-    for ( size_t n = 0; n < ITEMS; n++ )
+    for ( size_t m = 0; m < ITEMS; m++ )
     {
         wxLongLong a = RAND_LL();
 
         for ( size_t n = 0; n < 33; n++ )
         {
             wxLongLong b(a.GetHi(), a.GetLo()), c, d = b, e;
-            d >>= n; 
-            c = b >> n; 
+            d >>= n;
+            c = b >> n;
             CPPUNIT_ASSERT( c == d );
-            d <<= n; 
-            e = c << n; 
+            d <<= n;
+            e = c << n;
             CPPUNIT_ASSERT( d == e );
 
 #if wxUSE_LONGLONG_WX
             wxLongLongWx b1(a.GetHi(), a.GetLo()), c1, d1 = b1, e1;
-            d1 >>= n; 
-            c1 = b1 >> n; 
+            d1 >>= n;
+            c1 = b1 >> n;
             CPPUNIT_ASSERT( c1 == d1 );
-            d1 <<= n; 
-            e1 = c1 << n; 
+            d1 <<= n;
+            e1 = c1 << n;
             CPPUNIT_ASSERT( d1 == e1 );
 #endif
 
 #if wxUSE_LONGLONG_NATIVE
             wxLongLongNative b2(a.GetHi(), a.GetLo()), c2, d2 = b2, e2;
-            d2 >>= n; 
-            c2 = b2 >> n; 
+            d2 >>= n;
+            c2 = b2 >> n;
             CPPUNIT_ASSERT( c2 == d2 );
-            d2 <<= n; 
-            e2 = c2 << n; 
+            d2 <<= n;
+            e2 = c2 << n;
             CPPUNIT_ASSERT( d2 == e2 );
 #endif
         }
@@ -283,6 +285,10 @@ void LongLongTestCase::ToString()
         s2 = a.ToString();
         CPPUNIT_ASSERT( s1 == s2 );
 
+        s2 = wxEmptyString;
+        s2 << a;
+        CPPUNIT_ASSERT( s1 == s2 );
+
 #if wxUSE_LONGLONG_WX
         wxLongLongWx a1 = testLongs[n];
         s2 = a1.ToString();
@@ -301,6 +307,9 @@ void LongLongTestCase::ToString()
     a.Negate();
     CPPUNIT_ASSERT( a.ToString() == _T("-1311768467139281697") );
 
+    wxLongLong llMin(-2147483647L - 1L, 0);
+    CPPUNIT_ASSERT( llMin.ToString() == _T("-9223372036854775808") );
+
 #if wxUSE_LONGLONG_WX
     wxLongLongWx a1(a.GetHi(), a.GetLo());
     CPPUNIT_ASSERT( a1.ToString() == _T("-1311768467139281697") );
@@ -317,3 +326,15 @@ void LongLongTestCase::ToString()
 
 }
 
+void LongLongTestCase::LoHi()
+{
+    wxLongLong ll(123, 456);
+    CPPUNIT_ASSERT_EQUAL( 456u, ll.GetLo() );
+    CPPUNIT_ASSERT_EQUAL( 123, ll.GetHi() );
+
+    wxULongLong ull(987, 654);
+    CPPUNIT_ASSERT_EQUAL( 654u, ull.GetLo() );
+    CPPUNIT_ASSERT_EQUAL( 987u, ull.GetHi() );
+}
+
+#endif // wxUSE_LONGLONG