]> granicus.if.org Git - clang/commitdiff
clang-format: Add test for AlignAfterOpenBracket = AlwaysBreak in C++.
authorDaniel Jasper <djasper@google.com>
Mon, 14 Dec 2015 08:41:18 +0000 (08:41 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 14 Dec 2015 08:41:18 +0000 (08:41 +0000)
Revision 251405 added AlwaysBreak to support Google's JavaScript style. This
changeset complete existing AlignsAfterOpenBracket tests to exercise
AlwaysBreak for C++.

I thought this would be worthwhile.  With this option we can support request
from http://lists.llvm.org/pipermail/cfe-dev/2015-May/042942.html, that had
been requested a few times. This also partially solve related Bug 23422 and is
probably sufficient for most people.

  AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
  BinPackArguments = false;
  BinPackParameters = false;

With these setting we obtain this formatting:

  void fooWithAVeryLongParamList(
      int firstParameter,
      int secondParameter
      int lastParameter)
  {
      object.alsoThisDoenstFitSoIBreakImmidiatly(
          firstParameter,
          secondParameter,
          lastParameter);
  }

Patch by Jean-Philippe Dufraigne, thank you.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@255486 91177308-0d34-0410-b5e6-96231b3b80d8

unittests/Format/FormatTest.cpp

index ecaf8d804f6857600e50f90a0a2516d2e84d3355..e43453dd17fa6a138a378046cf32525fa94b5e1d 100644 (file)
@@ -4371,6 +4371,26 @@ TEST_F(FormatTest, AlignsAfterOpenBracket) {
       "SomeLongVariableName->someFunction(foooooooo(aaaaaaaaaaaaaaa,\n"
       "    aaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa));",
       Style);
+
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BinPackArguments = false;
+  Style.BinPackParameters = false;
+  verifyFormat("void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+               "    aaaaaaaaaaa aaaaaaaa,\n"
+               "    aaaaaaaaa aaaaaaa,\n"
+               "    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}",
+               Style);
+  verifyFormat("SomeLongVariableName->someVeryLongFunctionName(\n"
+               "    aaaaaaaaaaa aaaaaaaaa,\n"
+               "    aaaaaaaaaaa aaaaaaaaa,\n"
+               "    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);",
+               Style);
+  verifyFormat("SomeLongVariableName->someFunction(\n"
+               "    foooooooo(\n"
+               "        aaaaaaaaaaaaaaa,\n"
+               "        aaaaaaaaaaaaaaaaaaaaa,\n"
+               "        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa));",
+               Style);
 }
 
 TEST_F(FormatTest, ParenthesesAndOperandAlignment) {