summaryrefslogtreecommitdiffstats
path: root/unittests
diff options
context:
space:
mode:
authorKrasimir Georgiev <krasimir@google.com>2017-06-27 13:43:07 +0000
committerKrasimir Georgiev <krasimir@google.com>2017-06-27 13:43:07 +0000
commitace84ec3ef5538e6249e57961324448552b80f40 (patch)
treec316e7a6fcf7982fd4c96d153475ca0baa503233 /unittests
parent7a2b28407501faafdbd0c3c6785895e49d13d514 (diff)
[clang-format] Support <>-style proto message fields
Summary: This patch adds support for <>-style proto message fields inside proto options. Previously these were wrongly treated as binary operators and as such were working only by chance for a limited number of cases. Reviewers: djasper Reviewed By: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D34621 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306406 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Format/FormatTestProto.cpp136
1 files changed, 136 insertions, 0 deletions
diff --git a/unittests/Format/FormatTestProto.cpp b/unittests/Format/FormatTestProto.cpp
index 3f690c369b..0b052bd4c6 100644
--- a/unittests/Format/FormatTestProto.cpp
+++ b/unittests/Format/FormatTestProto.cpp
@@ -207,6 +207,142 @@ TEST_F(FormatTestProto, FormatsOptions) {
" field_c: \"OK\",\n"
" msg_field: <field_d: 123>\n"
"};");
+
+ verifyFormat("option (MyProto.options) = {\n"
+ " msg_field: <>\n"
+ " field_c: \"OK\",\n"
+ " msg_field: <field_d: 123>\n"
+ " field_e: OK\n"
+ " msg_field: <field_d: 12>\n"
+ "};");
+
+ verifyFormat("option (MyProto.options) = <\n"
+ " field_a: OK\n"
+ " field_b: \"OK\"\n"
+ " field_c: 1\n"
+ " field_d: 12.5\n"
+ " field_e: OK\n"
+ ">;");
+
+ verifyFormat("option (MyProto.options) = <\n"
+ " field_a: OK,\n"
+ " field_b: \"OK\",\n"
+ " field_c: 1,\n"
+ " field_d: 12.5,\n"
+ " field_e: OK,\n"
+ ">;");
+
+ verifyFormat("option (MyProto.options) = <\n"
+ " field_a: \"OK\"\n"
+ " msg_field: {field_b: OK}\n"
+ " field_g: OK\n"
+ " field_g: OK\n"
+ " field_g: OK\n"
+ ">;");
+
+ verifyFormat("option (MyProto.options) = <\n"
+ " field_a: \"OK\"\n"
+ " msg_field<\n"
+ " field_b: OK\n"
+ " field_c: OK\n"
+ " field_d: OK\n"
+ " field_e: OK\n"
+ " field_f: OK\n"
+ " >\n"
+ " field_g: OK\n"
+ ">;");
+
+ verifyFormat("option (MyProto.options) = <\n"
+ " field_a: \"OK\"\n"
+ " msg_field<\n"
+ " field_b: OK,\n"
+ " field_c: OK,\n"
+ " field_d: OK,\n"
+ " field_e: OK,\n"
+ " field_f: OK\n"
+ " >\n"
+ " field_g: OK\n"
+ ">;");
+
+ verifyFormat("option (MyProto.options) = <\n"
+ " field_a: \"OK\"\n"
+ " msg_field: <\n"
+ " field_b: OK\n"
+ " field_c: OK\n"
+ " field_d: OK\n"
+ " field_e: OK\n"
+ " field_f: OK\n"
+ " >\n"
+ " field_g: OK\n"
+ ">;");
+
+ verifyFormat("option (MyProto.options) = <\n"
+ " field_a: \"OK\"\n"
+ " msg_field: {\n"
+ " field_b: OK\n"
+ " field_c: OK\n"
+ " field_d: OK\n"
+ " field_e: OK\n"
+ " field_f: OK\n"
+ " }\n"
+ " field_g: OK\n"
+ ">;");
+
+ verifyFormat("option (MyProto.options) = <\n"
+ " field_a: \"OK\"\n"
+ " msg_field{\n"
+ " field_b: OK\n"
+ " field_c: OK\n"
+ " field_d: OK\n"
+ " field_e: OK\n"
+ " field_f: OK\n"
+ " }\n"
+ " field_g: OK\n"
+ ">;");
+
+ verifyFormat("option (MyProto.options) = {\n"
+ " field_a: \"OK\"\n"
+ " msg_field<\n"
+ " field_b: OK\n"
+ " field_c: OK\n"
+ " field_d: OK\n"
+ " field_e: OK\n"
+ " field_f: OK\n"
+ " >\n"
+ " field_g: OK\n"
+ "};");
+
+ verifyFormat("option (MyProto.options) = {\n"
+ " field_a: \"OK\"\n"
+ " msg_field: <\n"
+ " field_b: OK\n"
+ " field_c: OK\n"
+ " field_d: OK\n"
+ " field_e: OK\n"
+ " field_f: OK\n"
+ " >\n"
+ " field_g: OK\n"
+ "};");
+
+ verifyFormat("option (MyProto.options) = <\n"
+ " field_a: \"OK\"\n"
+ " msg_field{\n"
+ " field_b: OK\n"
+ " field_c: OK\n"
+ " field_d: OK\n"
+ " msg_field<\n"
+ " field_A: 1\n"
+ " field_B: 2\n"
+ " field_C: 3\n"
+ " field_D: 4\n"
+ " field_E: 5\n"
+ " >\n"
+ " msg_field<field_A: 1 field_B: 2 field_C: 3 field_D: 4>\n"
+ " field_e: OK\n"
+ " field_f: OK\n"
+ " }\n"
+ " field_g: OK\n"
+ ">;");
}
TEST_F(FormatTestProto, FormatsService) {