Skip to content

Commit 1b9c1c0

Browse files
committed
unittests: removed not needed '\n' at the end of testcases.
1 parent a08083a commit 1b9c1c0

21 files changed

Lines changed: 1429 additions & 1430 deletions

test/testclass.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ class TestClass : public TestFixture {
577577
"public:\n"
578578
" A & operator=(const A &);\n"
579579
"};\n"
580-
"A & A::operator=(const A &a) { return *this; }\n");
580+
"A & A::operator=(const A &a) { return *this; }");
581581
ASSERT_EQUALS("", errout.str());
582582

583583
checkOpertorEqRetRefThis(
@@ -586,7 +586,7 @@ class TestClass : public TestFixture {
586586
"public:\n"
587587
" A & operator=(const A &a);\n"
588588
"};\n"
589-
"A & A::operator=(const A &a) { return *this; }\n");
589+
"A & A::operator=(const A &a) { return *this; }");
590590
ASSERT_EQUALS("", errout.str());
591591

592592
checkOpertorEqRetRefThis(
@@ -595,7 +595,7 @@ class TestClass : public TestFixture {
595595
"public:\n"
596596
" A & operator=(const A &);\n"
597597
"};\n"
598-
"A & A::operator=(const A &a) { return a; }\n");
598+
"A & A::operator=(const A &a) { return a; }");
599599
ASSERT_EQUALS("[test.cpp:6]: (style) 'operator=' should return reference to 'this' instance.\n", errout.str());
600600

601601
checkOpertorEqRetRefThis(
@@ -604,7 +604,7 @@ class TestClass : public TestFixture {
604604
"public:\n"
605605
" A & operator=(const A &a);\n"
606606
"};\n"
607-
"A & A::operator=(const A &a) { return a; }\n");
607+
"A & A::operator=(const A &a) { return a; }");
608608
ASSERT_EQUALS("[test.cpp:6]: (style) 'operator=' should return reference to 'this' instance.\n", errout.str());
609609

610610
checkOpertorEqRetRefThis(
@@ -641,7 +641,7 @@ class TestClass : public TestFixture {
641641
" B & operator=(const B &);\n"
642642
" };\n"
643643
"};\n"
644-
"A::B & A::B::operator=(const A::B &b) { return *this; }\n");
644+
"A::B & A::B::operator=(const A::B &b) { return *this; }");
645645
ASSERT_EQUALS("", errout.str());
646646

647647
checkOpertorEqRetRefThis(
@@ -654,7 +654,7 @@ class TestClass : public TestFixture {
654654
" B & operator=(const B &);\n"
655655
" };\n"
656656
"};\n"
657-
"A::B & A::B::operator=(const A::B &b) { return b; }\n");
657+
"A::B & A::B::operator=(const A::B &b) { return b; }");
658658
ASSERT_EQUALS("[test.cpp:10]: (style) 'operator=' should return reference to 'this' instance.\n", errout.str());
659659
}
660660

@@ -847,7 +847,7 @@ class TestClass : public TestFixture {
847847
"public:\n"
848848
" A & operator=(const A &);\n"
849849
"};\n"
850-
"A & A::operator=(const A &a) { if (&a != this) { } return *this; }\n");
850+
"A & A::operator=(const A &a) { if (&a != this) { } return *this; }");
851851
ASSERT_EQUALS("", errout.str());
852852

853853
// this test doesn't have an assignment test but doesn't need it
@@ -857,7 +857,7 @@ class TestClass : public TestFixture {
857857
"public:\n"
858858
" A & operator=(const A &);\n"
859859
"};\n"
860-
"A & A::operator=(const A &a) { return *this; }\n");
860+
"A & A::operator=(const A &a) { return *this; }");
861861
ASSERT_EQUALS("", errout.str());
862862

863863
// this test needs an assignment test and has it
@@ -992,7 +992,7 @@ class TestClass : public TestFixture {
992992
" B & operator=(const B &);\n"
993993
" };\n"
994994
"};\n"
995-
"A::B & A::B::operator=(const A::B &b) { if (&b != this) { } return *this; }\n");
995+
"A::B & A::B::operator=(const A::B &b) { if (&b != this) { } return *this; }");
996996
ASSERT_EQUALS("", errout.str());
997997

998998
// this test doesn't have an assignment test but doesn't need it
@@ -1006,7 +1006,7 @@ class TestClass : public TestFixture {
10061006
" B & operator=(const B &);\n"
10071007
" };\n"
10081008
"};\n"
1009-
"A::B & A::B::operator=(const A::B &b) { return *this; }\n");
1009+
"A::B & A::B::operator=(const A::B &b) { return *this; }");
10101010
ASSERT_EQUALS("", errout.str());
10111011

