aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-04-05 09:38:50 +0000
committerDaniel Jasper <djasper@google.com>2013-04-05 09:38:50 +0000
commitadc0f09585f10061007ec529451a6dd10f86fea6 (patch)
tree964a4c4fef1bcb886c258a464b36ad2f432b3d07 /unittests
parent50f9de5d893694a7e46ba655ec9fce5dfeae9362 (diff)
Improve formatting of multi-variable DeclStmts.
This fixed llvm.org/PR15670 Before: aaaaaaaaa a = aaaaaaaaaaaaaaaaaaaa, b = bbbbbbbbbbbbbbbbbbbb, c = cccccccccccccccccccc, d = dddddddddddddddddddd; aaaaaaaaa *a = aaaaaaaaaaaaaaaaaaa, *b = bbbbbbbbbbbbbbbbbbb, *c = ccccccccccccccccccc, *d = ddddddddddddddddddd; After: aaaaaaaaa a = aaaaaaaaaaaaaaaaaaaa, b = bbbbbbbbbbbbbbbbbbbb, c = cccccccccccccccccccc, d = dddddddddddddddddddd; aaaaaaaaa *a = aaaaaaaaaaaaaaaaaaa, *b = bbbbbbbbbbbbbbbbbbb, *c = ccccccccccccccccccc, *d = ddddddddddddddddddd; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178860 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Format/FormatTest.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 2038ee167f..e01034b09a 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -1864,7 +1864,22 @@ TEST_F(FormatTest, DeclarationsOfMultipleVariables) {
"bool aaaaaaaaaaaaaaaaaaaaa =\n"
" bbbbbbbbbbbbbbbbbbbbbbbbbbbb && cccccccccccccccccccccccccccc,\n"
" d = e && f;");
-
+ verifyFormat("aaaaaaaaa a = aaaaaaaaaaaaaaaaaaaa, b = bbbbbbbbbbbbbbbbbbbb,\n"
+ " c = cccccccccccccccccccc, d = dddddddddddddddddddd;");
+ verifyFormat("aaaaaaaaa *a = aaaaaaaaaaaaaaaaaaa, *b = bbbbbbbbbbbbbbbbbbb,\n"
+ " *c = ccccccccccccccccccc, *d = ddddddddddddddddddd;");
+ verifyFormat("aaaaaaaaa ***a = aaaaaaaaaaaaaaaaaaa, ***b = bbbbbbbbbbbbbbb,\n"
+ " ***c = ccccccccccccccccccc, ***d = ddddddddddddddd;");
+ // FIXME: If multiple variables are defined, the "*" needs to move to the new
+ // line. Also fix indent for breaking after the type, this looks bad.
+ verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *\n"
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaa,\n"
+ " *b = bbbbbbbbbbbbbbbbbbb;");
+
+ // Not ideal, but pointer-with-type does not allow much here.
+ verifyGoogleFormat(
+ "aaaaaaaaa* a = aaaaaaaaaaaaaaaaaaa, *b = bbbbbbbbbbbbbbbbbbb,\n"
+ " *b = bbbbbbbbbbbbbbbbbbb, *d = ddddddddddddddddddd;");
}
TEST_F(FormatTest, ConditionalExpressionsInBrackets) {