From d6888410ece2223e0398e9eb131e5c298f9ca617 Mon Sep 17 00:00:00 2001 From: Alexander Mai Date: Fri, 28 Mar 2014 20:09:22 +0100 Subject: [PATCH] Ticket #3322: Add test cases. The bug got fixed long time ago --- test/testclass.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/testclass.cpp b/test/testclass.cpp index ce9ced32b..de4bfb853 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -145,6 +145,7 @@ private: TEST_CASE(const57); // tickets #2669 and #2477 TEST_CASE(const58); // ticket #2698 TEST_CASE(const59); // ticket #4646 + TEST_CASE(const60); // ticket #3322 TEST_CASE(const_handleDefaultParameters); TEST_CASE(const_passThisToMemberOfOtherClass); TEST_CASE(assigningPointerToPointerIsNotAConstOperation); @@ -4767,6 +4768,31 @@ private: ASSERT_EQUALS("", errout.str()); } + void const60() { // ticket #3322 + checkConst("class MyString {\n" + "public:\n" + " MyString() : m_ptr(0){}\n" + " MyString& operator+=( const MyString& rhs ) {\n" + " delete m_ptr;\n" + " m_ptr = new char[42];\n" + " }\n" + " MyString append( const MyString& str )\n" + " { return operator+=( str ); } \n" + " char *m_ptr;\n" + "};"); + ASSERT_EQUALS("", errout.str()); + checkConst("class MyString {\n" + "public:\n" + " MyString() : m_ptr(0){}\n" + " MyString& operator+=( const MyString& rhs );\n" + " MyString append( const MyString& str )\n" + " { return operator+=( str ); } \n" + " char *m_ptr;\n" + "};"); + ASSERT_EQUALS("", errout.str()); + } + + void const_handleDefaultParameters() { checkConst("struct Foo {\n" " void foo1(int i, int j = 0) {\n"