fix(NumericString): Bug in NumericString with decSep != '.' #3159

This commit is contained in:
Alex Fabijanic 2021-06-25 21:03:28 +02:00
parent ba6404917c
commit b9b540faff
2 changed files with 5 additions and 2 deletions

View File

@ -16,7 +16,8 @@
// +++ double conversion +++
#define double_conversion poco_double_conversion // don't collide with standalone double_conversion library
// don't collide with standalone double_conversion library
#define double_conversion poco_double_conversion
#define UNIMPLEMENTED poco_bugcheck
#include "diy-fp.cc"
#include "cached-powers.cc"
@ -50,7 +51,7 @@ void pad(std::string& str, int precision, int width, char prefix = ' ', char dec
std::string::size_type decSepPos = str.find(decSep);
if (decSepPos == std::string::npos)
{
str.append(1, '.');
str.append(1, decSep);
decSepPos = str.size() - 1;
}

View File

@ -812,6 +812,7 @@ void StringTest::testNumericStringPadding()
{
std::string str;
assertTrue (floatToStr(str, 0.999f, 2, 4) == "1.00");
assertTrue (floatToStr(str, 0.999f, 2, 4, '.', ',') == "1,00");
assertTrue (floatToStr(str, 0.945f, 2, 4) == "0.95");
assertTrue (floatToStr(str, 0.944f, 2, 4) == "0.94");
assertTrue (floatToStr(str, 12.45f, 2, 5) == "12.45");
@ -829,6 +830,7 @@ void StringTest::testNumericStringPadding()
assertTrue (doubleToStr(str, 12.45, 2, 6) == " 12.45");
assertTrue (doubleToStr(str, 12.455, 3, 7) == " 12.455");
assertTrue (doubleToStr(str, 12.455, 2, 6) == " 12.46");
assertTrue (doubleToStr(str, 12345.678, 3, 6, '.', ',') == "12.345,678");
assertTrue (doubleToStr(str, 1.23556E-16, 2, 6) == "1.24e-16");
}