refactoring - handling the stlOutOfBounds error message the new way
This commit is contained in:
parent
001cb0a7ec
commit
aee39ae929
|
@ -125,13 +125,18 @@ void CheckStl::stlOutOfBounds()
|
|||
|
||||
if (Token::Match(tok, pattern.c_str()))
|
||||
{
|
||||
_errorLogger->stlOutOfBounds(_tokenizer, tok, "When " + num->str() + " == size(), " + pattern);
|
||||
stlOutOfBoundsError(tok, num->str(), var->str());
|
||||
}
|
||||
|
||||
tok = tok->next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Error message for bad iterator usage..
|
||||
void CheckStl::stlOutOfBoundsError(const Token *tok, const std::string &num, const std::string &var)
|
||||
{
|
||||
reportError(tok, "error", "stlOutOfBounds", "When " + num + "==" + var + ".size(), " + var + "[" + num + "] is out of bounds");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -81,11 +81,13 @@ private:
|
|||
*/
|
||||
void eraseCheckLoop(const Token *it);
|
||||
|
||||
void stlOutOfBoundsError(const Token *tok, const std::string &num, const std::string &var);
|
||||
void iteratorsError(const Token *tok, const std::string &container1, const std::string &container2);
|
||||
|
||||
void getErrorMessages()
|
||||
{
|
||||
iteratorsError(0, "container1", "container2");
|
||||
stlOutOfBoundsError(0, "i", "foo");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ private:
|
|||
" foo[ii] = 0;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string("[test.cpp:6]: (error) When ii == size(), foo [ ii ] is out of bounds\n"), errout.str());
|
||||
ASSERT_EQUALS(std::string("[test.cpp:6]: (error) When ii==foo.size(), foo[ii] is out of bounds\n"), errout.str());
|
||||
}
|
||||
|
||||
void STLSizeNoErr()
|
||||
|
|
Loading…
Reference in New Issue