summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-02-15 22:05:29 +0100
committerEike Rathke <erack@redhat.com>2017-02-15 22:06:03 +0100
commit5e180078ecc4501900e41da48b279033a7529a96 (patch)
tree949424657e475148e9a2e8b77299a2e187ef4d07 /svl
parent63bc2b13cb344cce99348496838d7d2c2f690211 (diff)
unit test for engineering notation, tdf#105968
Change-Id: Ib5303f09cfda232b0bee88df3d76650165337c08
Diffstat (limited to 'svl')
-rw-r--r--svl/qa/unit/svl.cxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 9804c7eeaca5..8e185d561912 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -1221,6 +1221,41 @@ void Test::testUserDefinedNumberFormats()
sCode = "[DBNum2][$-0404]General\\ ";
checkPreviewString(aFormatter, sCode, 120, eLang, sExpected);
}
+ { // tdf#105968 engineering format with value rounded up to next magnitude
+ sCode = "##0.00E+00";
+ sExpected = "100.00E+00";
+ checkPreviewString(aFormatter, sCode, 99.995, eLang, sExpected);
+ // test '1'=='1' assumption
+ checkPreviewString(aFormatter, sCode, 100.0, eLang, sExpected);
+ sExpected = "199.99E+00";
+ checkPreviewString(aFormatter, sCode, 199.99, eLang, sExpected);
+ sExpected = "1.00E+03";
+ checkPreviewString(aFormatter, sCode, 1000.0, eLang, sExpected);
+ // and another just "normally" rounded value
+ sExpected = "894.55E-06";
+ checkPreviewString(aFormatter, sCode, 0.000894549, eLang, sExpected);
+ // not expecting rounding into another magnitude
+ sExpected = "999.99E-06";
+ checkPreviewString(aFormatter, sCode, 0.000999991, eLang, sExpected);
+ // expecting rounding into another magnitude
+ sExpected = "1.00E-03";
+ checkPreviewString(aFormatter, sCode, 0.000999999, eLang, sExpected);
+
+ // Now the same all negative values.
+ sExpected = "-100.00E+00";
+ checkPreviewString(aFormatter, sCode, -99.995, eLang, sExpected);
+ checkPreviewString(aFormatter, sCode, -100.0, eLang, sExpected);
+ sExpected = "-199.99E+00";
+ checkPreviewString(aFormatter, sCode, -199.99, eLang, sExpected);
+ sExpected = "-1.00E+03";
+ checkPreviewString(aFormatter, sCode, -1000.0, eLang, sExpected);
+ sExpected = "-894.55E-06";
+ checkPreviewString(aFormatter, sCode, -0.000894549, eLang, sExpected);
+ sExpected = "-999.99E-06";
+ checkPreviewString(aFormatter, sCode, -0.000999991, eLang, sExpected);
+ sExpected = "-1.00E-03";
+ checkPreviewString(aFormatter, sCode, -0.000999999, eLang, sExpected);
+ }
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test);