Added test case which currently fails, #undef is not handled

This commit is contained in:
Reijo Tomperi 2009-01-12 18:23:53 +00:00
parent fdf5b215f9
commit ee54d4da91
1 changed files with 19 additions and 0 deletions

View File

@ -77,6 +77,7 @@ private:
TEST_CASE(macro_simple5); TEST_CASE(macro_simple5);
TEST_CASE(macro_mismatch); TEST_CASE(macro_mismatch);
TEST_CASE(preprocessor_inside_string); TEST_CASE(preprocessor_inside_string);
TEST_CASE(preprocessor_undef);
} }
@ -509,6 +510,24 @@ private:
ASSERT_EQUALS(1, actual.size()); ASSERT_EQUALS(1, actual.size());
ASSERT_EQUALS("int main(){ const char *a = \"#define A\n\";}\n", actual[""]); ASSERT_EQUALS("int main(){ const char *a = \"#define A\n\";}\n", actual[""]);
} }
void preprocessor_undef()
{
const char filedata[] = "#define AAA int a;\n"
"#undef AAA\n"
"#define AAA char b=0;\n"
"AAA\n";
// Preprocess => actual result..
std::istringstream istr(filedata);
std::map<std::string, std::string> actual;
Preprocessor preprocessor;
preprocessor.preprocess(istr, actual);
// Compare results..
ASSERT_EQUALS(1, actual.size());
ASSERT_EQUALS("\n\n\nchar b=0;\n", actual[""]);
}
}; };
REGISTER_TEST(TestPreprocessor) REGISTER_TEST(TestPreprocessor)