Test case for Ticket #32

This commit is contained in:
Reijo Tomperi 2009-01-17 19:26:58 +00:00
parent b9b250f4cc
commit f6452e3613
1 changed files with 15 additions and 0 deletions

View File

@ -43,6 +43,9 @@ private:
TEST_CASE(virtualDestructor5); // Derived class has empty destructor => no error TEST_CASE(virtualDestructor5); // Derived class has empty destructor => no error
TEST_CASE(uninitVar1); TEST_CASE(uninitVar1);
// TODO, cppcheck currently produces false positive, this should be fixed
// TEST_CASE(uninitVarStream);
} }
// Check that base classes have virtual destructors // Check that base classes have virtual destructors
@ -165,6 +168,18 @@ private:
ASSERT_EQUALS("[test.cpp:10]: Uninitialized member variable 'Fred::_code'\n", errout.str()); ASSERT_EQUALS("[test.cpp:10]: Uninitialized member variable 'Fred::_code'\n", errout.str());
} }
void uninitVarStream()
{
checkUninitVar("#include <fstream>\n"
"class Foo {\n"
"int foo;\n"
"public:\n"
"Foo(std::istream &in) { if(!(in >> foo)) throw 0; }\n"
"};\n");
ASSERT_EQUALS(std::string(""), errout.str());
}
}; };
REGISTER_TEST(TestClass) REGISTER_TEST(TestClass)