aboutsummaryrefslogtreecommitdiff
path: root/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2013-02-08 17:38:27 +0000
committerManuel Klimek <klimek@google.com>2013-02-08 17:38:27 +0000
commit547d5db5ed482e23edf62130ffdee86ba810d432 (patch)
tree173b5aca5a24e38d3001557325f9dcef8c98f7f9 /unittests/Format/FormatTest.cpp
parentbfaa111e7106ad15a73513d953a1a19a7b626f10 (diff)
Takes the context into account when re-indenting regions.
Fixes llvm.org/PR14916. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174720 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format/FormatTest.cpp')
-rw-r--r--unittests/Format/FormatTest.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 997a55353b..df0b2962f2 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -2544,5 +2544,56 @@ TEST_F(FormatTest, ObjCLiterals) {
}
+TEST_F(FormatTest, ReformatRegionAdjustsIndent) {
+ EXPECT_EQ("{\n"
+ "{\n"
+ "a;\n"
+ "b;\n"
+ "}\n"
+ "}", format("{\n"
+ "{\n"
+ "a;\n"
+ " b;\n"
+ "}\n"
+ "}", 13, 2, getLLVMStyle()));
+ EXPECT_EQ("{\n"
+ "{\n"
+ " a;\n"
+ "b;\n"
+ "}\n"
+ "}", format("{\n"
+ "{\n"
+ " a;\n"
+ "b;\n"
+ "}\n"
+ "}", 9, 2, getLLVMStyle()));
+ EXPECT_EQ("{\n"
+ "{\n"
+ "public:\n"
+ " b;\n"
+ "}\n"
+ "}", format("{\n"
+ "{\n"
+ "public:\n"
+ " b;\n"
+ "}\n"
+ "}", 17, 2, getLLVMStyle()));
+ EXPECT_EQ("{\n"
+ "{\n"
+ "a;\n"
+ "}\n"
+ "{\n"
+ " b;\n"
+ "}\n"
+ "}", format("{\n"
+ "{\n"
+ "a;\n"
+ "}\n"
+ "{\n"
+ " b;\n"
+ "}\n"
+ "}", 22, 2, getLLVMStyle()));
+}
+
} // end namespace tooling
} // end namespace clang