clang-format: Improve clang-format's detection about comment binding.
Before, existing code in the form of:
int a; // this is a.
// This is
// b.
int b;
Got turned into:
int a; // this is a.
// This is
// b.
int b;
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194294 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 794fb1a..e37f0cd 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -787,6 +787,26 @@
"// first\n"
" // at start\n"
"otherLine(); // comment"));
+ verifyFormat("f(); // comment\n"
+ "// first\n"
+ "// at start\n"
+ "otherLine();");
+ EXPECT_EQ("f(); // comment\n"
+ "// first\n"
+ "// at start\n"
+ "otherLine();",
+ format("f(); // comment\n"
+ "// first\n"
+ " // at start\n"
+ "otherLine();"));
+ EXPECT_EQ("f(); // comment\n"
+ " // first\n"
+ "// at start\n"
+ "otherLine();",
+ format("f(); // comment\n"
+ " // first\n"
+ "// at start\n"
+ "otherLine();"));
}
TEST_F(FormatTest, CanFormatCommentsLocally) {