summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 32f9d95d668..a26bf607214 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -876,6 +876,16 @@ TEST_F(FormatTest, SplitsLongCxxComments) {
format("// A comment before a macro definition\n"
"#define a b",
getLLVMStyleWithColumns(20)));
+ EXPECT_EQ("void ffffff(int aaaaaaaaa, // wwww\n"
+ " int a, int bbb, // xxxxxxx\n"
+ " // yyyyyyyyy\n"
+ " int c, int d, int e) {}",
+ format("void ffffff(\n"
+ " int aaaaaaaaa, // wwww\n"
+ " int a,\n"
+ " int bbb, // xxxxxxx yyyyyyyyy\n"
+ " int c, int d, int e) {}",
+ getLLVMStyleWithColumns(40)));
}
TEST_F(FormatTest, PriorityOfCommentBreaking) {
@@ -2456,6 +2466,14 @@ TEST_F(FormatTest, BreaksDesireably) {
" Line.Tokens[i - 1].Tok.isNot(tok::l_paren) &&\n"
" Line.Tokens[i - 1].Tok.isNot(tok::l_square);\n"
" }\n }\n}");
+
+ // Break on an outer level if there was a break on an inner level.
+ EXPECT_EQ("f(g(h(a, // comment\n"
+ " b, c),\n"
+ " d, e),\n"
+ " x, y);",
+ format("f(g(h(a, // comment\n"
+ " b, c), d, e), x, y);"));
}
TEST_F(FormatTest, FormatsOneParameterPerLineIfNecessary) {
@@ -4565,6 +4583,18 @@ TEST_F(FormatTest, BreakStringLiterals) {
format("variable = f(\"long string literal\", short, "
"loooooooooooooooooooong);",
getLLVMStyleWithColumns(20)));
+
+ EXPECT_EQ("f(g(\"long string \"\n"
+ " \"literal\"),\n"
+ " b);",
+ format("f(g(\"long string literal\"), b);",
+ getLLVMStyleWithColumns(20)));
+ EXPECT_EQ("f(g(\"long string \"\n"
+ " \"literal\",\n"
+ " a),\n"
+ " b);",
+ format("f(g(\"long string literal\", a), b);",
+ getLLVMStyleWithColumns(20)));
EXPECT_EQ(
"f(\"one two\".split(\n"
" variable));",
OpenPOWER on IntegriCloud