Skip to content

Commit e917529

Browse files
committed
testrunner: pass Standards::Language to SimpleTokenList
1 parent 0682c8f commit e917529

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

test/helpers.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define helpersH
2121

2222
#include "settings.h"
23+
#include "standards.h"
2324
#include "tokenize.h"
2425
#include "tokenlist.h"
2526

@@ -64,10 +65,10 @@ class SimpleTokenList
6465
{
6566
public:
6667

67-
explicit SimpleTokenList(const char code[], bool cpp = true)
68+
explicit SimpleTokenList(const char code[], Standards::Language lang = Standards::Language::CPP)
6869
{
6970
std::istringstream iss(code);
70-
if (!list.createTokens(iss, cpp ? "test.cpp" : "test.c"))
71+
if (!list.createTokens(iss, lang))
7172
throw std::runtime_error("creating tokens failed");
7273
}
7374

test/testtoken.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,22 +562,22 @@ class TestToken : public TestFixture {
562562
}
563563

564564
void eraseTokens() const {
565-
SimpleTokenList code("begin ; { this code will be removed } end", true);
565+
SimpleTokenList code("begin ; { this code will be removed } end", Standards::Language::C);
566566
Token::eraseTokens(code.front()->next(), code.front()->tokAt(9));
567567
ASSERT_EQUALS("begin ; end", code.front()->stringifyList(nullptr, false));
568568
}
569569

570570

571571
void matchAny() const {
572-
const SimpleTokenList varBitOrVar("abc|def", true);
572+
const SimpleTokenList varBitOrVar("abc|def");
573573
ASSERT_EQUALS(true, Token::Match(varBitOrVar.front(), "%name% %or% %name%"));
574574

575-
const SimpleTokenList varLogOrVar("abc||def", true);
575+
const SimpleTokenList varLogOrVar("abc||def");
576576
ASSERT_EQUALS(true, Token::Match(varLogOrVar.front(), "%name% %oror% %name%"));
577577
}
578578

579579
void matchSingleChar() const {
580-
const SimpleTokenList singleChar("a", true);
580+
const SimpleTokenList singleChar("a");
581581
ASSERT_EQUALS(true, Token::Match(singleChar.front(), "[a|bc]"));
582582
ASSERT_EQUALS(false, Token::Match(singleChar.front(), "[d|ef]"));
583583

@@ -595,7 +595,7 @@ class TestToken : public TestFixture {
595595
const SimpleTokenList ifSemicolon("if ;");
596596
ASSERT_EQUALS(true, Token::Match(ifSemicolon.front(), "if ; !!else"));
597597

598-
const SimpleTokenList ifSemicolonSomething("if ; something", true);
598+
const SimpleTokenList ifSemicolonSomething("if ; something");
599599
ASSERT_EQUALS(true, Token::Match(ifSemicolonSomething.front(), "if ; !!else"));
600600

601601
const SimpleTokenList justElse("else");
@@ -617,7 +617,7 @@ class TestToken : public TestFixture {
617617
const SimpleTokenList noType1_cpp("delete");
618618
ASSERT_EQUALS(false, Token::Match(noType1_cpp.front(), "%type%"));
619619

620-
const SimpleTokenList noType1_c("delete", false);
620+
const SimpleTokenList noType1_c("delete", Standards::Language::C);
621621
ASSERT_EQUALS(true, Token::Match(noType1_c.front(), "%type%"));
622622

623623
const SimpleTokenList noType2("void delete");

test/testtokenlist.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class TestTokenList : public TestFixture {
7272
const char code[] = "for a int delete true";
7373

7474
{
75-
const SimpleTokenList tokenlist(code, false);
75+
const SimpleTokenList tokenlist(code, Standards::Language::C);
7676

7777
ASSERT_EQUALS(true, tokenlist.front()->isKeyword());
7878
ASSERT_EQUALS(true, tokenlist.front()->isControlFlowKeyword());
@@ -112,7 +112,7 @@ class TestTokenList : public TestFixture {
112112

113113
{
114114
const char code2[] = "_Generic"; // C11 keyword
115-
const SimpleTokenList tokenlist(code2, false); // default settings use latest standard
115+
const SimpleTokenList tokenlist(code2, Standards::Language::C); // default settings use latest standard
116116
ASSERT_EQUALS(true, tokenlist.front()->isKeyword());
117117
}
118118

@@ -133,7 +133,7 @@ class TestTokenList : public TestFixture {
133133

134134
{
135135
const char code2[] = "co_return"; // C++20 keyword
136-
const SimpleTokenList tokenlist(code2, false); // default settings use latest standard
136+
const SimpleTokenList tokenlist(code2, Standards::Language::C); // default settings use latest standard
137137
ASSERT_EQUALS(false, tokenlist.front()->isKeyword());
138138
}
139139

0 commit comments

Comments
 (0)