Skip to content

Commit c0d3e00

Browse files
committed
preprocessor check for #define A 0
1 parent 1e0d538 commit c0d3e00

1 file changed

Lines changed: 33 additions & 13 deletions

File tree

test/testpreprocessor.cpp

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,21 +1226,41 @@ class TestPreprocessor : public TestFixture
12261226

12271227
void if_cond7()
12281228
{
1229-
const char filedata[] = "#define A 1\n"
1230-
"#if A==1\n"
1231-
"a1;\n"
1232-
"#endif\n";
1229+
{
1230+
const char filedata[] = "#define A 1\n"
1231+
"#if A==1\n"
1232+
"a1;\n"
1233+
"#endif\n";
12331234

1234-
// Preprocess => actual result..
1235-
std::istringstream istr(filedata);
1236-
std::map<std::string, std::string> actual;
1237-
Settings settings;
1238-
Preprocessor preprocessor(&settings, this);
1239-
preprocessor.preprocess(istr, actual, "file.c");
1235+
// Preprocess => actual result..
1236+
std::istringstream istr(filedata);
1237+
std::map<std::string, std::string> actual;
1238+
Settings settings;
1239+
Preprocessor preprocessor(&settings, this);
1240+
preprocessor.preprocess(istr, actual, "file.c");
12401241

1241-
// Compare results..
1242-
ASSERT_EQUALS(1, (int)actual.size());
1243-
ASSERT_EQUALS("\n\na1;\n\n", actual[""]);
1242+
// Compare results..
1243+
ASSERT_EQUALS(1, (int)actual.size());
1244+
ASSERT_EQUALS("\n\na1;\n\n", actual[""]);
1245+
}
1246+
1247+
{
1248+
const char filedata[] = "#define A 0\n"
1249+
"#if A\n"
1250+
"foo();\n"
1251+
"#endif\n";
1252+
1253+
// Preprocess => actual result..
1254+
std::istringstream istr(filedata);
1255+
std::map<std::string, std::string> actual;
1256+
Settings settings;
1257+
Preprocessor preprocessor(&settings, this);
1258+
preprocessor.preprocess(istr, actual, "file.c");
1259+
1260+
// Compare results..
1261+
ASSERT_EQUALS(2, static_cast<unsigned int>(actual.size()));
1262+
ASSERT_EQUALS("\n\n\n\n", actual[""]);
1263+
}
12441264
}
12451265

12461266

0 commit comments

Comments
 (0)