Skip to content

Commit f177eb3

Browse files
committed
testrunner: adjusted several Tokenizer creations
1 parent 48942c2 commit f177eb3

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

test/testlibrary.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ class TestLibrary : public TestFixture {
567567
}
568568
}
569569

570-
void function_method() const {
570+
void function_method() {
571571
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
572572
"<def>\n"
573573
" <function name=\"CString::Format\">\n"
@@ -580,21 +580,21 @@ class TestLibrary : public TestFixture {
580580
ASSERT_EQUALS(library.functions.size(), 1U);
581581

582582
{
583-
Tokenizer tokenizer(&settings, nullptr);
583+
Tokenizer tokenizer(&settings, this);
584584
std::istringstream istr("CString str; str.Format();");
585585
ASSERT(tokenizer.tokenize(istr, "test.cpp"));
586586
ASSERT(library.isnotnoreturn(Token::findsimplematch(tokenizer.tokens(), "Format")));
587587
}
588588

589589
{
590-
Tokenizer tokenizer(&settings, nullptr);
590+
Tokenizer tokenizer(&settings, this);
591591
std::istringstream istr("HardDrive hd; hd.Format();");
592592
ASSERT(tokenizer.tokenize(istr, "test.cpp"));
593593
ASSERT(!library.isnotnoreturn(Token::findsimplematch(tokenizer.tokens(), "Format")));
594594
}
595595
}
596596

597-
void function_baseClassMethod() const {
597+
void function_baseClassMethod() {
598598
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
599599
"<def>\n"
600600
" <function name=\"Base::f\">\n"
@@ -606,14 +606,14 @@ class TestLibrary : public TestFixture {
606606
ASSERT(loadxmldata(library, xmldata, sizeof(xmldata)));
607607

608608
{
609-
Tokenizer tokenizer(&settings, nullptr);
609+
Tokenizer tokenizer(&settings, this);
610610
std::istringstream istr("struct X : public Base { void dostuff() { f(0); } };");
611611
ASSERT(tokenizer.tokenize(istr, "test.cpp"));
612612
ASSERT(library.isnullargbad(Token::findsimplematch(tokenizer.tokens(), "f"),1));
613613
}
614614

615615
{
616-
Tokenizer tokenizer(&settings, nullptr);
616+
Tokenizer tokenizer(&settings, this);
617617
std::istringstream istr("struct X : public Base { void dostuff() { f(1,2); } };");
618618
ASSERT(tokenizer.tokenize(istr, "test.cpp"));
619619
ASSERT(!library.isnullargbad(Token::findsimplematch(tokenizer.tokens(), "f"),1));

test/testtokenize.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5902,9 +5902,9 @@ class TestTokenizer : public TestFixture {
59025902
Z3
59035903
};
59045904

5905-
std::string testAst(const char code[], AstStyle style = AstStyle::Simple) const {
5905+
std::string testAst(const char code[], AstStyle style = AstStyle::Simple) {
59065906
// tokenize given code..
5907-
Tokenizer tokenList(&settings0, nullptr);
5907+
Tokenizer tokenList(&settings0, this);
59085908
std::istringstream istr(code);
59095909
if (!tokenList.list.createTokens(istr,"test.cpp"))
59105910
return "ERROR";
@@ -5951,7 +5951,7 @@ class TestTokenizer : public TestFixture {
59515951
return ret;
59525952
}
59535953

5954-
void astexpr() const { // simple expressions with arithmetical ops
5954+
void astexpr() { // simple expressions with arithmetical ops
59555955
ASSERT_EQUALS("12+3+", testAst("1+2+3"));
59565956
ASSERT_EQUALS("12*3+", testAst("1*2+3"));
59575957
ASSERT_EQUALS("123*+", testAst("1+2*3"));
@@ -6212,7 +6212,7 @@ class TestTokenizer : public TestFixture {
62126212
ASSERT_NO_THROW(tokenizeAndStringify(code));
62136213
}
62146214

6215-
void astnewdelete() const {
6215+
void astnewdelete() {
62166216
ASSERT_EQUALS("aintnew=", testAst("a = new int;"));
62176217
ASSERT_EQUALS("aint4[new=", testAst("a = new int[4];"));
62186218
ASSERT_EQUALS("aFoobar(new=", testAst("a = new Foo(bar);"));
@@ -6436,15 +6436,15 @@ class TestTokenizer : public TestFixture {
64366436
"}\n"));
64376437
}
64386438

6439-
void astbrackets() const { // []
6439+
void astbrackets() { // []
64406440
ASSERT_EQUALS("a23+[4+", testAst("a[2+3]+4"));
64416441
ASSERT_EQUALS("a1[0[", testAst("a[1][0]"));
64426442
ASSERT_EQUALS("ab0[=", testAst("a=(b)[0];"));
64436443
ASSERT_EQUALS("abc.0[=", testAst("a=b.c[0];"));
64446444
ASSERT_EQUALS("ab0[1[=", testAst("a=b[0][1];"));
64456445
}
64466446

6447-
void astvardecl() const {
6447+
void astvardecl() {
64486448
// Variable declaration
64496449
ASSERT_EQUALS("a1[\"\"=", testAst("char a[1]=\"\";"));
64506450
ASSERT_EQUALS("charp*(3[char5[3[new=", testAst("char (*p)[3] = new char[5][3];"));
@@ -6478,7 +6478,7 @@ class TestTokenizer : public TestFixture {
64786478
ASSERT_EQUALS("i(j=", testAst("(int&)(i) = j;"));
64796479
}
64806480

6481-
void astunaryop() const { // unary operators
6481+
void astunaryop() { // unary operators
64826482
ASSERT_EQUALS("1a--+", testAst("1 + --a"));
64836483
ASSERT_EQUALS("1a--+", testAst("1 + a--"));
64846484
ASSERT_EQUALS("ab+!", testAst("!(a+b)"));
@@ -6504,7 +6504,7 @@ class TestTokenizer : public TestFixture {
65046504
ASSERT_EQUALS("int0{1&return", testAst("int g() { return int{ 0 } & 1; }"));
65056505
}
65066506

6507-
void astfunction() const { // function calls
6507+
void astfunction() { // function calls
65086508
ASSERT_EQUALS("1f(+2+", testAst("1+f()+2"));
65096509
ASSERT_EQUALS("1f2(+3+", testAst("1+f(2)+3"));
65106510
ASSERT_EQUALS("1f23,(+4+", testAst("1+f(2,3)+4"));
@@ -6567,7 +6567,7 @@ class TestTokenizer : public TestFixture {
65676567
"}\n"));
65686568
}
65696569

6570-
void astcast() const {
6570+
void astcast() {
65716571
ASSERT_EQUALS("ac&(=", testAst("a = (long)&c;"));
65726572
ASSERT_EQUALS("ac*(=", testAst("a = (Foo*)*c;"));
65736573
ASSERT_EQUALS("ac-(=", testAst("a = (long)-c;"));
@@ -6740,14 +6740,14 @@ class TestTokenizer : public TestFixture {
67406740
ASSERT_EQUALS("sf.{(i[{={", testAst("void g(int i) { S s{ .f = { [i]() {} } }; }"));
67416741
}
67426742

6743-
void astcase() const {
6743+
void astcase() {
67446744
ASSERT_EQUALS("0case", testAst("case 0:"));
67456745
ASSERT_EQUALS("12+case", testAst("case 1+2:"));
67466746
ASSERT_EQUALS("xyz:?case", testAst("case (x?y:z):"));
67476747
ASSERT_EQUALS("switchx( 1case y++ 2case", testAst("switch(x){case 1:{++y;break;case 2:break;}}"));
67486748
}
67496749

6750-
void astrefqualifier() const {
6750+
void astrefqualifier() {
67516751
ASSERT_EQUALS("b(int.", testAst("class a { auto b() -> int&; };"));
67526752
ASSERT_EQUALS("b(int.", testAst("class a { auto b() -> int&&; };"));
67536753
ASSERT_EQUALS("b(", testAst("class a { void b() &&; };"));
@@ -6758,7 +6758,7 @@ class TestTokenizer : public TestFixture {
67586758

67596759
//Verify that returning a newly constructed object generates the correct AST even when the class name is scoped
67606760
//Addresses https://trac.cppcheck.net/ticket/9700
6761-
void astnewscoped() const {
6761+
void astnewscoped() {
67626762
ASSERT_EQUALS("(return (new A))", testAst("return new A;", AstStyle::Z3));
67636763
ASSERT_EQUALS("(return (new (( A)))", testAst("return new A();", AstStyle::Z3));
67646764
ASSERT_EQUALS("(return (new (( A true)))", testAst("return new A(true);", AstStyle::Z3));

test/testtokenrange.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ class TestTokenRange : public TestFixture {
100100
ASSERT_EQUALS("", testTokenRange(ConstTokenRange{ start, end }, start, end));
101101
}
102102

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

0 commit comments

Comments
 (0)