3333
3434enum Input {
3535 Stringstream,
36- Fstream
36+ Fstream,
37+ File
3738};
3839
3940static 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+
122133static 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