preprocessor check for #define A 0

This commit is contained in:
Greg Hewgill 2011-02-08 20:59:30 +13:00
parent 1e0d538273
commit c0d3e002a9
1 changed files with 33 additions and 13 deletions

View File

@ -1225,6 +1225,7 @@ private:
}
void if_cond7()
{
{
const char filedata[] = "#define A 1\n"
"#if A==1\n"
@ -1243,6 +1244,25 @@ private:
ASSERT_EQUALS("\n\na1;\n\n", actual[""]);
}
{
const char filedata[] = "#define A 0\n"
"#if A\n"
"foo();\n"
"#endif\n";
// Preprocess => actual result..
std::istringstream istr(filedata);
std::map<std::string, std::string> actual;
Settings settings;
Preprocessor preprocessor(&settings, this);
preprocessor.preprocess(istr, actual, "file.c");
// Compare results..
ASSERT_EQUALS(2, static_cast<unsigned int>(actual.size()));
ASSERT_EQUALS("\n\n\n\n", actual[""]);
}
}
void if_cond8()
{