From e8ac1f07d96f8b9feb05146d1f6058ef9d9bf101 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Mon, 19 Apr 2010 21:18:53 +0200 Subject: [PATCH] Unit Testing: Added TODO testcases for ticket #1593 (false negative: the function can be declared as const) --- test/testclass.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/testclass.cpp b/test/testclass.cpp index ce0c10c14..98172f2eb 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -121,6 +121,7 @@ private: TEST_CASE(constReturnReference); TEST_CASE(constDelete); // delete member variable => not 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 @@ -3316,6 +3317,27 @@ private: "};\n"); 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 \n" + "class A\n" + "{\n" + " std::vector 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)