Skip to content

Commit 1d0788a

Browse files
committed
testrunner: adjusted several Tokenizer creations
1 parent 264f85c commit 1d0788a

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
@@ -5904,9 +5904,9 @@ class TestTokenizer : public TestFixture {
59045904
Z3
59055905
};
59065906

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

5956-
void astexpr() const { // simple expressions with arithmetical ops
5956+
void astexpr() { // simple expressions with arithmetical ops
59575957
ASSERT_EQUALS("12+3+", testAst("1+2+3"));
59585958
ASSERT_EQUALS("12*3+", testAst("1*2+3"));
59595959
ASSERT_EQUALS("123*+", testAst("1+2*3"));
@@ -6214,7 +6214,7 @@ class TestTokenizer : public TestFixture {
62146214
ASSERT_NO_THROW(tokenizeAndStringify(code));
62156215
}
62166216

6217-
void astnewdelete() const {
6217+
void astnewdelete() {
62186218
ASSERT_EQUALS("aintnew=", testAst("a = new int;"));
62196219
ASSERT_EQUALS("aint4[new=", testAst("a = new int[4];"));
62206220
ASSERT_EQUALS("aFoobar(new=", testAst("a = new Foo(bar);"));
@@ -6438,15 +6438,15 @@ class TestTokenizer : public TestFixture {
64386438
"}\n"));
64396439
}
64406440

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

6449-
void astvardecl() const {
6449+
void astvardecl() {
64506450
// Variable declaration
64516451
ASSERT_EQUALS("a1[\"\"=", testAst("char a[1]=\"\";"));
64526452
ASSERT_EQUALS("charp*(3[char5[3[new=", testAst("char (*p)[3] = new char[5][3];"));
@@ -6480,7 +6480,7 @@ class TestTokenizer : public TestFixture {
64806480
ASSERT_EQUALS("i(j=", testAst("(int&)(i) = j;"));
64816481
}
64826482

6483-
void astunaryop() const { // unary operators
6483+
void astunaryop() { // unary operators
64846484
ASSERT_EQUALS("1a--+", testAst("1 + --a"));
64856485
ASSERT_EQUALS("1a--+", testAst("1 + a--"));
64866486
ASSERT_EQUALS("ab+!", testAst("!(a+b)"));
@@ -6506,7 +6506,7 @@ class TestTokenizer : public TestFixture {
65066506
ASSERT_EQUALS("int0{1&return", testAst("int g() { return int{ 0 } & 1; }"));
65076507
}
65086508

6509-
void astfunction() const { // function calls
6509+
void astfunction() { // function calls
65106510
ASSERT_EQUALS("1f(+2+", testAst("1+f()+2"));
65116511
ASSERT_EQUALS("1f2(+3+", testAst("1+f(2)+3"));
65126512
ASSERT_EQUALS("1f23,(+4+", testAst("1+f(2,3)+4"));
@@ -6569,7 +6569,7 @@ class TestTokenizer : public TestFixture {
65696569
"}\n"));
65706570
}
65716571

6572-
void astcast() const {
6572+
void astcast() {
65736573
ASSERT_EQUALS("ac&(=", testAst("a = (long)&c;"));
65746574
ASSERT_EQUALS("ac*(=", testAst("a = (Foo*)*c;"));
65756575
ASSERT_EQUALS("ac-(=", testAst("a = (long)-c;"));
@@ -6742,14 +6742,14 @@ class TestTokenizer : public TestFixture {
67426742
ASSERT_EQUALS("sf.{(i[{={", testAst("void g(int i) { S s{ .f = { [i]() {} } }; }"));
67436743
}
67446744

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

6752-
void astrefqualifier() const {
6752+
void astrefqualifier() {
67536753
ASSERT_EQUALS("b(int.", testAst("class a { auto b() -> int&; };"));
67546754
ASSERT_EQUALS("b(int.", testAst("class a { auto b() -> int&&; };"));
67556755
ASSERT_EQUALS("b(", testAst("class a { void b() &&; };"));
@@ -6760,7 +6760,7 @@ class TestTokenizer : public TestFixture {
67606760

67616761
//Verify that returning a newly constructed object generates the correct AST even when the class name is scoped
67626762
//Addresses https://trac.cppcheck.net/ticket/9700
6763-
void astnewscoped() const {
6763+
void astnewscoped() {
67646764
ASSERT_EQUALS("(return (new A))", testAst("return new A;", AstStyle::Z3));
67656765
ASSERT_EQUALS("(return (new (( A)))", testAst("return new A();", AstStyle::Z3));
67666766
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)