Fix ticket #632 (Mathlib isInt() identifies "330L" as not int)
http://sourceforge.net/apps/trac/cppcheck/ticket/632
This commit is contained in:
parent
8837e0dcff
commit
ed1c9bed49
|
@ -99,7 +99,7 @@ bool MathLib::isInt(const std::string & s)
|
|||
{
|
||||
Mode = eHex;
|
||||
}
|
||||
else if (s.find("0", n, 1) != std::string::npos && std::isdigit(s[n+1]))
|
||||
else if (s.length() > 1 && s[0] == '0' && std::isdigit(s[1]))
|
||||
{
|
||||
Mode = eOctal;
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ private:
|
|||
|
||||
void isint()
|
||||
{
|
||||
ASSERT_EQUALS(true, MathLib::isInt("0"));
|
||||
ASSERT_EQUALS(true, MathLib::isInt("0xa"));
|
||||
ASSERT_EQUALS(true, MathLib::isInt("0l"));
|
||||
ASSERT_EQUALS(true, MathLib::isInt("0L"));
|
||||
|
@ -63,8 +64,10 @@ private:
|
|||
ASSERT_EQUALS(true, MathLib::isInt("0ull"));
|
||||
ASSERT_EQUALS(true, MathLib::isInt("0llu"));
|
||||
ASSERT_EQUALS(true, MathLib::isInt("333L"));
|
||||
TODO_ASSERT_EQUALS(true, MathLib::isInt("330L"));
|
||||
TODO_ASSERT_EQUALS(true, MathLib::isInt("330llu"));
|
||||
ASSERT_EQUALS(true, MathLib::isInt("330L"));
|
||||
ASSERT_EQUALS(true, MathLib::isInt("330llu"));
|
||||
ASSERT_EQUALS(true, MathLib::isInt("07"));
|
||||
ASSERT_EQUALS(true, MathLib::isInt("0123"));
|
||||
ASSERT_EQUALS(false, MathLib::isInt("0.4"));
|
||||
ASSERT_EQUALS(false, MathLib::isInt("2352.3f"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue