preprocessor: Added a test to see that "<backslash><newline>" is handled correctly inside strings

This commit is contained in:
Daniel Marjamäki 2009-01-11 08:16:15 +00:00
parent 9d8af10583
commit e42953bd3b
1 changed files with 14 additions and 1 deletions

View File

@ -63,6 +63,7 @@ private:
TEST_CASE(multiline1); TEST_CASE(multiline1);
TEST_CASE(multiline2); TEST_CASE(multiline2);
TEST_CASE(multiline3);
TEST_CASE(if_defined); // "#if defined(AAA)" => "#ifdef AAA" TEST_CASE(if_defined); // "#if defined(AAA)" => "#ifdef AAA"
@ -387,7 +388,6 @@ private:
ASSERT_EQUALS("#define str \"abc\" \"def\" \n\nabcdef = str;\n", preprocessor.read(istr)); ASSERT_EQUALS("#define str \"abc\" \"def\" \n\nabcdef = str;\n", preprocessor.read(istr));
} }
void multiline2() void multiline2()
{ {
const char filedata[] = "#define sqr(aa) aa * \\\n" const char filedata[] = "#define sqr(aa) aa * \\\n"
@ -400,6 +400,19 @@ private:
ASSERT_EQUALS("#define sqr(aa) aa * aa\n\nsqr(5);\n", preprocessor.read(istr)); ASSERT_EQUALS("#define sqr(aa) aa * aa\n\nsqr(5);\n", preprocessor.read(istr));
} }
void multiline3()
{
const char filedata[] = "const char *str = \"abc\\\n"
"def\\\n"
"ghi\"\n";
// Preprocess => actual result..
std::istringstream istr(filedata);
Preprocessor preprocessor;
ASSERT_EQUALS("const char *str = \"abcdefghi\"\n\n\n", preprocessor.read(istr));
}
void if_defined() void if_defined()
{ {