summaryrefslogtreecommitdiffstats
path: root/unittests
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-11-18 23:55:27 +0000
committerDaniel Jasper <djasper@google.com>2014-11-18 23:55:27 +0000
commit39ce853225c88b0ecd00fdae8a6f00f5d7c91fef (patch)
tree3ed6e134b39a38bc9ba680b4d97ec51fda5ada20 /unittests
parent5ba90485a05f5e6431bca36ba1c64c3cbce80def (diff)
clang-format: Add option to disable alignment after opening brackets
Before: SomeFunction(parameter, parameter); After: SomeFunction(parameter, parameter); Patch by Harry Terkelsen, thank you! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222284 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Format/FormatTest.cpp40
-rw-r--r--unittests/Format/FormatTestJava.cpp11
2 files changed, 50 insertions, 1 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index cada2bf6d7..a6bbe16d86 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -4026,6 +4026,44 @@ TEST_F(FormatTest, AlignsAfterReturn) {
" code == a || code == b;");
}
+TEST_F(FormatTest, AlignsAfterOpenBracket) {
+ verifyFormat(
+ "void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaa aaaaaaaa,\n"
+ " aaaaaaaaa aaaaaaa) {}");
+ verifyFormat(
+ "SomeLongVariableName->someVeryLongFunctionName(aaaaaaaaaaa aaaaaaaaa,\n"
+ " aaaaaaaaaaa aaaaaaaaa);");
+ verifyFormat(
+ "SomeLongVariableName->someFunction(foooooooo(aaaaaaaaaaaaaaa,\n"
+ " aaaaaaaaaaaaaaaaaaaaa));");
+ FormatStyle Style = getLLVMStyle();
+ Style.AlignAfterOpenBracket = false;
+ verifyFormat(
+ "void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+ " aaaaaaaaaaa aaaaaaaa, aaaaaaaaa aaaaaaa) {}",
+ Style);
+ verifyFormat(
+ "SomeLongVariableName->someVeryLongFunctionName(\n"
+ " aaaaaaaaaaa aaaaaaaaa, aaaaaaaaaaa aaaaaaaaa);",
+ Style);
+ verifyFormat(
+ "SomeLongVariableName->someFunction(\n"
+ " foooooooo(aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaa));",
+ Style);
+ verifyFormat(
+ "void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaa aaaaaaaa,\n"
+ " aaaaaaaaa aaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}",
+ Style);
+ verifyFormat(
+ "SomeLongVariableName->someVeryLongFunctionName(aaaaaaaaaaa aaaaaaaaa,\n"
+ " aaaaaaaaaaa aaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);",
+ Style);
+ verifyFormat(
+ "SomeLongVariableName->someFunction(foooooooo(aaaaaaaaaaaaaaa,\n"
+ " aaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa));",
+ Style);
+}
+
TEST_F(FormatTest, BreaksConditionalExpressions) {
verifyFormat(
"aaaa(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaa\n"
@@ -9088,7 +9126,7 @@ TEST_F(FormatTest, FormatsWithWebKitStyle) {
verifyFormat("Constructor()\n"
" : aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"
" , aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaa, // break\n"
- " aaaaaaaaaaaaaa)\n"
+ " aaaaaaaaaaaaaa)\n"
" , aaaaaaaaaaaaaaaaaaaaaaa()\n"
"{\n"
"}",
diff --git a/unittests/Format/FormatTestJava.cpp b/unittests/Format/FormatTestJava.cpp
index d60ab965b9..57a0d51542 100644
--- a/unittests/Format/FormatTestJava.cpp
+++ b/unittests/Format/FormatTestJava.cpp
@@ -264,5 +264,16 @@ TEST_F(FormatTestJava, ImportDeclarations) {
getStyleWithColumns(50));
}
+TEST_F(FormatTestJava, MethodDeclarations) {
+ verifyFormat("void methodName(Object arg1,\n"
+ " Object arg2, Object arg3) {\n"
+ "}",
+ getStyleWithColumns(40));
+ verifyFormat("void methodName(\n"
+ " Object arg1, Object arg2) {\n"
+ "}",
+ getStyleWithColumns(40));
+}
+
} // end namespace tooling
} // end namespace clang