atirit updated this revision to Diff 314296.
atirit added a comment.

Added unit test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93938

Files:
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1352,6 +1352,49 @@
                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, AfterEnum2;", Style);
+  verifyFormat("enum\n"
+               "{\n"
+               "  A,\n"
+               "  B, // foo\n"
+               "  C\n"
+               "} Test2,\n"
+               "    AfterEnum2;",
+               Style);
+  Style.BraceWrapping.AfterEnum = false;
+  verifyFormat("enum { A, B, C } Test3, AfterEnum2;", Style);
+  verifyFormat("enum {\n"
+               "  A,\n"
+               "  B, // foo\n"
+               "  C\n"
+               "} Test4,\n"
+               "    AfterEnum2;",
+               Style);
+
+  Style.AllowShortEnumsOnASingleLine = false;
+  Style.BraceWrapping.AfterEnum = true;
+  verifyFormat("enum\n"
+               "{\n"
+               "  A,\n"
+               "  B,\n"
+               "  C\n"
+               "} Test5, AfterEnum2;",
+               Style);
+  Style.BraceWrapping.AfterEnum = false;
+  verifyFormat("enum {\n"
+               "  A,\n"
+               "  B,\n"
+               "  C\n"
+               "} Test6, AfterEnum2;",
+               Style);
+}
+
 TEST_F(FormatTest, ShortCaseLabels) {
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortCaseLabelsOnASingleLine = true;


Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1352,6 +1352,49 @@
                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, AfterEnum2;", Style);
+  verifyFormat("enum\n"
+               "{\n"
+               "  A,\n"
+               "  B, // foo\n"
+               "  C\n"
+               "} Test2,\n"
+               "    AfterEnum2;",
+               Style);
+  Style.BraceWrapping.AfterEnum = false;
+  verifyFormat("enum { A, B, C } Test3, AfterEnum2;", Style);
+  verifyFormat("enum {\n"
+               "  A,\n"
+               "  B, // foo\n"
+               "  C\n"
+               "} Test4,\n"
+               "    AfterEnum2;",
+               Style);
+
+  Style.AllowShortEnumsOnASingleLine = false;
+  Style.BraceWrapping.AfterEnum = true;
+  verifyFormat("enum\n"
+               "{\n"
+               "  A,\n"
+               "  B,\n"
+               "  C\n"
+               "} Test5, AfterEnum2;",
+               Style);
+  Style.BraceWrapping.AfterEnum = false;
+  verifyFormat("enum {\n"
+               "  A,\n"
+               "  B,\n"
+               "  C\n"
+               "} Test6, AfterEnum2;",
+               Style);
+}
+
 TEST_F(FormatTest, ShortCaseLabels) {
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortCaseLabelsOnASingleLine = true;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to