Skip to content

Commit ce78fd9

Browse files
committed
Test
1 parent 1dc9543 commit ce78fd9

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

test/testpreprocessor.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ class TestPreprocessor : public TestFixture {
386386
TEST_CASE(writeLocations);
387387

388388
TEST_CASE(pragmaAsm);
389+
390+
TEST_CASE(dumpPreprocessor);
389391
}
390392

391393
template<size_t size>
@@ -3204,6 +3206,30 @@ class TestPreprocessor : public TestFixture {
32043206
const char code[] = "#pragma asm\n";
32053207
ASSERT_THROW_INTERNAL(getcodeforcfg(settingsDefault, *this, code, "", "test.cpp"), InternalError::SYNTAX);
32063208
}
3209+
3210+
void dumpPreprocessor() {
3211+
const char code[] = "#if M == 0\n"
3212+
"#endif\n;\n";
3213+
std::vector<std::string> files;
3214+
simplecpp::OutputList outputList;
3215+
3216+
Settings settings;
3217+
settings.relativePaths = true;
3218+
settings.basePaths.emplace_back("/some/path");
3219+
3220+
simplecpp::TokenList tokens1(code, files, "/some/path/test.cpp", {}, &outputList);
3221+
Preprocessor preprocessor(tokens1, settings, *this, Standards::Language::CPP);
3222+
(void)preprocessor.preprocess("", files, outputList);
3223+
(void)preprocessor.reportOutput(outputList, true);
3224+
3225+
std::ostringstream ostr;
3226+
preprocessor.dump(ostr);
3227+
ASSERT_EQUALS(
3228+
" <simplecpp-if-cond>\n"
3229+
" <if-cond file=\"test.cpp\" line=\"1\" column=\"2\" E=\"M == 0\" result=\"1\"/>\n"
3230+
" </simplecpp-if-cond>\n",
3231+
ostr.str());
3232+
}
32073233
};
32083234

32093235
REGISTER_TEST(TestPreprocessor)

0 commit comments

Comments
 (0)