Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions test/testcppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include <algorithm>
#include <cstdlib>
#include <list>
#include <sstream>
#include <string>
#include <unordered_set>
#include <utility>
Expand Down Expand Up @@ -486,9 +485,8 @@ class TestCppcheck : public TestFixture {
"y\n"
";\n";

std::istringstream fin(code);
simplecpp::OutputList outputList;
const simplecpp::TokenList tokens2(fin, files, "", &outputList);
const simplecpp::TokenList tokens2(code, files, "", &outputList);
const std::string expected2 = " <rawtokens>\n"
" <file index=\"0\" name=\"test.c\"/>\n"
" <file index=\"1\" name=\"\"/>\n"
Expand Down Expand Up @@ -531,8 +529,8 @@ class TestCppcheck : public TestFixture {

std::vector<std::string> files;

std::istringstream istr("void f();\nint x;\n");
const simplecpp::TokenList tokens(istr, files, "m1.c");
const char code[] = "void f();\nint x;\n";
const simplecpp::TokenList tokens(code, files, "m1.c");

Preprocessor preprocessor(settings, errorLogger, Standards::Language::C);
ASSERT(preprocessor.loadFiles(tokens, files));
Expand Down
12 changes: 6 additions & 6 deletions test/testpreprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class TestPreprocessor : public TestFixture {
std::string expandMacros(const char (&code)[size], ErrorLogger &errorLogger) const {
simplecpp::OutputList outputList;
std::vector<std::string> files;
const simplecpp::TokenList tokens1 = simplecpp::TokenList(code, size-1, files, "file.cpp", &outputList);
Comment thread
chrchr-github marked this conversation as resolved.
const simplecpp::TokenList tokens1 = simplecpp::TokenList(code, files, "file.cpp", &outputList);
Preprocessor p(settingsDefault, errorLogger, Path::identify(tokens1.getFiles()[0], false));
simplecpp::TokenList tokens2 = p.preprocess(tokens1, "", files, true);
p.reportOutput(outputList, true);
Expand All @@ -69,7 +69,7 @@ class TestPreprocessor : public TestFixture {
if (tokenlist.front())
throw std::runtime_error("token list not empty");

const simplecpp::TokenList tokens1(code, size-1, files, file0);
const simplecpp::TokenList tokens1(code, files, file0);

// Preprocess..
simplecpp::TokenList tokens2(files);
Expand All @@ -85,7 +85,7 @@ class TestPreprocessor : public TestFixture {
std::vector<RemarkComment> getRemarkComments(const char (&code)[size], ErrorLogger& errorLogger) const
{
std::vector<std::string> files;
const simplecpp::TokenList tokens1(code, size-1, files, "test.cpp");
const simplecpp::TokenList tokens1(code, files, "test.cpp");

const Preprocessor preprocessor(settingsDefault, errorLogger, Path::identify(tokens1.getFiles()[0], false));
return preprocessor.getRemarkComments(tokens1);
Expand Down Expand Up @@ -365,7 +365,7 @@ class TestPreprocessor : public TestFixture {
settings.userUndefs.insert(arg+2);
std::vector<std::string> files;
// TODO: this adds an empty filename
simplecpp::TokenList tokens(code,size-1,files);
simplecpp::TokenList tokens(code,files);
tokens.removeComments();
Preprocessor preprocessor(settings, *this, Standards::Language::C); // TODO: do we need to consider #file?
const std::set<std::string> configs = preprocessor.getConfigs(tokens);
Expand All @@ -379,7 +379,7 @@ class TestPreprocessor : public TestFixture {
std::size_t getHash(const char (&code)[size]) {
std::vector<std::string> files;
// TODO: this adds an empty filename
simplecpp::TokenList tokens(code,size-1,files);
simplecpp::TokenList tokens(code,files);
tokens.removeComments();
Preprocessor preprocessor(settingsDefault, *this, Standards::Language::C); // TODO: do we need to consider #file?
return preprocessor.calculateHash(tokens, "");
Expand Down Expand Up @@ -534,7 +534,7 @@ class TestPreprocessor : public TestFixture {
"2\n"
"#endif\n";
std::vector<std::string> files;
simplecpp::TokenList tokens(filedata, sizeof(filedata), files, "test.c");
simplecpp::TokenList tokens(filedata, files, "test.c");

// preprocess code with unix32 platform..
{
Expand Down
2 changes: 1 addition & 1 deletion test/testtokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ class TestTokenizer : public TestFixture {
void directiveDump(const char (&code)[size], const char filename[], const Settings& settings, std::ostream& ostr) {
simplecpp::OutputList outputList;
std::vector<std::string> files;
const simplecpp::TokenList tokens1(code, size-1, files, filename, &outputList);
const simplecpp::TokenList tokens1(code, files, filename, &outputList);
Preprocessor preprocessor(settings, *this, Path::identify(tokens1.getFiles()[0], false));
std::list<Directive> directives = preprocessor.createDirectives(tokens1);

Expand Down
2 changes: 1 addition & 1 deletion test/testtokenlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class TestTokenList : public TestFixture {
// TokenList::determineCppC() because there are no tokens
const char code[] = "#include <sys/poll.h>";
std::vector<std::string> files;
simplecpp::TokenList tokens1(code, sizeof(code), files, "poll.h", nullptr);
simplecpp::TokenList tokens1(code, files, "poll.h", nullptr);
Preprocessor preprocessor(settingsDefault, *this, Path::identify(tokens1.getFiles()[0], false));
simplecpp::TokenList tokensP = preprocessor.preprocess(tokens1, "", files, true);
TokenList tokenlist(settingsDefault, Standards::Language::C); // headers are treated as C files
Expand Down