Added TODO test case to reduce false negatives for uninitialized class members

This commit is contained in:
Daniel Marjamäki 2010-04-02 19:10:05 +02:00
parent 805c683c1a
commit 4225544c82
1 changed files with 15 additions and 0 deletions

View File

@ -1149,6 +1149,7 @@ private:
void uninitVar3() void uninitVar3()
{ {
// No FP when struct has constructor
checkUninitVar("class Foo\n" checkUninitVar("class Foo\n"
"{\n" "{\n"
"public:\n" "public:\n"
@ -1160,6 +1161,20 @@ private:
" Bar bars[2];\n" " Bar bars[2];\n"
"};\n"); "};\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
// Using struct that doesn't have constructor
checkUninitVar("class Foo\n"
"{\n"
"public:\n"
" Foo() { }\n"
"private:\n"
" struct Bar {\n"
" int x;\n"
" };\n"
" Bar bars[2];\n"
"};\n");
TODO_ASSERT_EQUALS("[test.cpp:4]: (style) Member variable not initialized in the constructor 'Foo::bars'\n", errout.str());
ASSERT_EQUALS("", errout.str()); // So we notice if something is reported.
} }
void uninitVar4() void uninitVar4()