From ccff4d1e60ceda9bd295116596029c0537033dbf Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 4 Jan 2016 07:27:33 +0000 Subject: clang-format: [Proto] Improve wrapping of message field attributes. Before: optional AAA aaa = 1 [foo = { key: "a" // }, bar = { key: "a" // }]; After: optional AAA aaa = 1 [ foo = { key: "a" // }, bar = { key: "a" // } ]; llvm-svn: 256736 --- clang/unittests/Format/FormatTestProto.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'clang/unittests/Format/FormatTestProto.cpp') diff --git a/clang/unittests/Format/FormatTestProto.cpp b/clang/unittests/Format/FormatTestProto.cpp index cd2c0c8aa46..6580443a021 100644 --- a/clang/unittests/Format/FormatTestProto.cpp +++ b/clang/unittests/Format/FormatTestProto.cpp @@ -88,9 +88,10 @@ TEST_F(FormatTestProto, UnderstandsReturns) { TEST_F(FormatTestProto, MessageFieldAttributes) { verifyFormat("optional string test = 1 [default = \"test\"];"); verifyFormat("optional bool a = 1 [default = true, deprecated = true];"); - verifyFormat("optional LongMessageType long_proto_field = 1\n" - " [default = REALLY_REALLY_LONG_CONSTANT_VALUE,\n" - " deprecated = true];"); + verifyFormat("optional LongMessageType long_proto_field = 1 [\n" + " default = REALLY_REALLY_LONG_CONSTANT_VALUE,\n" + " deprecated = true\n" + "];"); verifyFormat("optional LongMessageType long_proto_field = 1\n" " [default = REALLY_REALLY_LONG_CONSTANT_VALUE];"); verifyFormat("repeated double value = 1\n" @@ -103,6 +104,16 @@ TEST_F(FormatTestProto, MessageFieldAttributes) { " aaaaaaaaaaaaaaaa: AAAAAAAAAA\n" " bbbbbbbbbbbbbbbb: BBBBBBBBBB\n" "}];"); + verifyFormat("repeated double value = 1 [\n" + " (aaaaaaa.aaaaaaaaa) = {\n" + " aaaaaaaaaaaaaaaa: AAAAAAAAAA\n" + " bbbbbbbbbbbbbbbb: BBBBBBBBBB\n" + " },\n" + " (bbbbbbb.bbbbbbbbb) = {\n" + " aaaaaaaaaaaaaaaa: AAAAAAAAAA\n" + " bbbbbbbbbbbbbbbb: BBBBBBBBBB\n" + " }\n" + "];"); verifyFormat("repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = {\n" " type: \"AAAAAAAAAA\"\n" " is: \"AAAAAAAAAA\"\n" @@ -113,6 +124,14 @@ TEST_F(FormatTestProto, MessageFieldAttributes) { " bbbbbbb: BBBB,\n" " bbbb: BBB\n" "}];"); + verifyFormat("optional AAA aaa = 1 [\n" + " foo = {\n" + " key: 'a' //\n" + " },\n" + " bar = {\n" + " key: 'a' //\n" + " }\n" + "];"); } TEST_F(FormatTestProto, DoesntWrapFileOptions) { @@ -130,7 +149,6 @@ TEST_F(FormatTestProto, FormatsOptions) { " field_c: \"OK\"\n" " msg_field: {field_d: 123}\n" "};"); - verifyFormat("option (MyProto.options) = {\n" " field_a: OK\n" " field_b: \"OK\"\n" @@ -140,14 +158,12 @@ TEST_F(FormatTestProto, FormatsOptions) { " field_e: OK\n" " }\n" "};"); - verifyFormat("option (MyProto.options) = {\n" " field_a: OK // Comment\n" " field_b: \"OK\"\n" " field_c: \"OK\"\n" " msg_field: {field_d: 123}\n" "};"); - verifyFormat("option (MyProto.options) = {\n" " field_c: \"OK\"\n" " msg_field{field_d: 123}\n" -- cgit v1.2.3