Skip to content

Commit 3cdf060

Browse files
committed
small test classes initialization cleanup
1 parent ce7c8e1 commit 3cdf060

File tree

7 files changed

+20
-32
lines changed

7 files changed

+20
-32
lines changed

test/testcmdlineparser.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@
3535

3636
class TestCmdlineParser : public TestFixture {
3737
public:
38-
TestCmdlineParser()
39-
: TestFixture("TestCmdlineParser")
40-
, defParser(&settings) {
38+
TestCmdlineParser() : TestFixture("TestCmdlineParser")
39+
{
4140
#if defined(_WIN64) || defined(_WIN32)
4241
CmdLineParser::SHOW_DEF_PLATFORM_MSG = false;
4342
#endif
@@ -51,7 +50,7 @@ class TestCmdlineParser : public TestFixture {
5150

5251
private:
5352
Settings settings; // TODO: reset after each test
54-
CmdLineParser defParser; // TODO: reset after each test
53+
CmdLineParser defParser{&settings}; // TODO: reset after each test
5554

5655
void run() override {
5756
TEST_CASE(nooptions);

test/testerrorlogger.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232

3333
class TestErrorLogger : public TestFixture {
3434
public:
35-
TestErrorLogger() : TestFixture("TestErrorLogger"), fooCpp5("foo.cpp", 5, 1), barCpp8("bar.cpp", 8, 1) {}
35+
TestErrorLogger() : TestFixture("TestErrorLogger") {}
3636

3737
private:
38-
const ErrorMessage::FileLocation fooCpp5;
39-
const ErrorMessage::FileLocation barCpp8;
38+
const ErrorMessage::FileLocation fooCpp5{"foo.cpp", 5, 1};
39+
const ErrorMessage::FileLocation barCpp8{"bar.cpp", 8, 1};
4040

4141
void run() override {
4242
TEST_CASE(PatternSearchReplace);

test/testfilelister.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929

3030
class TestFileLister : public TestFixture {
3131
public:
32-
TestFileLister()
33-
: TestFixture("TestFileLister") {}
32+
TestFileLister() : TestFixture("TestFileLister") {}
3433

3534
private:
3635
void run() override {

test/testpathmatch.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,13 @@
2525

2626
class TestPathMatch : public TestFixture {
2727
public:
28-
TestPathMatch()
29-
: TestFixture("TestPathMatch")
30-
, emptyMatcher(std::vector<std::string>())
31-
, srcMatcher(std::vector<std::string>(1, "src/"))
32-
, fooCppMatcher(std::vector<std::string>(1, "foo.cpp"))
33-
, srcFooCppMatcher(std::vector<std::string>(1, "src/foo.cpp")) {}
28+
TestPathMatch() : TestFixture("TestPathMatch") {}
3429

3530
private:
36-
const PathMatch emptyMatcher;
37-
const PathMatch srcMatcher;
38-
const PathMatch fooCppMatcher;
39-
const PathMatch srcFooCppMatcher;
31+
const PathMatch emptyMatcher{std::vector<std::string>()};
32+
const PathMatch srcMatcher{std::vector<std::string>(1, "src/")};
33+
const PathMatch fooCppMatcher{std::vector<std::string>(1, "foo.cpp")};
34+
const PathMatch srcFooCppMatcher{std::vector<std::string>(1, "src/foo.cpp")};
4035

4136
void run() override {
4237
TEST_CASE(emptymaskemptyfile);

test/testpreprocessor.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ class ErrorLogger;
4545

4646
class TestPreprocessor : public TestFixture {
4747
public:
48-
TestPreprocessor()
49-
: TestFixture("TestPreprocessor")
50-
, preprocessor0(settings0, this) {}
48+
TestPreprocessor() : TestFixture("TestPreprocessor") {}
5149

5250
class OurPreprocessor : public Preprocessor {
5351
public:
@@ -73,7 +71,7 @@ class TestPreprocessor : public TestFixture {
7371

7472
private:
7573
Settings settings0 = settingsBuilder().severity(Severity::information).build();
76-
Preprocessor preprocessor0;
74+
Preprocessor preprocessor0{settings0, this};
7775

7876
void run() override {
7977

test/testsymboldatabase.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,11 @@ class TestSymbolDatabase;
6565

6666
class TestSymbolDatabase : public TestFixture {
6767
public:
68-
TestSymbolDatabase()
69-
: TestFixture("TestSymbolDatabase")
70-
,vartok(nullptr)
71-
,typetok(nullptr) {}
68+
TestSymbolDatabase() : TestFixture("TestSymbolDatabase") {}
7269

7370
private:
74-
const Token* vartok;
75-
const Token* typetok;
71+
const Token* vartok{nullptr};
72+
const Token* typetok{nullptr};
7673
// If there are unused templates, keep those
7774
Settings settings1 = settingsBuilder().library("std.cfg").checkUnusedTemplates().build();
7875
Settings settings2 = settingsBuilder().checkUnusedTemplates().build();

test/testvarid.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ struct InternalError;
3232

3333
class TestVarID : public TestFixture {
3434
public:
35-
TestVarID() : TestFixture("TestVarID") {
36-
PLATFORM(settings, cppcheck::Platform::Unix64);
37-
}
35+
TestVarID() : TestFixture("TestVarID") {}
3836

3937
private:
4038
Settings settings = settingsBuilder().c(Standards::C89).cpp(Standards::CPPLatest).checkUnusedTemplates().build();
4139
void run() override {
40+
PLATFORM(settings, cppcheck::Platform::Unix64);
41+
4242
TEST_CASE(varid1);
4343
TEST_CASE(varid2);
4444
TEST_CASE(varid3);

0 commit comments

Comments
 (0)