| Index: third_party/protobuf/src/google/protobuf/descriptor_unittest.cc
|
| diff --git a/third_party/protobuf/src/google/protobuf/descriptor_unittest.cc b/third_party/protobuf/src/google/protobuf/descriptor_unittest.cc
|
| index f937b9eac253c4b56426b0ac441fa60ecccc946e..f6b3f1c55aba687e567095ed9e77b86184dae789 100644
|
| --- a/third_party/protobuf/src/google/protobuf/descriptor_unittest.cc
|
| +++ b/third_party/protobuf/src/google/protobuf/descriptor_unittest.cc
|
| @@ -55,7 +55,6 @@
|
| #include <google/protobuf/stubs/common.h>
|
| #include <google/protobuf/stubs/logging.h>
|
| #include <google/protobuf/stubs/logging.h>
|
| -#include <google/protobuf/stubs/scoped_ptr.h>
|
| #include <google/protobuf/testing/googletest.h>
|
| #include <gtest/gtest.h>
|
|
|
| @@ -774,9 +773,9 @@ TEST_F(DescriptorTest, FieldFullName) {
|
| TEST_F(DescriptorTest, FieldJsonName) {
|
| EXPECT_EQ("fieldName1", message4_->field(0)->json_name());
|
| EXPECT_EQ("fieldName2", message4_->field(1)->json_name());
|
| - EXPECT_EQ("fieldName3", message4_->field(2)->json_name());
|
| - EXPECT_EQ("fieldName4", message4_->field(3)->json_name());
|
| - EXPECT_EQ("fIELDNAME5", message4_->field(4)->json_name());
|
| + EXPECT_EQ("FieldName3", message4_->field(2)->json_name());
|
| + EXPECT_EQ("FieldName4", message4_->field(3)->json_name());
|
| + EXPECT_EQ("FIELDNAME5", message4_->field(4)->json_name());
|
| EXPECT_EQ("@type", message4_->field(5)->json_name());
|
|
|
| DescriptorProto proto;
|
| @@ -794,10 +793,20 @@ TEST_F(DescriptorTest, FieldJsonName) {
|
| ASSERT_EQ(6, proto.field_size());
|
| EXPECT_EQ("fieldName1", proto.field(0).json_name());
|
| EXPECT_EQ("fieldName2", proto.field(1).json_name());
|
| - EXPECT_EQ("fieldName3", proto.field(2).json_name());
|
| - EXPECT_EQ("fieldName4", proto.field(3).json_name());
|
| - EXPECT_EQ("fIELDNAME5", proto.field(4).json_name());
|
| + EXPECT_EQ("FieldName3", proto.field(2).json_name());
|
| + EXPECT_EQ("FieldName4", proto.field(3).json_name());
|
| + EXPECT_EQ("FIELDNAME5", proto.field(4).json_name());
|
| EXPECT_EQ("@type", proto.field(5).json_name());
|
| +
|
| + // Test generated descriptor.
|
| + const Descriptor* generated = protobuf_unittest::TestJsonName::descriptor();
|
| + ASSERT_EQ(6, generated->field_count());
|
| + EXPECT_EQ("fieldName1", generated->field(0)->json_name());
|
| + EXPECT_EQ("fieldName2", generated->field(1)->json_name());
|
| + EXPECT_EQ("FieldName3", generated->field(2)->json_name());
|
| + EXPECT_EQ("FieldName4", generated->field(3)->json_name());
|
| + EXPECT_EQ("FIELDNAME5", generated->field(4)->json_name());
|
| + EXPECT_EQ("@type", generated->field(5)->json_name());
|
| }
|
|
|
| TEST_F(DescriptorTest, FieldFile) {
|
| @@ -2705,6 +2714,7 @@ TEST(CustomOptions, OptionLocations) {
|
| protobuf_unittest::TestMessageWithCustomOptions::descriptor();
|
| const FileDescriptor* file = message->file();
|
| const FieldDescriptor* field = message->FindFieldByName("field1");
|
| + const OneofDescriptor* oneof = message->FindOneofByName("AnOneof");
|
| const EnumDescriptor* enm = message->FindEnumTypeByName("AnEnum");
|
| // TODO(benjy): Support EnumValue options, once the compiler does.
|
| const ServiceDescriptor* service =
|
| @@ -2719,6 +2729,8 @@ TEST(CustomOptions, OptionLocations) {
|
| field->options().GetExtension(protobuf_unittest::field_opt1));
|
| EXPECT_EQ(42, // Check that we get the default for an option we don't set.
|
| field->options().GetExtension(protobuf_unittest::field_opt2));
|
| + EXPECT_EQ(-99,
|
| + oneof->options().GetExtension(protobuf_unittest::oneof_opt1));
|
| EXPECT_EQ(-789,
|
| enm->options().GetExtension(protobuf_unittest::enum_opt1));
|
| EXPECT_EQ(123,
|
| @@ -5027,7 +5039,7 @@ TEST_F(ValidationErrorTest, AggregateValueParseError) {
|
| BuildFileWithErrors(
|
| EmbedAggregateValue("aggregate_value: \"1+2\""),
|
| "foo.proto: foo.proto: OPTION_VALUE: Error while parsing option "
|
| - "value for \"foo\": Expected identifier.\n");
|
| + "value for \"foo\": Expected identifier, got: 1\n");
|
| }
|
|
|
| TEST_F(ValidationErrorTest, AggregateValueUnknownFields) {
|
| @@ -5551,6 +5563,69 @@ TEST_F(ValidationErrorTest, MapEntryConflictsWithEnum) {
|
| "with an existing enum type.\n");
|
| }
|
|
|
| +TEST_F(ValidationErrorTest, EnumValuesConflictWhenPrefixesStripped) {
|
| + BuildFileWithErrors(
|
| + "syntax: 'proto3'"
|
| + "name: 'foo.proto' "
|
| + "enum_type {"
|
| + " name: 'FooEnum' "
|
| + " value { name: 'FOO_ENUM_BAZ' number: 0 }"
|
| + " value { name: 'BAZ' number: 1 }"
|
| + "}",
|
| + "foo.proto: BAZ: NAME: When enum name is stripped and label is "
|
| + "PascalCased (Baz), this value label conflicts with FOO_ENUM_BAZ. This "
|
| + "will make the proto fail to compile for some languages, such as C#.\n");
|
| +
|
| + BuildFileWithErrors(
|
| + "syntax: 'proto3'"
|
| + "name: 'foo.proto' "
|
| + "enum_type {"
|
| + " name: 'FooEnum' "
|
| + " value { name: 'FOOENUM_BAZ' number: 0 }"
|
| + " value { name: 'BAZ' number: 1 }"
|
| + "}",
|
| + "foo.proto: BAZ: NAME: When enum name is stripped and label is "
|
| + "PascalCased (Baz), this value label conflicts with FOOENUM_BAZ. This "
|
| + "will make the proto fail to compile for some languages, such as C#.\n");
|
| +
|
| + BuildFileWithErrors(
|
| + "syntax: 'proto3'"
|
| + "name: 'foo.proto' "
|
| + "enum_type {"
|
| + " name: 'FooEnum' "
|
| + " value { name: 'FOO_ENUM_BAR_BAZ' number: 0 }"
|
| + " value { name: 'BAR__BAZ' number: 1 }"
|
| + "}",
|
| + "foo.proto: BAR__BAZ: NAME: When enum name is stripped and label is "
|
| + "PascalCased (BarBaz), this value label conflicts with "
|
| + "FOO_ENUM_BAR_BAZ. This "
|
| + "will make the proto fail to compile for some languages, such as C#.\n");
|
| +
|
| + BuildFileWithErrors(
|
| + "syntax: 'proto3'"
|
| + "name: 'foo.proto' "
|
| + "enum_type {"
|
| + " name: 'FooEnum' "
|
| + " value { name: 'FOO_ENUM__BAR_BAZ' number: 0 }"
|
| + " value { name: 'BAR_BAZ' number: 1 }"
|
| + "}",
|
| + "foo.proto: BAR_BAZ: NAME: When enum name is stripped and label is "
|
| + "PascalCased (BarBaz), this value label conflicts with "
|
| + "FOO_ENUM__BAR_BAZ. This "
|
| + "will make the proto fail to compile for some languages, such as C#.\n");
|
| +
|
| + // This isn't an error because the underscore will cause the PascalCase to
|
| + // differ by case (BarBaz vs. Barbaz).
|
| + BuildFile(
|
| + "syntax: 'proto3'"
|
| + "name: 'foo.proto' "
|
| + "enum_type {"
|
| + " name: 'FooEnum' "
|
| + " value { name: 'BAR_BAZ' number: 0 }"
|
| + " value { name: 'BARBAZ' number: 1 }"
|
| + "}");
|
| +}
|
| +
|
| TEST_F(ValidationErrorTest, MapEntryConflictsWithOneof) {
|
| FileDescriptorProto file_proto;
|
| FillValidMapEntry(&file_proto);
|
| @@ -5834,7 +5909,7 @@ TEST_F(ValidationErrorTest, ValidateProto3JsonName) {
|
| " field { name:'name' number:1 label:LABEL_OPTIONAL type:TYPE_INT32 }"
|
| " field { name:'Name' number:2 label:LABEL_OPTIONAL type:TYPE_INT32 }"
|
| "}",
|
| - "foo.proto: Foo: OTHER: The JSON camcel-case name of field \"Name\" "
|
| + "foo.proto: Foo: OTHER: The JSON camel-case name of field \"Name\" "
|
| "conflicts with field \"name\". This is not allowed in proto3.\n");
|
| // Underscores are ignored.
|
| BuildFileWithErrors(
|
| @@ -5845,7 +5920,7 @@ TEST_F(ValidationErrorTest, ValidateProto3JsonName) {
|
| " field { name:'ab' number:1 label:LABEL_OPTIONAL type:TYPE_INT32 }"
|
| " field { name:'_a__b_' number:2 label:LABEL_OPTIONAL type:TYPE_INT32 }"
|
| "}",
|
| - "foo.proto: Foo: OTHER: The JSON camcel-case name of field \"_a__b_\" "
|
| + "foo.proto: Foo: OTHER: The JSON camel-case name of field \"_a__b_\" "
|
| "conflicts with field \"ab\". This is not allowed in proto3.\n");
|
| }
|
|
|
|
|