Skip to content

run tests with std::istringstream,std::ifstream, buffer and file input #261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
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
Prev Previous commit
Next Next commit
test.cpp: check for existence before opening file
  • Loading branch information
firewave committed Mar 28, 2024
commit a483a1d710a6aa9f8990e13702c2fe7f4ec8f6d1
5 changes: 5 additions & 0 deletions test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ static simplecpp::TokenList makeTokenListFromFstream(const char code[], std::siz
{
const std::string tmpfile = writeFile(code, size, filename);
std::ifstream fin(tmpfile);
if (!fin.is_open())
throw std::runtime_error("could not open " + tmpfile);
simplecpp::TokenList tokenList(fin, filenames, tmpfile, outputList);
remove(tmpfile.c_str());
return tokenList;
Expand All @@ -112,6 +114,9 @@ static simplecpp::TokenList makeTokenListFromFstream(const char code[], std::siz
static simplecpp::TokenList makeTokenListFromFile(const char code[], std::size_t size, std::vector<std::string> &filenames, const std::string &filename, simplecpp::OutputList *outputList)
{
const std::string tmpfile = writeFile(code, size, filename);
std::ifstream fin(tmpfile);
if (!fin.is_open())
throw std::runtime_error("could not open " + tmpfile);
simplecpp::TokenList tokenList(tmpfile, filenames, outputList);
remove(tmpfile.c_str());
return tokenList;
Expand Down