Added test case for preprocessor which currently fails. codeblocks project file updated, tools-files added.

This commit is contained in:
Reijo Tomperi 2009-01-08 22:28:54 +00:00
parent 46f4701c26
commit c7730044c7
2 changed files with 23 additions and 0 deletions

View File

@ -81,6 +81,12 @@
<Unit filename="test/testtokenize.cpp" /> <Unit filename="test/testtokenize.cpp" />
<Unit filename="test/testunusedprivfunc.cpp" /> <Unit filename="test/testunusedprivfunc.cpp" />
<Unit filename="test/testunusedvar.cpp" /> <Unit filename="test/testunusedvar.cpp" />
<Unit filename="tools/dmake.cpp">
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Unit filename="tools/errmsg.cpp">
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Extensions> <Extensions>
<code_completion /> <code_completion />
<debugger /> <debugger />

View File

@ -70,6 +70,7 @@ private:
TEST_CASE(macro_simple2); TEST_CASE(macro_simple2);
TEST_CASE(macro_mismatch); TEST_CASE(macro_mismatch);
TEST_CASE(macro_multiline); TEST_CASE(macro_multiline);
TEST_CASE(preprocessor_inside_string);
} }
@ -434,7 +435,23 @@ private:
ASSERT_EQUALS("\n\n5*5;\n", Preprocessor::expandMacros(filedata)); ASSERT_EQUALS("\n\n5*5;\n", Preprocessor::expandMacros(filedata));
} }
void preprocessor_inside_string()
{
const char filedata[] = "int main()"
"{"
" const char *a = \"#define A\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("int main(){ const char *a = \"#define A\n\";}\n", actual[""]);
}
}; };
REGISTER_TEST(TestPreprocessor) REGISTER_TEST(TestPreprocessor)