diff options
author | Krasimir Georgiev <krasimir@google.com> | 2018-06-11 12:53:25 +0000 |
---|---|---|
committer | Krasimir Georgiev <krasimir@google.com> | 2018-06-11 12:53:25 +0000 |
commit | 8b98f5517f241ea07009cfb7c17588513c7e06ef (patch) | |
tree | 5cc7170fcff4abf3151552725d88976b8c85e13e /clang/unittests/Format/FormatTestRawStrings.cpp | |
parent | 5f8ede4f0dbf14d34088438cb92a5bfc5cf16406 (diff) | |
download | bcm5719-llvm-8b98f5517f241ea07009cfb7c17588513c7e06ef.tar.gz bcm5719-llvm-8b98f5517f241ea07009cfb7c17588513c7e06ef.zip |
[clang-format] text protos: put entries on separate lines if there is a submessage
Summary:
This patch updates clang-format text protos to put entries of a submessage into separate lines if the submessage contains at least two entries and contains at least one submessage entry.
For example, the entries here are kept on separate lines even if putting them on a single line would be under the column limit:
```
message: {
entry: 1
submessage: { key: value }
}
```
Messages containing a single submessage or several scalar entries can still be put on one line if they fit:
```
message { submessage { key: value } }
message { x: 1 y: 2 z: 3 }
```
Reviewers: sammccall
Reviewed By: sammccall
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D46757
llvm-svn: 334401
Diffstat (limited to 'clang/unittests/Format/FormatTestRawStrings.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTestRawStrings.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/clang/unittests/Format/FormatTestRawStrings.cpp b/clang/unittests/Format/FormatTestRawStrings.cpp index 84bb4a12aa1..3ec6bb9cb44 100644 --- a/clang/unittests/Format/FormatTestRawStrings.cpp +++ b/clang/unittests/Format/FormatTestRawStrings.cpp @@ -199,12 +199,6 @@ TEST_F(FormatTestRawStrings, ReformatsShortRawStringsOnSingleLine) { format( R"test(P p = TP(R"pb(item_1:1 item_2:2)pb");)test", getRawStringPbStyleWithColumns(40))); - expect_eq( - R"test(P p = TP(R"pb(item_1 < 1 > item_2: { 2 })pb");)test", - format( - R"test(P p = TP(R"pb(item_1<1> item_2:{2})pb");)test", - getRawStringPbStyleWithColumns(40))); - // Merge two short lines into one. expect_eq(R"test( std::string s = R"pb( @@ -220,6 +214,18 @@ std::string s = R"pb( getRawStringPbStyleWithColumns(40))); } +TEST_F(FormatTestRawStrings, BreaksShortRawStringsWhenNeeded) { + // The raw string contains multiple submessage entries, so break for + // readability. + expect_eq(R"test( +P p = TP(R"pb(item_1 < 1 > + item_2: { 2 })pb");)test", + format( + R"test( +P p = TP(R"pb(item_1<1> item_2:{2})pb");)test", + getRawStringPbStyleWithColumns(40))); +} + TEST_F(FormatTestRawStrings, BreaksRawStringsExceedingColumnLimit) { expect_eq(R"test( P p = TPPPPPPPPPPPPPPP( |