10121012
// this test needs an assignment test and has it
@@ -1029,7 +1029,7 @@ class TestClass : public TestFixture {
10291029
" s = strdup(b.s);\n"
10301030
" }\n"
10311031
" return *this;\n"
1032-
" }\n");
1032+
" }");
10331033
ASSERT_EQUALS("", errout.str());
10341034

10351035
// this test needs an assignment test but doesn't have it
@@ -1049,7 +1049,7 @@ class TestClass : public TestFixture {
10491049
" free(s);\n"
10501050
" s = strdup(b.s);\n"
10511051
" return *this;\n"
1052-
" }\n");
1052+
" }");
10531053
ASSERT_EQUALS("[test.cpp:11]: (warning) 'operator=' should check for assignment to self to avoid problems with dynamic memory.\n", errout.str());
10541054
}
10551055

@@ -1085,7 +1085,7 @@ class TestClass : public TestFixture {
10851085
"public:\n"
10861086
" A & operator=(const A &);\n"
10871087
"};\n"
1088-
"A & A::operator=(const A &a) { return *this; }\n");
1088+
"A & A::operator=(const A &a) { return *this; }");
10891089
ASSERT_EQUALS("", errout.str());
10901090

10911091
// this test has multiple inheritance and needs an assignment test but there is no trivial way to test for it
@@ -1149,7 +1149,7 @@ class TestClass : public TestFixture {
11491149
" B & operator=(const B &);\n"
11501150
" };\n"
11511151
"};\n"
1152-
"A::B & A::B::operator=(const A::B &b) { return *this; }\n");
1152+
"A::B & A::B::operator=(const A::B &b) { return *this; }");
11531153
ASSERT_EQUALS("", errout.str());
11541154

11551155
// this test has multiple inheritance and needs an assignment test but there is no trivial way to test for it
@@ -1882,7 +1882,7 @@ class TestClass : public TestFixture {
18821882
"};\n"
18831883
"\n"
18841884
"void Fred::foobar()\n"
1885-
"{ }\n");
1885+
"{ }");
18861886
ASSERT_EQUALS("", errout.str());
18871887
}
18881888

@@ -2870,7 +2870,7 @@ class TestClass : public TestFixture {
28702870
" };\n"
28712871
"};\n"
28722872
"int Fred::B::A::getA() { return a; }\n"
2873-
"int Fred::B::getB() { return b; }\n");
2873+
"int Fred::B::getB() { return b; }");
28742874
ASSERT_EQUALS("[test.cpp:12] -> [test.cpp:4]: (style, inconclusive) Technically the member function 'Fred::B::getB' can be const.\n"
28752875
"[test.cpp:11] -> [test.cpp:7]: (style, inconclusive) Technically the member function 'Fred::B::A::getA' can be const.\n" , errout.str());
28762876
}
@@ -4023,7 +4023,7 @@ class TestClass : public TestFixture {
40234023
" int var;\n"
40244024
" };\n"
40254025
"}\n"
4026-
"int N::Base::getResourceName() { return var; }\n");
4026+
"int N::Base::getResourceName() { return var; }");
40274027
ASSERT_EQUALS("[test.cpp:10] -> [test.cpp:6]: (style, inconclusive) Technically the member function 'N::Base::getResourceName' can be const.\n", errout.str());
40284028

40294029
checkConst("namespace N\n"
@@ -4051,7 +4051,7 @@ class TestClass : public TestFixture {
40514051
" };\n"
40524052
"}\n"
40534053
"using namespace N;\n"
4054-
"int Base::getResourceName() { return var; }\n");
4054+
"int Base::getResourceName() { return var; }");
40554055
TODO_ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:6]: (style, inconclusive) Technically the member function 'N::Base::getResourceName' can be const.\n",
40564056
"", errout.str());
40574057
}
@@ -5191,7 +5191,7 @@ class TestClass : public TestFixture {
51915191
" B() : b(0) { }\n"
51925192
" int func();\n"
51935193
"};\n"
5194-
"int B::func() { return b; }\n");
5194+
"int B::func() { return b; }");
51955195
ASSERT_EQUALS("[test.cpp:8] -> [test.cpp:6]: (style, inconclusive) Technically the member function 'B::func' can be const.\n", errout.str());
51965196

51975197
// base class has no virtual function
@@ -5217,7 +5217,7 @@ class TestClass : public TestFixture {
52175217
" B() : b(0) { }\n"
52185218
" int func();\n"
52195219
"};\n"
5220-
"int B::func() { return b; }\n");
5220+
"int B::func() { return b; }");
52215221
ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:9]: (style, inconclusive) Technically the member function 'B::func' can be const.\n", errout.str());
52225222

