mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-26 18:42:41 +01:00
Poco::NumberFormatter::format(float, precision) rounding changed #1128
This commit is contained in:
@@ -686,6 +686,28 @@ void StringTest::testStringToDouble()
|
||||
}
|
||||
|
||||
|
||||
void StringTest::testNumericStringPadding()
|
||||
{
|
||||
std::string str;
|
||||
assert (floatToStr(str, 0.999f, 2, 4) == "1.00");
|
||||
assert (floatToStr(str, 0.945f, 2, 4) == "0.95");
|
||||
assert (floatToStr(str, 0.944f, 2, 4) == "0.94");
|
||||
assert (floatToStr(str, 12.45f, 2, 5) == "12.45");
|
||||
assert (floatToStr(str, 12.45f, 1, 4) == "12.5");
|
||||
assert (floatToStr(str, 12.45f, 2, 6) == " 12.45");
|
||||
assert (floatToStr(str, 12.455f, 3, 7) == " 12.455");
|
||||
assert (floatToStr(str, 12.455f, 2, 6) == " 12.46");
|
||||
|
||||
assert (doubleToStr(str, 0.999, 2, 4) == "1.00");
|
||||
assert (doubleToStr(str, 0.945, 2, 4) == "0.95");
|
||||
assert (doubleToStr(str, 0.944, 2, 4) == "0.94");
|
||||
assert (doubleToStr(str, 12.45, 2, 5) == "12.45");
|
||||
assert (doubleToStr(str, 12.45, 1, 4) == "12.5");
|
||||
assert (doubleToStr(str, 12.45, 2, 6) == " 12.45");
|
||||
assert (floatToStr(str, 12.455f, 3, 7) == " 12.455");
|
||||
assert (floatToStr(str, 12.455f, 2, 6) == " 12.46");
|
||||
}
|
||||
|
||||
void StringTest::testStringToFloatError()
|
||||
{
|
||||
char ds = decimalSeparator();
|
||||
@@ -1166,6 +1188,7 @@ CppUnit::Test* StringTest::suite()
|
||||
CppUnit_addTest(pSuite, StringTest, testStringToInt);
|
||||
CppUnit_addTest(pSuite, StringTest, testStringToFloat);
|
||||
CppUnit_addTest(pSuite, StringTest, testStringToDouble);
|
||||
CppUnit_addTest(pSuite, StringTest, testNumericStringPadding);
|
||||
CppUnit_addTest(pSuite, StringTest, testStringToFloatError);
|
||||
CppUnit_addTest(pSuite, StringTest, testNumericLocale);
|
||||
//CppUnit_addTest(pSuite, StringTest, benchmarkStrToFloat);
|
||||
|
||||
Reference in New Issue
Block a user