From bcab694a749eed7f8724964ccb8a090f72e5340b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 12 Aug 2009 20:28:43 +0200 Subject: [PATCH] preprocessor: added todo testcase for detecting redundant preprocessor conditions --- test/testpreprocessor.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index 880b59961..4c11e47df 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -346,6 +346,32 @@ private: ASSERT_EQUALS("#if (AAA)\n#if (AAA)\n", actual); } + void test7() + { + const char filedata[] = "#ifdef ABC\n" + "A\n" + "#ifdef ABC\n" + "B\n" + "#endif\n" + "#endif\n"; + + // Preprocess => actual result.. + std::istringstream istr(filedata); + std::map actual; + Preprocessor preprocessor; + errout.str(""); + preprocessor.preprocess(istr, actual, "file.c"); + + // Make sure an error message is written.. + ASSERT_EQUALS("", errout.str()); // no change? + TODO_ASSERT_EQUALS("[test.cpp:3]: this preprocessor condition is always true", errout.str()); + + // Compare results.. + ASSERT_EQUALS("\n\n\n\n\n\n", actual[""]); + ASSERT_EQUALS("\nA\n\nB\n\n\n", actual["ABC"]); + ASSERT_EQUALS(2, static_cast(actual.size())); + } + void includeguard() {