From e9f5357f495dabedcc84bd956da7c357d8547fd1 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Thu, 30 Apr 2015 09:24:17 +0000 Subject: clang-format: Don't merge short else blocks. Before (with the appropriate flags settings): if (a) { f(); } else { g(); } Before (with other appropriate flags settings): if (a) { f(); } else { g(); } After: if (a) { f(); } else { g(); } llvm-svn: 236217 --- clang/unittests/Format/FormatTest.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'clang/unittests/Format/FormatTest.cpp') diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 9f340042c43..e2db4d10b95 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -416,6 +416,12 @@ TEST_F(FormatTest, FormatShortBracedStatements) { " f();\n" "}", AllowSimpleBracedStatements); + verifyFormat("if (true) {\n" + " f();\n" + "} else {\n" + " f();\n" + "}", + AllowSimpleBracedStatements); verifyFormat("template struct A2 {\n" " struct B {};\n" @@ -427,6 +433,12 @@ TEST_F(FormatTest, FormatShortBracedStatements) { " f();\n" "}", AllowSimpleBracedStatements); + verifyFormat("if (true) {\n" + " f();\n" + "} else {\n" + " f();\n" + "}", + AllowSimpleBracedStatements); AllowSimpleBracedStatements.AllowShortLoopsOnASingleLine = false; verifyFormat("while (true) {\n" -- cgit v1.2.3