summaryrefslogtreecommitdiffstats
path: root/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorIvan Donchevskii <ivan.donchevskii@qt.io>2018-10-12 08:19:25 +0200
committerIvan Donchevskii <ivan.donchevskii@qt.io>2019-04-04 06:32:38 +0000
commitfa1b9053729ec6a4425a44ec5502dd388928274a (patch)
tree1fd37f1e5874b79f463c782faa6023e2f12f99c4 /unittests/Format/FormatTest.cpp
parent1c6ea8a0b9c22d674854c09460e2bee4bbd1725b (diff)
[clang-format] Introduce the flag which allows not to shrink lines
-------------------------------------------------------------------------- * https://reviews.llvm.org/D53072 -------------------------------------------------------------------------- Currently there's no way to prevent to lines optimization even if you have intentionally put <CR> to split the line. In general case it's fine. So I would prefer to have such option which you can enable in special cases (for me it's an IDE related use case). Revert this change if upstream clang-format offers better solution. This is a cherry pick from commits b748c82e3664c2e2e3d29645ede472d87b8cde63 and 1817513d4f3a2e4e26be124dbe395340f798fd51. Change-Id: I9d2935b937bb68ea8dc59fac8463718475e9c080 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'unittests/Format/FormatTest.cpp')
-rw-r--r--unittests/Format/FormatTest.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index c05fceb476..38906d9ee3 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -385,6 +385,22 @@ TEST_F(FormatTest, RemovesEmptyLines) {
" void funk() {}\n"
"};",
Style));
+
+ Style.KeepLineBreaksForNonEmptyLines = true;
+ Style.ColumnLimit = 0;
+ EXPECT_EQ("int foo(int a,\n"
+ " int b)\n"
+ "{\n"
+ "}",
+ format("int foo(int a,\n"
+ "int b) {}",
+ Style));
+
+ EXPECT_EQ("[]() {\n"
+ " foo(); }",
+ format("[]() {\n"
+ "foo(); }",
+ Style));
}
TEST_F(FormatTest, RecognizesBinaryOperatorKeywords) {