test/testbufferoverrun.cpp: improve test cases.

This commit is contained in:
Slava Semushin 2009-08-02 19:24:54 +07:00
parent 35e35b38a7
commit f38530fb31
1 changed files with 6 additions and 3 deletions

View File

@ -249,20 +249,22 @@ private:
check("void f()\n"
"{\n"
" int val[50];\n"
" int i;\n"
" for (i = 0; i < 100; i++)\n"
" sum += val[i];\n"
"}\n");
ASSERT_EQUALS("[test.cpp:5]: (possible error) Buffer overrun\n", errout.str());
ASSERT_EQUALS("[test.cpp:6]: (possible error) Buffer overrun\n", errout.str());
}
{
check("void f()\n"
"{\n"
" int val[50];\n"
" int i;\n"
" for (i = 1; i < 100; i++)\n"
" sum += val[i];\n"
"}\n");
ASSERT_EQUALS("[test.cpp:5]: (possible error) Buffer overrun\n", errout.str());
ASSERT_EQUALS("[test.cpp:6]: (possible error) Buffer overrun\n", errout.str());
}
@ -270,10 +272,11 @@ private:
check("void f(int a)\n"
"{\n"
" int val[50];\n"
" int i;\n"
" for (i = a; i < 100; i++)\n"
" sum += val[i];\n"
"}\n");
ASSERT_EQUALS("[test.cpp:5]: (possible error) Buffer overrun\n", errout.str());
ASSERT_EQUALS("[test.cpp:6]: (possible error) Buffer overrun\n", errout.str());
}
}