Skip to content

Commit e7bc1ff

Browse files
committed
testrunner: adjusted several Tokenizer creations [skip ci]
1 parent abb91cd commit e7bc1ff

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
@@ -568,7 +568,7 @@ class TestLibrary : public TestFixture {
568568
}
569569
}
570570

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

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

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

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

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

616616
{
617-
Tokenizer tokenizer(settings, nullptr);
617+
Tokenizer tokenizer(settings, this);
618618
std::istringstream istr("struct X : public Base { void dostuff() { f(1,2); } };");
619619
ASSERT(tokenizer.tokenize(istr, "test.cpp"));
620620
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
@@ -5957,9 +5957,9 @@ class TestTokenizer : public TestFixture {
59575957
Z3
59585958
};
59595959

5960-
std::string testAst(const char code[], AstStyle style = AstStyle::Simple) const {
5960+
std::string testAst(const char code[], AstStyle style = AstStyle::Simple) {
59615961
// tokenize given code..
5962-
Tokenizer tokenizer(settings0, nullptr);
5962+
Tokenizer tokenizer(settings0, this);
59635963
std::istringstream istr(code);
59645964
if (!tokenizer.list.createTokens(istr,"test.cpp"))
59655965
return "ERROR";
@@ -6006,7 +6006,7 @@ class TestTokenizer : public TestFixture {
60066006
return ret;
60076007
}
60086008

6009-
void astexpr() const { // simple expressions with arithmetical ops
6009+
void astexpr() { // simple expressions with arithmetical ops
60106010
ASSERT_EQUALS("12+3+", testAst("1+2+3"));
60116011
ASSERT_EQUALS("12*3+", testAst("1*2+3"));
60126012
ASSERT_EQUALS("123*+", testAst("1+2*3"));
@@ -6268,7 +6268,7 @@ class TestTokenizer : public TestFixture {
62686268
ASSERT_NO_THROW(tokenizeAndStringify(code));
62696269
}
62706270

6271-
void astnewdelete() const {
6271+
void astnewdelete() {
62726272
ASSERT_EQUALS("aintnew=", testAst("a = new int;"));
62736273
ASSERT_EQUALS("aint4[new=", testAst("a = new int[4];"));
62746274
ASSERT_EQUALS("aFoobar(new=", testAst("a = new Foo(bar);"));
@@ -6492,15 +6492,15 @@ class TestTokenizer : public TestFixture {
64926492
"}\n"));
64936493
}
64946494

6495-
void astbrackets() const { // []
6495+
void astbrackets() { // []
64966496
ASSERT_EQUALS("a23+[4+", testAst("a[2+3]+4"));
64976497
ASSERT_EQUALS("a1[0[", testAst("a[1][0]"));
64986498
ASSERT_EQUALS("ab0[=", testAst("a=(b)[0];"));
64996499
ASSERT_EQUALS("abc.0[=", testAst("a=b.c[0];"));
65006500
ASSERT_EQUALS("ab0[1[=", testAst("a=b[0][1];"));
65016501
}
65026502

6503-
void astvardecl() const {
6503+
void astvardecl() {
65046504
// Variable declaration
65056505
ASSERT_EQUALS("a1[\"\"=", testAst("char a[1]=\"\";"));
65066506
ASSERT_EQUALS("charp*(3[char5[3[new=", testAst("char (*p)[3] = new char[5][3];"));
@@ -6538,7 +6538,7 @@ class TestTokenizer : public TestFixture {
65386538
ASSERT_EQUALS("", testAst("void f(bool& var){}"));
65396539
}
65406540

6541-
void astunaryop() const { // unary operators
6541+
void astunaryop() { // unary operators
65426542
ASSERT_EQUALS("1a--+", testAst("1 + --a"));
65436543
ASSERT_EQUALS("1a--+", testAst("1 + a--"));
65446544
ASSERT_EQUALS("ab+!", testAst("!(a+b)"));
@@ -6564,7 +6564,7 @@ class TestTokenizer : public TestFixture {
65646564
ASSERT_EQUALS("int0{1&return", testAst("int g() { return int{ 0 } & 1; }"));
65656565
}
65666566

6567-
void astfunction() const { // function calls
6567+
void astfunction() { // function calls
65686568
ASSERT_EQUALS("1f(+2+", testAst("1+f()+2"));
65696569
ASSERT_EQUALS("1f2(+3+", testAst("1+f(2)+3"));
65706570
ASSERT_EQUALS("1f23,(+4+", testAst("1+f(2,3)+4"));
@@ -6628,7 +6628,7 @@ class TestTokenizer : public TestFixture {
66286628
"}\n"));
66296629
}
66306630

6631-
void astcast() const {
6631+
void astcast() {
66326632
ASSERT_EQUALS("ac&(=", testAst("a = (long)&c;"));
66336633
ASSERT_EQUALS("ac*(=", testAst("a = (Foo*)*c;"));
66346634
ASSERT_EQUALS("ac-(=", testAst("a = (long)-c;"));
@@ -6814,14 +6814,14 @@ class TestTokenizer : public TestFixture {
68146814
ASSERT_EQUALS("sf.{(i[{={", testAst("void g(int i) { S s{ .f = { [i]() {} } }; }"));
68156815
}
68166816

6817-
void astcase() const {
6817+
void astcase() {
68186818
ASSERT_EQUALS("0case", testAst("case 0:"));
68196819
ASSERT_EQUALS("12+case", testAst("case 1+2:"));
68206820
ASSERT_EQUALS("xyz:?case", testAst("case (x?y:z):"));
68216821
ASSERT_EQUALS("switchx( 1case y++ 2case", testAst("switch(x){case 1:{++y;break;case 2:break;}}"));
68226822
}
68236823

6824-
void astrefqualifier() const {
6824+
void astrefqualifier() {
68256825
ASSERT_EQUALS("b(int.", testAst("class a { auto b() -> int&; };"));
68266826
ASSERT_EQUALS("b(int.", testAst("class a { auto b() -> int&&; };"));
68276827
ASSERT_EQUALS("b(", testAst("class a { void b() &&; };"));
@@ -6832,7 +6832,7 @@ class TestTokenizer : public TestFixture {
68326832

68336833
//Verify that returning a newly constructed object generates the correct AST even when the class name is scoped
68346834
//Addresses https://trac.cppcheck.net/ticket/9700
6835-
void astnewscoped() const {
6835+
void astnewscoped() {
68366836
ASSERT_EQUALS("(return (new A))", testAst("return new A;", AstStyle::Z3));
68376837
ASSERT_EQUALS("(return (new (( A)))", testAst("return new A();", AstStyle::Z3));
68386838
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,8 +100,8 @@ class TestTokenRange : public TestFixture {
100100
ASSERT_EQUALS("", testTokenRange(ConstTokenRange{ start, end }, start, end));
101101
}
102102

103-
void scopeExample() const {
104-
Tokenizer tokenizer(settingsDefault);
103+
void scopeExample() {
104+
Tokenizer tokenizer(settingsDefault, this);
105105
std::istringstream sample("void a(){} void main(){ if(true){a();} }");
106106
ASSERT(tokenizer.tokenize(sample, "test.cpp"));
107107

0 commit comments

Comments
 (0)