mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 10:32:57 +01:00
fix(NumericString): Bug in NumericString with decSep != '.' #3159
This commit is contained in:
parent
ba6404917c
commit
b9b540faff
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user