Skip to content

Commit a031228

Browse files
committed
made some Settings objects in tests const
1 parent fe5a456 commit a031228

6 files changed

Lines changed: 17 additions & 16 deletions

File tree

test/testastutils.cpp

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

4949
#define findLambdaEndToken(code) findLambdaEndToken_(code, __FILE__, __LINE__)
5050
bool findLambdaEndToken_(const char code[], const char* file, int line) {
51-
Settings settings;
51+
const Settings settings;
5252
Tokenizer tokenizer(&settings, this);
5353
std::istringstream istr(code);
5454
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
@@ -82,7 +82,7 @@ class TestAstUtils : public TestFixture {
8282

8383
#define findLambdaStartToken(code) findLambdaStartToken_(code, __FILE__, __LINE__)
8484
bool findLambdaStartToken_(const char code[], const char* file, int line) {
85-
Settings settings;
85+
const Settings settings;
8686
Tokenizer tokenizer(&settings, this);
8787
std::istringstream istr(code);
8888
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
@@ -115,7 +115,7 @@ class TestAstUtils : public TestFixture {
115115

116116
#define isNullOperand(code) isNullOperand_(code, __FILE__, __LINE__)
117117
bool isNullOperand_(const char code[], const char* file, int line) {
118-
Settings settings;
118+
const Settings settings;
119119
Tokenizer tokenizer(&settings, this);
120120
std::istringstream istr(code);
121121
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
@@ -137,7 +137,7 @@ class TestAstUtils : public TestFixture {
137137

138138
#define isReturnScope(code, offset) isReturnScope_(code, offset, __FILE__, __LINE__)
139139
bool isReturnScope_(const char code[], int offset, const char* file, int line) {
140-
Settings settings;
140+
const Settings settings;
141141
Tokenizer tokenizer(&settings, this);
142142
std::istringstream istr(code);
143143
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
@@ -168,7 +168,7 @@ class TestAstUtils : public TestFixture {
168168

169169
#define isSameExpression(code, tokStr1, tokStr2) isSameExpression_(code, tokStr1, tokStr2, __FILE__, __LINE__)
170170
bool isSameExpression_(const char code[], const char tokStr1[], const char tokStr2[], const char* file, int line) {
171-
Settings settings;
171+
const Settings settings;
172172
Library library;
173173
Tokenizer tokenizer(&settings, this);
174174
std::istringstream istr(code);
@@ -208,7 +208,7 @@ class TestAstUtils : public TestFixture {
208208

209209
#define isVariableChanged(code, startPattern, endPattern) isVariableChanged_(code, startPattern, endPattern, __FILE__, __LINE__)
210210
bool isVariableChanged_(const char code[], const char startPattern[], const char endPattern[], const char* file, int line) {
211-
Settings settings;
211+
const Settings settings;
212212
Tokenizer tokenizer(&settings, this);
213213
std::istringstream istr(code);
214214
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
@@ -231,7 +231,7 @@ class TestAstUtils : public TestFixture {
231231

232232
#define isVariableChangedByFunctionCall(code, pattern, inconclusive) isVariableChangedByFunctionCall_(code, pattern, inconclusive, __FILE__, __LINE__)
233233
bool isVariableChangedByFunctionCall_(const char code[], const char pattern[], bool *inconclusive, const char* file, int line) {
234-
Settings settings;
234+
const Settings settings;
235235
Tokenizer tokenizer(&settings, this);
236236
std::istringstream istr(code);
237237
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
@@ -260,7 +260,7 @@ class TestAstUtils : public TestFixture {
260260

261261
#define nextAfterAstRightmostLeaf(code, parentPattern, rightPattern) nextAfterAstRightmostLeaf_(code, parentPattern, rightPattern, __FILE__, __LINE__)
262262
bool nextAfterAstRightmostLeaf_(const char code[], const char parentPattern[], const char rightPattern[], const char* file, int line) {
263-
Settings settings;
263+
const Settings settings;
264264
Tokenizer tokenizer(&settings, this);
265265
std::istringstream istr(code);
266266
ASSERT_LOC(tokenizer.tokenize(istr, "test.cpp"), file, line);
@@ -285,7 +285,7 @@ class TestAstUtils : public TestFixture {
285285
enum class Result {False, True, Fail};
286286

287287
Result isUsedAsBool(const char code[], const char pattern[]) {
288-
Settings settings;
288+
const Settings settings;
289289
Tokenizer tokenizer(&settings, this);
290290
std::istringstream istr(code);
291291
if (!tokenizer.tokenize(istr, "test.cpp"))

test/testlibrary.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class TestLibrary : public TestFixture {
4141
TestLibrary() : TestFixture("TestLibrary") {}
4242

4343
private:
44-
Settings settings;
44+
const Settings settings;
4545

4646
void run() override {
4747
TEST_CASE(isCompliantValidationExpression);

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-
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);

test/testtoken.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ class TestToken : public TestFixture {
396396

397397
void getStrSize() const {
398398
Token tok;
399-
Settings settings;
399+
const Settings settings;
400400

401401
tok.str("\"\"");
402402
ASSERT_EQUALS(sizeof(""), Token::getStrSize(&tok, &settings));

test/testtokenlist.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class TestTokenList : public TestFixture {
2929
TestTokenList() : TestFixture("TestTokenList") {}
3030

3131
private:
32-
Settings settings;
32+
const Settings settings;
3333

3434
void run() override {
3535
TEST_CASE(testaddtoken1);
@@ -48,8 +48,9 @@ class TestTokenList : public TestFixture {
4848

4949
void testaddtoken2() {
5050
const std::string code = "0xF0000000";
51-
settings.int_bit = 32;
52-
TokenList tokenlist(&settings);
51+
Settings settings1;
52+
settings1.int_bit = 32;
53+
TokenList tokenlist(&settings1);
5354
tokenlist.addtoken(code, 1, 1, false);
5455
ASSERT_EQUALS("0xF0000000", tokenlist.front()->str());
5556
}

test/testtokenrange.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class TestTokenRange : public TestFixture {
101101
}
102102

103103
void scopeExample() const {
104-
Settings settings;
104+
const Settings settings;
105105
Tokenizer tokenizer{ &settings, nullptr };
106106
std::istringstream sample("void a(){} void main(){ if(true){a();} }");
107107
ASSERT(tokenizer.tokenize(sample, "test.cpp"));

0 commit comments

Comments
 (0)