Removed more duplicate unit tests

This commit is contained in:
PKEuS 2013-04-13 00:49:00 -07:00
parent 3b880f9e2e
commit 8e4f99884b
3 changed files with 5 additions and 188 deletions

View File

@ -614,10 +614,6 @@ private:
"void f() { bValue++; }"); "void f() { bValue++; }");
ASSERT_EQUALS("[test.cpp:2]: (style) Incrementing a variable of type 'bool' with postfix operator++ is deprecated by the C++ Standard. You should assign it the value 'true' instead.\n", errout.str()); ASSERT_EQUALS("[test.cpp:2]: (style) Incrementing a variable of type 'bool' with postfix operator++ is deprecated by the C++ Standard. You should assign it the value 'true' instead.\n", errout.str());
check("_Bool bValue = true;\n"
"void f() { bValue++; }");
ASSERT_EQUALS("[test.cpp:2]: (style) Incrementing a variable of type 'bool' with postfix operator++ is deprecated by the C++ Standard. You should assign it the value 'true' instead.\n", errout.str());
check("void f(bool test){\n" check("void f(bool test){\n"
" test++;\n" " test++;\n"
"}"); "}");

View File

@ -2355,12 +2355,6 @@ private:
"}"); "}");
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:1]: (warning) Memory for class instance allocated with realloc(), but class provides constructors.\n", errout.str()); ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:1]: (warning) Memory for class instance allocated with realloc(), but class provides constructors.\n", errout.str());
checkNoMemset("struct C { C() {} };\n"
"void foo(C*& p) {\n"
" p = realloc(p, sizeof(C));\n"
"}");
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:1]: (warning) Memory for class instance allocated with realloc(), but class provides constructors.\n", errout.str());
checkNoMemset("struct C { virtual void bar(); };\n" checkNoMemset("struct C { virtual void bar(); };\n"
"void foo(C*& p) {\n" "void foo(C*& p) {\n"
" p = malloc(sizeof(C));\n" " p = malloc(sizeof(C));\n"
@ -3213,37 +3207,6 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkConst("using namespace std;"
"class A {\n"
"public:\n"
" A(){}\n"
" pair< int,vector<int> > GetPair() {return m_pair;}\n"
"private:\n"
" pair< int,vector<int> > m_pair;\n"
"};");
ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str());
checkConst("using namespace std;"
"class A {\n"
"public:\n"
" A(){}\n"
" const pair< int,vector<int> >& GetPair() {return m_pair;}\n"
"private:\n"
" pair< int,vector<int> > m_pair;\n"
"};");
ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str());
checkConst("using namespace std;"
"class A {\n"
"public:\n"
" A(){}\n"
" pair< int,vector<int> >& GetPair() {return m_pair;}\n"
"private:\n"
" pair< int,vector<int> > m_pair;\n"
"};");
ASSERT_EQUALS("", errout.str());
checkConst("using namespace std;" checkConst("using namespace std;"
"class A {\n" "class A {\n"
"public:\n" "public:\n"
@ -3302,37 +3265,6 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkConst("using namespace std;"
"class A {\n"
"public:\n"
" A(){}\n"
" pair< vector<int>, vector<int> > GetPair() {return m_pair;}\n"
"private:\n"
" pair< vector<int>, vector<int> > m_pair;\n"
"};");
ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str());
checkConst("using namespace std;"
"class A {\n"
"public:\n"
" A(){}\n"
" const pair< vector<int>, vector<int> >& GetPair() {return m_pair;}\n"
"private:\n"
" pair< vector<int>, vector<int> > m_pair;\n"
"};");
ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str());
checkConst("using namespace std;"
"class A {\n"
"public:\n"
" A(){}\n"
" pair< vector<int>, vector<int> >& GetPair() {return m_pair;}\n"
"private:\n"
" pair< vector<int>, vector<int> > m_pair;\n"
"};");
ASSERT_EQUALS("", errout.str());
checkConst("class A {\n" checkConst("class A {\n"
"public:\n" "public:\n"
@ -3361,67 +3293,6 @@ private:
"};"); "};");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkConst("using namespace std;"
"class A {\n"
"public:\n"
" A(){}\n"
" pair< pair < int, char > , int > GetPair() {return m_pair;}\n"
"private:\n"
" pair< pair < int, char > , int > m_pair;\n"
"};");
ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str());
checkConst("using namespace std;"
"class A {\n"
"public:\n"
" A(){}\n"
" const pair< pair < int, char > , int > & GetPair() {return m_pair;}\n"
"private:\n"
" pair< pair < int, char > , int > m_pair;\n"
"};");
ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str());
checkConst("using namespace std;"
"class A {\n"
"public:\n"
" A(){}\n"
" pair< pair < int, char > , int > & GetPair() {return m_pair;}\n"
"private:\n"
" pair< pair < int, char > , int > m_pair;\n"
"};");
ASSERT_EQUALS("", errout.str());
checkConst("using namespace std;"
"class A {\n"
"public:\n"
" A(){}\n"
" pair< int , pair < int, char > > GetPair() {return m_pair;}\n"
"private:\n"
" pair< int , pair < int, char > > m_pair;\n"
"};");
ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str());
checkConst("using namespace std;"
"class A {\n"
"public:\n"
" A(){}\n"
" const pair< int , pair < int, char > > & GetPair() {return m_pair;}\n"
"private:\n"
" pair< int , pair < int, char > > m_pair;\n"
"};");
ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'A::GetPair' can be const.\n", errout.str());
checkConst("using namespace std;"
"class A {\n"
"public:\n"
" A(){}\n"
" pair< int , pair < int, char > > & GetPair() {return m_pair;}\n"
"private:\n"
" pair< int , pair < int, char > > m_pair;\n"
"};");
ASSERT_EQUALS("", errout.str());
checkConst("class A {\n" checkConst("class A {\n"
"public:\n" "public:\n"
@ -3497,14 +3368,6 @@ private:
" const int * x;\n" " const int * x;\n"
"};"); "};");
ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'A::foo' can be const.\n", errout.str()); ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'A::foo' can be const.\n", errout.str());
checkConst("class A {\n"
"public:\n"
" const int * const * foo() { return &x; }\n"
"private:\n"
" const int * x;\n"
"};");
ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'A::foo' can be const.\n", errout.str());
} }
void const15() { void const15() {
@ -5134,16 +4997,17 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
// A function that returns LPVOID can't be const // A function that returns unknown types can't be const (#1579)
void constLPVOID() { void constLPVOID() {
checkConst("class Fred {\n" checkConst("class Fred {\n"
" LPVOID a() { return 0; };\n" " UNKNOWN a() { return 0; };\n"
"};"); "};");
ASSERT_EQUALS("", errout.str()); TODO_ASSERT_EQUALS("[test.cpp:2]: (performance, inconclusive) Technically the member function 'Fred::a' can be static.\n", "", errout.str());
// #1579 - HDC // #1579 - HDC
checkConst("class Fred {\n" checkConst("class Fred {\n"
" HDC a() { return 0; };\n" " foo bar;\n"
" UNKNOWN a() { return b; };\n"
"};"); "};");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }

View File

@ -66,7 +66,6 @@ private:
TEST_CASE(simple10); // ticket #4388 TEST_CASE(simple10); // ticket #4388
TEST_CASE(simple11); // ticket #4536 TEST_CASE(simple11); // ticket #4536
TEST_CASE(simple12); // ticket #4620 TEST_CASE(simple12); // ticket #4620
TEST_CASE(simple13); // ticket #4617
TEST_CASE(initvar_with_this); // BUG 2190300 TEST_CASE(initvar_with_this); // BUG 2190300
TEST_CASE(initvar_if); // BUG 2190290 TEST_CASE(initvar_if); // BUG 2190290
@ -390,36 +389,6 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void simple13() { // ticket #4617
check("class Fred {\n"
" int x;\n"
"public:\n"
" Fred() noexcept;\n"
"};");
ASSERT_EQUALS("", errout.str());
check("class Fred {\n"
" int x;\n"
"public:\n"
" Fred() noexcept(true);\n"
"};");
ASSERT_EQUALS("", errout.str());
check("class Fred {\n"
" int x;\n"
"public:\n"
" Fred() noexcept { x = 0; }\n"
"};");
ASSERT_EQUALS("", errout.str());
check("class Fred {\n"
" int x;\n"
"public:\n"
" Fred() noexcept(true) { x = 0; }\n"
"};");
ASSERT_EQUALS("", errout.str());
}
void initvar_with_this() { void initvar_with_this() {
check("struct Fred\n" check("struct Fred\n"
"{\n" "{\n"
@ -885,18 +854,6 @@ private:
"};"); "};");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
check("class Fred\n"
"{\n"
"private:\n"
" std::string var;\n"
"public:\n"
" Fred();\n"
" Fred(const Fred &);\n"
"};\n"
"Fred::Fred() { };\n"
"Fred::Fred(const Fred &) { };");
ASSERT_EQUALS("", errout.str());
check("class Fred\n" check("class Fred\n"
"{\n" "{\n"
"private:\n" "private:\n"