Don't simply give up when exceeding 80cols, choose an "ok" option.
This addresses llvm.org/PR14847.
We can now format something like:
int aaaaaaaaaaaaaaaaaaaaaaaaaaa =
// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaiaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
clang-format unavoidably exceeds the column limit, but does not just
flush everything into a single line. Moreover, it tries to minimize the
number of characters beyond the column limit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171964 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 56d4e17..495fc7f 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -1026,6 +1026,15 @@
// Error recovery tests.
//===----------------------------------------------------------------------===//
+TEST_F(FormatTest, IndentationWithinColumnLimitNotPossible) {
+ verifyFormat("int aaaaaaaa =\n"
+ " // Overly long comment\n"
+ " b;", getLLVMStyleWithColumns(20));
+ verifyFormat("function(\n"
+ " ShortArgument,\n"
+ " LoooooooooooongArgument);\n", getLLVMStyleWithColumns(20));
+}
+
TEST_F(FormatTest, IncorrectAccessSpecifier) {
verifyFormat("public:");
verifyFormat("class A {\n"