summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTestTextProto.cpp
diff options
context:
space:
mode:
authorKrasimir Georgiev <krasimir@google.com>2018-05-09 09:02:11 +0000
committerKrasimir Georgiev <krasimir@google.com>2018-05-09 09:02:11 +0000
commit8b4bc76a2323961f6f8502e0d5249e53ac41c6ac (patch)
treeec8c313955390b1e2e991e6276b3f84959f30222 /clang/unittests/Format/FormatTestTextProto.cpp
parent8e1c75a4c51528c0ad3a41300e9394df0b50b752 (diff)
downloadbcm5719-llvm-8b4bc76a2323961f6f8502e0d5249e53ac41c6ac.tar.gz
bcm5719-llvm-8b4bc76a2323961f6f8502e0d5249e53ac41c6ac.zip
[clang-format] Respect BreakBeforeClosingBrace while calculating length
Summary: This patch makes `getLengthToMatchingParen` respect the `BreakBeforeClosingBrace` ParenState for matching scope closers. In order to distinguish between paren states introduced by real vs. fake parens, I've added the token opening the ParensState to that struct. Reviewers: djasper Reviewed By: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D46519 llvm-svn: 331857
Diffstat (limited to 'clang/unittests/Format/FormatTestTextProto.cpp')
-rw-r--r--clang/unittests/Format/FormatTestTextProto.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestTextProto.cpp b/clang/unittests/Format/FormatTestTextProto.cpp
index 4e4387b9d38..6088409b2ff 100644
--- a/clang/unittests/Format/FormatTestTextProto.cpp
+++ b/clang/unittests/Format/FormatTestTextProto.cpp
@@ -469,6 +469,7 @@ TEST_F(FormatTestTextProto, AcceptsOperatorAsKey) {
" ccccccccccccccccccccccc: <\n"
" operator: 1\n"
" operator: 2\n"
+ " operator: 3\n"
" operator { key: value }\n"
" >\n"
" >\n"
@@ -495,5 +496,16 @@ TEST_F(FormatTestTextProto, PutsMultipleEntriesInExtensionsOnNewlines) {
"}", Style);
}
+TEST_F(FormatTestTextProto, BreaksAfterBraceFollowedByClosingBraceOnNextLine) {
+ FormatStyle Style = getGoogleStyle(FormatStyle::LK_TextProto);
+ Style.ColumnLimit = 60;
+ verifyFormat("keys: [\n"
+ " data: { item: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }\n"
+ "]");
+ verifyFormat("keys: <\n"
+ " data: { item: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' }\n"
+ ">");
+}
+
} // end namespace tooling
} // end namespace clang
OpenPOWER on IntegriCloud