diff options
author | Daniel Jasper <djasper@google.com> | 2013-11-29 09:27:43 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-11-29 09:27:43 +0000 |
commit | 38c82408a7e9fb4c593eeb4a2b1b0f0993cd3b92 (patch) | |
tree | 9c49d7c0ec01bc204caff8750df555e1be129f35 /clang/unittests/Format/FormatTest.cpp | |
parent | 1556b5933848fe363811a1e71ac04a5f9c4802b2 (diff) | |
download | bcm5719-llvm-38c82408a7e9fb4c593eeb4a2b1b0f0993cd3b92.tar.gz bcm5719-llvm-38c82408a7e9fb4c593eeb4a2b1b0f0993cd3b92.zip |
clang-format: Extends formatted ranges to subsequent lines comments.
Before:
int aaaa; // This line is formatted.
// The comment continues ..
// .. here.
Before:
int aaaa; // This line is formatted.
// The comment continues ..
// .. here.
This fixes llvm.org/PR17914.
llvm-svn: 195954
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index ccad1d4b004..76796e4f281 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -829,6 +829,36 @@ TEST_F(FormatTest, CanFormatCommentsLocally) { "int b;\n" "int c; // unrelated comment", 31, 0, getLLVMStyle())); + + EXPECT_EQ("int a; // This\n" + " // is\n" + " // a", + format("int a; // This\n" + " // is\n" + " // a", + 0, 0, getLLVMStyle())); + EXPECT_EQ("int a; // This\n" + " // is\n" + " // a\n" + "// This is b\n" + "int b;", + format("int a; // This\n" + " // is\n" + " // a\n" + "// This is b\n" + "int b;", + 0, 0, getLLVMStyle())); + EXPECT_EQ("int a; // This\n" + " // is\n" + " // a\n" + "\n" + " // This is unrelated", + format("int a; // This\n" + " // is\n" + " // a\n" + "\n" + " // This is unrelated", + 0, 0, getLLVMStyle())); } TEST_F(FormatTest, RemovesTrailingWhitespaceOfComments) { @@ -843,11 +873,11 @@ TEST_F(FormatTest, RemovesTrailingWhitespaceOfComments) { TEST_F(FormatTest, UnderstandsBlockComments) { verifyFormat("f(/*noSpaceAfterParameterNamingComment=*/true);"); verifyFormat("void f() { g(/*aaa=*/x, /*bbb=*/!y); }"); - EXPECT_EQ( - "f(aaaaaaaaaaaaaaaaaaaaaaaaa, /* Trailing comment for aa... */\n" - " bbbbbbbbbbbbbbbbbbbbbbbbb);", - format("f(aaaaaaaaaaaaaaaaaaaaaaaaa , \\\n/* Trailing comment for aa... */\n" - " bbbbbbbbbbbbbbbbbbbbbbbbb);")); + EXPECT_EQ("f(aaaaaaaaaaaaaaaaaaaaaaaaa, /* Trailing comment for aa... */\n" + " bbbbbbbbbbbbbbbbbbbbbbbbb);", + format("f(aaaaaaaaaaaaaaaaaaaaaaaaa , \\\n" + "/* Trailing comment for aa... */\n" + " bbbbbbbbbbbbbbbbbbbbbbbbb);")); EXPECT_EQ( "f(aaaaaaaaaaaaaaaaaaaaaaaaa,\n" " /* Leading comment for bb... */ bbbbbbbbbbbbbbbbbbbbbbbbb);", |