From 4737966cafc842ed2a3c29f80dee01f4fa960dfe Mon Sep 17 00:00:00 2001 From: PKEuS Date: Thu, 6 Dec 2012 10:19:22 -0800 Subject: [PATCH] Unit test cleanup: Removed some empty lines and whitespaces before \n. --- test/testbufferoverrun.cpp | 10 +++++----- test/testclass.cpp | 16 ++++++++-------- test/testconstructors.cpp | 2 +- test/testmemleak.cpp | 26 +++++++++++++------------- test/testnullpointer.cpp | 8 ++++---- test/testother.cpp | 18 +++++++++--------- test/testsimplifytokens.cpp | 17 ++++++++--------- test/teststl.cpp | 29 +++++++++++++---------------- test/testtokenize.cpp | 2 +- test/testuninitvar.cpp | 3 +-- 10 files changed, 63 insertions(+), 68 deletions(-) diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 4dced8439..d8e98df50 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -1401,7 +1401,7 @@ private: void array_index_43() { // #3838 - check("int f( ) \n" + check("int f( )\n" "{\n" " struct {\n" " int arr[ 3 ];\n" @@ -1415,7 +1415,7 @@ private: "}\n"); TODO_ASSERT_EQUALS("[test.cpp:10]: (error) Array 'var[0].arr[3]' index 3 out of bounds.\n","", errout.str()); - check("int f( ) \n" + check("int f( )\n" "{\n" " struct {\n" " int arr[ 3 ];\n" @@ -2592,7 +2592,7 @@ private: check("void main() {\n" " int array[] = {1,2};\n" " int x = 0;\n" - " for( int i = 0; i<6; ) { \n" + " for( int i = 0; i<6; ) {\n" " x += array[i];\n" " i++; }\n" "}\n"); @@ -2601,7 +2601,7 @@ private: check("void main() {\n" " int array[] = {1,2};\n" " int x = 0;\n" - " for( int i = 0; i<6; ) { \n" + " for( int i = 0; i<6; ) {\n" " i++; }\n" "}\n"); ASSERT_EQUALS("", errout.str()); @@ -2611,7 +2611,7 @@ private: check("void main() {\n" " int array[] = {1,2};\n" " int x = 0;\n" - " for( int i = 0; i<6; ) { \n" + " for( int i = 0; i<6; ) {\n" " x += array[i++];\n" " }\n" "}\n"); diff --git a/test/testclass.cpp b/test/testclass.cpp index 538dde683..40c01cc60 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -1936,7 +1936,7 @@ private: checkNoMemset("class Fred\n" "{\n" - " std::string * b; \n" + " std::string * b;\n" "};\n" "void f()\n" "{\n" @@ -1947,7 +1947,7 @@ private: checkNoMemset("class Fred\n" "{\n" - " std::string b; \n" + " std::string b;\n" "};\n" "void f()\n" "{\n" @@ -1958,7 +1958,7 @@ private: checkNoMemset("class Fred\n" "{\n" - " mutable std::string b; \n" + " mutable std::string b;\n" "};\n" "void f()\n" "{\n" @@ -2041,7 +2041,7 @@ private: checkNoMemset("namespace n1 {\n" " class Fred\n" " {\n" - " std::string b; \n" + " std::string b;\n" " };\n" "}\n" "void f()\n" @@ -2055,7 +2055,7 @@ private: checkNoMemset("namespace n1 {\n" " class Fred\n" " {\n" - " std::string b; \n" + " std::string b;\n" " };\n" "}\n" "void f()\n" @@ -2069,7 +2069,7 @@ private: checkNoMemset("namespace n1 {\n" " class Fred\n" " {\n" - " std::string b; \n" + " std::string b;\n" " };\n" "}\n" "void f()\n" @@ -2122,7 +2122,7 @@ private: "{\n" " void g( struct sockaddr_in6& a);\n" "private:\n" - " std::string b; \n" + " std::string b;\n" "};\n" "void f()\n" "{\n" @@ -4181,7 +4181,7 @@ private: "class A\n" "{\n" " public:\n" - " \n" + "\n" " AA::BB::CC::DD a;\n" " void foo(AA::BB::CC::DD b)\n" " {\n" diff --git a/test/testconstructors.cpp b/test/testconstructors.cpp index d6c408941..6d9f7a160 100644 --- a/test/testconstructors.cpp +++ b/test/testconstructors.cpp @@ -1524,7 +1524,7 @@ private: "private:\n" " int a[23];\n" "public:\n" - " Fred(); \n" + " Fred();\n" "};\n" "Fred::Fred() {\n" " a[x::y] = 0;\n" diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 69661bfa6..b2a7d49c3 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -2201,13 +2201,13 @@ private: // #2705 void func24() { - check("void f(void) \n" + check("void f(void)\n" "{\n" " std::string *x = new std::string;\n" "}\n"); TODO_ASSERT_EQUALS("[test.cpp:3]: (error) Memory leak: x\n","", errout.str()); - check("void f(void) \n" + check("void f(void)\n" "{\n" " std::string *x = new std::string;\n" " delete x;\n" @@ -2217,7 +2217,7 @@ private: void func25() { // ticket #2904 check("class Fred { };\n" - "void f(void) \n" + "void f(void)\n" "{\n" " Fred *f = new Fred();\n" " delete f;\n" @@ -2225,14 +2225,14 @@ private: ASSERT_EQUALS("", errout.str()); check("class Fred { };\n" - "void f(void) \n" + "void f(void)\n" "{\n" " Fred *f = new Fred();\n" "}\n"); ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: f\n", errout.str()); check("class Fred { void foo(){ } };\n" - "void f(void) \n" + "void f(void)\n" "{\n" " Fred *f = new Fred();\n" " delete f;\n" @@ -2240,7 +2240,7 @@ private: ASSERT_EQUALS("", errout.str()); check("class Fred { void foo(){ } };\n" - "void f(void) \n" + "void f(void)\n" "{\n" " Fred *f = new Fred();\n" "}\n"); @@ -3479,11 +3479,11 @@ private: check("int myfunc()\n" "{\n" " int handle;\n" - " \n" + "\n" " handle = open(\"myfile\");\n" " if (handle < 0) return 1;\n" - " \n" - " while (some_condition()) \n" + "\n" + " while (some_condition())\n" " if (some_other_condition())\n" " {\n" " close(handle);\n" @@ -3497,11 +3497,11 @@ private: check("int myfunc()\n" "{\n" " int handle;\n" - " \n" + "\n" " handle = open(\"myfile\", O_RDONLY);\n" " if (handle < 0) return 1;\n" - " \n" - " while (some_condition()) \n" + "\n" + " while (some_condition())\n" " if (some_other_condition())\n" " {\n" " return 3;\n" @@ -4115,7 +4115,7 @@ private: "{\n" "public:\n" " void foo()\n" - " { \n" + " {\n" " char *str = new char[100];\n" " delete [] str;\n" " hello();\n" diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index f73325554..34da50ccc 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -699,7 +699,7 @@ private: ASSERT_EQUALS("", errout.str()); // Ticket #2463 - check("struct A \n" + check("struct A\n" "{\n" " B* W;\n" "\n" @@ -1122,7 +1122,7 @@ private: check("void foo()\n" "{\n" " struct my_type* p;\n" - " p = 0; \n" + " p = 0;\n" " p->x = 0;\n" "}\n"); ASSERT_EQUALS("[test.cpp:5]: (error) Possible null pointer dereference: p\n", errout.str()); @@ -1146,7 +1146,7 @@ private: check("int foo()\n" "{\n" " my_type* p;\n" - " p = 0; \n" + " p = 0;\n" " return p->x;\n" "}\n"); ASSERT_EQUALS("[test.cpp:5]: (error) Possible null pointer dereference: p\n", errout.str()); @@ -1154,7 +1154,7 @@ private: check("int foo()\n" "{\n" " struct my_type* p;\n" - " p = 0; \n" + " p = 0;\n" " return p->x;\n" "}\n"); ASSERT_EQUALS("[test.cpp:5]: (error) Possible null pointer dereference: p\n", errout.str()); diff --git a/test/testother.cpp b/test/testother.cpp index 9a964c6c1..1003f6fe6 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -274,12 +274,12 @@ private: "}", "test.cpp", true, true); ASSERT_EQUALS("[test.cpp:3]: (warning, inconclusive) Opposite conditions in nested 'if' blocks lead to a dead code block.\n", errout.str()); - check("void foo(int i) \n" + check("void foo(int i)\n" "{\n" " if(i > 5) {\n" " i = bar();\n" " if(i < 5) {\n" - " cout << a; \n" + " cout << a;\n" " }\n" " }\n" "}", "test.cpp", true, true); @@ -329,7 +329,7 @@ private: " int n = 100;\n" " for(int i = 0; i < n; i ++)\n" " {\n" - " sum += i; \n" + " sum += i;\n" " }\n" " cout< [test.cpp:3]: (style) Found duplicate branches for 'if' and 'else'.\n", errout.str()); check("void f()\n" "{\n" - " if (front < 0) \n" + " if (front < 0)\n" " { frac = (front)/(front-back);}\n" - " else \n" + " else\n" " frac = (front)/(front-back);\n" "}\n"); ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (style) Found duplicate branches for 'if' and 'else'.\n", errout.str()); check("void f()\n" "{\n" - " if (front < 0) \n" + " if (front < 0)\n" " { frac = (front)/(front-back);}\n" - " else \n" + " else\n" " frac = (front)/((front-back));\n" "}\n"); ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (style) Found duplicate branches for 'if' and 'else'.\n", errout.str()); diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 8c9424b55..1718cdee5 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -1706,7 +1706,6 @@ private: "{\n" "public:\n" " typedef ABC m;\n" - "\n" "};\n"; const std::string expected("template < class T > class ABC { public: } ;"); @@ -5257,10 +5256,10 @@ private: } void simplifyTypedef65() { // ticket #2314 - const char code[] = "typedef BAR Foo; \n" - "int main() { \n" - " Foo b(0); \n" - " return b > Foo(10); \n" + const char code[] = "typedef BAR Foo;\n" + "int main() {\n" + " Foo b(0);\n" + " return b > Foo(10);\n" "}"; const std::string actual(tok(code)); ASSERT_EQUALS("int main ( ) { BAR < int > b ( 0 ) ; return b > BAR < int > ( 10 ) ; }", actual); @@ -5296,7 +5295,7 @@ private: void simplifyTypedef69() { // ticket #2348 const char code[] = "typedef int (*CompilerHook)();\n" - "typedef struct VirtualMachine \n" + "typedef struct VirtualMachine\n" "{\n" " CompilerHook *(*compilerHookVector)(void);\n" "}VirtualMachine;\n"; @@ -5417,7 +5416,7 @@ private: } void simplifyTypedef75() { // ticket #2426 - const char code[] = "typedef _Packed struct S { long l; }; \n"; + const char code[] = "typedef _Packed struct S { long l; };\n"; const std::string expected = ""; ASSERT_EQUALS(expected, tok(code)); ASSERT_EQUALS("", errout.str()); @@ -7002,7 +7001,7 @@ private: void enum10() { // ticket 1445 const char code[] = "enum {\n" - "SHELL_SIZE = sizeof(union { int i; char *cp; double d; }) - 1, \n" + "SHELL_SIZE = sizeof(union { int i; char *cp; double d; }) - 1,\n" "} e = SHELL_SIZE;"; const char expected[] = "int e ; e = sizeof ( union { int i ; char * cp ; double d ; } ) - 1 ;"; ASSERT_EQUALS(expected, checkSimplifyEnum(code)); @@ -7186,7 +7185,7 @@ private: void enum28() { const char code[] = "enum { x=0 };\n" - "void f() { char x[4]; memset(x, 0, 4); \n" + "void f() { char x[4]; memset(x, 0, 4);\n" "{ x } };\n" "void g() { x; }"; ASSERT_EQUALS("void f ( ) { char x [ 4 ] ; memset ( x , 0 , 4 ) ; { x } } ; void g ( ) { 0 ; }", checkSimplifyEnum(code)); diff --git a/test/teststl.cpp b/test/teststl.cpp index 0c2f7510b..59bb159a3 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -1187,7 +1187,7 @@ private: errout.str(""); const std::string src = "void f()\n" "{\n" - " for ( \n" + " for (\n" "}\n"; Settings settings; @@ -1910,7 +1910,7 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); - check("void f() \n" + check("void f()\n" "{\n" " auto_ptr p2;\n" " p2 = new T;\n" @@ -1945,39 +1945,39 @@ private: ASSERT_EQUALS("", errout.str()); // ticket #748 - check("void f() \n" + check("void f()\n" "{\n" " T* var = new T[10];\n" " auto_ptr p2( var );\n" "}\n"); ASSERT_EQUALS("[test.cpp:4]: (error) Object pointed by an 'auto_ptr' is destroyed using operator 'delete'. You should not use 'auto_ptr' for pointers obtained with operator 'new[]'.\n", errout.str()); - check("void f() \n" + check("void f()\n" "{\n" " foo::bar::baz* var = new foo::bar::baz[10];\n" " auto_ptr p2( var );\n" "}\n"); ASSERT_EQUALS("[test.cpp:4]: (error) Object pointed by an 'auto_ptr' is destroyed using operator 'delete'. You should not use 'auto_ptr' for pointers obtained with operator 'new[]'.\n", errout.str()); - check("void f() \n" + check("void f()\n" "{\n" " auto_ptr p2( new T[] );\n" "}\n"); ASSERT_EQUALS("[test.cpp:3]: (error) Object pointed by an 'auto_ptr' is destroyed using operator 'delete'. You should not use 'auto_ptr' for pointers obtained with operator 'new[]'.\n", errout.str()); - check("void f() \n" + check("void f()\n" "{\n" " auto_ptr p2( new T[5] );\n" "}\n"); ASSERT_EQUALS("[test.cpp:3]: (error) Object pointed by an 'auto_ptr' is destroyed using operator 'delete'. You should not use 'auto_ptr' for pointers obtained with operator 'new[]'.\n", errout.str()); - check("void f() \n" + check("void f()\n" "{\n" " auto_ptr p(new foo::bar[10]);\n" "}\n"); ASSERT_EQUALS("[test.cpp:3]: (error) Object pointed by an 'auto_ptr' is destroyed using operator 'delete'. You should not use 'auto_ptr' for pointers obtained with operator 'new[]'.\n", errout.str()); - check("void f() \n" + check("void f()\n" "{\n" " auto_ptr p2;\n" " p2.reset( new T[] );\n" @@ -1985,34 +1985,34 @@ private: ASSERT_EQUALS("[test.cpp:4]: (error) Object pointed by an 'auto_ptr' is destroyed using operator 'delete'. You should not use 'auto_ptr' for pointers obtained with operator 'new[]'.\n", errout.str()); - check("void f() \n" + check("void f()\n" "{\n" " auto_ptr p2( new T[][] );\n" "}\n"); ASSERT_EQUALS("[test.cpp:3]: (error) Object pointed by an 'auto_ptr' is destroyed using operator 'delete'. You should not use 'auto_ptr' for pointers obtained with operator 'new[]'.\n", errout.str()); - check("void f() \n" + check("void f()\n" "{\n" " auto_ptr p2;\n" " p2 = new T[10];\n" "}\n"); ASSERT_EQUALS("[test.cpp:4]: (error) Object pointed by an 'auto_ptr' is destroyed using operator 'delete'. You should not use 'auto_ptr' for pointers obtained with operator 'new[]'.\n", errout.str()); - check("void f() \n" + check("void f()\n" "{\n" " auto_ptr p2;\n" " p2 = new T::B[10];\n" "}\n"); ASSERT_EQUALS("[test.cpp:4]: (error) Object pointed by an 'auto_ptr' is destroyed using operator 'delete'. You should not use 'auto_ptr' for pointers obtained with operator 'new[]'.\n", errout.str()); - check("void f() \n" + check("void f()\n" "{\n" " auto_ptr p2;\n" " p2.reset( new T[10] );\n" "}\n"); ASSERT_EQUALS("[test.cpp:4]: (error) Object pointed by an 'auto_ptr' is destroyed using operator 'delete'. You should not use 'auto_ptr' for pointers obtained with operator 'new[]'.\n", errout.str()); - check("void f() \n" + check("void f()\n" "{\n" " auto_ptr p2;\n" " p2.reset( new T::B[10] );\n" @@ -2034,7 +2034,6 @@ private: " string s1, s2;\n" " s1.swap(s2);\n" " s2.swap(s2);\n" - " \n" "};\n"); ASSERT_EQUALS("[test.cpp:5]: (performance) It is inefficient to swap a object with itself by calling 's2.swap(s2)'\n", errout.str()); @@ -2045,7 +2044,6 @@ private: " s2.compare(s2);\n" " s1.compare(s2.c_str());\n" " s1.compare(0, s1.size(), s1);\n" - " \n" "};\n"); ASSERT_EQUALS("[test.cpp:5]: (warning) It is inefficient to call 's2.compare(s2)' as it always returns 0.\n", errout.str()); @@ -2058,7 +2056,6 @@ private: " s1 = s2.substr(0, x);\n" " s1 = s2.substr(0,std::string::npos);\n" " s1 = s2.substr(x+5-n, 0);\n" - " \n" "};\n"); ASSERT_EQUALS("[test.cpp:5]: (performance) Ineffective call of function \'substr\' because it returns a copy of " "the object. Use operator= instead.\n" diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index f4443a0b2..b504a9109 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -1153,7 +1153,7 @@ private: "{\n" " if (a)\n" " bar1 ();\n" - " \n" + "\n" " else\n" " bar2 ();\n" "}\n"; diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 8bace803e..fb2ba7d81 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -1192,8 +1192,7 @@ private: "{\n" " int y[2];\n" " int s;\n" - " GetField( y + 0, \n" - " y + 1 );\n" + " GetField( y + 0, y + 1 );\n" " s = y[0]*y[1];\n" "}\n"); ASSERT_EQUALS("", errout.str());