refactoring - handling the stlOutOfBounds error message the new way

This commit is contained in:
Daniel Marjamäki 2009-03-21 14:20:10 +01:00
parent 001cb0a7ec
commit aee39ae929
3 changed files with 9 additions and 2 deletions

View File

@ -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");
}

View File

@ -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");
}
};

View File

@ -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()