@@ -61,13 +61,16 @@ class TestPreprocessor : public TestFixture {
6161 return tokens2.stringify ();
6262 }
6363
64- static void preprocess (const char code[], std::vector<std::string> &files, TokenList& tokenlist, const simplecpp::DUI& dui)
64+ static void preprocess (const char code[], std::vector<std::string> &files, const std::string& file0, TokenList& tokenlist, const simplecpp::DUI& dui)
6565 {
66+ if (!files.empty ())
67+ throw std::runtime_error (" file list not empty" );
68+
6669 if (tokenlist.front ())
6770 throw std::runtime_error (" token list not empty" );
6871
6972 std::istringstream istr (code);
70- const simplecpp::TokenList tokens1 (istr, files, files[ 0 ] );
73+ const simplecpp::TokenList tokens1 (istr, files, file0 );
7174
7275 // Preprocess..
7376 simplecpp::TokenList tokens2 (files);
@@ -81,9 +84,9 @@ class TestPreprocessor : public TestFixture {
8184
8285 static std::vector<RemarkComment> getRemarkComments (const char code[], ErrorLogger& errorLogger)
8386 {
84- std::vector<std::string> files{ " test.cpp " } ;
87+ std::vector<std::string> files;
8588 std::istringstream istr (code);
86- const simplecpp::TokenList tokens1 (istr, files, files[ 0 ] );
89+ const simplecpp::TokenList tokens1 (istr, files, " test.cpp " );
8790
8891 const Settings settings;
8992
@@ -2570,44 +2573,48 @@ class TestPreprocessor : public TestFixture {
25702573 }
25712574
25722575 void standard () const {
2573- std::vector<std::string> files = {" test.cpp" };
25742576
25752577 const char code[] = " int a;" ;
25762578 // TODO: this bypasses the standard determined from the settings - the parameter should not be exposed
25772579 simplecpp::DUI dui;
25782580
25792581 {
25802582 dui.std = " c89" ;
2583+ std::vector<std::string> files;
25812584 TokenList tokenlist{&settingsDefault};
2582- preprocess (code, files, tokenlist, dui);
2585+ preprocess (code, files, " test.cpp " , tokenlist, dui);
25832586 ASSERT (tokenlist.front ());
25842587 }
25852588
25862589 {
25872590 dui.std = " gnu23" ;
2591+ std::vector<std::string> files;
25882592 TokenList tokenlist{&settingsDefault};
2589- preprocess (code, files, tokenlist, dui);
2593+ preprocess (code, files, " test.cpp " , tokenlist, dui);
25902594 ASSERT (tokenlist.front ());
25912595 }
25922596
25932597 {
25942598 dui.std = " c++98" ;
2599+ std::vector<std::string> files;
25952600 TokenList tokenlist{&settingsDefault};
2596- preprocess (code, files, tokenlist, dui);
2601+ preprocess (code, files, " test.cpp " , tokenlist, dui);
25972602 ASSERT (tokenlist.front ());
25982603 }
25992604
26002605 {
26012606 dui.std = " gnu++26" ;
2607+ std::vector<std::string> files;
26022608 TokenList tokenlist{&settingsDefault};
2603- preprocess (code, files, tokenlist, dui);
2609+ preprocess (code, files, " test.cpp " , tokenlist, dui);
26042610 ASSERT (tokenlist.front ());
26052611 }
26062612
26072613 {
26082614 dui.std = " gnu77" ;
2615+ std::vector<std::string> files;
26092616 TokenList tokenlist{&settingsDefault};
2610- preprocess (code, files, tokenlist, dui);
2617+ preprocess (code, files, " test.cpp " , tokenlist, dui);
26112618 ASSERT (!tokenlist.front ()); // nothing is tokenized when an unknown standard is provided
26122619 }
26132620 }
0 commit comments