Added more test cases for sprintf counter
This commit is contained in:
parent
13e43b8710
commit
52ca36a6ed
|
@ -1027,6 +1027,10 @@ private:
|
|||
ASSERT_EQUALS(2, CheckBufferOverrun::countSprintfLength("\\\"", unknownParameter));
|
||||
ASSERT_EQUALS(7, CheckBufferOverrun::countSprintfLength("Hello \0Text", unknownParameter));
|
||||
ASSERT_EQUALS(2, CheckBufferOverrun::countSprintfLength("%%", unknownParameter));
|
||||
ASSERT_EQUALS(3, CheckBufferOverrun::countSprintfLength("%d%d", unknownParameter));
|
||||
ASSERT_EQUALS(10, CheckBufferOverrun::countSprintfLength("\\\\\\\\Hello%d \0Text\\\\\\\\", unknownParameter));
|
||||
ASSERT_EQUALS(4, CheckBufferOverrun::countSprintfLength("%%%%%d", unknownParameter));
|
||||
|
||||
|
||||
std::list<const Token*> stringAsParameter;
|
||||
{
|
||||
|
@ -1036,6 +1040,9 @@ private:
|
|||
}
|
||||
|
||||
TODO_ASSERT_EQUALS(9, CheckBufferOverrun::countSprintfLength("str%s", stringAsParameter));
|
||||
TODO_ASSERT_EQUALS(6, CheckBufferOverrun::countSprintfLength("%-4s", stringAsParameter));
|
||||
ASSERT_EQUALS(6, CheckBufferOverrun::countSprintfLength("%-5s", stringAsParameter));
|
||||
ASSERT_EQUALS(7, CheckBufferOverrun::countSprintfLength("%-6s", stringAsParameter));
|
||||
|
||||
std::list<const Token*> intAsParameter;
|
||||
{
|
||||
|
@ -1045,6 +1052,22 @@ private:
|
|||
}
|
||||
|
||||
TODO_ASSERT_EQUALS(6, CheckBufferOverrun::countSprintfLength("%02ld", intAsParameter));
|
||||
ASSERT_EQUALS(9, CheckBufferOverrun::countSprintfLength("%08ld", intAsParameter));
|
||||
|
||||
std::list<const Token*> multipleParams;
|
||||
{
|
||||
Token tok;
|
||||
tok.str("\"12345\"");
|
||||
multipleParams.push_back(&tok);
|
||||
|
||||
multipleParams.push_back(0);
|
||||
|
||||
tok.str("12345");
|
||||
multipleParams.push_back(&tok);
|
||||
}
|
||||
|
||||
TODO_ASSERT_EQUALS(15, CheckBufferOverrun::countSprintfLength("str%s%d%d", multipleParams));
|
||||
ASSERT_EQUALS(26, CheckBufferOverrun::countSprintfLength("str%-6s%08ld%08ld", multipleParams));
|
||||
}
|
||||
|
||||
void strncpy1()
|
||||
|
|
Loading…
Reference in New Issue