aboutsummaryrefslogtreecommitdiff
path: root/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-01-16 15:44:34 +0000
committerDaniel Jasper <djasper@google.com>2013-01-16 15:44:34 +0000
commitdf3736aa70443ac0f33af094989b4ba88d73f568 (patch)
tree58dee32bdd6068bca3dae7608bc59c3dffc65139 /unittests/Format/FormatTest.cpp
parent0df6acdf4f6faf7579775a739e1c09448c076c0f (diff)
Disable inlining of short ifs in Google style.
Various reasons seem to speak against it, so I am disabling this for now. Changed tests to still test this option. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172618 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format/FormatTest.cpp')
-rw-r--r--unittests/Format/FormatTest.cpp40
1 files changed, 24 insertions, 16 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 066e8881eb..7d8ed14191 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -151,23 +151,31 @@ TEST_F(FormatTest, FormatIfWithoutCompountStatement) {
verifyFormat("if (true)\n f();\ng();");
verifyFormat("if (a)\n if (b)\n if (c)\n g();\nh();");
verifyFormat("if (a)\n if (b) {\n f();\n }\ng();");
- verifyGoogleFormat("if (a)\n"
- " // comment\n"
- " f();");
- verifyFormat("if (a) return;", getGoogleStyleWithColumns(14));
- verifyFormat("if (a)\n return;", getGoogleStyleWithColumns(13));
+
+ FormatStyle AllowsMergedIf = getGoogleStyle();
+ AllowsMergedIf.AllowShortIfStatementsOnASingleLine = true;
+ verifyFormat("if (a)\n"
+ " // comment\n"
+ " f();", AllowsMergedIf);
+
+ verifyFormat("if (a) // Can't merge this\n"
+ " f();\n", AllowsMergedIf);
+ verifyFormat("if (a) /* still don't merge */\n"
+ " f();", AllowsMergedIf);
+ verifyFormat("if (a) { // Never merge this\n"
+ " f();\n"
+ "}", AllowsMergedIf);
+ verifyFormat("if (a) { /* Never merge this */\n"
+ " f();\n"
+ "}", AllowsMergedIf);
+
+ AllowsMergedIf.ColumnLimit = 14;
+ verifyFormat("if (a) return;", AllowsMergedIf);
verifyFormat("if (aaaaaaaaa)\n"
- " return;", getGoogleStyleWithColumns(14));
- verifyGoogleFormat("if (a) // Can't merge this\n"
- " f();\n");
- verifyGoogleFormat("if (a) /* still don't merge */\n"
- " f();");
- verifyGoogleFormat("if (a) { // Never merge this\n"
- " f();\n"
- "}");
- verifyGoogleFormat("if (a) { /* Never merge this */\n"
- " f();\n"
- "}");
+ " return;", AllowsMergedIf);
+
+ AllowsMergedIf.ColumnLimit = 13;
+ verifyFormat("if (a)\n return;", AllowsMergedIf);
}
TEST_F(FormatTest, ParseIfElse) {