aboutsummaryrefslogtreecommitdiff
path: root/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-02-15 11:07:25 +0000
committerDaniel Jasper <djasper@google.com>2013-02-15 11:07:25 +0000
commit7878a7bdebceaa8d8a893abb295027cde619e467 (patch)
treeda8028738de74974b5dfc15f60067f25b4cc169c /unittests/Format/FormatTest.cpp
parentc1ea4b96adca4767991bb0a7b21052cef4db059c (diff)
Prevent only breaking before "?" in conditional expressions.
This is almost always more readable. Before: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaaaaaaa; After: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaaaaaaa; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175262 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format/FormatTest.cpp')
-rw-r--r--unittests/Format/FormatTest.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 9dab260512..8c45325ecc 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -1323,11 +1323,20 @@ TEST_F(FormatTest, BreaksConditionalExpressions) {
" : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa),\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaa);");
+
+ verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
+ " ? aaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
+ " : aaaaaaaaaaaaaaaaaaaaaaaaaaa;");
+
+ // FIXME: The trailing third parameter here is kind of hidden. Prefer putting
+ // it on the next line.
verifyFormat(
- "unsigned Indent = formatFirstToken(\n"
- " TheLine.First, IndentForLevel[TheLine.Level] >= 0\n"
- " ? IndentForLevel[TheLine.Level] : TheLine * 2,\n"
- " TheLine.InPPDirective, PreviousEndOfLineColumn);");
+ "unsigned Indent =\n"
+ " format(TheLine.First, IndentForLevel[TheLine.Level] >= 0\n"
+ " ? IndentForLevel[TheLine.Level]\n"
+ " : TheLine * 2, TheLine.InPPDirective,\n"
+ " PreviousEndOfLineColumn);", getLLVMStyleWithColumns(70));
+
}
TEST_F(FormatTest, DeclarationsOfMultipleVariables) {