add some more CheckClass::noMemset tests

This commit is contained in:
Robert Reif 2011-03-22 22:45:19 -04:00
parent 14c07e988e
commit ac7f1f874e
1 changed files with 33 additions and 0 deletions

View File

@ -2933,6 +2933,28 @@ private:
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); 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" checkNoMemset("class Fred\n"
"{\n" "{\n"
" std::string b; \n" " std::string b; \n"
@ -2944,6 +2966,17 @@ private:
"}\n"); "}\n");
ASSERT_EQUALS("[test.cpp:8]: (error) Using 'memset' on class that contains a 'std::string'\n", errout.str()); 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" checkNoMemset("class Fred\n"
"{\n" "{\n"
"};\n" "};\n"