Unit Testing: Added TODO testcases for ticket #1593 (false negative: the function can be declared as const)
This commit is contained in:
parent
9e048ed3ff
commit
e8ac1f07d9
|
@ -121,6 +121,7 @@ private:
|
||||||
TEST_CASE(constReturnReference);
|
TEST_CASE(constReturnReference);
|
||||||
TEST_CASE(constDelete); // delete member variable => not const
|
TEST_CASE(constDelete); // delete member variable => not const
|
||||||
TEST_CASE(constLPVOID); // a function that returns LPVOID can't be const
|
TEST_CASE(constLPVOID); // a function that returns LPVOID can't be const
|
||||||
|
TEST_CASE(constFunc); // a function that calls const functions can be const
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the operator Equal
|
// Check the operator Equal
|
||||||
|
@ -3316,6 +3317,27 @@ private:
|
||||||
"};\n");
|
"};\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// a function that calls const functions can be const
|
||||||
|
void constFunc()
|
||||||
|
{
|
||||||
|
checkConst("class Fred {\n"
|
||||||
|
" void f() const { };\n"
|
||||||
|
" void a() { f(); };\n"
|
||||||
|
"};\n");
|
||||||
|
TODO_ASSERT_EQUALS("[test.cpp:3]: (style) The function 'Fred::a' can be const\n", errout.str());
|
||||||
|
|
||||||
|
// ticket #1593
|
||||||
|
checkConst("#include <vector>\n"
|
||||||
|
"class A\n"
|
||||||
|
"{\n"
|
||||||
|
" std::vector<int> m_v;\n"
|
||||||
|
"public:\n"
|
||||||
|
" A(){}\n"
|
||||||
|
" unsigned int GetVecSize() {return m_v.size();}\n"
|
||||||
|
"}");
|
||||||
|
TODO_ASSERT_EQUALS("[test.cpp:7]: (style) The function 'A::GetVecSize' can be const\n", errout.str());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_TEST(TestClass)
|
REGISTER_TEST(TestClass)
|
||||||
|
|
Loading…
Reference in New Issue