Skip to content

Commit 06bcb77

Browse files
committed
small test classes initialization cleanup
1 parent e989f2a commit 06bcb77

7 files changed

Lines changed: 20 additions & 32 deletions

test/testcmdlineparser.cpp

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

3737
class TestCmdlineParser : public TestFixture {
3838
public:
39-
TestCmdlineParser()
40-
: TestFixture("TestCmdlineParser")
41-
, defParser(settings) {
39+
TestCmdlineParser() : TestFixture("TestCmdlineParser")
40+
{
4241
#if defined(_WIN64) || defined(_WIN32)
4342
CmdLineParser::SHOW_DEF_PLATFORM_MSG = false;
4443
#endif
@@ -52,7 +51,7 @@ class TestCmdlineParser : public TestFixture {
5251

5352
private:
5453
Settings settings; // TODO: reset after each test
55-
CmdLineParser defParser; // TODO: reset after each test
54+
CmdLineParser defParser{settings}; // TODO: reset after each test
5655

5756
void run() override {
5857
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
@@ -44,9 +44,7 @@ class ErrorLogger;
4444

4545
class TestPreprocessor : public TestFixture {
4646
public:
47-
TestPreprocessor()
48-
: TestFixture("TestPreprocessor")
49-
, preprocessor0(settings0, settings0.nomsg, this) {}
47+
TestPreprocessor() : TestFixture("TestPreprocessor") {}
5048

5149
class OurPreprocessor : public Preprocessor {
5250
public:
@@ -72,7 +70,7 @@ class TestPreprocessor : public TestFixture {
7270

7371
private:
7472
Settings settings0 = settingsBuilder().severity(Severity::information).build();
75-
Preprocessor preprocessor0;
73+
Preprocessor preprocessor0{settings0, settings0.nomsg, this};
7674

7775
void run() override {
7876

test/testsymboldatabase.cpp

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

6565
class TestSymbolDatabase : public TestFixture {
6666
public:
67-
TestSymbolDatabase()
68-
: TestFixture("TestSymbolDatabase")
69-
,vartok(nullptr)
70-
,typetok(nullptr) {}
67+
TestSymbolDatabase() : TestFixture("TestSymbolDatabase") {}
7168

7269
private:
73-
const Token* vartok;
74-
const Token* typetok;
70+
const Token* vartok{nullptr};
71+
const Token* typetok{nullptr};
7572
// If there are unused templates, keep those
7673
Settings settings1 = settingsBuilder().library("std.cfg").checkUnusedTemplates().build();
7774
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.platform, cppcheck::Platform::Type::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.platform, cppcheck::Platform::Type::Unix64);
41+
4242
TEST_CASE(varid1);
4343
TEST_CASE(varid2);
4444
TEST_CASE(varid3);

0 commit comments

Comments
 (0)