Skip to content

Commit bcaa6c7

Browse files
committed
do not use static const settings in tests
1 parent 2fa670b commit bcaa6c7

13 files changed

+23
-25
lines changed

test/helpers.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,3 @@ ScopedFile::~ScopedFile() {
6262
#endif
6363
}
6464
}
65-
66-
const Settings givenACodeSampleToTokenize::settings;

test/helpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Token;
3737
class givenACodeSampleToTokenize {
3838
private:
3939
Tokenizer tokenizer;
40-
static const Settings settings;
40+
const Settings settings;
4141

4242
public:
4343
explicit givenACodeSampleToTokenize(const char sample[], bool createOnly = false, bool cpp = true)

test/testastutils.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class TestAstUtils : public TestFixture {
5050

5151
#define findLambdaEndToken(code) findLambdaEndToken_(code, __FILE__, __LINE__)
5252
bool findLambdaEndToken_(const char code[], const char* file, int line) {
53-
static const Settings settings;
53+
const Settings settings;
5454
Tokenizer tokenizer(&settings, this);
5555
std::istringstream istr(code);
5656
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
@@ -84,7 +84,7 @@ class TestAstUtils : public TestFixture {
8484

8585
#define findLambdaStartToken(code) findLambdaStartToken_(code, __FILE__, __LINE__)
8686
bool findLambdaStartToken_(const char code[], const char* file, int line) {
87-
static const Settings settings;
87+
const Settings settings;
8888
Tokenizer tokenizer(&settings, this);
8989
std::istringstream istr(code);
9090
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
@@ -117,7 +117,7 @@ class TestAstUtils : public TestFixture {
117117

118118
#define isNullOperand(code) isNullOperand_(code, __FILE__, __LINE__)
119119
bool isNullOperand_(const char code[], const char* file, int line) {
120-
static const Settings settings;
120+
const Settings settings;
121121
Tokenizer tokenizer(&settings, this);
122122
std::istringstream istr(code);
123123
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
@@ -139,7 +139,7 @@ class TestAstUtils : public TestFixture {
139139

140140
#define isReturnScope(code, offset) isReturnScope_(code, offset, __FILE__, __LINE__)
141141
bool isReturnScope_(const char code[], int offset, const char* file, int line) {
142-
static const Settings settings;
142+
const Settings settings;
143143
Tokenizer tokenizer(&settings, this);
144144
std::istringstream istr(code);
145145
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
@@ -170,7 +170,7 @@ class TestAstUtils : public TestFixture {
170170

171171
#define isSameExpression(code, tokStr1, tokStr2) isSameExpression_(code, tokStr1, tokStr2, __FILE__, __LINE__)
172172
bool isSameExpression_(const char code[], const char tokStr1[], const char tokStr2[], const char* file, int line) {
173-
static const Settings settings;
173+
const Settings settings;
174174
Library library;
175175
Tokenizer tokenizer(&settings, this);
176176
std::istringstream istr(code);
@@ -210,7 +210,7 @@ class TestAstUtils : public TestFixture {
210210

211211
#define isVariableChanged(code, startPattern, endPattern) isVariableChanged_(code, startPattern, endPattern, __FILE__, __LINE__)
212212
bool isVariableChanged_(const char code[], const char startPattern[], const char endPattern[], const char* file, int line) {
213-
static const Settings settings;
213+
const Settings settings;
214214
Tokenizer tokenizer(&settings, this);
215215
std::istringstream istr(code);
216216
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
@@ -240,7 +240,7 @@ class TestAstUtils : public TestFixture {
240240

241241
#define isVariableChangedByFunctionCall(code, pattern, inconclusive) isVariableChangedByFunctionCall_(code, pattern, inconclusive, __FILE__, __LINE__)
242242
bool isVariableChangedByFunctionCall_(const char code[], const char pattern[], bool *inconclusive, const char* file, int line) {
243-
static const Settings settings;
243+
const Settings settings;
244244
Tokenizer tokenizer(&settings, this);
245245
std::istringstream istr(code);
246246
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
@@ -416,7 +416,7 @@ class TestAstUtils : public TestFixture {
416416

417417
#define nextAfterAstRightmostLeaf(code, parentPattern, rightPattern) nextAfterAstRightmostLeaf_(code, parentPattern, rightPattern, __FILE__, __LINE__)
418418
bool nextAfterAstRightmostLeaf_(const char code[], const char parentPattern[], const char rightPattern[], const char* file, int line) {
419-
static const Settings settings;
419+
const Settings settings;
420420
Tokenizer tokenizer(&settings, this);
421421
std::istringstream istr(code);
422422
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
@@ -441,7 +441,7 @@ class TestAstUtils : public TestFixture {
441441
enum class Result {False, True, Fail};
442442

443443
Result isUsedAsBool(const char code[], const char pattern[]) {
444-
static const Settings settings;
444+
const Settings settings;
445445
Tokenizer tokenizer(&settings, this);
446446
std::istringstream istr(code);
447447
if (!tokenizer.tokenize(istr, "test.cpp"))

test/testbufferoverrun.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5499,7 +5499,7 @@ class TestBufferOverrun : public TestFixture {
54995499

55005500
void checkPipeParameterSize() { // #3521
55015501

5502-
static const Settings settings = settingsBuilder().library("posix.cfg").build();
5502+
const Settings settings = settingsBuilder().library("posix.cfg").build();
55035503

55045504
check("void f(){\n"
55055505
"int pipefd[1];\n" // <-- array of two integers is needed

test/testclangimport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class TestClangImport : public TestFixture {
137137
}
138138

139139
std::string parse(const char clang[]) {
140-
static const Settings settings = settingsBuilder().clang().build();
140+
const Settings settings = settingsBuilder().clang().build();
141141
Tokenizer tokenizer(&settings, this);
142142
std::istringstream istr(clang);
143143
clangimport::parseClangAstDump(&tokenizer, istr);

test/testclass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8317,7 +8317,7 @@ class TestClass : public TestFixture {
83178317

83188318

83198319
void ctu(const std::vector<std::string> &code) {
8320-
static const Settings settings;
8320+
const Settings settings;
83218321
auto &check = getCheck<CheckClass>();
83228322

83238323
// getFileInfo

test/testconstructors.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,7 +1948,7 @@ class TestConstructors : public TestFixture {
19481948

19491949
void initvar_smartptr() { // #10237
19501950
// TODO: test should probably not pass without library
1951-
static const Settings s = settingsBuilder() /*.library("std.cfg")*/.build();
1951+
const Settings s = settingsBuilder() /*.library("std.cfg")*/.build();
19521952
check("struct S {\n"
19531953
" explicit S(const std::shared_ptr<S>& sp) {\n"
19541954
" set(*sp);\n"
@@ -1990,7 +1990,7 @@ class TestConstructors : public TestFixture {
19901990
"{ }", true);
19911991
ASSERT_EQUALS("[test.cpp:13]: (warning, inconclusive) Member variable 'Fred::ints' is not assigned a value in 'Fred::operator='.\n", errout.str());
19921992

1993-
static const Settings s = settingsBuilder().certainty(Certainty::inconclusive).severity(Severity::style).severity(Severity::warning).library("std.cfg").build();
1993+
const Settings s = settingsBuilder().certainty(Certainty::inconclusive).severity(Severity::style).severity(Severity::warning).library("std.cfg").build();
19941994
check("struct S {\n"
19951995
" S& operator=(const S& s) { return *this; }\n"
19961996
" std::mutex m;\n"
@@ -3603,7 +3603,7 @@ class TestConstructors : public TestFixture {
36033603

36043604
void uninitVarInheritClassInit() {
36053605
// TODO: test should probably not pass without library
3606-
static const Settings s = settingsBuilder() /*.library("vcl.cfg")*/.build();
3606+
const Settings s = settingsBuilder() /*.library("vcl.cfg")*/.build();
36073607

36083608
check("class Fred: public TObject\n"
36093609
"{\n"

test/testnullpointer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class TestNullPointer : public TestFixture {
194194
// Clear the error buffer..
195195
errout.str("");
196196

197-
static const Settings settings1 = settingsBuilder(settings).certainty(Certainty::inconclusive, false).build();
197+
const Settings settings1 = settingsBuilder(settings).certainty(Certainty::inconclusive, false).build();
198198

199199
// Raw tokens..
200200
std::vector<std::string> files(1, "test.cpp");

test/testsimplifytypedef.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ class TestSimplifyTypedef : public TestFixture {
279279
errout.str("");
280280
// Tokenize..
281281
// show warnings about unhandled typedef
282-
static const Settings settings = settingsBuilder(settings2).certainty(Certainty::inconclusive).debugwarnings().build();
282+
const Settings settings = settingsBuilder(settings2).certainty(Certainty::inconclusive).debugwarnings().build();
283283
Tokenizer tokenizer(&settings, this);
284284
std::istringstream istr(code);
285285
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);

test/testsummaries.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class TestSummaries : public TestFixture {
4444
errout.str("");
4545

4646
// tokenize..
47-
static const Settings settings;
47+
const Settings settings;
4848
Tokenizer tokenizer(&settings, this);
4949
std::istringstream istr(code);
5050
ASSERT_LOC(tokenizer.tokenize(istr, filename), file, line);

0 commit comments

Comments
 (0)