aboutsummaryrefslogtreecommitdiff
path: root/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2012-12-17 14:34:14 +0000
committerDaniel Jasper <djasper@google.com>2012-12-17 14:34:14 +0000
commit9a0b494f999dfd47152565f7bbeaa69b3fef8feb (patch)
tree33aeefdc50fc77eda89d3bb8cccae3acf5cba64d /unittests/Format/FormatTest.cpp
parent61dde19d72a86ad180840ff858fa9a688de81bbc (diff)
Add basic support for splitting before function calls if it can't be
avoided. This required a minor modification of the memoization as now the "CurrentPenalty" depends on whether or not we break before the current token. Therefore, the CurrentPenalty should not be memoized but added after retrieving a value from memory. This should not affect the runtime behavior. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170337 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format/FormatTest.cpp')
-rw-r--r--unittests/Format/FormatTest.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 5ce1022d86..bcac37c007 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -444,6 +444,37 @@ TEST_F(FormatTest, UnderstandsEquals) {
" 100000000 + 100000000) {\n}");
}
+TEST_F(FormatTest, WrapsAtFunctionCallsIfNecessary) {
+ verifyFormat(
+ "LoooooooooooooooooooooooooooooooooooooongObject\n"
+ " .looooooooooooooooooooooooooooooooooooooongFunction();");
+
+ verifyFormat(
+ "LoooooooooooooooooooooooooooooooooooooongObject\n"
+ " ->looooooooooooooooooooooooooooooooooooooongFunction();");
+
+ verifyFormat(
+ "LooooooooooooooooooooooooooooooooongObject->shortFunction(Parameter1,\n"
+ " Parameter2);");
+
+ verifyFormat(
+ "ShortObject->shortFunction(\n"
+ " LooooooooooooooooooooooooooooooooooooooooooooooongParameter1,\n"
+ " LooooooooooooooooooooooooooooooooooooooooooooooongParameter2);");
+
+ verifyFormat("loooooooooooooongFunction(\n"
+ " LoooooooooooooongObject->looooooooooooooooongFunction());");
+
+ verifyFormat(
+ "function(LoooooooooooooooooooooooooooooooooooongObject\n"
+ " ->loooooooooooooooooooooooooooooooooooooooongFunction());");
+
+ verifyFormat(
+ "if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaa) ||\n"
+ " aaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {\n"
+ "}");
+}
+
TEST_F(FormatTest, UnderstandsTemplateParameters) {
verifyFormat("A<int> a;");
verifyFormat("A<A<A<int> > > a;");