More test cases for sprintf counter
This commit is contained in:
parent
5eee9af974
commit
a078c9353d
|
@ -1039,6 +1039,11 @@ private:
|
|||
ASSERT_EQUALS(6, CheckBufferOverrun::countSprintfLength("%-4s", stringAsParameter));
|
||||
ASSERT_EQUALS(6, CheckBufferOverrun::countSprintfLength("%-5s", stringAsParameter));
|
||||
ASSERT_EQUALS(7, CheckBufferOverrun::countSprintfLength("%-6s", stringAsParameter));
|
||||
TODO_ASSERT_EQUALS(5, CheckBufferOverrun::countSprintfLength("%.4s", stringAsParameter));
|
||||
ASSERT_EQUALS(6, CheckBufferOverrun::countSprintfLength("%.5s", stringAsParameter));
|
||||
ASSERT_EQUALS(6, CheckBufferOverrun::countSprintfLength("%.6s", stringAsParameter));
|
||||
ASSERT_EQUALS(6, CheckBufferOverrun::countSprintfLength("%5.6s", stringAsParameter));
|
||||
ASSERT_EQUALS(7, CheckBufferOverrun::countSprintfLength("%6.6s", stringAsParameter));
|
||||
|
||||
std::list<const Token*> intAsParameter;
|
||||
Token numTok;
|
||||
|
@ -1046,6 +1051,24 @@ private:
|
|||
stringAsParameter.push_back(&numTok);
|
||||
TODO_ASSERT_EQUALS(6, CheckBufferOverrun::countSprintfLength("%02ld", intAsParameter));
|
||||
ASSERT_EQUALS(9, CheckBufferOverrun::countSprintfLength("%08ld", intAsParameter));
|
||||
TODO_ASSERT_EQUALS(6, CheckBufferOverrun::countSprintfLength("%.2d", intAsParameter));
|
||||
ASSERT_EQUALS(9, CheckBufferOverrun::countSprintfLength("%08.2d", intAsParameter));
|
||||
|
||||
std::list<const Token*> floatAsParameter;
|
||||
Token floatTok;
|
||||
floatTok.str("1.12345f");
|
||||
stringAsParameter.push_back(&floatTok);
|
||||
TODO_ASSERT_EQUALS(5, CheckBufferOverrun::countSprintfLength("%.2f", floatAsParameter));
|
||||
ASSERT_EQUALS(9, CheckBufferOverrun::countSprintfLength("%8.2f", floatAsParameter));
|
||||
TODO_ASSERT_EQUALS(5, CheckBufferOverrun::countSprintfLength("%2.2f", floatAsParameter));
|
||||
|
||||
std::list<const Token*> floatAsParameter2;
|
||||
Token floatTok2;
|
||||
floatTok2.str("100.12345f");
|
||||
stringAsParameter.push_back(&floatTok2);
|
||||
TODO_ASSERT_EQUALS(7, CheckBufferOverrun::countSprintfLength("%2.2f", floatAsParameter2));
|
||||
TODO_ASSERT_EQUALS(7, CheckBufferOverrun::countSprintfLength("%.2f", floatAsParameter));
|
||||
TODO_ASSERT_EQUALS(7, CheckBufferOverrun::countSprintfLength("%4.2f", floatAsParameter));
|
||||
|
||||
std::list<const Token*> multipleParams;
|
||||
multipleParams.push_back(&strTok);
|
||||
|
|
Loading…
Reference in New Issue