preprocessor: make sure macros are not expanded when they are found in strings

This commit is contained in:
Daniel Marjamäki 2009-01-18 16:58:57 +00:00
parent 965daabe60
commit c7311b4b3c
1 changed files with 13 additions and 2 deletions

View File

@ -77,7 +77,8 @@ private:
TEST_CASE(macro_simple5); TEST_CASE(macro_simple5);
TEST_CASE(macro_simple6); TEST_CASE(macro_simple6);
TEST_CASE(macro_mismatch); TEST_CASE(macro_mismatch);
TEST_CASE(preprocessor_inside_string); TEST_CASE(string1);
TEST_CASE(string2);
TEST_CASE(preprocessor_undef); TEST_CASE(preprocessor_undef);
} }
@ -501,7 +502,7 @@ private:
ASSERT_EQUALS("\nAAA(5);\n", Preprocessor::expandMacros(filedata)); ASSERT_EQUALS("\nAAA(5);\n", Preprocessor::expandMacros(filedata));
} }
void preprocessor_inside_string() void string1()
{ {
const char filedata[] = "int main()" const char filedata[] = "int main()"
"{" "{"
@ -519,6 +520,16 @@ private:
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 string2()
{
const char filedata[] = "#define AAA 123\n"
"str = \"AAA\"";
// Compare results..
ASSERT_EQUALS("\nstr = \"AAA\"", Preprocessor::expandMacros(filedata));
}
void preprocessor_undef() void preprocessor_undef()
{ {
const char filedata[] = "#define AAA int a;\n" const char filedata[] = "#define AAA int a;\n"