diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index cd53ba092..cefb45cc2 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -958,12 +958,11 @@ private: } void array_index_22() { - check("#include \n" - "int main() {\n" + check("int main() {\n" " size_t indices[2];\n" " int b = indices[2];\n" "}\n"); - ASSERT_EQUALS("[test.cpp:4]: (error) Array 'indices[2]' accessed at index 2, which is out of bounds\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (error) Array 'indices[2]' accessed at index 2, which is out of bounds\n", errout.str()); } void array_index_23() { diff --git a/test/testclass.cpp b/test/testclass.cpp index fca24e879..f2827b08b 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -4786,25 +4786,23 @@ private: ASSERT_EQUALS("[test.cpp:3]: (style, inconclusive) Technically the member function 'Fred::a' can be const.\n", errout.str()); // ticket #1593 - checkConst("#include \n" - "class A\n" + checkConst("class A\n" "{\n" " std::vector m_v;\n" "public:\n" " A(){}\n" " unsigned int GetVecSize() {return m_v.size();}\n" "};"); - ASSERT_EQUALS("[test.cpp:7]: (style, inconclusive) Technically the member function 'A::GetVecSize' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:6]: (style, inconclusive) Technically the member function 'A::GetVecSize' can be const.\n", errout.str()); - checkConst("#include \n" - "class A\n" + checkConst("class A\n" "{\n" " std::vector m_v;\n" "public:\n" " A(){}\n" " bool GetVecEmpty() {return m_v.empty();}\n" "};"); - ASSERT_EQUALS("[test.cpp:7]: (style, inconclusive) Technically the member function 'A::GetVecEmpty' can be const.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:6]: (style, inconclusive) Technically the member function 'A::GetVecEmpty' can be const.\n", errout.str()); } void constVirtualFunc() { diff --git a/test/testconstructors.cpp b/test/testconstructors.cpp index 94c51c288..63bcbe7ca 100644 --- a/test/testconstructors.cpp +++ b/test/testconstructors.cpp @@ -1887,8 +1887,7 @@ private: } void uninitVarStream() { - check("#include \n" - "class Foo\n" + check("class Foo\n" "{\n" "private:\n" " int foo;\n" diff --git a/test/testother.cpp b/test/testother.cpp index fc251545d..ff0cb4e50 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -2345,8 +2345,7 @@ private: } void trac1132() { - check("#include \n" - "class Lock\n" + check("class Lock\n" "{\n" "public:\n" " Lock(int i)\n" @@ -2365,7 +2364,7 @@ private: " return 0;\n" "}\n" ); - ASSERT_EQUALS("[test.cpp:16]: (error) Instance of \"Lock\" object destroyed immediately.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:15]: (error) Instance of \"Lock\" object destroyed immediately.\n", errout.str()); } void trac3693() { @@ -2449,10 +2448,7 @@ private: } void testMisusedScopeObjectDoesNotPickFunctor() { - check("\n" - "#include \n" - "\n" - "class IncrementFunctor\n" + check("class IncrementFunctor\n" "{\n" "public:\n" " void operator()(int &i)\n" @@ -2545,9 +2541,7 @@ private: } void trac2084() { - check("#include \n" - "\n" - "void f()\n" + check("void f()\n" "{\n" " struct sigaction sa;\n" "\n" diff --git a/test/testpostfixoperator.cpp b/test/testpostfixoperator.cpp index 8707b7b20..e8c822207 100644 --- a/test/testpostfixoperator.cpp +++ b/test/testpostfixoperator.cpp @@ -70,9 +70,7 @@ private: } void testsimple() { - check("\n" - "#include \n" - "int main(int argc, char *argv[])\n" + check("int main()\n" "{\n" " unsigned int k(0);\n" " std::cout << k << std::endl;\n" @@ -88,10 +86,8 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); - check("\n" - "#include \n" - "class K {};" - "int main(int argc, char *argv[])\n" + check("class K {};" + "int main()\n" "{\n" " K k(0);\n" " std::cout << k << std::endl;\n" @@ -99,30 +95,26 @@ private: " std::cout << k << std::endl;\n" " return 0;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:7]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); - check("\n" - "struct K {};" + check("struct K {};" "void foo()\n" "{\n" " K k(0);\n" " k++;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:5]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); - check("\n" - "union K {};" + check("union K {};" "void foo()\n" "{\n" " K k(0);\n" " k++;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:5]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); - check("\n" - "#include \n" - "class K {};" - "int main(int argc, char *argv[])\n" + check("class K {};" + "int main()\n" "{\n" " K k(1);\n" " std::cout << k << std::endl;\n" @@ -132,12 +124,10 @@ private: " 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()); + ASSERT_EQUALS("[test.cpp:6]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); - check("\n" - "#include \n" - "class K {};" - "int main(int argc, char *argv[])\n" + check("class K {};" + "int main()\n" "{\n" " K k(1);\n" " std::cout << k << std::endl;\n" @@ -148,13 +138,11 @@ private: " std::cout << k << std::endl;\n" " return 0;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:10]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:8]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); - check("\n" - "#include \n" - "class K {};" - "int main(int argc, char *argv[])\n" + check("class K {};" + "int main()\n" "{\n" " K k(0);\n" " std::cout << k << std::endl;\n" @@ -162,12 +150,10 @@ private: " std::cout << k << std::endl;\n" " return 0;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:7]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:5]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); - check("\n" - "#include \n" - "class K {};" - "int main(int argc, char *argv[])\n" + check("class K {};" + "int main()\n" "{\n" " K k(0);\n" " std::cout << k << std::endl;\n" @@ -177,10 +163,8 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); - check("\n" - "#include \n" - "class K {};" - "int main(int argc, char *argv[])\n" + check("class K {};" + "int main()\n" "{\n" " K k(0);\n" " std::cout << k << std::endl;\n" @@ -193,9 +177,7 @@ private: } void testfor() { - check("\n" - "#include \n" - "int main(int argc, char *argv[])\n" + check("int main()\n" "{\n" " for ( unsigned int i=0; i <= 10; i++) {\n" " std::cout << i << std::endl;\n" @@ -204,22 +186,18 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); - check("\n" - "#include \n" - "class K {};\n" - "int main(int argc, char *argv[])\n" + check("class K {};\n" + "int main()\n" "{\n" " for ( K i(0); i <= 10; i++) {\n" " std::cout << i << std::endl;\n" " }\n" " return 0;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:6]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); - check("\n" - "#include \n" - "class K {};\n" - "int main(int argc, char *argv[])\n" + check("class K {};\n" + "int main()\n" "{\n" " for ( K i(0); i <= 10; ++i) {\n" " std::cout << i << std::endl;\n" @@ -228,21 +206,17 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); - check("\n" - "#include \n" - "class K {};\n" - "int main(int argc, char *argv[])\n" + check("class K {};\n" + "int main()\n" "{\n" " for ( K i(10); i > 1; i--) {\n" " std::cout << i << std::endl;\n" " }\n" " return 0;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:6]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); - check("\n" - "#include \n" - "class K {};\n" + check("class K {};\n" "int main(int argc, char *argv[])\n" "{\n" " for ( K i=10; i > 1; --i) {\n" @@ -256,9 +230,7 @@ private: } void teststream() { - check("\n" - "#include \n" - "int main(int argc, char *argv[])\n" + check("int main()\n" "{\n" " int k(0);\n" " std::cout << k << std::endl;\n" @@ -268,22 +240,18 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); - check("\n" - "#include \n" - "class K {};\n" - "int main(int argc, char *argv[])\n" + check("class K {};\n" + "int main()\n" "{\n" " K k(0);\n" " std::cout << k << std::endl;\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()); + ASSERT_EQUALS("[test.cpp:6]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); - check("\n" - "#include \n" - "class K {};\n" - "int main(int argc, char *argv[])\n" + check("class K {};\n" + "int main()\n" "{\n" " K k(0);\n" " std::cout << k << std::endl;\n" @@ -295,10 +263,8 @@ private: } void testvolatile() { - check("\n" - "#include \n" - "class K {};\n" - "int main(int argc, char *argv[])\n" + check("class K {};\n" + "int main()\n" "{\n" " volatile K k(0);\n" " std::cout << k << std::endl;\n" @@ -307,13 +273,11 @@ private: " return 0;\n" "}\n"); TODO_ASSERT_EQUALS("", - "[test.cpp:8]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); + "[test.cpp:6]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); } void testiterator() { - check("\n" - "#include \n" - "class Base {};\n" + check("class Base {};\n" "int main() {\n" " std::vector v;\n" " v.push_back(new Base());\n" @@ -324,12 +288,9 @@ private: " v.clear();\n" " return 0;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:8]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:6]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); - check("\n" - "#include \n" - "#include \n" - "int main() {\n" + check("int main() {\n" " std::vector v;\n" " std::vector::iterator it;\n" " for( int i=0; i < 10; ++i ) v.push_back(i);\n" @@ -341,12 +302,9 @@ private: " }\n" " return 0;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:12]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:9]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); - check("\n" - "#include \n" - "#include \n" - "int main() {\n" + check("int main() {\n" " std::vector v;\n" " std::vector::const_iterator it;\n" " for( int i=0; i < 10; ++i ) v.push_back(i);\n" @@ -357,12 +315,9 @@ private: " }\n" " return 0;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:11]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:8]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); - check("\n" - "#include \n" - "#include \n" - "int main() {\n" + check("int main() {\n" " std::vector v;\n" " std::vector::iterator it;\n" " for( int i=0; i < 10; ++i ) v.push_back(i);\n" @@ -374,7 +329,7 @@ private: " }\n" " return 0;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:12]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:9]: (performance) Prefer prefix ++/-- operators for non-primitive types.\n", errout.str()); } diff --git a/test/teststl.cpp b/test/teststl.cpp index b75185238..bccf202e9 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -1857,8 +1857,7 @@ private: "the object. Use operator= instead.\n" "[test.cpp:9]: (performance) Useless call of function \'substr\' because it returns an empty string.\n", errout.str()); - check("#include \n" - "int main()\n" + check("int main()\n" "{\n" " std::string str = \"a1b1\";\n" " return str.find(str[1], 2);\n" diff --git a/test/testunusedprivfunc.cpp b/test/testunusedprivfunc.cpp index ed1401176..bf97fc73a 100644 --- a/test/testunusedprivfunc.cpp +++ b/test/testunusedprivfunc.cpp @@ -547,8 +547,7 @@ private: } void testDoesNotIdentifyMethodAsFirstFunctionArgument() { - check("#include " - "void callback(void (*func)(int), int arg)" + check("void callback(void (*func)(int), int arg)" "{" " (*func)(arg);" "}" @@ -575,8 +574,7 @@ private: } void testDoesNotIdentifyMethodAsMiddleFunctionArgument() { - check("#include " - "void callback(char, void (*func)(int), int arg)" + check("void callback(char, void (*func)(int), int arg)" "{" " (*func)(arg);" "}" @@ -603,8 +601,7 @@ private: } void testDoesNotIdentifyMethodAsLastFunctionArgument() { - check("#include " - "void callback(int arg, void (*func)(int))" + check("void callback(int arg, void (*func)(int))" "{" " (*func)(arg);" "}"