From ac7f1f874e597ee29a85fa0cffc1f394fa32e54a Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Tue, 22 Mar 2011 22:45:19 -0400 Subject: [PATCH] add some more CheckClass::noMemset tests --- test/testclass.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/testclass.cpp b/test/testclass.cpp index e4944addc..86822b058 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -2933,6 +2933,28 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + checkNoMemset("class Fred\n" + "{\n" + " static std::string b;\n" + "};\n" + "void f()\n" + "{\n" + " Fred fred;\n" + " memset(&fred, 0, sizeof(Fred));\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + + checkNoMemset("class Fred\n" + "{\n" + " std::string * b; \n" + "};\n" + "void f()\n" + "{\n" + " Fred fred;\n" + " memset(&fred, 0, sizeof(Fred));\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + checkNoMemset("class Fred\n" "{\n" " std::string b; \n" @@ -2944,6 +2966,17 @@ private: "}\n"); ASSERT_EQUALS("[test.cpp:8]: (error) Using 'memset' on class that contains a 'std::string'\n", errout.str()); + checkNoMemset("class Fred\n" + "{\n" + " mutable std::string b; \n" + "};\n" + "void f()\n" + "{\n" + " Fred fred;\n" + " memset(&fred, 0, sizeof(Fred));\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:8]: (error) Using 'memset' on class that contains a 'std::string'\n", errout.str()); + checkNoMemset("class Fred\n" "{\n" "};\n"