[clang] [clang-format] Change BinPackParameters to an enum to add a BreakAlways (PR #101882)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 17 01:14:17 PDT 2024


================
@@ -362,6 +362,26 @@ TEST_F(FormatTestComments, KeepsParameterWithTrailingCommentsOnTheirOwnLine) {
             format("aaaaaaaaaa(aaaa(aaaa,\n"
                    "aaaa), //\n"
                    "aaaa, bbbbb);"));
+
+  FormatStyle BreakAlways = getLLVMStyle();
+  BreakAlways.BinPackParameters = FormatStyle::BPPS_OnePerLine;
+  EXPECT_EQ("SomeFunction(a,\n"
+            "             b, // comment\n"
+            "             c,\n"
+            "             d);",
+            format("SomeFunction(a,\n"
+                   "          b, // comment\n"
+                   "      c, d);",
+                   BreakAlways));
+  EXPECT_EQ("SomeFunction(a,\n"
+            "             b,\n"
+            "             // comment\n"
+            "             c);",
+            format("SomeFunction(a,\n"
+                   "          b,\n"
+                   "  // comment\n"
+                   "      c);",
+                   BreakAlways));
----------------
owenca wrote:

Please use `verifyFormat()` instead.

https://github.com/llvm/llvm-project/pull/101882


More information about the cfe-commits mailing list