2525
2626enum Input {
2727 Stringstream,
28- Fstream
28+ Fstream,
29+ File
2930};
3031
3132static 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+
114125static 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
@@ -2815,5 +2828,6 @@ int main(int argc, char **argv)
28152828{
28162829 runTests (argc, argv, Stringstream);
28172830 runTests (argc, argv, Fstream);
2831+ runTests (argc, argv, File);
28182832 return numberOfFailedAssertions > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
28192833}
0 commit comments