clang-format: Make continuation indent width configurable.
Patch by Kim Gräsman. Thank you!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192964 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 5a8b5d6..1e898d8 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -6495,6 +6495,7 @@
CHECK_PARSE("SpacesBeforeTrailingComments: 1234",
SpacesBeforeTrailingComments, 1234u);
CHECK_PARSE("IndentWidth: 32", IndentWidth, 32u);
+ CHECK_PARSE("ContinuationIndentWidth: 11", ContinuationIndentWidth, 11u);
Style.Standard = FormatStyle::LS_Auto;
CHECK_PARSE("Standard: Cpp03", Standard, FormatStyle::LS_Cpp03);
@@ -6876,5 +6877,23 @@
"};");
}
+TEST_F(FormatTest, ConfigurableContinuationIndentWidth) {
+ FormatStyle TwoIndent = getLLVMStyleWithColumns(15);
+ TwoIndent.ContinuationIndentWidth = 2;
+
+ EXPECT_EQ("int i =\n"
+ " longFunction(\n"
+ " arg);",
+ format("int i = longFunction(arg);", TwoIndent));
+
+ FormatStyle SixIndent = getLLVMStyleWithColumns(20);
+ SixIndent.ContinuationIndentWidth = 6;
+
+ EXPECT_EQ("int i =\n"
+ " longFunction(\n"
+ " arg);",
+ format("int i = longFunction(arg);", SixIndent));
+}
+
} // end namespace tooling
} // end namespace clang