Skip to content

Commit 4acb91b

Browse files
committed
test.cpp: run tests with filename input
1 parent 16f2269 commit 4acb91b

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
@@ -25,7 +25,8 @@
2525

2626
enum Input {
2727
Stringstream,
28-
Fstream
28+
Fstream,
29+
File
2930
};
3031

3132
static Input USE_INPUT = Stringstream;
@@ -51,6 +52,8 @@ static const char* inputString(Input input) {
5152
return "Stringstream";
5253
case Fstream:
5354
return "Fstream";
55+
case File:
56+
return "File";
5457
}
5558
}
5659

@@ -111,6 +114,14 @@ static simplecpp::TokenList makeTokenListFromFstream(const char code[], std::siz
111114
return tokenList;
112115
}
113116

117+
static simplecpp::TokenList makeTokenListFromFile(const char code[], std::size_t size, std::vector<std::string> &filenames, const std::string &filename, simplecpp::OutputList *outputList)
118+
{
119+
const std::string tmpfile = writeFile(code, size, filename);
120+
simplecpp::TokenList tokenList(tmpfile, filenames, outputList);
121+
remove(tmpfile.c_str());
122+
return tokenList;
123+
}
124+
114125
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)
115126
{
116127
switch (USE_INPUT) {
@@ -120,6 +131,8 @@ static simplecpp::TokenList makeTokenList(const char code[], std::size_t size, s
120131
}
121132
case Fstream:
122133
return makeTokenListFromFstream(code, size, filenames, filename, outputList);
134+
case File:
135+
return makeTokenListFromFile(code, size, filenames, filename, outputList);
123136
}
124137
}
125138

@@ -2802,5 +2815,6 @@ int main(int argc, char **argv)
28022815
{
28032816
runTests(argc, argv, Stringstream);
28042817
runTests(argc, argv, Fstream);
2818+
runTests(argc, argv, File);
28052819
return numberOfFailedAssertions > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
28062820
}

0 commit comments

Comments
 (0)