Skip to content

Commit

Permalink
testrunner: added missing TokenList::createTokens() checks
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Mar 8, 2024
1 parent 202ae05 commit 24cb9cd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
10 changes: 5 additions & 5 deletions test/testlibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class TestLibrary : public TestFixture {

TokenList tokenList(&settings);
std::istringstream istr("foo();"); // <- too few arguments, not library function
tokenList.createTokens(istr, Standards::Language::CPP);
ASSERT(tokenList.createTokens(istr, Standards::Language::CPP));
Token::createMutualLinks(tokenList.front()->next(), tokenList.back()->previous());
tokenList.createAst();

Expand All @@ -186,7 +186,7 @@ class TestLibrary : public TestFixture {
{
TokenList tokenList(&settings);
std::istringstream istr("foo();"); // <- too few arguments, not library function
tokenList.createTokens(istr, Standards::Language::CPP);
ASSERT(tokenList.createTokens(istr, Standards::Language::CPP));
Token::createMutualLinks(tokenList.front()->next(), tokenList.back()->previous());
tokenList.createAst();

Expand All @@ -195,7 +195,7 @@ class TestLibrary : public TestFixture {
{
TokenList tokenList(&settings);
std::istringstream istr("foo(a);"); // <- library function
tokenList.createTokens(istr, Standards::Language::CPP);
ASSERT(tokenList.createTokens(istr, Standards::Language::CPP));
Token::createMutualLinks(tokenList.front()->next(), tokenList.back()->previous());
tokenList.createAst();

Expand All @@ -204,7 +204,7 @@ class TestLibrary : public TestFixture {
{
TokenList tokenList(&settings);
std::istringstream istr("foo(a, b);"); // <- library function
tokenList.createTokens(istr, Standards::Language::CPP);
ASSERT(tokenList.createTokens(istr, Standards::Language::CPP));
Token::createMutualLinks(tokenList.front()->next(), tokenList.back()->previous());
tokenList.createAst();

Expand All @@ -213,7 +213,7 @@ class TestLibrary : public TestFixture {
{
TokenList tokenList(&settings);
std::istringstream istr("foo(a, b, c);"); // <- too much arguments, not library function
tokenList.createTokens(istr, Standards::Language::CPP);
ASSERT(tokenList.createTokens(istr, Standards::Language::CPP));
Token::createMutualLinks(tokenList.front()->next(), tokenList.back()->previous());
tokenList.createAst();

Expand Down
12 changes: 8 additions & 4 deletions test/testsimplifytemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5290,7 +5290,8 @@ class TestSimplifyTemplate : public TestFixture {
Tokenizer tokenizer(settings, this);

std::istringstream istr(code);
tokenizer.list.createTokens(istr, "test.cpp");
if (!tokenizer.list.createTokens(istr, "test.cpp"))
return false;
tokenizer.createLinks();
tokenizer.splitTemplateRightAngleBrackets(false);

Expand Down Expand Up @@ -5357,7 +5358,8 @@ class TestSimplifyTemplate : public TestFixture {
Tokenizer tokenizer(settings, this);

std::istringstream istr(code);
tokenizer.list.createTokens(istr, "test.cpp");
if (!tokenizer.list.createTokens(istr, "test.cpp"))
return false;
tokenizer.createLinks();
tokenizer.splitTemplateRightAngleBrackets(false);

Expand Down Expand Up @@ -5427,7 +5429,8 @@ class TestSimplifyTemplate : public TestFixture {
Tokenizer tokenizer(settings, this);

std::istringstream istr(code);
tokenizer.list.createTokens(istr, "test.cpp");
if (!tokenizer.list.createTokens(istr, "test.cpp"))
return false;
tokenizer.createLinks();
tokenizer.splitTemplateRightAngleBrackets(false);

Expand Down Expand Up @@ -5456,7 +5459,8 @@ class TestSimplifyTemplate : public TestFixture {
Tokenizer tokenizer(settings, this);

std::istringstream istr(code);
tokenizer.list.createTokens(istr, "test.cpp");
if (!tokenizer.list.createTokens(istr, "test.cpp"))
return false;
tokenizer.createLinks();
tokenizer.splitTemplateRightAngleBrackets(false);

Expand Down
8 changes: 5 additions & 3 deletions test/testsimplifytypedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ class TestSimplifyTypedef : public TestFixture {
Tokenizer tokenizer(settings1, this);

std::istringstream istr(code);
tokenizer.list.createTokens(istr, Standards::Language::CPP);
if (!tokenizer.list.createTokens(istr, Standards::Language::CPP))
return "";
tokenizer.createLinks();
tokenizer.simplifyTypedef();

Expand Down Expand Up @@ -296,7 +297,8 @@ class TestSimplifyTypedef : public TestFixture {
Tokenizer tokenizer(settings1, this);

std::istringstream istr(code);
tokenizer.list.createTokens(istr, "file.c");
if (!tokenizer.list.createTokens(istr, "file.c"))
return "";
tokenizer.createLinks();
tokenizer.simplifyTypedef();
try {
Expand Down Expand Up @@ -4157,7 +4159,7 @@ class TestSimplifyTypedef : public TestFixture {

Tokenizer tokenizer(settings1, this);
std::istringstream istr(code);
tokenizer.list.createTokens(istr, "file.c");
ASSERT(tokenizer.list.createTokens(istr, "file.c"));
tokenizer.createLinks();
tokenizer.simplifyTypedef();

Expand Down
4 changes: 2 additions & 2 deletions test/testtokenlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class TestTokenList : public TestFixture {
const Settings s = settingsBuilder().c(Standards::C89).build();
TokenList tokenlist(&s);
std::istringstream istr(code2);
tokenlist.createTokens(istr, "a.c");
ASSERT(tokenlist.createTokens(istr, "a.c"));
ASSERT_EQUALS(false, tokenlist.front()->isKeyword());
}

Expand All @@ -142,7 +142,7 @@ class TestTokenList : public TestFixture {
const Settings s = settingsBuilder().cpp(Standards::CPP03).build();
TokenList tokenlist(&s);
std::istringstream istr(code2);
tokenlist.createTokens(istr, "a.cpp");
ASSERT(tokenlist.createTokens(istr, "a.cpp"));
ASSERT_EQUALS(false, tokenlist.front()->isKeyword());
}
}
Expand Down

0 comments on commit 24cb9cd

Please sign in to comment.