52235223
// base class has virtual function
@@ -5243,7 +5243,7 @@ class TestClass : public TestFixture {
52435243
" B() : b(0) { }\n"
52445244
" int func();\n"
52455245
"};\n"
5246-
"int B::func() { return b; }\n");
5246+
"int B::func() { return b; }");
52475247
ASSERT_EQUALS("", errout.str());
52485248

52495249
checkConst("class A {\n"
@@ -5256,7 +5256,7 @@ class TestClass : public TestFixture {
52565256
" B() : b(0) { }\n"
52575257
" int func();\n"
52585258
"};\n"
5259-
"int B::func() { return b; }\n");
5259+
"int B::func() { return b; }");
52605260
ASSERT_EQUALS("", errout.str());
52615261

52625262
// base class has no virtual function
@@ -5302,7 +5302,7 @@ class TestClass : public TestFixture {
53025302
" C() : c(0) { }\n"
53035303
" int func();\n"
53045304
"};\n"
5305-
"int C::func() { return c; }\n");
5305+
"int C::func() { return c; }");
53065306
ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:5]: (style, inconclusive) Technically the member function 'A::func' can be const.\n"
53075307
"[test.cpp:14] -> [test.cpp:12]: (style, inconclusive) Technically the member function 'B::func' can be const.\n"
53085308
"[test.cpp:21] -> [test.cpp:19]: (style, inconclusive) Technically the member function 'C::func' can be const.\n", errout.str());
@@ -5348,7 +5348,7 @@ class TestClass : public TestFixture {
53485348
" C() : c(0) { }\n"
53495349
" int func();\n"
53505350
"};\n"
5351-
"int C::func() { return c; }\n");
5351+
"int C::func() { return c; }");
53525352
ASSERT_EQUALS("", errout.str());
53535353

53545354
// ticket #1311
@@ -5394,7 +5394,7 @@ class TestClass : public TestFixture {
53945394
" Z(int x, int y, int z) : Y(x, y), z(z) { }\n"
53955395
" int getZ();\n"
53965396
"};\n"
5397-
"int Z::getZ() { return z; }\n");
5397+
"int Z::getZ() { return z; }");
53985398
ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:5]: (style, inconclusive) Technically the member function 'X::getX' can be const.\n"
53995399
"[test.cpp:14] -> [test.cpp:12]: (style, inconclusive) Technically the member function 'Y::getY' can be const.\n"
54005400
"[test.cpp:21] -> [test.cpp:19]: (style, inconclusive) Technically the member function 'Z::getZ' can be const.\n", errout.str());

test/testconstructors.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class TestConstructors : public TestFixture {
226226
" int i;\n"
227227
"};\n"
228228
"Fred::Fred() :i(0)\n"
229-
"{ }\n");
229+
"{ }");
230230
ASSERT_EQUALS("", errout.str());
231231

232232
check("struct Fred\n"
@@ -235,7 +235,7 @@ class TestConstructors : public TestFixture {
235235
" int i;\n"
236236
"};\n"
237237
"Fred::Fred()\n"
238-
"{ i = 0; }\n");
238+
"{ i = 0; }");
239239
ASSERT_EQUALS("", errout.str());
240240

241241
check("struct Fred\n"
@@ -244,7 +244,7 @@ class TestConstructors : public TestFixture {
244244
" int i;\n"
245245
"};\n"
246246
"Fred::Fred()\n"
247-
"{ }\n");
247+
"{ }");
248248
ASSERT_EQUALS("[test.cpp:6]: (warning) Member variable 'Fred::i' is not initialized in the constructor.\n", errout.str());
249249
}
250250

@@ -321,7 +321,7 @@ class TestConstructors : public TestFixture {
321321
void simple8() {
322322
check("struct Fred { int x; };\n"
323323
"class Barney { Fred fred; };\n"
324-
"class Wilma { struct Betty { int x; } betty; };\n");
324+
"class Wilma { struct Betty { int x; } betty; };");
325325
ASSERT_EQUALS("[test.cpp:2]: (style) The class 'Barney' does not have a constructor.\n"
326326
"[test.cpp:3]: (style) The class 'Wilma' does not have a constructor.\n", errout.str());
327327
}
@@ -363,7 +363,7 @@ class TestConstructors : public TestFixture {
363363
" Fred() { Init(); }\n"
364364
" void Init(int i = 0);\n"
365365
"};\n"
366-
"void Fred::Init(int i) { x = i; }\n");
366+
"void Fred::Init(int i) { x = i; }");
367367
ASSERT_EQUALS("", errout.str());
368368

369369
check("class Fred {\n"
@@ -373,7 +373,7 @@ class TestConstructors : public TestFixture {
373373
" Fred() { Init(0); }\n"
374374
" void Init(int i, int j = 0);\n"
375375
"};\n"
376-
"void Fred::Init(int i, int j) { x = i; y = j; }\n");
376+
"void Fred::Init(int i, int j) { x = i; y = j; }");
377377
ASSERT_EQUALS("", errout.str());
378378
}
379379

