Skip to content

Commit

Permalink
fix(NumericString): Bug in NumericString with decSep != '.' #3159
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-f committed Jun 25, 2021
1 parent ba64049 commit b9b540f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Foundation/src/NumericString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions Foundation/testsuite/src/StringTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
}

Expand Down

0 comments on commit b9b540f

Please sign in to comment.