diff options
author | Daniel Jasper <djasper@google.com> | 2015-10-28 01:08:22 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2015-10-28 01:08:22 +0000 |
commit | a1036e5d081dd800c71bdbdf858908b99eed03a4 (patch) | |
tree | b35dd26dec1d3ae5090e6e51389e3c42670af6b3 /clang/unittests/Format/FormatTestSelective.cpp | |
parent | f6bd01097a04635343c97818d157450a8df863b9 (diff) | |
download | bcm5719-llvm-a1036e5d081dd800c71bdbdf858908b99eed03a4.tar.gz bcm5719-llvm-a1036e5d081dd800c71bdbdf858908b99eed03a4.zip |
clang-format: When a line is formatted, also format subsequence lines if their indent is off.
Summary: This is especially important so that if a change is solely inserting a block around a few statements, clang-format-diff.py will still clean up and add indentation to the inner parts.
Reviewers: klimek
Subscribers: cfe-commits, klimek
Differential Revision: http://reviews.llvm.org/D14105
llvm-svn: 251474
Diffstat (limited to 'clang/unittests/Format/FormatTestSelective.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTestSelective.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/clang/unittests/Format/FormatTestSelective.cpp b/clang/unittests/Format/FormatTestSelective.cpp index 8d2cb5a2fcb..a28dfd32e1c 100644 --- a/clang/unittests/Format/FormatTestSelective.cpp +++ b/clang/unittests/Format/FormatTestSelective.cpp @@ -45,8 +45,14 @@ TEST_F(FormatTestSelective, RemovesTrailingWhitespaceOfFormattedLine) { } TEST_F(FormatTestSelective, FormatsCorrectRegionForLeadingWhitespace) { - EXPECT_EQ("int b;\nint a;", format("int b;\n int a;", 7, 0)); - EXPECT_EQ("int b;\n int a;", format("int b;\n int a;", 6, 0)); + EXPECT_EQ("{int b;\n" + " int a;\n" + "}", + format("{int b;\n int a;}", 8, 0)); + EXPECT_EQ("{\n" + " int b;\n" + " int a;}", + format("{int b;\n int a;}", 7, 0)); Style.ColumnLimit = 12; EXPECT_EQ("#define A \\\n" @@ -84,11 +90,11 @@ TEST_F(FormatTestSelective, ReformatsMovedLines) { "template <typename T> T *getFETokenInfo() const {\n" " return static_cast<T *>(FETokenInfo);\n" "}\n" - " int a; // <- Should not be formatted", + "int a; // <- Should not be formatted", format( "template<typename T>\n" "T *getFETokenInfo() const { return static_cast<T*>(FETokenInfo); }\n" - " int a; // <- Should not be formatted", + "int a; // <- Should not be formatted", 9, 5)); } @@ -142,12 +148,12 @@ TEST_F(FormatTestSelective, FormatsCommentsLocally) { " // is\n" " // a\n" "\n" - " // This is unrelated", + "//This is unrelated", format("int a; // This\n" " // is\n" " // a\n" "\n" - " // This is unrelated", + "//This is unrelated", 0, 0)); EXPECT_EQ("int a;\n" "// This is\n" @@ -310,13 +316,17 @@ TEST_F(FormatTestSelective, ReformatRegionAdjustsIndent) { EXPECT_EQ("{\n" "{\n" " a;\n" - "b;\n" + " b;\n" + " c;\n" + " d;\n" "}\n" "}", format("{\n" "{\n" " a;\n" - "b;\n" + " b;\n" + " c;\n" + " d;\n" "}\n" "}", 9, 2)); |