Remove unncessary whitespace when triggered on empty line.
With the cursor located at "I", clang-format would not do anything to:
int a;
I
int b;
With this patch, it reduces the number of empty lines as necessary, and
removes unnecessary whitespace. It does not change/reformat "int a;" or
"int b;".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176650 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index eafc4c8..1e92592 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -194,6 +194,13 @@
25, 0, getLLVMStyleWithColumns(12)));
}
+TEST_F(FormatTest, RemovesWhitespaceWhenTriggeredOnEmptyLine) {
+ EXPECT_EQ("int a;\n\n int b;",
+ format("int a;\n \n\n int b;", 7, 0, getLLVMStyle()));
+ EXPECT_EQ("int a;\n\n int b;",
+ format("int a;\n \n\n int b;", 9, 0, getLLVMStyle()));
+}
+
TEST_F(FormatTest, ReformatsMovedLines) {
EXPECT_EQ(
"template <typename T> T *getFETokenInfo() const {\n"