#4665 added todo unittest

This commit is contained in:
Ettl Martin 2013-03-19 08:47:05 +01:00
parent ff826d7c62
commit 7c0905cd4e
1 changed files with 10 additions and 0 deletions

View File

@ -56,6 +56,7 @@ private:
TEST_CASE(nullpointer20); // #3807 (fp: return p ? (p->x() || p->y()) : z)
TEST_CASE(nullpointer21); // #4038 (fp: if (x) p=q; else return;)
TEST_CASE(nullpointer22); // #4007 (fp: (uri != NULL) && (*uri == 0))
TEST_CASE(nullpointer23); // #4665 (false positive)
TEST_CASE(nullpointer_castToVoid); // #3771
TEST_CASE(pointerCheckAndDeRef); // check if pointer is null and then dereference it
TEST_CASE(nullConstantDereference); // Dereference NULL constant
@ -1334,6 +1335,15 @@ private:
ASSERT_EQUALS("", errout.str());
}
void nullpointer23() { // #4665
check("void f(){\n"
" char *c = NULL;\n"
" char cBuf[10];\n"
" sprintf(cBuf, \"%s\", c ? c : \"0\" );\n"
"}");
TODO_ASSERT_EQUALS("","[test.cpp:4]: (error) Possible null pointer dereference: c\n", errout.str());
}
void nullpointer_castToVoid() { // #3771
check("void f () {\n"
" int *buf = NULL;\n"