Fix several problems with number formatting in wxNumberFormatter.

We shouldn't add thousands separators nor remove trailing zeros for the
numbers in scientific format.

Also avoid "-0" as output.

See #15625.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75560 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-01-05 21:10:52 +00:00
parent d49096e10f
commit 419480cf22
2 changed files with 52 additions and 2 deletions

View File

@@ -147,6 +147,14 @@ void NumFormatterTestCase::DoubleToString()
wxNumberFormatter::ToString(123456789., 1));
CPPUNIT_ASSERT_EQUAL("123,456,789.012",
wxNumberFormatter::ToString(123456789.012, 3));
CPPUNIT_ASSERT_EQUAL("12,345",
wxNumberFormatter::ToString(12345.012, -1));
CPPUNIT_ASSERT_EQUAL("-123.1230",
wxNumberFormatter::ToString(-123.123, 4, wxNumberFormatter::Style_None));
CPPUNIT_ASSERT_EQUAL("0.0",
wxNumberFormatter::ToString(0.02, 1, wxNumberFormatter::Style_None));
CPPUNIT_ASSERT_EQUAL("-0.0",
wxNumberFormatter::ToString(-0.02, 1, wxNumberFormatter::Style_None));
}
void NumFormatterTestCase::NoTrailingZeroes()
@@ -194,6 +202,36 @@ void NumFormatterTestCase::NoTrailingZeroes()
"123.456",
wxNumberFormatter::ToString(123.456, 9, wxNumberFormatter::Style_NoTrailingZeroes)
);
CPPUNIT_ASSERT_EQUAL
(
"123.12",
wxNumberFormatter::ToString(123.123, 2, wxNumberFormatter::Style_NoTrailingZeroes)
);
CPPUNIT_ASSERT_EQUAL
(
"123",
wxNumberFormatter::ToString(123.123, 0, wxNumberFormatter::Style_NoTrailingZeroes)
);
CPPUNIT_ASSERT_EQUAL
(
"0",
wxNumberFormatter::ToString(-0.000123, 3, wxNumberFormatter::Style_NoTrailingZeroes)
);
CPPUNIT_ASSERT_EQUAL
(
"123",
wxNumberFormatter::ToString(123., -1, wxNumberFormatter::Style_NoTrailingZeroes)
);
CPPUNIT_ASSERT_EQUAL
(
"1e-120",
wxNumberFormatter::ToString(1e-120, -1, wxNumberFormatter::Style_NoTrailingZeroes)
);
}
void NumFormatterTestCase::LongFromString()