@@ -881,7 +881,7 @@ class TestConstructors : public TestFixture {
881881
" Fred(const Fred &);\n"
882882
"};\n"
883883
"Fred::Fred() { };\n"
884-
"Fred::Fred(const Fred &) { };\n");
884+
"Fred::Fred(const Fred &) { };");
885885
ASSERT_EQUALS("", errout.str());
886886

887887
check("class Fred\n"
@@ -930,7 +930,7 @@ class TestConstructors : public TestFixture {
930930
"A::A(){}\n"
931931
"A::B::B(int x){}\n"
932932
"A::B::C::C(int y){}\n"
933-
"A::B::C::D::D(int z){}\n");
933+
"A::B::C::D::D(int z){}");
934934
// Note that the example code is not compilable. The A constructor must
935935
// explicitly initialize A::b. A warning for A::b is not necessary.
936936
ASSERT_EQUALS("[test.cpp:20]: (warning) Member variable 'A::a' is not initialized in the constructor.\n"
@@ -960,7 +960,7 @@ class TestConstructors : public TestFixture {
960960
"A::A(){}\n"
961961
"A::B::B(int x){}\n"
962962
"A::B::C::C(int y){}\n"
963-
"A::B::C::D::D(const A::B::C::D & d){}\n");
963+
"A::B::C::D::D(const A::B::C::D & d){}");
964964
// Note that the example code is not compilable. The A constructor must
965965
// explicitly initialize A::b. A warning for A::b is not necessary.
966966
ASSERT_EQUALS("[test.cpp:20]: (warning) Member variable 'A::a' is not initialized in the constructor.\n"
@@ -991,7 +991,7 @@ class TestConstructors : public TestFixture {
991991
"A::A(){}\n"
992992
"A::B::B(int x){}\n"
993993
"A::B::C::C(int y){}\n"
994-
"A::B::C::D::D(const A::B::C::D::E & e){}\n");
994+
"A::B::C::D::D(const A::B::C::D::E & e){}");
995995
// Note that the example code is not compilable. The A constructor must
996996
// explicitly initialize A::b. A warning for A::b is not necessary.
997997
ASSERT_EQUALS("[test.cpp:21]: (warning) Member variable 'A::a' is not initialized in the constructor.\n"
@@ -1998,7 +1998,7 @@ class TestConstructors : public TestFixture {
19981998
" Fred() : f{0, true} { }\n"
19991999
" float get() const\n"
20002000
"};\n"
2001-
"float Fred::get() const { return g; }\n");
2001+
"float Fred::get() const { return g; }");
20022002
ASSERT_EQUALS("[test.cpp:9]: (warning) Member variable 'Fred::g' is not initialized in the constructor.\n", errout.str());
20032003
}
20042004

test/testdivision.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,15 @@ class TestDivision : public TestFixture {
131131
check("void foo()\n"
132132
"{\n"
133133
" unsigned int val = 32;\n"
134-
" int i = val / -2; }\n"
135-
);
134+
" int i = val / -2; }");
136135
ASSERT_EQUALS("[test.cpp:4]: (error) Unsigned division. The result will be wrong.\n", errout.str());
137136
}
138137

139138
void division7() {
140139
check("void foo()\n"
141140
"{\n"
142141
" unsigned int val = 32;\n"
143-
" int i = -96 / val; }\n");
142+
" int i = -96 / val; }");
144143
ASSERT_EQUALS("[test.cpp:4]: (error) Unsigned division. The result will be wrong.\n", errout.str());
145144
}
146145

test/testexceptionsafety.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class TestExceptionSafety : public TestFixture {
160160
" {\n"
161161
" throw err;\n"
162162
" }\n"
163-
"}\n");
163+
"}");
164164
ASSERT_EQUALS("[test.cpp:8]: (style) Throwing a copy of the caught exception instead of rethrowing the original exception.\n", errout.str());
165165
}
166166

@@ -174,7 +174,7 @@ class TestExceptionSafety : public TestFixture {
174174
" {\n"
175175
" throw err;\n"
176176
" }\n"
177-
"}\n");
177+
"}");
178178
ASSERT_EQUALS("[test.cpp:8]: (style) Throwing a copy of the caught exception instead of rethrowing the original exception.\n", errout.str());
179179
}
180180

@@ -201,7 +201,7 @@ class TestExceptionSafety : public TestFixture {
201201
" exception err2;\n"
202202
" throw err2;\n"
203203
" }\n"
204-
"}\n");
204+
"}");
205205
ASSERT_EQUALS("", errout.str());
206206
}
207207

0 commit comments

Comments
 (0)