]> git.saurik.com Git - wxWidgets.git/commitdiff
fixed ToString() for negative long longs (bug 1101426)
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 27 Feb 2005 23:08:13 +0000 (23:08 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 27 Feb 2005 23:08:13 +0000 (23:08 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32433 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/longlong.cpp
tests/longlong/longlongtest.cpp

index 62afbf79a4dc92e3a00d6218d025376015cb2762..aa40465563c3c8b3e3972acc09dcbb0ff25c5977 100644 (file)
@@ -1105,7 +1105,10 @@ void *wxULongLongWx::asArray(void) const
                                                                      \
         while ( ll != 0 )                                            \
         {                                                            \
                                                                      \
         while ( ll != 0 )                                            \
         {                                                            \
-            result.Prepend((wxChar)(_T('0') + (ll % 10).ToLong()));  \
+            long digit = (ll % 10).ToLong();                         \
+            if ( neg )                                               \
+                digit = -digit;                                      \
+            result.Prepend((wxChar)(_T('0') + digit));               \
             ll /= 10;                                                \
         }                                                            \
                                                                      \
             ll /= 10;                                                \
         }                                                            \
                                                                      \
index 5b7920bf879990c03990d53ea10a5cebed698f0a..043a259cefdbe5094a38ee0266618d7cfbd93bf5 100644 (file)
@@ -303,6 +303,9 @@ void LongLongTestCase::ToString()
     a.Negate();
     CPPUNIT_ASSERT( a.ToString() == _T("-1311768467139281697") );
 
     a.Negate();
     CPPUNIT_ASSERT( a.ToString() == _T("-1311768467139281697") );
 
+    wxLongLong llMin(LONG_MIN, 0);
+    CPPUNIT_ASSERT( a.ToString() == _T("-9223372036854775808") );
+
 #if wxUSE_LONGLONG_WX
     wxLongLongWx a1(a.GetHi(), a.GetLo());
     CPPUNIT_ASSERT( a1.ToString() == _T("-1311768467139281697") );
 #if wxUSE_LONGLONG_WX
     wxLongLongWx a1(a.GetHi(), a.GetLo());
     CPPUNIT_ASSERT( a1.ToString() == _T("-1311768467139281697") );