From fc74ff5a0792641885551a63d9ddf8cbfdf76e3c Mon Sep 17 00:00:00 2001
From: dim <dim@FreeBSD.org>
Date: Wed, 6 Jan 2016 20:02:26 +0000
Subject: Vendor import of clang trunk r256945:
 https://llvm.org/svn/llvm-project/cfe/trunk@256945

---
 unittests/Format/FormatTestProto.cpp | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

(limited to 'unittests/Format/FormatTestProto.cpp')

diff --git a/unittests/Format/FormatTestProto.cpp b/unittests/Format/FormatTestProto.cpp
index cd2c0c8..d3d3d42 100644
--- a/unittests/Format/FormatTestProto.cpp
+++ b/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,18 +158,22 @@ 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"
                "};");
+
+  // Support syntax with <> instead of {}.
+  verifyFormat("option (MyProto.options) = {\n"
+               "  field_c: \"OK\",\n"
+               "  msg_field: <field_d: 123>\n"
+               "};");
 }
 
 TEST_F(FormatTestProto, FormatsService) {
-- 
cgit v1.1