unittests: removed not needed '\n' at the end of testcases.
This commit is contained in:
parent
a08083a342
commit
1b9c1c03fa
|
@ -577,7 +577,7 @@ private:
|
|||
"public:\n"
|
||||
" A & operator=(const A &);\n"
|
||||
"};\n"
|
||||
"A & A::operator=(const A &a) { return *this; }\n");
|
||||
"A & A::operator=(const A &a) { return *this; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkOpertorEqRetRefThis(
|
||||
|
@ -586,7 +586,7 @@ private:
|
|||
"public:\n"
|
||||
" A & operator=(const A &a);\n"
|
||||
"};\n"
|
||||
"A & A::operator=(const A &a) { return *this; }\n");
|
||||
"A & A::operator=(const A &a) { return *this; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkOpertorEqRetRefThis(
|
||||
|
@ -595,7 +595,7 @@ private:
|
|||
"public:\n"
|
||||
" A & operator=(const A &);\n"
|
||||
"};\n"
|
||||
"A & A::operator=(const A &a) { return a; }\n");
|
||||
"A & A::operator=(const A &a) { return a; }");
|
||||
ASSERT_EQUALS("[test.cpp:6]: (style) 'operator=' should return reference to 'this' instance.\n", errout.str());
|
||||
|
||||
checkOpertorEqRetRefThis(
|
||||
|
@ -604,7 +604,7 @@ private:
|
|||
"public:\n"
|
||||
" A & operator=(const A &a);\n"
|
||||
"};\n"
|
||||
"A & A::operator=(const A &a) { return a; }\n");
|
||||
"A & A::operator=(const A &a) { return a; }");
|
||||
ASSERT_EQUALS("[test.cpp:6]: (style) 'operator=' should return reference to 'this' instance.\n", errout.str());
|
||||
|
||||
checkOpertorEqRetRefThis(
|
||||
|
@ -641,7 +641,7 @@ private:
|
|||
" B & operator=(const B &);\n"
|
||||
" };\n"
|
||||
"};\n"
|
||||
"A::B & A::B::operator=(const A::B &b) { return *this; }\n");
|
||||
"A::B & A::B::operator=(const A::B &b) { return *this; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkOpertorEqRetRefThis(
|
||||
|
@ -654,7 +654,7 @@ private:
|
|||
" B & operator=(const B &);\n"
|
||||
" };\n"
|
||||
"};\n"
|
||||
"A::B & A::B::operator=(const A::B &b) { return b; }\n");
|
||||
"A::B & A::B::operator=(const A::B &b) { return b; }");
|
||||
ASSERT_EQUALS("[test.cpp:10]: (style) 'operator=' should return reference to 'this' instance.\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -847,7 +847,7 @@ private:
|
|||
"public:\n"
|
||||
" A & operator=(const A &);\n"
|
||||
"};\n"
|
||||
"A & A::operator=(const A &a) { if (&a != this) { } return *this; }\n");
|
||||
"A & A::operator=(const A &a) { if (&a != this) { } return *this; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// this test doesn't have an assignment test but doesn't need it
|
||||
|
@ -857,7 +857,7 @@ private:
|
|||
"public:\n"
|
||||
" A & operator=(const A &);\n"
|
||||
"};\n"
|
||||
"A & A::operator=(const A &a) { return *this; }\n");
|
||||
"A & A::operator=(const A &a) { return *this; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// this test needs an assignment test and has it
|
||||
|
@ -992,7 +992,7 @@ private:
|
|||
" B & operator=(const B &);\n"
|
||||
" };\n"
|
||||
"};\n"
|
||||
"A::B & A::B::operator=(const A::B &b) { if (&b != this) { } return *this; }\n");
|
||||
"A::B & A::B::operator=(const A::B &b) { if (&b != this) { } return *this; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// this test doesn't have an assignment test but doesn't need it
|
||||
|
@ -1006,7 +1006,7 @@ private:
|
|||
" B & operator=(const B &);\n"
|
||||
" };\n"
|
||||
"};\n"
|
||||
"A::B & A::B::operator=(const A::B &b) { return *this; }\n");
|
||||
"A::B & A::B::operator=(const A::B &b) { return *this; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// this test needs an assignment test and has it
|
||||
|
@ -1029,7 +1029,7 @@ private:
|
|||
" s = strdup(b.s);\n"
|
||||
" }\n"
|
||||
" return *this;\n"
|
||||
" }\n");
|
||||
" }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// this test needs an assignment test but doesn't have it
|
||||
|
@ -1049,7 +1049,7 @@ private:
|
|||
" free(s);\n"
|
||||
" s = strdup(b.s);\n"
|
||||
" return *this;\n"
|
||||
" }\n");
|
||||
" }");
|
||||
ASSERT_EQUALS("[test.cpp:11]: (warning) 'operator=' should check for assignment to self to avoid problems with dynamic memory.\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -1085,7 +1085,7 @@ private:
|
|||
"public:\n"
|
||||
" A & operator=(const A &);\n"
|
||||
"};\n"
|
||||
"A & A::operator=(const A &a) { return *this; }\n");
|
||||
"A & A::operator=(const A &a) { return *this; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// this test has multiple inheritance and needs an assignment test but there is no trivial way to test for it
|
||||
|
@ -1149,7 +1149,7 @@ private:
|
|||
" B & operator=(const B &);\n"
|
||||
" };\n"
|
||||
"};\n"
|
||||
"A::B & A::B::operator=(const A::B &b) { return *this; }\n");
|
||||
"A::B & A::B::operator=(const A::B &b) { return *this; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// this test has multiple inheritance and needs an assignment test but there is no trivial way to test for it
|
||||
|
@ -1882,7 +1882,7 @@ private:
|
|||
"};\n"
|
||||
"\n"
|
||||
"void Fred::foobar()\n"
|
||||
"{ }\n");
|
||||
"{ }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -2870,7 +2870,7 @@ private:
|
|||
" };\n"
|
||||
"};\n"
|
||||
"int Fred::B::A::getA() { return a; }\n"
|
||||
"int Fred::B::getB() { return b; }\n");
|
||||
"int Fred::B::getB() { return b; }");
|
||||
ASSERT_EQUALS("[test.cpp:12] -> [test.cpp:4]: (style, inconclusive) Technically the member function 'Fred::B::getB' can be const.\n"
|
||||
"[test.cpp:11] -> [test.cpp:7]: (style, inconclusive) Technically the member function 'Fred::B::A::getA' can be const.\n" , errout.str());
|
||||
}
|
||||
|
@ -4023,7 +4023,7 @@ private:
|
|||
" int var;\n"
|
||||
" };\n"
|
||||
"}\n"
|
||||
"int N::Base::getResourceName() { return var; }\n");
|
||||
"int N::Base::getResourceName() { return var; }");
|
||||
ASSERT_EQUALS("[test.cpp:10] -> [test.cpp:6]: (style, inconclusive) Technically the member function 'N::Base::getResourceName' can be const.\n", errout.str());
|
||||
|
||||
checkConst("namespace N\n"
|
||||
|
@ -4051,7 +4051,7 @@ private:
|
|||
" };\n"
|
||||
"}\n"
|
||||
"using namespace N;\n"
|
||||
"int Base::getResourceName() { return var; }\n");
|
||||
"int Base::getResourceName() { return var; }");
|
||||
TODO_ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:6]: (style, inconclusive) Technically the member function 'N::Base::getResourceName' can be const.\n",
|
||||
"", errout.str());
|
||||
}
|
||||
|
@ -5191,7 +5191,7 @@ private:
|
|||
" B() : b(0) { }\n"
|
||||
" int func();\n"
|
||||
"};\n"
|
||||
"int B::func() { return b; }\n");
|
||||
"int B::func() { return b; }");
|
||||
ASSERT_EQUALS("[test.cpp:8] -> [test.cpp:6]: (style, inconclusive) Technically the member function 'B::func' can be const.\n", errout.str());
|
||||
|
||||
// base class has no virtual function
|
||||
|
@ -5217,7 +5217,7 @@ private:
|
|||
" B() : b(0) { }\n"
|
||||
" int func();\n"
|
||||
"};\n"
|
||||
"int B::func() { return b; }\n");
|
||||
"int B::func() { return b; }");
|
||||
ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:9]: (style, inconclusive) Technically the member function 'B::func' can be const.\n", errout.str());
|
||||
|
||||
// base class has virtual function
|
||||
|
@ -5243,7 +5243,7 @@ private:
|
|||
" B() : b(0) { }\n"
|
||||
" int func();\n"
|
||||
"};\n"
|
||||
"int B::func() { return b; }\n");
|
||||
"int B::func() { return b; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkConst("class A {\n"
|
||||
|
@ -5256,7 +5256,7 @@ private:
|
|||
" B() : b(0) { }\n"
|
||||
" int func();\n"
|
||||
"};\n"
|
||||
"int B::func() { return b; }\n");
|
||||
"int B::func() { return b; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// base class has no virtual function
|
||||
|
@ -5302,7 +5302,7 @@ private:
|
|||
" C() : c(0) { }\n"
|
||||
" int func();\n"
|
||||
"};\n"
|
||||
"int C::func() { return c; }\n");
|
||||
"int C::func() { return c; }");
|
||||
ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:5]: (style, inconclusive) Technically the member function 'A::func' can be const.\n"
|
||||
"[test.cpp:14] -> [test.cpp:12]: (style, inconclusive) Technically the member function 'B::func' can be const.\n"
|
||||
"[test.cpp:21] -> [test.cpp:19]: (style, inconclusive) Technically the member function 'C::func' can be const.\n", errout.str());
|
||||
|
@ -5348,7 +5348,7 @@ private:
|
|||
" C() : c(0) { }\n"
|
||||
" int func();\n"
|
||||
"};\n"
|
||||
"int C::func() { return c; }\n");
|
||||
"int C::func() { return c; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// ticket #1311
|
||||
|
@ -5394,7 +5394,7 @@ private:
|
|||
" Z(int x, int y, int z) : Y(x, y), z(z) { }\n"
|
||||
" int getZ();\n"
|
||||
"};\n"
|
||||
"int Z::getZ() { return z; }\n");
|
||||
"int Z::getZ() { return z; }");
|
||||
ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:5]: (style, inconclusive) Technically the member function 'X::getX' can be const.\n"
|
||||
"[test.cpp:14] -> [test.cpp:12]: (style, inconclusive) Technically the member function 'Y::getY' can be const.\n"
|
||||
"[test.cpp:21] -> [test.cpp:19]: (style, inconclusive) Technically the member function 'Z::getZ' can be const.\n", errout.str());
|
||||
|
|
|
@ -226,7 +226,7 @@ private:
|
|||
" int i;\n"
|
||||
"};\n"
|
||||
"Fred::Fred() :i(0)\n"
|
||||
"{ }\n");
|
||||
"{ }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("struct Fred\n"
|
||||
|
@ -235,7 +235,7 @@ private:
|
|||
" int i;\n"
|
||||
"};\n"
|
||||
"Fred::Fred()\n"
|
||||
"{ i = 0; }\n");
|
||||
"{ i = 0; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("struct Fred\n"
|
||||
|
@ -244,7 +244,7 @@ private:
|
|||
" int i;\n"
|
||||
"};\n"
|
||||
"Fred::Fred()\n"
|
||||
"{ }\n");
|
||||
"{ }");
|
||||
ASSERT_EQUALS("[test.cpp:6]: (warning) Member variable 'Fred::i' is not initialized in the constructor.\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -321,7 +321,7 @@ private:
|
|||
void simple8() {
|
||||
check("struct Fred { int x; };\n"
|
||||
"class Barney { Fred fred; };\n"
|
||||
"class Wilma { struct Betty { int x; } betty; };\n");
|
||||
"class Wilma { struct Betty { int x; } betty; };");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (style) The class 'Barney' does not have a constructor.\n"
|
||||
"[test.cpp:3]: (style) The class 'Wilma' does not have a constructor.\n", errout.str());
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ private:
|
|||
" Fred() { Init(); }\n"
|
||||
" void Init(int i = 0);\n"
|
||||
"};\n"
|
||||
"void Fred::Init(int i) { x = i; }\n");
|
||||
"void Fred::Init(int i) { x = i; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("class Fred {\n"
|
||||
|
@ -373,7 +373,7 @@ private:
|
|||
" Fred() { Init(0); }\n"
|
||||
" void Init(int i, int j = 0);\n"
|
||||
"};\n"
|
||||
"void Fred::Init(int i, int j) { x = i; y = j; }\n");
|
||||
"void Fred::Init(int i, int j) { x = i; y = j; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -881,7 +881,7 @@ private:
|
|||
" Fred(const Fred &);\n"
|
||||
"};\n"
|
||||
"Fred::Fred() { };\n"
|
||||
"Fred::Fred(const Fred &) { };\n");
|
||||
"Fred::Fred(const Fred &) { };");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("class Fred\n"
|
||||
|
@ -930,7 +930,7 @@ private:
|
|||
"A::A(){}\n"
|
||||
"A::B::B(int x){}\n"
|
||||
"A::B::C::C(int y){}\n"
|
||||
"A::B::C::D::D(int z){}\n");
|
||||
"A::B::C::D::D(int z){}");
|
||||
// Note that the example code is not compilable. The A constructor must
|
||||
// explicitly initialize A::b. A warning for A::b is not necessary.
|
||||
ASSERT_EQUALS("[test.cpp:20]: (warning) Member variable 'A::a' is not initialized in the constructor.\n"
|
||||
|
@ -960,7 +960,7 @@ private:
|
|||
"A::A(){}\n"
|
||||
"A::B::B(int x){}\n"
|
||||
"A::B::C::C(int y){}\n"
|
||||
"A::B::C::D::D(const A::B::C::D & d){}\n");
|
||||
"A::B::C::D::D(const A::B::C::D & d){}");
|
||||
// Note that the example code is not compilable. The A constructor must
|
||||
// explicitly initialize A::b. A warning for A::b is not necessary.
|
||||
ASSERT_EQUALS("[test.cpp:20]: (warning) Member variable 'A::a' is not initialized in the constructor.\n"
|
||||
|
@ -991,7 +991,7 @@ private:
|
|||
"A::A(){}\n"
|
||||
"A::B::B(int x){}\n"
|
||||
"A::B::C::C(int y){}\n"
|
||||
"A::B::C::D::D(const A::B::C::D::E & e){}\n");
|
||||
"A::B::C::D::D(const A::B::C::D::E & e){}");
|
||||
// Note that the example code is not compilable. The A constructor must
|
||||
// explicitly initialize A::b. A warning for A::b is not necessary.
|
||||
ASSERT_EQUALS("[test.cpp:21]: (warning) Member variable 'A::a' is not initialized in the constructor.\n"
|
||||
|
@ -1998,7 +1998,7 @@ private:
|
|||
" Fred() : f{0, true} { }\n"
|
||||
" float get() const\n"
|
||||
"};\n"
|
||||
"float Fred::get() const { return g; }\n");
|
||||
"float Fred::get() const { return g; }");
|
||||
ASSERT_EQUALS("[test.cpp:9]: (warning) Member variable 'Fred::g' is not initialized in the constructor.\n", errout.str());
|
||||
}
|
||||
|
||||
|
|
|
@ -131,8 +131,7 @@ private:
|
|||
check("void foo()\n"
|
||||
"{\n"
|
||||
" unsigned int val = 32;\n"
|
||||
" int i = val / -2; }\n"
|
||||
);
|
||||
" int i = val / -2; }");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Unsigned division. The result will be wrong.\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -140,7 +139,7 @@ private:
|
|||
check("void foo()\n"
|
||||
"{\n"
|
||||
" unsigned int val = 32;\n"
|
||||
" int i = -96 / val; }\n");
|
||||
" int i = -96 / val; }");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Unsigned division. The result will be wrong.\n", errout.str());
|
||||
}
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ private:
|
|||
" {\n"
|
||||
" throw err;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:8]: (style) Throwing a copy of the caught exception instead of rethrowing the original exception.\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ private:
|
|||
" {\n"
|
||||
" throw err;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:8]: (style) Throwing a copy of the caught exception instead of rethrowing the original exception.\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ private:
|
|||
" exception err2;\n"
|
||||
" throw err2;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ private:
|
|||
"{\n"
|
||||
" const char def[] =\n"
|
||||
" \"abc\";\n"
|
||||
"}\n");
|
||||
"}");
|
||||
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ private:
|
|||
check("void foo()\n"
|
||||
"{\n"
|
||||
" \"abc\";\n"
|
||||
"}\n");
|
||||
"}");
|
||||
|
||||
ASSERT_EQUALS("[test.cpp:3]: (warning) Redundant code: Found a statement that begins with string constant.\n", errout.str());
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ private:
|
|||
check("void foo()\n"
|
||||
"{\n"
|
||||
" const char *str[] = { \"abc\" };\n"
|
||||
"}\n");
|
||||
"}");
|
||||
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ private:
|
|||
"\"more \"\n"
|
||||
"\"world\"\n"
|
||||
"};\n"
|
||||
"}\n");
|
||||
"}");
|
||||
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ private:
|
|||
check("void foo()\n"
|
||||
"{\n"
|
||||
" 50;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
|
||||
ASSERT_EQUALS("[test.cpp:3]: (warning) Redundant code: Found a statement that begins with numeric constant.\n", errout.str());
|
||||
}
|
||||
|
@ -133,13 +133,13 @@ private:
|
|||
"{\n"
|
||||
"{ 346.1,114.1 }, { 347.1,111.1 }\n"
|
||||
"};\n"
|
||||
"}\n");
|
||||
"}");
|
||||
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void intarray() {
|
||||
check("int arr[] = { 100/2, 1*100 };\n");
|
||||
check("int arr[] = { 100/2, 1*100 };");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ private:
|
|||
check("struct st arr[] = {\n"
|
||||
" { 100/2, 1*100 }\n"
|
||||
" { 90, 70 }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -155,14 +155,14 @@ private:
|
|||
check("struct st arr[] = {\n"
|
||||
" { 100/2, 1*100 }\n"
|
||||
" { 90, 70 }\n"
|
||||
"};\n");
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void conditionalcall() {
|
||||
check("void f() {\n"
|
||||
" 0==x ? X() : Y();\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ private:
|
|||
// #2462 - C++11 struct initialization
|
||||
check("void f() {\n"
|
||||
" ABC abc{1,2,3};\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #2482 - false positive for empty struct
|
||||
|
|
|
@ -309,7 +309,7 @@ private:
|
|||
" Z(){\n"
|
||||
" z[0] = 0;\n"
|
||||
" }\n"
|
||||
"};\n");
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
|
|
@ -474,7 +474,7 @@ private:
|
|||
"{\n"
|
||||
" char str [8];\n"
|
||||
" scanf (\"%70s\",str);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Width 70 given in format string (no. 1) is larger than destination buffer 'str[8]', use %7s to prevent overflowing it.\n", errout.str());
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ private:
|
|||
" char *p = malloc(10);\n"
|
||||
" p = NULL;\n"
|
||||
" free(p);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.c:3]: (error) Memory leak: p\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ private:
|
|||
" char *p = malloc(10);\n"
|
||||
" char *q = p;\n"
|
||||
" free(q);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ private:
|
|||
" char *p = malloc(10);\n"
|
||||
" char *q = p + 1;\n"
|
||||
" free(q - 1);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ private:
|
|||
" char *a = malloc(10);\n"
|
||||
" a += 10;\n"
|
||||
" free(a - 10);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ private:
|
|||
"{\n"
|
||||
" char *p = new char[100];\n"
|
||||
" list += p;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ private:
|
|||
" char *p = malloc(10);\n"
|
||||
" p = strcpy(p,q);\n"
|
||||
" free(p);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ private:
|
|||
check("void foo(struct str *d) {\n"
|
||||
" struct str *p = malloc(10);\n"
|
||||
" d->p = p;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ private:
|
|||
check("void foo(struct str *d) {\n"
|
||||
" struct str *p = malloc(10);\n"
|
||||
" d->p = &p->x;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ private:
|
|||
" char *p = x();\n"
|
||||
" free(p);\n"
|
||||
" p = NULL;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -207,7 +207,7 @@ private:
|
|||
" if (x) { p = malloc(10); }\n"
|
||||
" if (!x) { p = NULL; }\n"
|
||||
" free(p);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -436,7 +436,7 @@ private:
|
|||
" free(a);\n"
|
||||
" else\n"
|
||||
" a = 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.c:6]: (error) Memory leak: a\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -459,7 +459,7 @@ private:
|
|||
" for (i=0;i<5;i++) { }\n"
|
||||
" if (x) { free(p) }\n"
|
||||
" else { a = p; }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -61,7 +61,7 @@ private:
|
|||
"{\n"
|
||||
" char *cpwd;"
|
||||
" crypt(pwd, cpwd);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (portability) Non reentrant function 'crypt' called. For threadsafe applications it is recommended to use the reentrant replacement function 'crypt_r'.\n", errout.str());
|
||||
|
||||
check("void f()\n"
|
||||
|
@ -69,14 +69,14 @@ private:
|
|||
" char *pwd = getpass(\"Password:\");"
|
||||
" char *cpwd;"
|
||||
" crypt(pwd, cpwd);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (portability) Non reentrant function 'crypt' called. For threadsafe applications it is recommended to use the reentrant replacement function 'crypt_r'.\n", errout.str());
|
||||
|
||||
check("int f()\n"
|
||||
"{\n"
|
||||
" int crypt = 0;"
|
||||
" return crypt;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -85,14 +85,14 @@ private:
|
|||
"{\n"
|
||||
" time_t t = 0;"
|
||||
" std::localtime(&t);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (portability) Non reentrant function 'localtime' called. For threadsafe applications it is recommended to use the reentrant replacement function 'localtime_r'.\n", errout.str());
|
||||
|
||||
// Passed as function argument
|
||||
check("int f()\n"
|
||||
"{\n"
|
||||
" printf(\"Magic guess: %d\n\", getpwent());\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (portability) Non reentrant function 'getpwent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getpwent_r'.\n", errout.str());
|
||||
|
||||
// Pass return value
|
||||
|
@ -100,35 +100,35 @@ private:
|
|||
"{\n"
|
||||
" time_t t = 0;"
|
||||
" struct tm *foo = localtime(&t);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (portability) Non reentrant function 'localtime' called. For threadsafe applications it is recommended to use the reentrant replacement function 'localtime_r'.\n", errout.str());
|
||||
|
||||
// Access via global namespace
|
||||
check("int f()\n"
|
||||
"{\n"
|
||||
" ::getpwent();\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (portability) Non reentrant function 'getpwent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getpwent_r'.\n", errout.str());
|
||||
|
||||
// Be quiet on function definitions
|
||||
check("int getpwent()\n"
|
||||
"{\n"
|
||||
" return 123;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// Be quiet on other namespaces
|
||||
check("int f()\n"
|
||||
"{\n"
|
||||
" foobar::getpwent();\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// Be quiet on class member functions
|
||||
check("int f()\n"
|
||||
"{\n"
|
||||
" foobar.getpwent();\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
|
|
@ -105,7 +105,7 @@ private:
|
|||
"{\n"
|
||||
" while (tok);\n"
|
||||
" tok = tok->next();\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:3]: (error) Possible null pointer dereference: tok - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
// #2681
|
||||
|
@ -133,7 +133,7 @@ private:
|
|||
" while (tok && tok->str() != \";\")\n"
|
||||
" tok = tok->next();\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:5]: (error) Possible null pointer dereference: tok - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
check("void foo(Token &tok)\n"
|
||||
|
@ -143,7 +143,7 @@ private:
|
|||
" while (!tok)\n"
|
||||
" char c = tok.read();\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo()\n"
|
||||
|
@ -154,7 +154,7 @@ private:
|
|||
" tok = tok->next();\n"
|
||||
" if( !tok ) break;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo()\n"
|
||||
|
@ -164,7 +164,7 @@ private:
|
|||
" while (tok && tok->str() != \";\")\n"
|
||||
" tok = tok->next();\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo(A*a)\n"
|
||||
|
@ -179,7 +179,7 @@ private:
|
|||
" a->b();\n"
|
||||
" break;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// dereference in outer scope..
|
||||
|
@ -222,7 +222,7 @@ private:
|
|||
" }\n"
|
||||
" else if (a->x == 2) { }\n"
|
||||
" if (a) { }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// ticket #2134 - sizeof doesn't dereference
|
||||
|
@ -266,14 +266,14 @@ private:
|
|||
" int a = abc->a;\n"
|
||||
" if (!abc)\n"
|
||||
" ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (error) Possible null pointer dereference: abc - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
check("void foo(struct ABC *abc) {\n"
|
||||
" bar(abc->a);\n"
|
||||
" if (!abc)\n"
|
||||
" ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (error) Possible null pointer dereference: abc - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
check("void foo(ABC *abc) {\n"
|
||||
|
@ -297,14 +297,14 @@ private:
|
|||
" abc->next->a = 0;\n"
|
||||
" if (abc->next)\n"
|
||||
" ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
TODO_ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (error) Possible null pointer dereference: abc - otherwise it is redundant to check it against null.\n", "", errout.str());
|
||||
|
||||
check("void foo(ABC *abc) {\n"
|
||||
" abc->a = 0;\n"
|
||||
" if (abc && abc->b == 0)\n"
|
||||
" ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (error) Possible null pointer dereference: abc - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
// ok dereferencing in a condition
|
||||
|
@ -313,7 +313,7 @@ private:
|
|||
" if (abc && abc->a);\n"
|
||||
" if (!abc)\n"
|
||||
" ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f(struct ABC *abc) {\n"
|
||||
|
@ -367,7 +367,7 @@ private:
|
|||
"out:\n"
|
||||
" if (!abc)\n"
|
||||
" ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// loops..
|
||||
|
@ -381,7 +381,7 @@ private:
|
|||
" --a;\n"
|
||||
" }\n"
|
||||
" while (a > 0);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f()\n"
|
||||
|
@ -393,7 +393,7 @@ private:
|
|||
" if (!tok)\n"
|
||||
" return;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// dynamic_cast..
|
||||
|
@ -402,7 +402,7 @@ private:
|
|||
" int a = abc->a;\n"
|
||||
" if (!dynamic_cast<DEF *>(abc))\n"
|
||||
" ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #2641 - global pointer, function call
|
||||
|
@ -486,21 +486,21 @@ private:
|
|||
" *p = 0;\n"
|
||||
" if (!p)\n"
|
||||
" ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (error) Possible null pointer dereference: p - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
check("void foo(int *p)\n"
|
||||
"{\n"
|
||||
" *p = 0;\n"
|
||||
" if (p) { }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (error) Possible null pointer dereference: p - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
check("void foo(int *p)\n"
|
||||
"{\n"
|
||||
" *p = 0;\n"
|
||||
" if (p || q) { }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (error) Possible null pointer dereference: p - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
check("void foo(int *p)\n"
|
||||
|
@ -508,7 +508,7 @@ private:
|
|||
" bar(*p);\n"
|
||||
" if (!p)\n"
|
||||
" ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (error) Possible null pointer dereference: p - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
check("void foo(char *p)\n"
|
||||
|
@ -516,14 +516,14 @@ private:
|
|||
" strcpy(p, \"abc\");\n"
|
||||
" if (!p)\n"
|
||||
" ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (error) Possible null pointer dereference: p - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
check("void foo(char *p)\n"
|
||||
"{\n"
|
||||
" if (*p == 0) { }\n"
|
||||
" if (!p) { }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
TODO_ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (error) Possible null pointer dereference: p - otherwise it is redundant to check it against null.\n", "", errout.str());
|
||||
|
||||
// no error
|
||||
|
@ -533,7 +533,7 @@ private:
|
|||
" f(&p);\n"
|
||||
" if (!p)\n"
|
||||
" ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo()\n"
|
||||
|
@ -552,7 +552,7 @@ private:
|
|||
" *p = 0;\n"
|
||||
" if (!p)\n"
|
||||
" ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo(int x)\n"
|
||||
|
@ -568,7 +568,7 @@ private:
|
|||
" int var1 = p ? *p : 0;\n"
|
||||
" if (!p)\n"
|
||||
" ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo(int *p)\n"
|
||||
|
@ -576,7 +576,7 @@ private:
|
|||
" int var1 = x ? *p : 5;\n"
|
||||
" if (!p)\n"
|
||||
" ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
TODO_ASSERT_EQUALS("error", "", errout.str());
|
||||
|
||||
// Ticket #3125
|
||||
|
@ -585,7 +585,7 @@ private:
|
|||
" int var1 = p ? (p->a) : 0;\n"
|
||||
" if (!p)\n"
|
||||
" ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo(ABC *p)\n"
|
||||
|
@ -593,7 +593,7 @@ private:
|
|||
" int var1 = p ? (1 + p->a) : 0;\n"
|
||||
" if (!p)\n"
|
||||
" ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
|
@ -625,7 +625,7 @@ private:
|
|||
" break;\n"
|
||||
" else\n"
|
||||
" p = p->next();\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f(Document *doc) {\n"
|
||||
|
@ -661,7 +661,7 @@ private:
|
|||
" p = p->next;\n"
|
||||
" if (!p)\n"
|
||||
" ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo(x *p)\n"
|
||||
|
@ -669,7 +669,7 @@ private:
|
|||
" p = bar(p->next);\n"
|
||||
" if (!p)\n"
|
||||
" ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo(x *p)\n"
|
||||
|
@ -677,7 +677,7 @@ private:
|
|||
" p = aa->bar(p->next);\n"
|
||||
" if (!p)\n"
|
||||
" ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo(x *p)\n"
|
||||
|
@ -685,7 +685,7 @@ private:
|
|||
" p = *p2 = p->next;\n"
|
||||
" if (!p)\n"
|
||||
" ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo(struct ABC *abc)\n"
|
||||
|
@ -693,7 +693,7 @@ private:
|
|||
" abc = abc ? abc->next : 0;\n"
|
||||
" if (!abc)\n"
|
||||
" ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f(struct ABC *abc) {\n" // #4523
|
||||
|
@ -711,14 +711,14 @@ private:
|
|||
check("int f(Item *item) {\n"
|
||||
" x = item ? ab(item->x) : 0;\n"
|
||||
" if (item) { }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("int f(Item *item) {\n"
|
||||
" item->x = 0;\n"
|
||||
" a = b ? c : d;\n"
|
||||
" if (item) { }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:4]: (error) Possible null pointer dereference: item - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
check("BOOL GotoFlyAnchor()\n" // #2243
|
||||
|
@ -730,7 +730,7 @@ private:
|
|||
"\n"
|
||||
" if( !pFrm )\n"
|
||||
" return FALSE;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// Ticket #2463
|
||||
|
@ -750,7 +750,7 @@ private:
|
|||
" break;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #2525 - sizeof
|
||||
|
@ -796,7 +796,7 @@ private:
|
|||
" char c = a.c();\n"
|
||||
" if (!a)\n"
|
||||
" return;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -811,7 +811,7 @@ private:
|
|||
" else if (a == 2)\n"
|
||||
" p = new FooCar;\n"
|
||||
" p->abcd();\n"
|
||||
"}\n");
|
||||
"}");
|
||||
TODO_ASSERT_EQUALS("[test.cpp:8]: (error) Possible null pointer dereference: p\n",
|
||||
"", errout.str());
|
||||
|
||||
|
@ -820,21 +820,21 @@ private:
|
|||
" int *p = 0;\n"
|
||||
" int *q = p;\n"
|
||||
" q[0] = 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (error) Possible null pointer dereference: q\n", errout.str());
|
||||
|
||||
check("static void foo()\n"
|
||||
"{\n"
|
||||
" int *p = 0;\n"
|
||||
" int &r = *p;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Null pointer dereference\n", errout.str());
|
||||
|
||||
check("static void foo(int x)\n"
|
||||
"{\n"
|
||||
" int *p = 0;\n"
|
||||
" int y = 5 + *p;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Null pointer dereference\n", errout.str());
|
||||
|
||||
{
|
||||
|
@ -857,7 +857,7 @@ private:
|
|||
"{\n"
|
||||
" int *p(0);\n"
|
||||
" std::cout << *p;"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Null pointer dereference\n", errout.str());
|
||||
|
||||
check("void f()\n"
|
||||
|
@ -867,14 +867,14 @@ private:
|
|||
" delete c;\n"
|
||||
" }\n"
|
||||
" c[0] = 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:7]: (error) Possible null pointer dereference: c\n", errout.str());
|
||||
|
||||
check("static void foo()\n"
|
||||
"{\n"
|
||||
" int *p = 0;\n"
|
||||
" if (3 > *p);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Null pointer dereference\n", errout.str());
|
||||
|
||||
check("void f()\n"
|
||||
|
@ -883,7 +883,7 @@ private:
|
|||
" char *c = 0;\n"
|
||||
" *c = 0;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (error) Null pointer dereference\n", errout.str());
|
||||
|
||||
// no false positive..
|
||||
|
@ -892,7 +892,7 @@ private:
|
|||
" Foo *p = 0;\n"
|
||||
" p = new Foo;\n"
|
||||
" p->abcd();\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("static void foo()\n"
|
||||
|
@ -901,7 +901,7 @@ private:
|
|||
" if (!p)\n"
|
||||
" return;\n"
|
||||
" p->abcd();\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("static void foo()\n"
|
||||
|
@ -909,7 +909,7 @@ private:
|
|||
" int *p = 0;\n"
|
||||
" exit();\n"
|
||||
" *p = 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("static void foo(int a)\n"
|
||||
|
@ -917,26 +917,26 @@ private:
|
|||
" Foo *p = 0;\n"
|
||||
" if (a && p)\n"
|
||||
" p->do_something();\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
" Foo *p = 0;\n"
|
||||
" bool b = (p && (p->type() == 1));\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo()\n"
|
||||
"{\n"
|
||||
" int sz = sizeof((*(struct dummy *)0).x);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void get_offset(long &offset)\n"
|
||||
"{\n"
|
||||
" mystruct * temp; temp = 0;\n"
|
||||
" offset = (long)(&(temp->z));\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// Ticket #1893 - try/catch inside else
|
||||
|
@ -955,7 +955,7 @@ private:
|
|||
" }\n"
|
||||
" *Q=1;\n"
|
||||
" return Q;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("int *test(int *Z)\n"
|
||||
|
@ -971,7 +971,7 @@ private:
|
|||
" }\n"
|
||||
" *Q=1;\n"
|
||||
" return Q;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:12]: (error) Possible null pointer dereference: Q\n", errout.str());
|
||||
|
||||
// Ticket #2052 (false positive for 'else continue;')
|
||||
|
@ -991,7 +991,7 @@ private:
|
|||
" void (*f)();\n"
|
||||
" f = 0;\n"
|
||||
" f();\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (error) Possible null pointer dereference: f\n", errout.str());
|
||||
|
||||
check("static void foo()\n"
|
||||
|
@ -1000,7 +1000,7 @@ private:
|
|||
" int *p2 = 0;\n"
|
||||
" int r = *p;\n"
|
||||
" int r2 = *p2;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (error) Null pointer dereference\n"
|
||||
"[test.cpp:6]: (error) Null pointer dereference\n", errout.str());
|
||||
|
||||
|
@ -1010,7 +1010,7 @@ private:
|
|||
" for (int i = 0; i < 10; ++i) {\n"
|
||||
" int x = *p + 1;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Possible null pointer dereference: p\n", errout.str());
|
||||
|
||||
check("void f(int a) {\n"
|
||||
|
@ -1078,7 +1078,7 @@ private:
|
|||
" for (int i = 0; i < n; i++) {\n"
|
||||
" argv32[i] = 0;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// No false negative:
|
||||
|
@ -1093,7 +1093,7 @@ private:
|
|||
" for (int i = 0; i < n; i++) {\n"
|
||||
" argv32[i] = 0;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
TODO_ASSERT_EQUALS("error",
|
||||
"", errout.str());
|
||||
|
||||
|
@ -1127,13 +1127,13 @@ private:
|
|||
"{\n"
|
||||
" const char * x = 0;\n"
|
||||
" strdup(x);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Possible null pointer dereference: x\n", errout.str());
|
||||
check("void foo()\n"
|
||||
"{\n"
|
||||
" char const * x = 0;\n"
|
||||
" strdup(x);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Possible null pointer dereference: x\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -1142,7 +1142,7 @@ private:
|
|||
"{\n"
|
||||
" std::string * x = 0;\n"
|
||||
" *x = \"test\";\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Null pointer dereference\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -1151,7 +1151,7 @@ private:
|
|||
"{\n"
|
||||
" struct my_type* p = 0;\n"
|
||||
" p->x = 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Possible null pointer dereference: p\n", errout.str());
|
||||
|
||||
check("void foo()\n"
|
||||
|
@ -1159,7 +1159,7 @@ private:
|
|||
" struct my_type* p;\n"
|
||||
" p = 0;\n"
|
||||
" p->x = 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (error) Possible null pointer dereference: p\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -1168,14 +1168,14 @@ private:
|
|||
"{\n"
|
||||
" my_type* p = 0;\n"
|
||||
" return p->x;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Possible null pointer dereference: p\n", errout.str());
|
||||
|
||||
check("int foo()\n"
|
||||
"{\n"
|
||||
" struct my_type* p = 0;\n"
|
||||
" return p->x;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Possible null pointer dereference: p\n", errout.str());
|
||||
|
||||
check("int foo()\n"
|
||||
|
@ -1183,7 +1183,7 @@ private:
|
|||
" my_type* p;\n"
|
||||
" p = 0;\n"
|
||||
" return p->x;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (error) Possible null pointer dereference: p\n", errout.str());
|
||||
|
||||
check("int foo()\n"
|
||||
|
@ -1191,7 +1191,7 @@ private:
|
|||
" struct my_type* p;\n"
|
||||
" p = 0;\n"
|
||||
" return p->x;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (error) Possible null pointer dereference: p\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -1221,7 +1221,7 @@ private:
|
|||
" s.d=NULL;\n"
|
||||
" double *pd = s.d;\n"
|
||||
" *pd = 10;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:10]: (error) Null pointer dereference\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -1229,13 +1229,13 @@ private:
|
|||
check("void foo()\n"
|
||||
"{\n"
|
||||
" strcpy(bar, 0);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Null pointer dereference\n", errout.str());
|
||||
|
||||
check("void foo()\n"
|
||||
"{\n"
|
||||
" memcmp(bar(xyz()), 0, 123);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Null pointer dereference\n", errout.str());
|
||||
|
||||
check("void foo(const char *s)\n"
|
||||
|
@ -1244,7 +1244,7 @@ private:
|
|||
" frexp(1.0, p);\n"
|
||||
" char *q = 0;\n"
|
||||
" frexp(1.0, q);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:6]: (error) Possible null pointer dereference: q\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -1358,48 +1358,48 @@ private:
|
|||
" if (!p) {\n"
|
||||
" }\n"
|
||||
" *p = 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:2]: (error) Possible null pointer dereference: p - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
check("void foo(char *p) {\n"
|
||||
" if (NULL == p) {\n"
|
||||
" }\n"
|
||||
" *p = 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:2]: (error) Possible null pointer dereference: p - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
check("void foo(char *p) {\n"
|
||||
" if (p == NULL) {\n"
|
||||
" }\n"
|
||||
" *p = 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:2]: (error) Possible null pointer dereference: p - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
check("void foo(char *p) {\n"
|
||||
" if (p == NULL) {\n"
|
||||
" }\n"
|
||||
" printf(\"%c\", *p);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:2]: (error) Possible null pointer dereference: p - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
check("void foo(char *p) {\n"
|
||||
" if (p && *p == 0) {\n"
|
||||
" }\n"
|
||||
" printf(\"%c\", *p);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:2]: (error) Possible null pointer dereference: p - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
check("void foo(char *p) {\n"
|
||||
" if (p && *p == 0) {\n"
|
||||
" } else { *p = 0; }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:2]: (error) Possible null pointer dereference: p - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
check("void foo(char *p) {\n"
|
||||
" if (p) {\n"
|
||||
" }\n"
|
||||
" strcpy(p, \"abc\");\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:2]: (error) Possible null pointer dereference: p - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
check("void foo(char *p) {\n"
|
||||
|
@ -1407,7 +1407,7 @@ private:
|
|||
" }\n"
|
||||
" bar();\n"
|
||||
" strcpy(p, \"abc\");\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:2]: (error) Possible null pointer dereference: p - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
check("void foo(abc *p) {\n"
|
||||
|
@ -1415,7 +1415,7 @@ private:
|
|||
" }\n"
|
||||
" else if (!p->x) {\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo(char *p) {\n"
|
||||
|
@ -1423,7 +1423,7 @@ private:
|
|||
" abort();\n"
|
||||
" }\n"
|
||||
" *p = 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo(char *p) {\n"
|
||||
|
@ -1439,7 +1439,7 @@ private:
|
|||
" (*bail)();\n"
|
||||
" }\n"
|
||||
" *p = 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo(char *p) {\n"
|
||||
|
@ -1447,7 +1447,7 @@ private:
|
|||
" throw x;\n"
|
||||
" }\n"
|
||||
" *p = 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo(char *p) {\n"
|
||||
|
@ -1455,7 +1455,7 @@ private:
|
|||
" ab.abort();\n"
|
||||
" }\n"
|
||||
" *p = 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo(char *p) {\n"
|
||||
|
@ -1487,7 +1487,7 @@ private:
|
|||
" if (!a) {\n"
|
||||
" a.x();\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// This is why this check can't be used on the simplified token list
|
||||
|
@ -1495,7 +1495,7 @@ private:
|
|||
" if (!dynamic_cast<bar *>(foo)) {\n"
|
||||
" *foo = 0;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// ticket: #2300 - calling unknown function that may initialize the pointer
|
||||
|
@ -1505,7 +1505,7 @@ private:
|
|||
" initfred();\n"
|
||||
" fred->x = 0;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// ticket #1219
|
||||
|
@ -1514,7 +1514,7 @@ private:
|
|||
" return;\n"
|
||||
" }\n"
|
||||
" *p = 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:2]: (error) Possible null pointer dereference: p - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
// #2467 - unknown macro may terminate the application
|
||||
|
@ -1618,7 +1618,7 @@ private:
|
|||
check("int foo(struct Fred *fred) {\n"
|
||||
" if (fred) { int a = 0; }\n"
|
||||
" return fred->a;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:2]: (error) Possible null pointer dereference: fred - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
// #2789 - assign and check pointer
|
||||
|
@ -1626,7 +1626,7 @@ private:
|
|||
" char *p;\n"
|
||||
" if (!(p=x())) { }\n"
|
||||
" *p = 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:3]: (error) Possible null pointer dereference: p - otherwise it is redundant to check it against null.\n", errout.str());
|
||||
|
||||
// check, assign and use
|
||||
|
@ -1707,7 +1707,7 @@ private:
|
|||
check("void f(char *s) {\n" // #3358
|
||||
" if (s==0);\n"
|
||||
" strcpy(a, s?b:c);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// sizeof
|
||||
|
@ -1743,7 +1743,7 @@ private:
|
|||
check("void foo() {\n"
|
||||
" char *p = 0;\n"
|
||||
" strcpy(p, \"abcd\");\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Null pointer dereference\n", errout.str());
|
||||
|
||||
// Ticket #1171
|
||||
|
@ -1816,7 +1816,7 @@ private:
|
|||
check("void f() {\n"
|
||||
" char *s = 0;\n"
|
||||
" printf(\"%s\", s == 0 ? a : s);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
|
|
|
@ -92,14 +92,14 @@ private:
|
|||
check("void f()\n"
|
||||
"{\n"
|
||||
" bsd_signal(SIGABRT, SIG_IGN);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (style) Obsolete function 'bsd_signal' called. It is recommended to use the function 'sigaction' instead.\n", errout.str());
|
||||
|
||||
check("int f()\n"
|
||||
"{\n"
|
||||
" int bsd_signal(0);\n"
|
||||
" return bsd_signal;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ private:
|
|||
" if(!hp = gethostbyname('127.0.0.1')) {\n"
|
||||
" exit(1);\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (style) Obsolete function 'gethostbyname' called. It is recommended to use the function 'getaddrinfo' instead.\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ private:
|
|||
" if(!hp = gethostbyaddr((char *) &addr, sizeof(addr), AF_INET)) {\n"
|
||||
" exit(1);\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (style) Obsolete function 'gethostbyaddr' called. It is recommended to use the function 'getnameinfo' instead.\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ private:
|
|||
check("void f()\n"
|
||||
"{\n"
|
||||
" usleep( 1000 );\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (style) Obsolete function 'usleep' called. It is recommended to use the 'nanosleep' or 'setitimer' function instead.\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ private:
|
|||
"int main()\n"
|
||||
"{\n"
|
||||
" n1::index();\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("std::size_t f()\n"
|
||||
|
@ -151,19 +151,19 @@ private:
|
|||
" std::size_t index(0);\n"
|
||||
" index++;\n"
|
||||
" return index;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("int f()\n"
|
||||
"{\n"
|
||||
" return this->index();\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f()\n"
|
||||
"{\n"
|
||||
" int index( 0 );\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("const char f()\n"
|
||||
|
@ -171,7 +171,7 @@ private:
|
|||
" const char var[6] = 'index';\n"
|
||||
" const char i = index(var, 0);\n"
|
||||
" return i;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (style) Obsolete function 'index' called. It is recommended to use the function 'strchr' instead.\n",
|
||||
errout.str());
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ private:
|
|||
void test_qt_index() {
|
||||
check("void TDataModel::forceRowRefresh(int row) {\n"
|
||||
" emit dataChanged(index(row, 0), index(row, columnCount() - 1));\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (style) Obsolete function 'index' called. It is recommended to use the function 'strchr' instead.\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -187,14 +187,14 @@ private:
|
|||
check("void f()\n"
|
||||
"{\n"
|
||||
" int rindex( 0 );\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f()\n"
|
||||
"{\n"
|
||||
" const char var[7] = 'rindex';\n"
|
||||
" print(rindex(var, 0));\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (style) Obsolete function 'rindex' called. It is recommended to use the function 'strrchr' instead.\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ private:
|
|||
"public:\n"
|
||||
" Fred() : index(0) { }\n"
|
||||
" int index;\n"
|
||||
"};\n");
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,7 @@ private:
|
|||
check("void f()\n"
|
||||
"{\n"
|
||||
" char *x = gets();\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (style) Obsolete function 'gets' called. It is recommended to use the function 'fgets' instead.\n", errout.str());
|
||||
|
||||
check("void f()\n"
|
||||
|
@ -246,7 +246,7 @@ private:
|
|||
"{\n"
|
||||
" int b ; b = ftime ( 1 ) ;\n"
|
||||
" return 0 ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,7 @@ private:
|
|||
check("void f(char * str)\n"
|
||||
"{\n"
|
||||
" char *x = std::gets(str);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (style) Obsolete function 'gets' called. It is recommended to use the function 'fgets' instead.\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -265,7 +265,7 @@ private:
|
|||
"{\n"
|
||||
" char *x = std::gets(str);\n"
|
||||
" usleep( 1000 );\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (style) Obsolete function 'gets' called. It is recommended to use the function 'fgets' instead.\n"
|
||||
"[test.cpp:4]: (style) Obsolete function 'usleep' called. It is recommended to use the 'nanosleep' or 'setitimer' function instead.\n", errout.str());
|
||||
}
|
||||
|
@ -276,14 +276,14 @@ private:
|
|||
"{\n"
|
||||
" char s [ 10 ] ;\n"
|
||||
" gets ( s ) ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (style) Obsolete function 'gets' called. It is recommended to use the function 'fgets' instead.\n", errout.str());
|
||||
|
||||
check("int getcontext(ucontext_t *ucp);\n"
|
||||
"int f (ucontext_t *ucp)\n"
|
||||
"{\n"
|
||||
" getcontext ( ucp ) ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (style) Obsolete function 'getcontext' called. Due to portability issues, applications are recommended to be rewritten to use POSIX threads.\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -293,7 +293,7 @@ private:
|
|||
"{\n"
|
||||
" char s [ 10 ] ;\n"
|
||||
" gets ( s ) ;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -83,7 +83,7 @@ private:
|
|||
" k--;\n"
|
||||
" std::cout << k << std::endl;\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("class K {};"
|
||||
|
@ -94,7 +94,7 @@ private:
|
|||
" k++;\n"
|
||||
" std::cout << k << std::endl;\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str());
|
||||
|
||||
check("struct K {};"
|
||||
|
@ -102,7 +102,7 @@ private:
|
|||
"{\n"
|
||||
" K k(0);\n"
|
||||
" k++;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str());
|
||||
|
||||
check("union K {};"
|
||||
|
@ -110,7 +110,7 @@ private:
|
|||
"{\n"
|
||||
" K k(0);\n"
|
||||
" k++;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str());
|
||||
|
||||
check("class K {};"
|
||||
|
@ -123,7 +123,7 @@ private:
|
|||
" }\n"
|
||||
" std::cout << k << std::endl;\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:6]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str());
|
||||
|
||||
check("class K {};"
|
||||
|
@ -137,7 +137,7 @@ private:
|
|||
" k++;\n"
|
||||
" std::cout << k << std::endl;\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:8]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str());
|
||||
|
||||
|
||||
|
@ -149,7 +149,7 @@ private:
|
|||
" k--;\n"
|
||||
" std::cout << k << std::endl;\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:5]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str());
|
||||
|
||||
check("class K {};"
|
||||
|
@ -160,7 +160,7 @@ private:
|
|||
" ++k;\n"
|
||||
" std::cout << k << std::endl;\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("class K {};"
|
||||
|
@ -171,7 +171,7 @@ private:
|
|||
" --k;\n"
|
||||
" std::cout << k << std::endl;\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ private:
|
|||
" std::cout << i << std::endl;\n"
|
||||
" }\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("class K {};\n"
|
||||
|
@ -193,7 +193,7 @@ private:
|
|||
" std::cout << i << std::endl;\n"
|
||||
" }\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str());
|
||||
|
||||
check("class K {};\n"
|
||||
|
@ -203,7 +203,7 @@ private:
|
|||
" std::cout << i << std::endl;\n"
|
||||
" }\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("class K {};\n"
|
||||
|
@ -213,7 +213,7 @@ private:
|
|||
" std::cout << i << std::endl;\n"
|
||||
" }\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str());
|
||||
|
||||
check("class K {};\n"
|
||||
|
@ -223,7 +223,7 @@ private:
|
|||
" std::cout << i << std::endl;\n"
|
||||
" }\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
|
||||
|
@ -237,7 +237,7 @@ private:
|
|||
" std::cout << k++ << std::endl;\n"
|
||||
" std::cout << k-- << std::endl;\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("class K {};\n"
|
||||
|
@ -247,7 +247,7 @@ private:
|
|||
" std::cout << k << std::endl;\n"
|
||||
" std::cout << k-- << std::endl;\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:6]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str());
|
||||
|
||||
check("class K {};\n"
|
||||
|
@ -258,7 +258,7 @@ private:
|
|||
" std::cout << ++k << std::endl;\n"
|
||||
" std::cout << --k << std::endl;\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -271,7 +271,7 @@ private:
|
|||
" k++;\n"
|
||||
" std::cout << k << std::endl;\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
TODO_ASSERT_EQUALS("",
|
||||
"[test.cpp:6]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str());
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ private:
|
|||
" }\n"
|
||||
" v.clear();\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:6]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str());
|
||||
|
||||
check("int main() {\n"
|
||||
|
@ -301,7 +301,7 @@ private:
|
|||
" it++;\n"
|
||||
" }\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:9]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str());
|
||||
|
||||
check("int main() {\n"
|
||||
|
@ -314,7 +314,7 @@ private:
|
|||
" it++;\n"
|
||||
" }\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:8]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str());
|
||||
|
||||
check("int main() {\n"
|
||||
|
@ -328,14 +328,14 @@ private:
|
|||
" rit--;\n"
|
||||
" }\n"
|
||||
" return 0;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:9]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str());
|
||||
|
||||
}
|
||||
|
||||
void test2168() {
|
||||
check("--> declare allocator lock here\n"
|
||||
"int main(){}\n");
|
||||
"int main(){}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
|
|
@ -1319,7 +1319,7 @@ private:
|
|||
"{\n"
|
||||
" int *n;\n"
|
||||
" sizeof *(n);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -5537,7 +5537,7 @@ private:
|
|||
"{\n"
|
||||
" B * b = new B;\n"
|
||||
" b->f = new A::F * [ 10 ];\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
|
280
test/teststl.cpp
280
test/teststl.cpp
File diff suppressed because it is too large
Load Diff
|
@ -966,7 +966,7 @@ private:
|
|||
" class X { X(int); };\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"namespace barney { X::X(int) { } }\n");
|
||||
"namespace barney { X::X(int) { } }");
|
||||
|
||||
// Locate the scope for the class..
|
||||
const Scope *scope = NULL;
|
||||
|
@ -1000,7 +1000,7 @@ private:
|
|||
" namespace barney {\n"
|
||||
" X::X(int) { }\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
|
||||
// Locate the scope for the class..
|
||||
const Scope *scope = NULL;
|
||||
|
@ -1026,7 +1026,7 @@ private:
|
|||
|
||||
void namespaces3() { // #3854 - namespace with unknown macro
|
||||
GET_SYMBOL_DB("namespace fred UNKNOWN_MACRO(default) {\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS(2U, db->scopeList.size());
|
||||
ASSERT_EQUALS(Scope::eGlobal, db->scopeList.front().type);
|
||||
ASSERT_EQUALS(Scope::eNamespace, db->scopeList.back().type);
|
||||
|
@ -1039,7 +1039,7 @@ private:
|
|||
" catch (const X::Error2 & x) { }\n"
|
||||
" catch (Error3 x) { }\n"
|
||||
" catch (X::Error4 x) { }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
GET_SYMBOL_DB(str.c_str())
|
||||
check(str.c_str(), false);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
@ -1077,7 +1077,7 @@ private:
|
|||
check("typedef void (func_type)();\n"
|
||||
"struct A {\n"
|
||||
" friend func_type f : 2;\n"
|
||||
"};\n");
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -1088,7 +1088,7 @@ private:
|
|||
"static void function_declaration_after(void) __attribute__((__used__));\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("main(int argc, char *argv[]) { }\n");
|
||||
check("main(int argc, char *argv[]) { }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("namespace boost {\n"
|
||||
|
@ -1096,7 +1096,7 @@ private:
|
|||
" {\n"
|
||||
" return std::locale();\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("namespace X {\n"
|
||||
|
@ -1104,12 +1104,12 @@ private:
|
|||
" static void function_declaration_before(void) {}\n"
|
||||
" static void function_declaration_after(void) {}\n"
|
||||
" static void function_declaration_after(void) __attribute__((__used__));\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("testing::testing()\n"
|
||||
"{\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -1117,7 +1117,7 @@ private:
|
|||
// ticket #2178 - segmentation fault
|
||||
check("int CL_INLINE_DECL(integer_decode_float) (int x) {\n"
|
||||
" return (sign ? cl_I() : 0);\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -1144,7 +1144,7 @@ private:
|
|||
"{\n"
|
||||
"public:\n"
|
||||
" int f() { return C< ::D,int>::f(); }\n"
|
||||
"};\n");
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -1157,7 +1157,7 @@ private:
|
|||
" {\n"
|
||||
" return vcl::unotools::createStandardColorSpace();\n"
|
||||
" }\n"
|
||||
"};\n");
|
||||
"};");
|
||||
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
@ -1184,7 +1184,7 @@ private:
|
|||
"};\n"
|
||||
"class B {\n"
|
||||
" friend void A::f();\n"
|
||||
"};\n");
|
||||
"};");
|
||||
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
@ -1194,7 +1194,7 @@ private:
|
|||
check("int g ();\n"
|
||||
"struct S {\n"
|
||||
" int i : (false ? g () : 1);\n"
|
||||
"};\n");
|
||||
"};");
|
||||
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
@ -1203,7 +1203,7 @@ private:
|
|||
// ticket #2547 - segmentation fault
|
||||
check("class foo {\n"
|
||||
" void bar2 () = __null;\n"
|
||||
"};\n");
|
||||
"};");
|
||||
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
@ -1212,7 +1212,7 @@ private:
|
|||
// ticket #2577 - segmentation fault
|
||||
check("class foo {\n"
|
||||
" void bar2 () = A::f;\n"
|
||||
"};\n");
|
||||
"};");
|
||||
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
@ -1240,7 +1240,7 @@ private:
|
|||
|
||||
void symboldatabase17() {
|
||||
// ticket #2657 - segmentation fault
|
||||
check("return f(){}\n");
|
||||
check("return f(){}");
|
||||
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
@ -1254,7 +1254,7 @@ private:
|
|||
|
||||
void symboldatabase19() {
|
||||
// ticket #2991 - segmentation fault
|
||||
check("::y(){x}\n");
|
||||
check("::y(){x}");
|
||||
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
@ -1273,7 +1273,7 @@ private:
|
|||
"};\n"
|
||||
"Fred::func() const {\n"
|
||||
" Foo foo;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
@ -1287,7 +1287,7 @@ private:
|
|||
|
||||
// #ticket 3435 (std::vector)
|
||||
void symboldatabase23() {
|
||||
GET_SYMBOL_DB("class A { std::vector<int*> ints; };\n");
|
||||
GET_SYMBOL_DB("class A { std::vector<int*> ints; };");
|
||||
ASSERT_EQUALS(2U, db->scopeList.size());
|
||||
const Scope &scope = db->scopeList.back();
|
||||
ASSERT_EQUALS(1U, scope.varlist.size());
|
||||
|
@ -1367,7 +1367,7 @@ private:
|
|||
"{\n"
|
||||
" B1()\n"
|
||||
" {} C(int) : B1() class\n"
|
||||
"};\n");
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -78,7 +78,7 @@ private:
|
|||
"{\n"
|
||||
" if (f1())\n"
|
||||
" { }\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ private:
|
|||
check("int f1()\n"
|
||||
"{\n"
|
||||
" return f1();\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ private:
|
|||
check("char * foo()\n"
|
||||
"{\n"
|
||||
" return *foo();\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ private:
|
|||
check("void f1()\n"
|
||||
"{\n"
|
||||
" void (*f)() = cond ? f1 : NULL;\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ private:
|
|||
"{\n"
|
||||
" if (cond) ;\n"
|
||||
" else f1();\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ private:
|
|||
"{\n"
|
||||
" f(&abc::foo);\n"
|
||||
" return 0\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("namespace abc {\n"
|
||||
|
@ -135,7 +135,7 @@ private:
|
|||
"{\n"
|
||||
" f = &abc::foo;\n"
|
||||
" return 0\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("namespace abc {\n" // #3875
|
||||
|
@ -146,7 +146,7 @@ private:
|
|||
"{\n"
|
||||
" f(abc::foo);\n"
|
||||
" return 0\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ private:
|
|||
"{\n"
|
||||
" foo<int>();\n"
|
||||
" return 0\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -167,12 +167,12 @@ private:
|
|||
"template<class T> void g()\n"
|
||||
"{\n"
|
||||
" f();\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void throwIsNotAFunction() {
|
||||
check("struct A {void f() const throw () {}}; int main() {A a; a.f();}\n");
|
||||
check("struct A {void f() const throw () {}}; int main() {A a; a.f();}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -195,20 +195,20 @@ private:
|
|||
}
|
||||
|
||||
void unusedMain() {
|
||||
check("int main() { }\n");
|
||||
check("int main() { }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("int _tmain() { }\n");
|
||||
check("int _tmain() { }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("int WinMain() { }\n");
|
||||
check("int WinMain() { }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void initializationIsNotAFunction() {
|
||||
check("struct B: N::A {\n"
|
||||
" B(): N::A() {};\n"
|
||||
"};\n");
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ private:
|
|||
"{ }\n"
|
||||
"\n"
|
||||
"unsigned int Fred::f()\n"
|
||||
"{ }\n");
|
||||
"{ }");
|
||||
|
||||
ASSERT_EQUALS("[test.cpp:4]: (style) Unused private function: 'Fred::f'\n", errout.str());
|
||||
|
||||
|
@ -124,7 +124,7 @@ private:
|
|||
"{ }\n"
|
||||
"\n"
|
||||
"unsigned int Fred::f()\n"
|
||||
"{ }\n");
|
||||
"{ }");
|
||||
|
||||
ASSERT_EQUALS("[p.h:4]: (style) Unused private function: 'Fred::f'\n", errout.str());
|
||||
|
||||
|
@ -140,7 +140,7 @@ private:
|
|||
"\n"
|
||||
"void Fred::f()\n"
|
||||
"{\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("[p.h:4]: (style) Unused private function: 'Fred::f'\n", errout.str());
|
||||
|
||||
// Don't warn about include files which implementation we don't see
|
||||
|
@ -156,7 +156,7 @@ private:
|
|||
"\n"
|
||||
"int main()\n"
|
||||
"{\n"
|
||||
"}\n");
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ private:
|
|||
"};\n"
|
||||
"\n"
|
||||
"A::A()\n"
|
||||
"{ }\n");
|
||||
"{ }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ private:
|
|||
"};\n"
|
||||
"\n"
|
||||
"A::~A()\n"
|
||||
"{ B(); }\n");
|
||||
"{ B(); }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ private:
|
|||
"};\n"
|
||||
"\n"
|
||||
"A::A() : _owner(false)\n"
|
||||
"{ b(); }\n");
|
||||
"{ b(); }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -215,14 +215,14 @@ private:
|
|||
" A() : lock(new Lock())\n"
|
||||
" { }\n"
|
||||
" Lock *lock;\n"
|
||||
"};\n");
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void test6() { // ticket #2602 segmentation fault
|
||||
check("class A {\n"
|
||||
" A& operator=(const A&);\n"
|
||||
"};\n");
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ private:
|
|||
"};\n"
|
||||
"\n"
|
||||
"Fred::Fred()\n"
|
||||
"{}\n");
|
||||
"{}");
|
||||
|
||||
ASSERT_EQUALS("[test.cpp:6]: (style) Unused private function: 'Fred::get'\n", errout.str());
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ private:
|
|||
" void callback(const& unsigned) const {}\n"
|
||||
"\n"
|
||||
" Observer<UnusedPrivateFunctionMemberPointer, unsigned> mObserver;\n"
|
||||
"};\n");
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -282,7 +282,7 @@ private:
|
|||
"\n"
|
||||
"private:\n"
|
||||
" void f1() const {}\n"
|
||||
"};\n");
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ private:
|
|||
" void (*fptr)();\n"
|
||||
"};\n"
|
||||
"myclass::myclass() { fptr = &f; }\n"
|
||||
"void myclass::f() {}\n");
|
||||
"void myclass::f() {}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -308,7 +308,7 @@ private:
|
|||
" void (*f)();\n"
|
||||
"private:\n"
|
||||
" static void func() { }\n"
|
||||
"};\n");
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -324,7 +324,7 @@ private:
|
|||
" }\n"
|
||||
"\n"
|
||||
" int numOfThreads;\n"
|
||||
"};\n");
|
||||
"};");
|
||||
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
@ -342,7 +342,7 @@ private:
|
|||
"private:\n"
|
||||
" static void f()\n"
|
||||
" { }\n"
|
||||
"};\n");
|
||||
"};");
|
||||
ASSERT_EQUALS("[test.cpp:10]: (style) Unused private function: 'A::f'\n", errout.str());
|
||||
|
||||
check("class A\n"
|
||||
|
@ -361,7 +361,7 @@ private:
|
|||
" B(A *a)\n"
|
||||
" { a->f(); }\n"
|
||||
" };\n"
|
||||
"};\n");
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -396,7 +396,7 @@ private:
|
|||
"};\n"
|
||||
"#endfile\n"
|
||||
"A::A() { }\n"
|
||||
"void A::b() { }\n");
|
||||
"void A::b() { }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -408,7 +408,7 @@ private:
|
|||
" derived() : base() { }\n"
|
||||
"private:\n"
|
||||
" void f();\n"
|
||||
"};\n");
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("class base {\n"
|
||||
|
@ -522,7 +522,7 @@ private:
|
|||
"template <class T>\n"
|
||||
"T A::getVal() const {\n"
|
||||
" return internalGetVal();\n"
|
||||
"};\n");
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
@ -538,7 +538,7 @@ private:
|
|||
"private:\n"
|
||||
" void startListening() {\n"
|
||||
" }\n"
|
||||
"};\n");
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("class Fred\n"
|
||||
|
@ -550,7 +550,7 @@ private:
|
|||
"private:\n"
|
||||
" void startListening() {\n"
|
||||
" }\n"
|
||||
"};\n");
|
||||
"};");
|
||||
ASSERT_EQUALS("[test.cpp:8]: (style) Unused private function: 'Fred::startListening'\n", errout.str());
|
||||
}
|
||||
|
||||
|
@ -649,7 +649,7 @@ private:
|
|||
"#endfile\n"
|
||||
"void Fred::Init()\n"
|
||||
"{\n"
|
||||
"}\n");
|
||||
"}");
|
||||
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue