[PATCH] D93938: [clang-format] Fixed AfterEnum handling

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 3 13:27:31 PST 2021


MyDeveloperDay added inline comments.


================
Comment at: clang/unittests/Format/FormatTest.cpp:1347
   Style.AllowShortEnumsOnASingleLine = false;
+  verifyFormat("enum {\n"
+               "  A,\n"
+               "  B,\n"
+               "  C\n"
+               "} ShortEnum1, ShortEnum2;",
+               Style);
+}
+
+TEST_F(FormatTest, AfterEnum) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+
+  Style.AllowShortEnumsOnASingleLine = true;
+  Style.BraceWrapping.AfterEnum = true;
+  verifyFormat("enum { A, B, C } Test1;", Style);
+  verifyFormat("enum\n"
+               "{\n"
+               "  A,\n"
+               "  B, // foo\n"
+               "  C\n"
+               "} Test2;",
+               Style);
+  Style.BraceWrapping.AfterEnum = false;
+  verifyFormat("enum { A, B, C } Test3;", Style);
+  verifyFormat("enum {\n"
+               "  A,\n"
+               "  B, // foo\n"
+               "  C\n"
+               "} Test4;",
+               Style);
+
+  Style.AllowShortEnumsOnASingleLine = false;
+  Style.BraceWrapping.AfterEnum = true;
   verifyFormat("enum\n"
                "{\n"
----------------
keep this test, you should keep one with 1 name and 1 with 2 names


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93938/new/

https://reviews.llvm.org/D93938



More information about the cfe-commits mailing list