Fixed #5492 (Fix small bug in MathLib::isFloat())

This commit is contained in:
Alexander Mai 2014-02-27 16:08:49 +01:00 committed by Daniel Marjamäki
parent dea4107245
commit a02bbfa47e
2 changed files with 7 additions and 0 deletions

View File

@ -131,6 +131,10 @@ bool MathLib::isFloat(const std::string &s)
case LEADING_DECIMAL: case LEADING_DECIMAL:
if (std::isdigit(*it)) if (std::isdigit(*it))
state=BASE_DIGITS2; state=BASE_DIGITS2;
else if (*it=='e' || *it=='E')
state=E;
else
return false;
break; break;
case BASE_DIGITS1: case BASE_DIGITS1:
if (*it=='e' || *it=='E') if (*it=='e' || *it=='E')

View File

@ -368,6 +368,9 @@ private:
ASSERT_EQUALS(false , MathLib::isFloat(" 0. ")); ASSERT_EQUALS(false , MathLib::isFloat(" 0. "));
ASSERT_EQUALS(false , MathLib::isFloat(" 0.")); ASSERT_EQUALS(false , MathLib::isFloat(" 0."));
ASSERT_EQUALS(false , MathLib::isFloat("0.."));
ASSERT_EQUALS(false , MathLib::isFloat("..0.."));
ASSERT_EQUALS(false , MathLib::isFloat("..0"));
ASSERT_EQUALS(true , MathLib::isFloat("0.0")); ASSERT_EQUALS(true , MathLib::isFloat("0.0"));
ASSERT_EQUALS(true , MathLib::isFloat("-0.")); ASSERT_EQUALS(true , MathLib::isFloat("-0."));
ASSERT_EQUALS(true , MathLib::isFloat("+0.")); ASSERT_EQUALS(true , MathLib::isFloat("+0."));