@@ -61,13 +61,16 @@ class TestPreprocessor : public TestFixture {
61
61
return tokens2.stringify ();
62
62
}
63
63
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)
65
65
{
66
+ if (!files.empty ())
67
+ throw std::runtime_error (" file list not empty" );
68
+
66
69
if (tokenlist.front ())
67
70
throw std::runtime_error (" token list not empty" );
68
71
69
72
std::istringstream istr (code);
70
- const simplecpp::TokenList tokens1 (istr, files, files[ 0 ] );
73
+ const simplecpp::TokenList tokens1 (istr, files, file0 );
71
74
72
75
// Preprocess..
73
76
simplecpp::TokenList tokens2 (files);
@@ -81,9 +84,9 @@ class TestPreprocessor : public TestFixture {
81
84
82
85
static std::vector<RemarkComment> getRemarkComments (const char code[], ErrorLogger& errorLogger)
83
86
{
84
- std::vector<std::string> files{ " test.cpp " } ;
87
+ std::vector<std::string> files;
85
88
std::istringstream istr (code);
86
- const simplecpp::TokenList tokens1 (istr, files, files[ 0 ] );
89
+ const simplecpp::TokenList tokens1 (istr, files, " test.cpp " );
87
90
88
91
const Settings settings;
89
92
@@ -2570,44 +2573,48 @@ class TestPreprocessor : public TestFixture {
2570
2573
}
2571
2574
2572
2575
void standard () const {
2573
- std::vector<std::string> files = {" test.cpp" };
2574
2576
2575
2577
const char code[] = " int a;" ;
2576
2578
// TODO: this bypasses the standard determined from the settings - the parameter should not be exposed
2577
2579
simplecpp::DUI dui;
2578
2580
2579
2581
{
2580
2582
dui.std = " c89" ;
2583
+ std::vector<std::string> files;
2581
2584
TokenList tokenlist{&settingsDefault};
2582
- preprocess (code, files, tokenlist, dui);
2585
+ preprocess (code, files, " test.cpp " , tokenlist, dui);
2583
2586
ASSERT (tokenlist.front ());
2584
2587
}
2585
2588
2586
2589
{
2587
2590
dui.std = " gnu23" ;
2591
+ std::vector<std::string> files;
2588
2592
TokenList tokenlist{&settingsDefault};
2589
- preprocess (code, files, tokenlist, dui);
2593
+ preprocess (code, files, " test.cpp " , tokenlist, dui);
2590
2594
ASSERT (tokenlist.front ());
2591
2595
}
2592
2596
2593
2597
{
2594
2598
dui.std = " c++98" ;
2599
+ std::vector<std::string> files;
2595
2600
TokenList tokenlist{&settingsDefault};
2596
- preprocess (code, files, tokenlist, dui);
2601
+ preprocess (code, files, " test.cpp " , tokenlist, dui);
2597
2602
ASSERT (tokenlist.front ());
2598
2603
}
2599
2604
2600
2605
{
2601
2606
dui.std = " gnu++26" ;
2607
+ std::vector<std::string> files;
2602
2608
TokenList tokenlist{&settingsDefault};
2603
- preprocess (code, files, tokenlist, dui);
2609
+ preprocess (code, files, " test.cpp " , tokenlist, dui);
2604
2610
ASSERT (tokenlist.front ());
2605
2611
}
2606
2612
2607
2613
{
2608
2614
dui.std = " gnu77" ;
2615
+ std::vector<std::string> files;
2609
2616
TokenList tokenlist{&settingsDefault};
2610
- preprocess (code, files, tokenlist, dui);
2617
+ preprocess (code, files, " test.cpp " , tokenlist, dui);
2611
2618
ASSERT (!tokenlist.front ()); // nothing is tokenized when an unknown standard is provided
2612
2619
}
2613
2620
}
0 commit comments