Skip to content

Commit

Permalink
test.cpp: adjusted testing of __FILE__
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Apr 20, 2022
1 parent bd34628 commit 5069892
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ static std::string readfile(const char code[], std::size_t size, simplecpp::Outp
return makeTokenList(code,size,files,std::string(),outputList).stringify();
}

static std::string preprocess(const char code[], const simplecpp::DUI &dui, simplecpp::OutputList *outputList)
static std::string preprocess(const char code[], const simplecpp::DUI &dui, simplecpp::OutputList *outputList, const std::string &file = std::string())
{
std::vector<std::string> files;
std::map<std::string, simplecpp::TokenList*> filedata;
simplecpp::TokenList tokens = makeTokenList(code,files);
simplecpp::TokenList tokens = makeTokenList(code,files,file);
tokens.removeComments();
simplecpp::TokenList tokens2(files);
simplecpp::preprocess(tokens2, tokens, files, filedata, dui, outputList);
Expand All @@ -156,6 +156,11 @@ static std::string preprocess(const char code[])
return preprocess(code, simplecpp::DUI(), nullptr);
}

static std::string preprocess(const char code[], const std::string &file)
{
return preprocess(code, simplecpp::DUI(), nullptr, file);
}

static std::string preprocess(const char code[], const simplecpp::DUI &dui)
{
return preprocess(code, dui, nullptr);
Expand Down Expand Up @@ -222,7 +227,7 @@ static void backslash()

static void builtin()
{
ASSERT_EQUALS("\"\" 1 0", preprocess("__FILE__ __LINE__ __COUNTER__"));
ASSERT_EQUALS("\"test.c\" 1 0", preprocess("__FILE__ __LINE__ __COUNTER__", "test.c"));
ASSERT_EQUALS("\n\n3", preprocess("\n\n__LINE__"));
ASSERT_EQUALS("\n\n0", preprocess("\n\n__COUNTER__"));
ASSERT_EQUALS("\n\n0 1", preprocess("\n\n__COUNTER__ __COUNTER__"));
Expand Down

0 comments on commit 5069892

Please sign in to comment.