aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2013-04-17 17:34:05 +0000
committerAlexander Kornienko <alexfh@google.com>2013-04-17 17:34:05 +0000
commit919398bb40d5d643f38b6595f5e8eac641e89d50 (patch)
tree6eaa11a379dea98cfa871eac894cb71cd4810568 /unittests
parentd82fdf059724bfa0b7601833db5fff2b42853f60 (diff)
Unified token breaking logic: support for line comments.
Summary: Added BreakableLineComment, moved common code from BreakableBlockComment to newly added BreakableComment. As a side-effect of the rewrite, found another problem with escaped newlines and had to change code which removes trailing whitespace from line comments not to break after this patch. Reviewers: klimek, djasper Reviewed By: klimek CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D682 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179693 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Format/FormatTest.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index ff277156e3..2ba6969d25 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -635,7 +635,7 @@ TEST_F(FormatTest, UnderstandsMultiLineComments) {
EXPECT_EQ(
"f(aaaaaaaaaaaaaaaaaaaaaaaaa, /* Trailing comment for aa... */\n"
" bbbbbbbbbbbbbbbbbbbbbbbbb);",
- format("f(aaaaaaaaaaaaaaaaaaaaaaaaa , /* Trailing comment for aa... */\n"
+ format("f(aaaaaaaaaaaaaaaaaaaaaaaaa , \\\n/* Trailing comment for aa... */\n"
" bbbbbbbbbbbbbbbbbbbbbbbbb);"));
EXPECT_EQ(
"f(aaaaaaaaaaaaaaaaaaaaaaaaa,\n"
@@ -701,6 +701,16 @@ TEST_F(FormatTest, SplitsLongCxxComments) {
"// one line",
format("// A comment that doesn't fit on one line",
getLLVMStyleWithColumns(20)));
+ EXPECT_EQ("// a b c d\n"
+ "// e f g\n"
+ "// h i j k",
+ format("// a b c d e f g h i j k",
+ getLLVMStyleWithColumns(10)));
+ EXPECT_EQ("// a b c d\n"
+ "// e f g\n"
+ "// h i j k",
+ format("\\\n// a b c d e f g h i j k",
+ getLLVMStyleWithColumns(10)));
EXPECT_EQ("if (true) // A comment that\n"
" // doesn't fit on\n"
" // one line",
@@ -743,6 +753,18 @@ TEST_F(FormatTest, SplitsLongLinesInComments) {
"doesn't "
"fit on one line. */",
getLLVMStyleWithColumns(20)));
+ EXPECT_EQ("/* a b c d\n"
+ " * e f g\n"
+ " * h i j k\n"
+ " */",
+ format("/* a b c d e f g h i j k */",
+ getLLVMStyleWithColumns(10)));
+ EXPECT_EQ("/* a b c d\n"
+ " * e f g\n"
+ " * h i j k\n"
+ " */",
+ format("\\\n/* a b c d e f g h i j k */",
+ getLLVMStyleWithColumns(10)));
EXPECT_EQ("/*\n"
"This is a long\n"
"comment that doesn't\n"
@@ -3670,6 +3692,9 @@ TEST_F(FormatTest, BreakStringLiterals) {
EXPECT_EQ("\"some text \"\n"
"\"other\";",
format("\"some text other\";", getLLVMStyleWithColumns(12)));
+ EXPECT_EQ("\"some text \"\n"
+ "\"other\";",
+ format("\\\n\"some text other\";", getLLVMStyleWithColumns(12)));
EXPECT_EQ(
"#define A \\\n"
" \"some \" \\\n"