diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 40e2cb054b242..d7d69f950a323 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1573,6 +1573,17 @@ TEST_F(FormatTest, FormatShortBracedStatements) { " f();\n" "}"); + AllowSimpleBracedStatements.AllowShortBlocksOnASingleLine = + FormatStyle::SBS_Empty; + AllowSimpleBracedStatements.AllowShortIfStatementsOnASingleLine = + FormatStyle::SIS_WithoutElse; + verifyFormat("if (true) {}", AllowSimpleBracedStatements); + verifyFormat("if (i) break;", AllowSimpleBracedStatements); + verifyFormat("if (i > 0) {\n" + " return i;\n" + "}", + AllowSimpleBracedStatements); + AllowSimpleBracedStatements.IfMacros.push_back("MYIF"); // Where line-lengths matter, a 2-letter synonym that maintains line length. // Not IF to avoid any confusion that IF is somehow special. @@ -1580,11 +1591,7 @@ TEST_F(FormatTest, FormatShortBracedStatements) { AllowSimpleBracedStatements.ColumnLimit = 40; AllowSimpleBracedStatements.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Always; - - AllowSimpleBracedStatements.AllowShortIfStatementsOnASingleLine = - FormatStyle::SIS_WithoutElse; AllowSimpleBracedStatements.AllowShortLoopsOnASingleLine = true; - AllowSimpleBracedStatements.BreakBeforeBraces = FormatStyle::BS_Custom; AllowSimpleBracedStatements.BraceWrapping.AfterFunction = true; AllowSimpleBracedStatements.BraceWrapping.SplitEmptyRecord = false;