[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/kspread
From:       Marijn Kruisselbrink <m.kruisselbrink () student ! tue ! nl>
Date:       2010-09-25 13:25:19
Message-ID: 20100925132519.7AF36AC88C () svn ! kde ! org
[Download RAW message or body]

SVN commit 1179445 by mkruisselbrink:

properly handle a data style with an unspecified precision
BUG: 239718

 M  +1 -1      ValueFormatter.cpp  
 M  +5 -1      tests/TestValueFormatter.cpp  


--- trunk/koffice/kspread/ValueFormatter.cpp #1179444:1179445
@@ -262,7 +262,7 @@
             return prefix + postfix;
         } else if (formatString.contains(QLatin1Char('.'))) {
             precision = formatString.length() - formatString.indexOf(QLatin1Char('.')) - 1;
-        } else {
+        } else if (precision != -1){
             precision = 0;
         }
     }
--- trunk/koffice/kspread/tests/TestValueFormatter.cpp #1179444:1179445
@@ -203,8 +203,12 @@
 
     QTest::newRow("negative sign in format string") <<
             -5.0 << 0 << Format::Number << Style::DefaultFloatFormat << "" << "(-.)" << "(-5)";
-}
 
+    QTest::newRow("unspecified precision 1") <<
+            1.0 << -1 << Format::Number << Style::DefaultFloatFormat << "" << "0" << "1";
+    QTest::newRow("unspecified precision 0.5") <<
+            0.5 << -1 << Format::Number << Style::DefaultFloatFormat << "" << "0" << "0.5";}
+
 void TestValueFormatter::testCreateNumberFormat()
 {
     QFETCH(double, value);
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic