aboutsummaryrefslogtreecommitdiff
path: root/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-03-04 13:43:19 +0000
committerDaniel Jasper <djasper@google.com>2013-03-04 13:43:19 +0000
commit1eee6c4269af28eb4e3500de7fc39c1eb8b26aa3 (patch)
treee7f9fe5d413c438122fa3ec1186d3fb9a625b4c2 /unittests/Format/FormatTest.cpp
parente3a2b81429d935e3cfafa4c3ad1b21b957653165 (diff)
Format a line if a range in its leading whitespace was selected.
With [] marking the selected range, clang-format invoked on [ ] int a; Would so far not reformat anything. With this patch, it formats a line if its leading whitespace is touched. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176435 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format/FormatTest.cpp')
-rw-r--r--unittests/Format/FormatTest.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 8cedfcedfd..46eb1bcfdf 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -172,6 +172,28 @@ TEST_F(FormatTest, RemovesTrailingWhitespaceOfFormattedLine) {
format("int a; \nint b; ", 0, 0, getLLVMStyle()));
}
+TEST_F(FormatTest, FormatsCorrectRegionForLeadingWhitespace) {
+ EXPECT_EQ("int b;\nint a;",
+ format("int b;\n int a;", 7, 0, getLLVMStyle()));
+ EXPECT_EQ("int b;\n int a;",
+ format("int b;\n int a;", 6, 0, getLLVMStyle()));
+
+ EXPECT_EQ("#define A \\\n"
+ " int a; \\\n"
+ " int b;",
+ format("#define A \\\n"
+ " int a; \\\n"
+ " int b;",
+ 26, 0, getLLVMStyleWithColumns(12)));
+ EXPECT_EQ("#define A \\\n"
+ " int a; \\\n"
+ " int b;",
+ format("#define A \\\n"
+ " int a; \\\n"
+ " int b;",
+ 25, 0, getLLVMStyleWithColumns(12)));
+}
+
TEST_F(FormatTest, ReformatsMovedLines) {
EXPECT_EQ(
"template <typename T> T *getFETokenInfo() const {\n"