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)