diff options
author | Alexander Kornienko <alexfh@google.com> | 2013-12-04 12:21:08 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2013-12-04 12:21:08 +0000 |
commit | 31e9554024e3c3f3ab2c406a489abd285bcdfc93 (patch) | |
tree | 45f1a4e96f0bfdbad1214f7f4cd73a61e05a49ee /clang/unittests/Format/FormatTest.cpp | |
parent | 0dc10d55dadb669fd476f483943fbbb24148e264 (diff) | |
download | bcm5719-llvm-31e9554024e3c3f3ab2c406a489abd285bcdfc93.tar.gz bcm5719-llvm-31e9554024e3c3f3ab2c406a489abd285bcdfc93.zip |
Leave constructor initializer lists on one line in styles with no column limit.
Summary:
Allow tryFitMultipleLinesInOne join unwrapped lines when
ContinuationIndenter::mustBreak doesn't agree. But don't merge any lines, that
are separate in the input.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D2321
llvm-svn: 196378
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 88b2a0b31a5..f5a0bdd6341 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -4891,6 +4891,28 @@ TEST_F(FormatTest, PullTrivialFunctionDefinitionsIntoSingleLine) { verifyFormat("void f() {}", getLLVMStyleWithColumns(11)); verifyFormat("void f() {\n}", getLLVMStyleWithColumns(10)); + + FormatStyle NoColumnLimit = getLLVMStyle(); + NoColumnLimit.ColumnLimit = 0; + EXPECT_EQ("A() : b(0) {}", format("A():b(0){}", NoColumnLimit)); + EXPECT_EQ("class C {\n" + " A() : b(0) {}\n" + "};", format("class C{A():b(0){}};", NoColumnLimit)); + EXPECT_EQ("A()\n" + " : b(0) {\n" + "}", + format("A()\n:b(0)\n{\n}", NoColumnLimit)); + + FormatStyle DoNotMergeNoColumnLimit = NoColumnLimit; + DoNotMergeNoColumnLimit.AllowShortFunctionsOnASingleLine = false; + EXPECT_EQ("A()\n" + " : b(0) {\n" + "}", + format("A():b(0){}", DoNotMergeNoColumnLimit)); + EXPECT_EQ("A()\n" + " : b(0) {\n" + "}", + format("A()\n:b(0)\n{\n}", DoNotMergeNoColumnLimit)); } TEST_F(FormatTest, UnderstandContextOfRecordTypeKeywords) { @@ -7340,12 +7362,18 @@ TEST_F(FormatTest, FormatsWithWebKitStyle) { // Constructor initializers are formatted one per line with the "," on the // new line. - verifyFormat("Constructor()\n" - " : aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" - " , aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaa, // break\n" - " aaaaaaaaaaaaaa)\n" - " , aaaaaaaaaaaaaaaaaaaaaaa() {}", - Style); + EXPECT_EQ( + "Constructor()\n" + " : aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" + " , aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaa, // break\n" + " aaaaaaaaaaaaaa)\n" + " , aaaaaaaaaaaaaaaaaaaaaaa() {}", + format("Constructor()\n" + " : aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" + " , aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaa, // break\n" + " aaaaaaaaaaaaaa)\n" + " , aaaaaaaaaaaaaaaaaaaaaaa() {}", + Style)); // Access specifiers should be aligned left. verifyFormat("class C {\n" |