Merge pull request #1285 from deathbaba/to_double-fix

Fixed bug when strings::to_double(“”, d) incorrectly returned true.
This commit is contained in:
Viktor Govako 2016-01-07 23:23:41 +03:00
commit 1d480e14c2
2 changed files with 7 additions and 1 deletions

View file

@ -137,6 +137,9 @@ UNIT_TEST(to_double)
string s;
double d;
s = "";
TEST(!strings::to_double(s, d), ());
s = "0.123";
TEST(strings::to_double(s, d), ());
TEST_ALMOST_EQUAL_ULPS(0.123, d, ());
@ -159,6 +162,9 @@ UNIT_TEST(to_double)
s = "labuda";
TEST(!strings::to_double(s, d), ());
s = "123.456 we don't parse it.";
TEST(!strings::to_double(s, d), ());
}
UNIT_TEST(to_int)

View file

@ -81,7 +81,7 @@ bool to_double(char const * s, double & d)
{
char * stop;
d = strtod(s, &stop);
return stop && *stop == 0;
return stop && *stop == 0 && s != stop;
}
UniString MakeLowerCase(UniString const & s)