Skip to content

Commit 498bd15

Browse files
committed
testrunner: adjusted several Tokenizer creations
1 parent db87503 commit 498bd15

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
@@ -5948,9 +5948,9 @@ class TestTokenizer : public TestFixture {
59485948
Z3
59495949
};
59505950

5951-
std::string testAst(const char code[], AstStyle style = AstStyle::Simple) const {
5951+
std::string testAst(const char code[], AstStyle style = AstStyle::Simple) {
59525952
// tokenize given code..
5953-
Tokenizer tokenizer(settings0, nullptr);
5953+
Tokenizer tokenizer(settings0, this);
59545954
std::istringstream istr(code);
59555955
if (!tokenizer.list.createTokens(istr,"test.cpp"))
59565956
return "ERROR";
@@ -5997,7 +5997,7 @@ class TestTokenizer : public TestFixture {
59975997
return ret;
59985998
}
59995999

6000-
void astexpr() const { // simple expressions with arithmetical ops
6000+
void astexpr() { // simple expressions with arithmetical ops
60016001
ASSERT_EQUALS("12+3+", testAst("1+2+3"));
60026002
ASSERT_EQUALS("12*3+", testAst("1*2+3"));
60036003
ASSERT_EQUALS("123*+", testAst("1+2*3"));
@@ -6259,7 +6259,7 @@ class TestTokenizer : public TestFixture {
62596259
ASSERT_NO_THROW(tokenizeAndStringify(code));
62606260
}
62616261

6262-
void astnewdelete() const {
6262+
void astnewdelete() {
62636263
ASSERT_EQUALS("aintnew=", testAst("a = new int;"));
62646264
ASSERT_EQUALS("aint4[new=", testAst("a = new int[4];"));
62656265
ASSERT_EQUALS("aFoobar(new=", testAst("a = new Foo(bar);"));
@@ -6483,15 +6483,15 @@ class TestTokenizer : public TestFixture {
64836483
"}\n"));
64846484
}
64856485

6486-
void astbrackets() const { // []
6486+
void astbrackets() { // []
64876487
ASSERT_EQUALS("a23+[4+", testAst("a[2+3]+4"));
64886488
ASSERT_EQUALS("a1[0[", testAst("a[1][0]"));
64896489
ASSERT_EQUALS("ab0[=", testAst("a=(b)[0];"));
64906490
ASSERT_EQUALS("abc.0[=", testAst("a=b.c[0];"));
64916491
ASSERT_EQUALS("ab0[1[=", testAst("a=b[0][1];"));
64926492
}
64936493

6494-
void astvardecl() const {
6494+
void astvardecl() {
64956495
// Variable declaration
64966496
ASSERT_EQUALS("a1[\"\"=", testAst("char a[1]=\"\";"));
64976497
ASSERT_EQUALS("charp*(3[char5[3[new=", testAst("char (*p)[3] = new char[5][3];"));
@@ -6529,7 +6529,7 @@ class TestTokenizer : public TestFixture {
65296529
ASSERT_EQUALS("", testAst("void f(bool& var){}"));
65306530
}
65316531

6532-
void astunaryop() const { // unary operators
6532+
void astunaryop() { // unary operators
65336533
ASSERT_EQUALS("1a--+", testAst("1 + --a"));
65346534
ASSERT_EQUALS("1a--+", testAst("1 + a--"));
65356535
ASSERT_EQUALS("ab+!", testAst("!(a+b)"));
@@ -6555,7 +6555,7 @@ class TestTokenizer : public TestFixture {
65556555
ASSERT_EQUALS("int0{1&return", testAst("int g() { return int{ 0 } & 1; }"));
65566556
}
65576557

6558-
void astfunction() const { // function calls
6558+
void astfunction() { // function calls
65596559
ASSERT_EQUALS("1f(+2+", testAst("1+f()+2"));
65606560
ASSERT_EQUALS("1f2(+3+", testAst("1+f(2)+3"));
65616561
ASSERT_EQUALS("1f23,(+4+", testAst("1+f(2,3)+4"));
@@ -6619,7 +6619,7 @@ class TestTokenizer : public TestFixture {
66196619
"}\n"));
66206620
}
66216621

6622-
void astcast() const {
6622+
void astcast() {
66236623
ASSERT_EQUALS("ac&(=", testAst("a = (long)&c;"));
66246624
ASSERT_EQUALS("ac*(=", testAst("a = (Foo*)*c;"));
66256625
ASSERT_EQUALS("ac-(=", testAst("a = (long)-c;"));
@@ -6805,14 +6805,14 @@ class TestTokenizer : public TestFixture {
68056805
ASSERT_EQUALS("sf.{(i[{={", testAst("void g(int i) { S s{ .f = { [i]() {} } }; }"));
68066806
}
68076807

6808-
void astcase() const {
6808+
void astcase() {
68096809
ASSERT_EQUALS("0case", testAst("case 0:"));
68106810
ASSERT_EQUALS("12+case", testAst("case 1+2:"));
68116811
ASSERT_EQUALS("xyz:?case", testAst("case (x?y:z):"));
68126812
ASSERT_EQUALS("switchx( 1case y++ 2case", testAst("switch(x){case 1:{++y;break;case 2:break;}}"));
68136813
}
68146814

6815-
void astrefqualifier() const {
6815+
void astrefqualifier() {
68166816
ASSERT_EQUALS("b(int.", testAst("class a { auto b() -> int&; };"));
68176817
ASSERT_EQUALS("b(int.", testAst("class a { auto b() -> int&&; };"));
68186818
ASSERT_EQUALS("b(", testAst("class a { void b() &&; };"));
@@ -6823,7 +6823,7 @@ class TestTokenizer : public TestFixture {
68236823

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