MathLib::isNullValue(): Fixed bug in detecting zero values. Improved test coverage of MathLib::IsNullValue().

This commit is contained in:
Martin Ettl 2014-04-12 02:14:50 +02:00
parent 9d51bfd015
commit 82092e412a
2 changed files with 22 additions and 1 deletions

View File

@ -561,7 +561,7 @@ bool MathLib::isNullValue(const std::string &s)
else if (*it == '.')
state = DOT;
else
return isValidSuffix(it, s.end());
return false;
break;
case PLUSMINUS:
if (*it == '0')

View File

@ -751,6 +751,14 @@ private:
ASSERT_EQUALS(true, MathLib::isNullValue("+00.00E+1f"));
ASSERT_EQUALS(true, MathLib::isNullValue("-00.00E+1f"));
// binary numbers
ASSERT_EQUALS(true, MathLib::isNullValue("0b00"));
ASSERT_EQUALS(true, MathLib::isNullValue("+0b00"));
ASSERT_EQUALS(true, MathLib::isNullValue("-0b00"));
// binary numbers (long)
ASSERT_EQUALS(true, MathLib::isNullValue("0b00L"));
ASSERT_EQUALS(true, MathLib::isNullValue("+0b00L"));
ASSERT_EQUALS(true, MathLib::isNullValue("-0b00L"));
// negative testing
ASSERT_EQUALS(false, MathLib::isNullValue("0.1"));
ASSERT_EQUALS(false, MathLib::isNullValue("1.0"));
@ -760,6 +768,19 @@ private:
ASSERT_EQUALS(false, MathLib::isNullValue(""));
ASSERT_EQUALS(false, MathLib::isNullValue("x"));
ASSERT_EQUALS(false, MathLib::isNullValue("garbage"));
ASSERT_EQUALS(false, MathLib::isNullValue("UL"));
ASSERT_EQUALS(false, MathLib::isNullValue("0x"));
ASSERT_EQUALS(false, MathLib::isNullValue("0xx"));
ASSERT_EQUALS(false, MathLib::isNullValue("0x0x"));
ASSERT_EQUALS(false, MathLib::isNullValue("0x000x"));
ASSERT_EQUALS(false, MathLib::isNullValue("0b"));
ASSERT_EQUALS(false, MathLib::isNullValue("0bx"));
ASSERT_EQUALS(false, MathLib::isNullValue("0b0x"));
ASSERT_EQUALS(false, MathLib::isNullValue("0b000x"));
ASSERT_EQUALS(false, MathLib::isNullValue("0.0Ex"));
ASSERT_EQUALS(false, MathLib::isNullValue("0.0E-x"));
ASSERT_EQUALS(false, MathLib::isNullValue("0.0E-1x"));
ASSERT_EQUALS(false, MathLib::isNullValue("0.0E-1fx"));
// suffix LUL is not allowed
ASSERT_EQUALS(false, MathLib::isNullValue("0LUL"));
ASSERT_EQUALS(false, MathLib::isNullValue("+0LUL"));