MathLib::isNullValue(): Fixed bug in detecting zero values. Improved test coverage of MathLib::IsNullValue().
This commit is contained in:
parent
9d51bfd015
commit
82092e412a
|
@ -561,7 +561,7 @@ bool MathLib::isNullValue(const std::string &s)
|
||||||
else if (*it == '.')
|
else if (*it == '.')
|
||||||
state = DOT;
|
state = DOT;
|
||||||
else
|
else
|
||||||
return isValidSuffix(it, s.end());
|
return false;
|
||||||
break;
|
break;
|
||||||
case PLUSMINUS:
|
case PLUSMINUS:
|
||||||
if (*it == '0')
|
if (*it == '0')
|
||||||
|
|
|
@ -751,6 +751,14 @@ private:
|
||||||
ASSERT_EQUALS(true, MathLib::isNullValue("+00.00E+1f"));
|
ASSERT_EQUALS(true, MathLib::isNullValue("+00.00E+1f"));
|
||||||
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
|
// negative testing
|
||||||
ASSERT_EQUALS(false, MathLib::isNullValue("0.1"));
|
ASSERT_EQUALS(false, MathLib::isNullValue("0.1"));
|
||||||
ASSERT_EQUALS(false, MathLib::isNullValue("1.0"));
|
ASSERT_EQUALS(false, MathLib::isNullValue("1.0"));
|
||||||
|
@ -760,6 +768,19 @@ private:
|
||||||
ASSERT_EQUALS(false, MathLib::isNullValue(""));
|
ASSERT_EQUALS(false, MathLib::isNullValue(""));
|
||||||
ASSERT_EQUALS(false, MathLib::isNullValue("x"));
|
ASSERT_EQUALS(false, MathLib::isNullValue("x"));
|
||||||
ASSERT_EQUALS(false, MathLib::isNullValue("garbage"));
|
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
|
// suffix LUL is not allowed
|
||||||
ASSERT_EQUALS(false, MathLib::isNullValue("0LUL"));
|
ASSERT_EQUALS(false, MathLib::isNullValue("0LUL"));
|
||||||
ASSERT_EQUALS(false, MathLib::isNullValue("+0LUL"));
|
ASSERT_EQUALS(false, MathLib::isNullValue("+0LUL"));
|
||||||
|
|
Loading…
Reference in New Issue