Skip to content

Commit e7e7903

Browse files
committed
made some Settings objects in tests const
1 parent c7d8bdc commit e7e7903

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
@@ -49,7 +49,7 @@ class TestAstUtils : public TestFixture {
4949

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

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

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

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

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

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

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

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

442442
Result isUsedAsBool(const char code[], const char pattern[]) {
443-
Settings settings;
443+
const Settings settings;
444444
Tokenizer tokenizer(&settings, this);
445445
std::istringstream istr(code);
446446
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.platform.int_bit = 32;
52-
TokenList tokenlist(&settings);
51+
Settings settings1;
52+
settings1.platform.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)