Skip to content

Commit 6a7230e

Browse files
committed
made some Settings objects in tests const
1 parent 05ce761 commit 6a7230e

File tree

6 files changed

+17
-16
lines changed

6 files changed

+17
-16
lines changed

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-
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-
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-
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-
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-
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-
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-
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-
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-
Settings settings;
444+
const Settings settings;
445445
Tokenizer tokenizer(&settings, this);
446446
std::istringstream istr(code);
447447
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
@@ -395,7 +395,7 @@ class TestToken : public TestFixture {
395395

396396
void getStrSize() const {
397397
Token tok;
398-
Settings settings;
398+
const Settings settings;
399399

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

test/testtokenlist.cpp

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

3232
private:
33-
Settings settings;
33+
const Settings settings;
3434

3535
void run() override {
3636
TEST_CASE(testaddtoken1);
@@ -49,8 +49,9 @@ class TestTokenList : public TestFixture {
4949

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

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)