Skip to content

Commit f0bfe43

Browse files
committed
testrunner: pass Standards::Language to SimpleTokenList
1 parent 1b67dec commit f0bfe43

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
@@ -561,22 +561,22 @@ class TestToken : public TestFixture {
561561
}
562562

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

569569

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

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

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

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

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

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

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

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