Add test to improve coverage of CheckIO::checkWrongPrintfScanfArguments()

This commit is contained in:
Alexander Mai 2014-04-18 11:39:58 +02:00
parent ccba934cb1
commit 1d78d74175
1 changed files with 8 additions and 0 deletions

View File

@ -1948,6 +1948,14 @@ private:
check(code, false, false, Settings::Win64);
ASSERT_EQUALS(result_win64, errout.str());
}
{
check("void g() {\n"
" const char c[]=\"42\";\n"
" scanf(\"%s\n\", c);\n"
"}\n");
ASSERT_EQUALS("[test.cpp:3]: (warning) %s in format string (no. 1) requires a 'char *' but the argument type is 'const char *'.\n"
"[test.cpp:3]: (warning) scanf without field width limits can crash with huge input data.\n", errout.str());
}
}