Skip to content

Commit 034da09

Browse files
committed
small test classes initialization cleanup
1 parent 38b57e6 commit 034da09

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
@@ -37,9 +37,8 @@
3737

3838
class TestCmdlineParser : public TestFixture {
3939
public:
40-
TestCmdlineParser()
41-
: TestFixture("TestCmdlineParser")
42-
, defParser(settings) {
40+
TestCmdlineParser() : TestFixture("TestCmdlineParser")
41+
{
4342
#if defined(_WIN64) || defined(_WIN32)
4443
CmdLineParser::SHOW_DEF_PLATFORM_MSG = false;
4544
#endif
@@ -53,7 +52,7 @@ class TestCmdlineParser : public TestFixture {
5352

5453
private:
5554
Settings settings; // TODO: reset after each test
56-
CmdLineParser defParser; // TODO: reset after each test
55+
CmdLineParser defParser{settings}; // TODO: reset after each test
5756

5857
void run() override {
5958
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
@@ -43,9 +43,7 @@ class ErrorLogger;
4343

4444
class TestPreprocessor : public TestFixture {
4545
public:
46-
TestPreprocessor()
47-
: TestFixture("TestPreprocessor")
48-
, preprocessor0(settings0, this) {}
46+
TestPreprocessor() : TestFixture("TestPreprocessor") {}
4947

5048
class OurPreprocessor : public Preprocessor {
5149
public:
@@ -71,7 +69,7 @@ class TestPreprocessor : public TestFixture {
7169

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

7674
void run() override {
7775

test/testsymboldatabase.cpp

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

6464
class TestSymbolDatabase : public TestFixture {
6565
public:
66-
TestSymbolDatabase()
67-
: TestFixture("TestSymbolDatabase")
68-
,vartok(nullptr)
69-
,typetok(nullptr) {}
66+
TestSymbolDatabase() : TestFixture("TestSymbolDatabase") {}
7067

7168
private:
72-
const Token* vartok;
73-
const Token* typetok;
69+
const Token* vartok{nullptr};
70+
const Token* typetok{nullptr};
7471
// If there are unused templates, keep those
7572
Settings settings1 = settingsBuilder().library("std.cfg").checkUnusedTemplates().build();
7673
Settings settings2 = settingsBuilder().checkUnusedTemplates().build();

test/testvarid.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131

3232
class TestVarID : public TestFixture {
3333
public:
34-
TestVarID() : TestFixture("TestVarID") {
35-
PLATFORM(settings.platform, cppcheck::Platform::Type::Unix64);
36-
}
34+
TestVarID() : TestFixture("TestVarID") {}
3735

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

0 commit comments

Comments
 (0)