diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp --- a/clang/unittests/Format/FormatTest.cpp +++ b/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;