diff options
author | Alexander Kornienko <alexfh@google.com> | 2013-04-15 14:28:00 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2013-04-15 14:28:00 +0000 |
commit | 70ce7881fc30a39b795b2873f008e7eca72ba669 (patch) | |
tree | f9190f278da3d6f81517e5f69243d13f3c46f15e /unittests | |
parent | 115ac5ac1281e6f301da4da6a5c669beae59ffcc (diff) |
Unified token breaking logic for strings and block comments.
Summary:
Both strings and block comments are broken into lines in
breakProtrudingToken. Logic specific for strings or block comments is abstracted
in implementations of the BreakToken interface. Among other goodness, this
change fixes placement of backslashes after a block comment inside a
preprocessor directive (see removed FIXMEs in unit tests).
The code is far from being polished, and some parts of it will be changed for
line comments support.
Reviewers: klimek
Reviewed By: klimek
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D665
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179526 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/Format/FormatTest.cpp | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 8dadd032ab..cbf5cf98b0 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -845,10 +845,7 @@ TEST_F(FormatTest, SplitsLongLinesInCommentsInPreprocessor) { " Macro comment \\\n" " with a long \\\n" " line \\\n" - // FIXME: We should look at the length of the last line of the token - // instead of the full token's length. - //" */ \\\n" - " */\\\n" + " */ \\\n" " A + B", format("#define X \\\n" " /*\n" @@ -860,10 +857,7 @@ TEST_F(FormatTest, SplitsLongLinesInCommentsInPreprocessor) { EXPECT_EQ("#define X \\\n" " /* Macro comment \\\n" " with a long \\\n" - // FIXME: We should look at the length of the last line of the token - // instead of the full token's length. - //" line */ \\\n" - " line */\\\n" + " line */ \\\n" " A + B", format("#define X \\\n" " /* Macro comment with a long\n" @@ -873,10 +867,7 @@ TEST_F(FormatTest, SplitsLongLinesInCommentsInPreprocessor) { EXPECT_EQ("#define X \\\n" " /* Macro comment \\\n" " * with a long \\\n" - // FIXME: We should look at the length of the last line of the token - // instead of the full token's length. - //" * line */ \\\n" - " * line */\\\n" + " * line */ \\\n" " A + B", format("#define X \\\n" " /* Macro comment with a long line */ \\\n" @@ -3697,7 +3688,8 @@ TEST_F(FormatTest, BreakStringLiterals) { "\"text\"", format("\"some text\"", getLLVMStyleWithColumns(7))); EXPECT_EQ("\"some\"\n" - "\" text\"", + "\" tex\"\n" + "\"t\"", format("\"some text\"", getLLVMStyleWithColumns(6))); EXPECT_EQ("\"some\"\n" "\" tex\"\n" @@ -3790,7 +3782,8 @@ TEST_F(FormatTest, DoNotBreakStringLiteralsInEscapeSequence) { "\"000001\"", format("\"test\\000000000001\"", getLLVMStyleWithColumns(9))); EXPECT_EQ("\"test\\000\"\n" - "\"000000001\"", + "\"00000000\"\n" + "\"1\"", format("\"test\\000000000001\"", getLLVMStyleWithColumns(10))); EXPECT_EQ("R\"(\\x\\x00)\"\n", format("R\"(\\x\\x00)\"\n", getLLVMStyleWithColumns(7))); |