Skip to content

Commit e4c2083

Browse files
committed
test.cpp: run tests with filename input
1 parent 818df94 commit e4c2083

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

test.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333

3434
enum Input {
3535
Stringstream,
36-
Fstream
36+
Fstream,
37+
File
3738
};
3839

3940
static Input USE_INPUT = Stringstream;
@@ -59,6 +60,8 @@ static const char* inputString(Input input) {
5960
return "Stringstream";
6061
case Fstream:
6162
return "Fstream";
63+
case File:
64+
return "File";
6265
}
6366
}
6467

@@ -119,6 +122,14 @@ static simplecpp::TokenList makeTokenListFromFstream(const char code[], std::siz
119122
return tokenList;
120123
}
121124

125+
static simplecpp::TokenList makeTokenListFromFile(const char code[], std::size_t size, std::vector<std::string> &filenames, const std::string &filename, simplecpp::OutputList *outputList)
126+
{
127+
const std::string tmpfile = writeFile(code, size, filename);
128+
simplecpp::TokenList tokenList(tmpfile, filenames, outputList);
129+
remove(tmpfile.c_str());
130+
return tokenList;
131+
}
132+
122133
static simplecpp::TokenList makeTokenList(const char code[], std::size_t size, std::vector<std::string> &filenames, const std::string &filename=std::string(), simplecpp::OutputList *outputList=nullptr)
123134
{
124135
switch (USE_INPUT) {
@@ -128,6 +139,8 @@ static simplecpp::TokenList makeTokenList(const char code[], std::size_t size, s
128139
}
129140
case Fstream:
130141
return makeTokenListFromFstream(code, size, filenames, filename, outputList);
142+
case File:
143+
return makeTokenListFromFile(code, size, filenames, filename, outputList);
131144
}
132145
}
133146

@@ -2896,5 +2909,6 @@ int main(int argc, char **argv)
28962909
{
28972910
runTests(argc, argv, Stringstream);
28982911
runTests(argc, argv, Fstream);
2912+
runTests(argc, argv, File);
28992913
return numberOfFailedAssertions > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
29002914
}

0 commit comments

Comments
 (0)