unittest.proto is old and does not test oneofs
- Dominant language
- Dart
- Stars
- 572
- Forks
- 196
- Avg merge
- 1h 59m
- Merged PRs (30d)
- 2
Description
I was looking at how `oneof` fields are implemented and I realized that the unittest proto that we copied from https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/unittest.proto is quite old and it does not have any `oneof` fields.
We should update the proto file and the tests.
I don't know if we're missing some other features. Here's the diff of the upstream unittest.proto and the version we're using now:
unittest.proto diff
```diff
--- /usr/local/google/home/omersa/dart/protobuf.dart_2/protoc_plugin/test/protos/google/protobuf/unittest.proto 2022-08-04 08:53:52.866332248 +0200
+++ src/google/protobuf/unittest.proto 2022-08-04 12:03:25.866081608 +0200
@@ -1,6 +1,6 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
-// http://code.google.com/p/protobuf/
+// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -33,6 +33,8 @@
// Sanjay Ghemawat, Jeff Dean, and others.
//
// A proto file we will use for unit testing.
+//
+// LINT: ALLOW_GROUPS, LEGACY_NAMES
syntax = "proto2";
@@ -41,6 +43,7 @@
option cc_generic_services = true; // auto-added
option java_generic_services = true; // auto-added
option py_generic_services = true; // auto-added
+option cc_enable_arenas = true;
import "google/protobuf/unittest_import.proto";
@@ -64,13 +67,13 @@
// a local variable named "b" in one of the generated methods. Doh.
// This file needs to compile in proto1 to test backwards-compatibility.
optional int32 bb = 1;
- optional int32 i = 2;
}
enum NestedEnum {
FOO = 1;
BAR = 2;
BAZ = 3;
+ NEG = -1; // Intentionally negative.
}
// Singular
@@ -105,6 +108,13 @@
optional string optional_string_piece = 24 [ctype=STRING_PIECE];
optional string optional_cord = 25 [ctype=CORD];
+ // Defined in unittest_import_public.proto
+ optional protobuf_unittest_import.PublicImportMessage
+ optional_public_import_message = 26;
+
+ optional NestedMessage optional_lazy_message = 27 [lazy=true];
+ optional NestedMessage optional_unverified_lazy_message = 28 [unverified_lazy=true];
+
// Repeated
repeated int32 repeated_int32 = 31;
repeated int64 repeated_int64 = 32;
@@ -137,6 +147,8 @@
repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
repeated string repeated_cord = 55 [ctype=CORD];
+ repeated NestedMessage repeated_lazy_message = 57 [lazy=true];
+
// Singular with defaults
optional int32 default_int32 = 61 [default = 41 ];
optional int64 default_int64 = 62 [default = 42 ];
@@ -161,16 +173,41 @@
optional string default_string_piece = 84 [ctype=STRING_PIECE,default="abc"];
optional string default_cord = 85 [ctype=CORD,default="123"];
+
+ // For oneof test
+ oneof oneof_field {
+ uint32 oneof_uint32 = 111;
+ NestedMessage oneof_nested_message = 112;
+ string oneof_string = 113;
+ bytes oneof_bytes = 114;
+ }
+}
+
+// This proto includes a recursively nested message.
+message NestedTestAllTypes {
+ optional NestedTestAllTypes child = 1;
+ optional TestAllTypes payload = 2;
+ repeated NestedTestAllTypes repeated_child = 3;
+ optional NestedTestAllTypes lazy_child = 4 [lazy=true];
+ optional TestAllTypes eager_child = 5 [lazy=false];
}
message TestDeprecatedFields {
optional int32 deprecated_int32 = 1 [deprecated=true];
+ oneof oneof_fields {
+ int32 deprecated_int32_in_oneof = 2 [deprecated=true];
+ }
+}
+
+message TestDeprecatedMessage {
+ option deprecated = true;
}
// Define these after TestAllTypes to make sure the compiler can handle
// that.
message ForeignMessage {
optional int32 c = 1;
+ optional int32 d = 2;
}
enum ForeignEnum {
@@ -179,6 +216,17 @@
FOREIGN_BAZ = 6;
}
+message TestReservedFields {
+ reserved 2, 15, 9 to 11;
+ reserved "bar", "baz";
+}
+
+enum TestReservedEnumFields {
+ UNKNOWN = 0;
+ reserved 2, 15, 9 to 11;
+ reserved "bar", "baz";
+}
+
message TestAllExtensions {
extensions 1 to max;
}
@@ -218,6 +266,14 @@
optional string optional_string_piece_extension = 24 [ctype=STRING_PIECE];
optional string optional_cord_extension = 25 [ctype=CORD];
+ optional protobuf_unittest_import.PublicImportMessage
+ optional_public_import_message_extension = 26;
+
+ optional TestAllTypes.NestedMessage
+ optional_lazy_message_extension = 27 [lazy=true];
+ optional TestAllTypes.NestedMessage
+ optional_unverified_lazy_message_extension = 28 [unverified_lazy=true];
+
// Repeated
repeated int32 repeated_int32_extension = 31;
repeated int64 repeated_int64_extension = 32;
@@ -252,6 +308,9 @@
repeated string repeated_string_piece_extension = 54 [ctype=STRING_PIECE];
repeated string repeated_cord_extension = 55 [ctype=CORD];
+ repeated TestAllTypes.NestedMessage
+ repeated_lazy_message_extension = 57 [lazy=true];
+
// Singular with defaults
optional int32 default_int32_extension = 61 [default = 41 ];
optional int64 default_int64_extension = 62 [default = 42 ];
@@ -279,6 +338,33 @@
optional string default_string_piece_extension = 84 [ctype=STRING_PIECE,
default="abc"];
optional string default_cord_extension = 85 [ctype=CORD, default="123"];
+
+ // For oneof test
+ optional uint32 oneof_uint32_extension = 111;
+ optional TestAllTypes.NestedMessage oneof_nested_message_extension = 112;
+ optional string oneof_string_extension = 113;
+ optional bytes oneof_bytes_extension = 114;
+}
+
+message TestMixedFieldsAndExtensions {
+ optional int32 a = 1;
+ repeated fixed32 b = 3;
+ extensions 2, 4;
+ extend TestMixedFieldsAndExtensions {
+ optional int32 c = 2;
+ repeated fixed32 d = 4;
+ }
+}
+
+message TestGroup {
+ optional group OptionalGroup = 16 {
+ optional int32 a = 17;
+ }
+ optional ForeignEnum optional_foreign_enum = 22;
+}
+
+message TestGroupExtension {
+ extensions 1 to max;
}
message TestNestedExtension {
@@ -286,7 +372,50 @@
// Check for bug where string extensions declared in tested scope did not
// compile.
optional string test = 1002 [default="test"];
+ // Used to test if generated extension name is correct when there are
+ // underscores.
+ optional string nested_string_extension = 1003;
+ }
+
+ extend TestGroupExtension {
+ optional group OptionalGroup_extension = 16 {
+ optional int32 a = 17;
+ }
+ optional ForeignEnum optional_foreign_enum_extension = 22;
+ }
+}
+
+message TestChildExtension {
+ optional string a = 1;
+ optional string b = 2;
+ optional TestAllExtensions optional_extension = 3;
+}
+
+// Emulates wireformat data of TestChildExtension with dynamic extension
+// (DynamicExtension).
+message TestChildExtensionData {
+ message NestedTestAllExtensionsData {
+ message NestedDynamicExtensions {
+ optional int32 a = 1;
+ optional int32 b = 2;
+ }
+ optional NestedDynamicExtensions dynamic = 409707008;
}
+ optional string a = 1;
+ optional string b = 2;
+ optional NestedTestAllExtensionsData optional_extension = 3;
+}
+
+message TestNestedChildExtension {
+ optional int32 a = 1;
+ optional TestChildExtension child = 2;
+}
+
+// Emulates wireformat data of TestNestedChildExtension with dynamic extension
+// (DynamicExtension).
+message TestNestedChildExtensionData {
+ optional int32 a = 1;
+ optional TestChildExtensionData child = 2;
}
// We have separate messages for testing required fields because it's
@@ -337,12 +466,30 @@
optional int32 dummy32 = 32;
required int32 c = 33;
+
+ // Add an optional child message to make this non-trivial for go/pdlazy.
+ optional ForeignMessage optional_foreign = 34;
}
message TestRequiredForeign {
optional TestRequired optional_message = 1;
repeated TestRequired repeated_message = 2;
optional int32 dummy = 3;
+
+ // Missing required fields must not affect verification of child messages.
+ optional NestedTestAllTypes optional_lazy_message = 4 [lazy = true];
+}
+
+message TestRequiredMessage {
+ optional TestRequired optional_message = 1;
+ repeated TestRequired repeated_message = 2;
+ required TestRequired required_message = 3;
+}
+
+message TestNestedRequiredForeign {
+ optional TestNestedRequiredForeign child = 1;
+ optional TestRequiredForeign payload = 2;
+ optional int32 dummy = 3;
}
// Test that we can use NestedMessage from outside TestAllTypes.
@@ -360,6 +507,16 @@
extensions 1 to max;
}
+// Needed for a Python test.
+message TestPickleNestedMessage {
+ message NestedMessage {
+ optional int32 bb = 1;
+ message NestedNestedMessage {
+ optional int32 cc = 1;
+ }
+ }
+}
+
message TestMultipleExtensionRanges {
extensions 42;
extensions 4143 to 4243;
@@ -381,7 +538,14 @@
// Test that mutual recursion works.
message TestMutualRecursionA {
+ message SubMessage {
+ optional TestMutualRecursionB b = 1;
+ }
optional TestMutualRecursionB bb = 1;
+ optional group SubGroup = 2 {
+ optional SubMessage sub_message = 3; // Needed because of bug in javatest
+ optional TestAllTypes not_in_this_scc = 4;
+ }
}
message TestMutualRecursionB {
@@ -389,8 +553,17 @@
optional int32 optional_int32 = 2;
}
+message TestIsInitialized {
+ message SubMessage {
+ optional group SubGroup = 1 {
+ required int32 i = 2;
+ }
+ }
+ optional SubMessage sub_message = 1;
+}
+
// Test that groups have disjoint field numbers from their siblings and
-// parents. This is NOT possible in proto1; only proto2. When attempting
+// parents. This is NOT possible in proto1; only google.protobuf. When attempting
// to compile with proto1, this will emit an error; so we only include it
// in protobuf_unittest_proto.
message TestDupFieldNumber { // NO_PROTO1
@@ -399,7 +572,21 @@
optional group Bar = 3 { optional int32 a = 1; } // NO_PROTO1
} // NO_PROTO1
-
+// Additional messages for testing lazy fields.
+message TestEagerMessage {
+ optional TestAllTypes sub_message = 1 [lazy=false];
+}
+message TestLazyMessage {
+ optional TestAllTypes sub_message = 1 [lazy=true];
+}
+message TestEagerMaybeLazy {
+ message NestedMessage {
+ optional TestPackedTypes packed = 1;
+ }
+ optional TestAllTypes message_foo = 1;
+ optional TestAllTypes message_bar = 2;
+ optional NestedMessage message_baz = 3;
+}
// Needed for a Python test.
message TestNestedMessageHasBits {
message NestedMessage {
@@ -459,14 +646,41 @@
optional int64 my_int = 1;
extensions 12 to 100;
optional float my_float = 101;
-}
+ message NestedMessage {
+ optional int64 oo = 2;
+ // The field name "b" fails to compile in proto1 because it conflicts with
+ // a local variable named "b" in one of the generated methods. Doh.
+ // This file needs to compile in proto1 to test backwards-compatibility.
+ optional int32 bb = 1;
+ }
+ optional NestedMessage optional_nested_message = 200;
+}
extend TestFieldOrderings {
optional string my_extension_string = 50;
optional int32 my_extension_int = 5;
}
+message TestExtensionOrderings1 {
+ extend TestFieldOrderings {
+ optional TestExtensionOrderings1 test_ext_orderings1 = 13;
+ }
+ optional string my_string = 1;
+}
+
+message TestExtensionOrderings2 {
+ extend TestFieldOrderings {
+ optional TestExtensionOrderings2 test_ext_orderings2 = 12;
+ }
+ message TestExtensionOrderings3 {
+ extend TestFieldOrderings {
+ optional TestExtensionOrderings3 test_ext_orderings3 = 14;
+ }
+ optional string my_string = 1;
+ }
+ optional string my_string = 1;
+}
message TestExtremeDefaultValues {
optional bytes escaped_bytes = 1 [default = "\0\001\a\b\f\n\r\t\v\\\'\"\xfe"];
@@ -474,6 +688,8 @@
optional uint64 large_uint64 = 3 [default = 0xFFFFFFFFFFFFFFFF];
optional int32 small_int32 = 4 [default = -0x7FFFFFFF];
optional int64 small_int64 = 5 [default = -0x7FFFFFFFFFFFFFFF];
+ optional int32 really_small_int32 = 21 [default = -0x80000000];
+ optional int64 really_small_int64 = 22 [default = -0x8000000000000000];
// The default value here is UTF-8 for "\u1234". (We could also just type
// the UTF-8 text directly into this text file rather than escape it, but
@@ -504,6 +720,15 @@
// Note that in .proto file, "\?" is a valid way to escape ? in string
// literals.
optional string cpp_trigraph = 20 [default = "? \? ?? \?? \??? ??/ ?\?-"];
+
+ // String defaults containing the character '\000'
+ optional string string_with_zero = 23 [default = "hel\000lo"];
+ optional bytes bytes_with_zero = 24 [default = "wor\000ld"];
+ optional string string_piece_with_zero = 25 [ctype=STRING_PIECE,
+ default="ab\000c"];
+ optional string cord_with_zero = 26 [ctype=CORD,
+ default="12\0003"];
+ optional string replacement_string = 27 [default="${unknown}"];
}
message SparseEnumMessage {
@@ -515,10 +740,153 @@
optional string data = 1;
}
+message MoreString {
+ repeated string data = 1;
+}
+
message OneBytes {
optional bytes data = 1;
}
+message MoreBytes {
+ repeated bytes data = 1;
+}
+
+message ManyOptionalString {
+ optional string str1 = 1;
+ optional string str2 = 2;
+ optional string str3 = 3;
+ optional string str4 = 4;
+ optional string str5 = 5;
+ optional string str6 = 6;
+ optional string str7 = 7;
+ optional string str8 = 8;
+ optional string str9 = 9;
+ optional string str10 = 10;
+ optional string str11 = 11;
+ optional string str12 = 12;
+ optional string str13 = 13;
+ optional string str14 = 14;
+ optional string str15 = 15;
+ optional string str16 = 16;
+ optional string str17 = 17;
+ optional string str18 = 18;
+ optional string str19 = 19;
+ optional string str20 = 20;
+ optional string str21 = 21;
+ optional string str22 = 22;
+ optional string str23 = 23;
+ optional string str24 = 24;
+ optional string str25 = 25;
+ optional string str26 = 26;
+ optional string str27 = 27;
+ optional string str28 = 28;
+ optional string str29 = 29;
+ optional string str30 = 30;
+ optional string str31 = 31;
+ optional string str32 = 32;
+}
+
+// Test int32, uint32, int64, uint64, and bool are all compatible
+message Int32Message {
+ optional int32 data = 1;
+}
+
+message Uint32Message {
+ optional uint32 data = 1;
+}
+
+message Int64Message {
+ optional int64 data = 1;
+}
+
+message Uint64Message {
+ optional uint64 data = 1;
+}
+
+message BoolMessage {
+ optional bool data = 1;
+}
+
+// Test oneofs.
+message TestOneof {
+ oneof foo {
+ int32 foo_int = 1;
+ string foo_string = 2;
+ TestAllTypes foo_message = 3;
+ group FooGroup = 4 {
+ optional int32 a = 5;
+ optional string b = 6;
+ }
+ }
+}
+
+message TestOneofBackwardsCompatible {
+ optional int32 foo_int = 1;
+ optional string foo_string = 2;
+ optional TestAllTypes foo_message = 3;
+ optional group FooGroup = 4 {
+ optional int32 a = 5;
+ optional string b = 6;
+ }
+}
+
+message TestOneof2 {
+ oneof foo {
+ int32 foo_int = 1;
+ string foo_string = 2;
+ string foo_cord = 3 [ctype=CORD];
+ string foo_string_piece = 4 [ctype=STRING_PIECE];
+ bytes foo_bytes = 5;
+ NestedEnum foo_enum = 6;
+ NestedMessage foo_message = 7;
+ group FooGroup = 8 {
+ optional int32 a = 9;
+ optional string b = 10;
+ }
+ NestedMessage foo_lazy_message = 11 [lazy=true];
+ }
+
+ oneof bar {
+ int32 bar_int = 12 [default = 5];
+ string bar_string = 13 [default = "STRING"];
+ string bar_cord = 14 [ctype=CORD, default = "CORD"];
+ string bar_string_piece = 15 [ctype=STRING_PIECE, default = "SPIECE"];
+ bytes bar_bytes = 16 [default = "BYTES"];
+ NestedEnum bar_enum = 17 [default = BAR];
+ string bar_string_with_empty_default = 20 [default = ""];
+ string bar_cord_with_empty_default = 21 [ctype=CORD, default = ""];
+ string bar_string_piece_with_empty_default = 22 [ctype=STRING_PIECE, default = ""];
+ bytes bar_bytes_with_empty_default = 23 [default = ""];
+ }
+
+ optional int32 baz_int = 18;
+ optional string baz_string = 19 [default = "BAZ"];
+
+ message NestedMessage {
+ optional int64 moo_int = 1;
+ repeated int32 corge_int = 2;
+ }
+
+ enum NestedEnum {
+ FOO = 1;
+ BAR = 2;
+ BAZ = 3;
+ }
+}
+
+message TestRequiredOneof {
+ oneof foo {
+ int32 foo_int = 1;
+ string foo_string = 2;
+ NestedMessage foo_message = 3;
+ }
+ message NestedMessage {
+ required double required_double = 1;
+ }
+}
+
+
// Test messages for packed fields
message TestPackedTypes {
@@ -578,6 +946,27 @@
repeated ForeignEnum packed_enum_extension = 103 [packed = true];
}
+message TestUnpackedExtensions {
+ extensions 1 to max;
+}
+
+extend TestUnpackedExtensions {
+ repeated int32 unpacked_int32_extension = 90 [packed = false];
+ repeated int64 unpacked_int64_extension = 91 [packed = false];
+ repeated uint32 unpacked_uint32_extension = 92 [packed = false];
+ repeated uint64 unpacked_uint64_extension = 93 [packed = false];
+ repeated sint32 unpacked_sint32_extension = 94 [packed = false];
+ repeated sint64 unpacked_sint64_extension = 95 [packed = false];
+ repeated fixed32 unpacked_fixed32_extension = 96 [packed = false];
+ repeated fixed64 unpacked_fixed64_extension = 97 [packed = false];
+ repeated sfixed32 unpacked_sfixed32_extension = 98 [packed = false];
+ repeated sfixed64 unpacked_sfixed64_extension = 99 [packed = false];
+ repeated float unpacked_float_extension = 100 [packed = false];
+ repeated double unpacked_double_extension = 101 [packed = false];
+ repeated bool unpacked_bool_extension = 102 [packed = false];
+ repeated ForeignEnum unpacked_enum_extension = 103 [packed = false];
+}
+
// Used by ExtensionSetTest/DynamicExtensions. The test actually builds
// a set of extensions to TestAllExtensions dynamically, based on the fields
// of this message type.
@@ -619,11 +1008,73 @@
repeated uint64 repeated_uint64 = 262143;
}
+// Test that if an optional or required message/group field appears multiple
+// times in the input, they need to be merged.
+message TestParsingMerge {
+ // RepeatedFieldsGenerator defines matching field types as TestParsingMerge,
+ // except that all fields are repeated. In the tests, we will serialize the
+ // RepeatedFieldsGenerator to bytes, and parse the bytes to TestParsingMerge.
+ // Repeated fields in RepeatedFieldsGenerator are expected to be merged into
+ // the corresponding required/optional fields in TestParsingMerge.
+ message RepeatedFieldsGenerator {
+ repeated TestAllTypes field1 = 1;
+ repeated TestAllTypes field2 = 2;
+ repeated TestAllTypes field3 = 3;
+ repeated group Group1 = 10 {
+ optional TestAllTypes field1 = 11;
+ }
+ repeated group Group2 = 20 {
+ optional TestAllTypes field1 = 21;
+ }
+ repeated TestAllTypes ext1 = 1000;
+ repeated TestAllTypes ext2 = 1001;
+ }
+ required TestAllTypes required_all_types = 1;
+ optional TestAllTypes optional_all_types = 2;
+ repeated TestAllTypes repeated_all_types = 3;
+ optional group OptionalGroup = 10 {
+ optional TestAllTypes optional_group_all_types = 11;
+ }
+ repeated group RepeatedGroup = 20 {
+ optional TestAllTypes repeated_group_all_types = 21;
+ }
+ extensions 1000 to max;
+ extend TestParsingMerge {
+ optional TestAllTypes optional_ext = 1000;
+ repeated TestAllTypes repeated_ext = 1001;
+ }
+}
+
+// Test that the correct exception is thrown by parseFrom in a corner case
+// involving merging, extensions, and required fields.
+message TestMergeException {
+ optional TestAllExtensions all_extensions = 1;
+}
+
+message TestCommentInjectionMessage {
+ // */ <- This should not close the generated doc comment
+ optional string a = 1 [default="*/ <- Neither should this."];
+}
+
+// Used to check that the c++ code generator re-orders messages to reduce
+// padding.
+message TestMessageSize {
+ optional bool m1 = 1;
+ optional int64 m2 = 2;
+ optional bool m3 = 3;
+ optional string m4 = 4;
+ optional int32 m5 = 5;
+ optional int64 m6 = 6;
+}
+
// Test that RPC services work.
message FooRequest {}
message FooResponse {}
+message FooClientMessage {}
+message FooServerMessage{}
+
service TestService {
rpc Foo(FooRequest) returns (FooResponse);
rpc Bar(BarRequest) returns (BarResponse);
@@ -632,3 +1083,474 @@
message BarRequest {}
message BarResponse {}
+
+message TestJsonName {
+ optional int32 field_name1 = 1;
+ optional int32 fieldName2 = 2;
+ optional int32 FieldName3 = 3;
+ optional int32 _field_name4 = 4;
+ optional int32 FIELD_NAME5 = 5;
+ optional int32 field_name6 = 6 [json_name = "@type"];
+ optional int32 fieldname7 = 7;
+}
+
+message TestHugeFieldNumbers {
+ optional int32 optional_int32 = 536870000;
+ optional int32 fixed_32 = 536870001;
+ repeated int32 repeated_int32 = 536870002 [packed = false];
+ repeated int32 packed_int32 = 536870003 [packed = true];
+
+ optional ForeignEnum optional_enum = 536870004;
+ optional string optional_string = 536870005;
+ optional bytes optional_bytes = 536870006;
+ optional ForeignMessage optional_message = 536870007;
+
+ optional group OptionalGroup = 536870008 {
+ optional int32 group_a = 536870009;
+ }
+
+ map string_string_map = 536870010;
+
+ oneof oneof_field {
+ uint32 oneof_uint32 = 536870011;
+ TestAllTypes oneof_test_all_types = 536870012;
+ string oneof_string = 536870013;
+ bytes oneof_bytes = 536870014;
+ }
+
+ extensions 536860000 to 536869999;
+}
+
+extend TestHugeFieldNumbers {
+ optional TestAllTypes test_all_types = 536860000;
+}
+
+message TestExtensionInsideTable {
+ optional int32 field1 = 1;
+ optional int32 field2 = 2;
+ optional int32 field3 = 3;
+ optional int32 field4 = 4;
+ extensions 5 to 5;
+ optional int32 field6 = 6;
+ optional int32 field7 = 7;
+ optional int32 field8 = 8;
+ optional int32 field9 = 9;
+ optional int32 field10 = 10;
+}
+
+extend TestExtensionInsideTable {
+ optional int32 test_extension_inside_table_extension = 5;
+}
+
+// NOTE(b/202996544): Intentionally nested to mirror go/glep.
+message TestNestedGroupExtensionOuter {
+ optional group Layer1OptionalGroup = 1 {
+ repeated group Layer2RepeatedGroup = 2 {
+ extensions 3
+ // NOTE: extension metadata is not supported due to targets such as
+ // `//third_party/protobuf_legacy_opensource/src:shell_scripts_test`,
+ // eee https://screenshot.googleplex.com/Axz2QD8nxjdpyFF
+ //[metadata = {
+ // NOTE: can't write type there due to some clever build gen code at
+ // http://google3/net/proto2/internal/BUILD;l=1247;rcl=411090862
+ // type: "protobuf_unittest.TestNestedGroupExtensionInnerExtension",
+ // name: "inner",
+ // }]
+ ;
+ optional string another_field = 6;
+ }
+ repeated group Layer2AnotherOptionalRepeatedGroup = 4 {
+ optional string but_why_tho = 5;
+ }
+ }
+}
+
+message TestNestedGroupExtensionInnerExtension {
+ optional string inner_name= 1;
+}
+
+extend TestNestedGroupExtensionOuter.Layer1OptionalGroup.Layer2RepeatedGroup {
+ optional TestNestedGroupExtensionInnerExtension inner = 3;
+}
+
+enum VeryLargeEnum {
+ ENUM_LABEL_DEFAULT = 0;
+ ENUM_LABEL_1 = 1;
+ ENUM_LABEL_2 = 2;
+ ENUM_LABEL_3 = 3;
+ ENUM_LABEL_4 = 4;
+ ENUM_LABEL_5 = 5;
+ ENUM_LABEL_6 = 6;
+ ENUM_LABEL_7 = 7;
+ ENUM_LABEL_8 = 8;
+ ENUM_LABEL_9 = 9;
+ ENUM_LABEL_10 = 10;
+ ENUM_LABEL_11 = 11;
+ ENUM_LABEL_12 = 12;
+ ENUM_LABEL_13 = 13;
+ ENUM_LABEL_14 = 14;
+ ENUM_LABEL_15 = 15;
+ ENUM_LABEL_16 = 16;
+ ENUM_LABEL_17 = 17;
+ ENUM_LABEL_18 = 18;
+ ENUM_LABEL_19 = 19;
+ ENUM_LABEL_20 = 20;
+ ENUM_LABEL_21 = 21;
+ ENUM_LABEL_22 = 22;
+ ENUM_LABEL_23 = 23;
+ ENUM_LABEL_24 = 24;
+ ENUM_LABEL_25 = 25;
+ ENUM_LABEL_26 = 26;
+ ENUM_LABEL_27 = 27;
+ ENUM_LABEL_28 = 28;
+ ENUM_LABEL_29 = 29;
+ ENUM_LABEL_30 = 30;
+ ENUM_LABEL_31 = 31;
+ ENUM_LABEL_32 = 32;
+ ENUM_LABEL_33 = 33;
+ ENUM_LABEL_34 = 34;
+ ENUM_LABEL_35 = 35;
+ ENUM_LABEL_36 = 36;
+ ENUM_LABEL_37 = 37;
+ ENUM_LABEL_38 = 38;
+ ENUM_LABEL_39 = 39;
+ ENUM_LABEL_40 = 40;
+ ENUM_LABEL_41 = 41;
+ ENUM_LABEL_42 = 42;
+ ENUM_LABEL_43 = 43;
+ ENUM_LABEL_44 = 44;
+ ENUM_LABEL_45 = 45;
+ ENUM_LABEL_46 = 46;
+ ENUM_LABEL_47 = 47;
+ ENUM_LABEL_48 = 48;
+ ENUM_LABEL_49 = 49;
+ ENUM_LABEL_50 = 50;
+ ENUM_LABEL_51 = 51;
+ ENUM_LABEL_52 = 52;
+ ENUM_LABEL_53 = 53;
+ ENUM_LABEL_54 = 54;
+ ENUM_LABEL_55 = 55;
+ ENUM_LABEL_56 = 56;
+ ENUM_LABEL_57 = 57;
+ ENUM_LABEL_58 = 58;
+ ENUM_LABEL_59 = 59;
+ ENUM_LABEL_60 = 60;
+ ENUM_LABEL_61 = 61;
+ ENUM_LABEL_62 = 62;
+ ENUM_LABEL_63 = 63;
+ ENUM_LABEL_64 = 64;
+ ENUM_LABEL_65 = 65;
+ ENUM_LABEL_66 = 66;
+ ENUM_LABEL_67 = 67;
+ ENUM_LABEL_68 = 68;
+ ENUM_LABEL_69 = 69;
+ ENUM_LABEL_70 = 70;
+ ENUM_LABEL_71 = 71;
+ ENUM_LABEL_72 = 72;
+ ENUM_LABEL_73 = 73;
+ ENUM_LABEL_74 = 74;
+ ENUM_LABEL_75 = 75;
+ ENUM_LABEL_76 = 76;
+ ENUM_LABEL_77 = 77;
+ ENUM_LABEL_78 = 78;
+ ENUM_LABEL_79 = 79;
+ ENUM_LABEL_80 = 80;
+ ENUM_LABEL_81 = 81;
+ ENUM_LABEL_82 = 82;
+ ENUM_LABEL_83 = 83;
+ ENUM_LABEL_84 = 84;
+ ENUM_LABEL_85 = 85;
+ ENUM_LABEL_86 = 86;
+ ENUM_LABEL_87 = 87;
+ ENUM_LABEL_88 = 88;
+ ENUM_LABEL_89 = 89;
+ ENUM_LABEL_90 = 90;
+ ENUM_LABEL_91 = 91;
+ ENUM_LABEL_92 = 92;
+ ENUM_LABEL_93 = 93;
+ ENUM_LABEL_94 = 94;
+ ENUM_LABEL_95 = 95;
+ ENUM_LABEL_96 = 96;
+ ENUM_LABEL_97 = 97;
+ ENUM_LABEL_98 = 98;
+ ENUM_LABEL_99 = 99;
+ ENUM_LABEL_100 = 100;
+};
+
+message TestExtensionRangeSerialize {
+ optional int32 foo_one = 1;
+
+ extensions 2 to 2;
+ extensions 3 to 4;
+
+ optional int32 foo_two = 6;
+ optional int32 foo_three = 7;
+
+ extensions 9 to 10;
+
+ optional int32 foo_four = 13;
+
+ extensions 15 to 15;
+ extensions 17 to 17;
+ extensions 19 to 19;
+
+ extend TestExtensionRangeSerialize {
+ optional int32 bar_one = 2;
+ optional int32 bar_two = 4;
+
+ optional int32 bar_three = 10;
+
+ optional int32 bar_four = 15;
+ optional int32 bar_five = 19;
+ }
+}
+
+message TestVerifyInt32Simple {
+ optional int32 optional_int32_1 = 1;
+ optional int32 optional_int32_2 = 2;
+ optional int32 optional_int32_63 = 63;
+ optional int32 optional_int32_64 = 64;
+}
+
+message TestVerifyInt32 {
+ optional int32 optional_int32_1 = 1;
+ optional int32 optional_int32_2 = 2;
+ optional int32 optional_int32_63 = 63;
+ optional int32 optional_int32_64 = 64;
+
+ optional TestAllTypes optional_all_types = 9;
+ repeated TestAllTypes repeated_all_types = 10;
+}
+
+message TestVerifyMostlyInt32 {
+ optional int64 optional_int64_30 = 30;
+
+ optional int32 optional_int32_1 = 1;
+ optional int32 optional_int32_2 = 2;
+ optional int32 optional_int32_3 = 3;
+ optional int32 optional_int32_4 = 4;
+ optional int32 optional_int32_63 = 63;
+ optional int32 optional_int32_64 = 64;
+
+ optional TestAllTypes optional_all_types = 9;
+ repeated TestAllTypes repeated_all_types = 10;
+}
+
+message TestVerifyMostlyInt32BigFieldNumber {
+ optional int64 optional_int64_30 = 30;
+ optional int32 optional_int32_300 = 300;
+
+ optional int32 optional_int32_1 = 1;
+ optional int32 optional_int32_2 = 2;
+ optional int32 optional_int32_3 = 3;
+ optional int32 optional_int32_4 = 4;
+ optional int32 optional_int32_63 = 63;
+ optional int32 optional_int32_64 = 64;
+
+ optional TestAllTypes optional_all_types = 9;
+ repeated TestAllTypes repeated_all_types = 10;
+}
+
+message TestVerifyUint32Simple {
+ optional uint32 optional_uint32_1 = 1;
+ optional uint32 optional_uint32_2 = 2;
+ optional uint32 optional_uint32_63 = 63;
+ optional uint32 optional_uint32_64 = 64;
+}
+
+message TestVerifyUint32 {
+ optional uint32 optional_uint32_1 = 1;
+ optional uint32 optional_uint32_2 = 2;
+ optional uint32 optional_uint32_63 = 63;
+ optional uint32 optional_uint32_64 = 64;
+
+ optional TestAllTypes optional_all_types = 9;
+ repeated TestAllTypes repeated_all_types = 10;
+}
+
+message TestVerifyOneUint32 {
+ optional uint32 optional_uint32_1 = 1;
+ optional int32 optional_int32_2 = 2;
+ optional int32 optional_int32_63 = 63;
+ optional int32 optional_int32_64 = 64;
+
+ optional TestAllTypes optional_all_types = 9;
+ repeated TestAllTypes repeated_all_types = 10;
+}
+
+message TestVerifyOneInt32BigFieldNumber {
+ optional int32 optional_int32_65 = 65;
+
+ optional int64 optional_int64_1 = 1;
+ optional int64 optional_int64_2 = 2;
+ optional int64 optional_int64_63 = 63;
+ optional int64 optional_int64_64 = 64;
+
+ optional TestAllTypes optional_all_types = 9;
+ repeated TestAllTypes repeated_all_types = 10;
+}
+
+message TestVerifyInt32BigFieldNumber {
+ optional int32 optional_int32_1000 = 1000;
+ optional int32 optional_int32_65 = 65;
+
+ optional int32 optional_int32_1 = 1;
+ optional int32 optional_int32_2 = 2;
+ optional int32 optional_int32_63 = 63;
+ optional int32 optional_int32_64 = 64;
+
+ optional TestAllTypes optional_all_types = 9;
+ repeated TestAllTypes repeated_all_types = 10;
+}
+
+message TestVerifyUint32BigFieldNumber {
+ optional uint32 optional_uint32_1000 = 1000;
+ optional uint32 optional_uint32_65 = 65;
+
+ optional uint32 optional_uint32_1 = 1;
+ optional uint32 optional_uint32_2 = 2;
+ optional uint32 optional_uint32_63 = 63;
+ optional uint32 optional_uint32_64 = 64;
+
+ optional TestAllTypes optional_all_types = 9;
+ repeated TestAllTypes repeated_all_types = 10;
+}
+
+message TestVerifyBigFieldNumberUint32 {
+ message Nested {
+ optional uint32 optional_uint32_5000 = 5000;
+ optional uint32 optional_uint32_1000 = 1000;
+ optional uint32 optional_uint32_66 = 66;
+ optional uint32 optional_uint32_65 = 65;
+
+ optional uint32 optional_uint32_1 = 1;
+ optional uint32 optional_uint32_2 = 2;
+ optional uint32 optional_uint32_63 = 63;
+ optional uint32 optional_uint32_64 = 64;
+
+ optional Nested optional_nested = 9;
+ repeated Nested repeated_nested = 10;
+ }
+ optional Nested optional_nested = 1;
+}
+
+
+// This message contains different kind of enums to exercise the different
+// parsers in table-driven.
+message EnumParseTester {
+ enum SeqSmall0 {
+ SEQ_SMALL_0_DEFAULT = 0;
+ SEQ_SMALL_0_1 = 1;
+ SEQ_SMALL_0_2 = 2;
+ };
+ optional SeqSmall0 optional_seq_small_0_lowfield = 1;
+ optional SeqSmall0 optional_seq_small_0_midfield = 1001;
+ optional SeqSmall0 optional_seq_small_0_hifield = 1000001;
+ repeated SeqSmall0 repeated_seq_small_0_lowfield = 2;
+ repeated SeqSmall0 repeated_seq_small_0_midfield = 1002;
+ repeated SeqSmall0 repeated_seq_small_0_hifield = 1000002;
+ repeated SeqSmall0 packed_seq_small_0_lowfield = 3 [packed = true];
+ repeated SeqSmall0 packed_seq_small_0_midfield = 1003 [packed = true];
+ repeated SeqSmall0 packed_seq_small_0_hifield = 1000003 [packed = true];
+
+ enum SeqSmall1 {
+ SEQ_SMALL_1_DEFAULT = 1;
+ SEQ_SMALL_1_2 = 2;
+ SEQ_SMALL_1_3 = 3;
+ };
+ optional SeqSmall1 optional_seq_small_1_lowfield = 4;
+ optional SeqSmall1 optional_seq_small_1_midfield = 1004;
+ optional SeqSmall1 optional_seq_small_1_hifield = 1000004;
+ repeated SeqSmall1 repeated_seq_small_1_lowfield = 5;
+ repeated SeqSmall1 repeated_seq_small_1_midfield = 1005;
+ repeated SeqSmall1 repeated_seq_small_1_hifield = 1000005;
+ repeated SeqSmall1 packed_seq_small_1_lowfield = 6 [packed = true];
+ repeated SeqSmall1 packed_seq_small_1_midfield = 1006 [packed = true];
+ repeated SeqSmall1 packed_seq_small_1_hifield = 1000006 [packed = true];
+
+ enum SeqLarge {
+ SEQ_LARGE_DEFAULT = -1;
+ SEQ_LARGE_0 = 0;
+ SEQ_LARGE_1 = 1;
+ SEQ_LARGE_2 = 2;
+ SEQ_LARGE_3 = 3;
+ SEQ_LARGE_4 = 4;
+ SEQ_LARGE_5 = 5;
+ SEQ_LARGE_6 = 6;
+ SEQ_LARGE_7 = 7;
+ SEQ_LARGE_8 = 8;
+ SEQ_LARGE_9 = 9;
+ SEQ_LARGE_10 = 10;
+ SEQ_LARGE_11 = 11;
+ SEQ_LARGE_12 = 12;
+ SEQ_LARGE_13 = 13;
+ SEQ_LARGE_14 = 14;
+ SEQ_LARGE_15 = 15;
+ SEQ_LARGE_16 = 16;
+ SEQ_LARGE_17 = 17;
+ SEQ_LARGE_18 = 18;
+ SEQ_LARGE_19 = 19;
+ SEQ_LARGE_20 = 20;
+ SEQ_LARGE_21 = 21;
+ SEQ_LARGE_22 = 22;
+ SEQ_LARGE_23 = 23;
+ SEQ_LARGE_24 = 24;
+ SEQ_LARGE_25 = 25;
+ SEQ_LARGE_26 = 26;
+ SEQ_LARGE_27 = 27;
+ SEQ_LARGE_28 = 28;
+ SEQ_LARGE_29 = 29;
+ SEQ_LARGE_30 = 30;
+ SEQ_LARGE_31 = 31;
+ SEQ_LARGE_32 = 32;
+ SEQ_LARGE_33 = 33;
+ };
+ optional SeqLarge optional_seq_large_lowfield = 7;
+ optional SeqLarge optional_seq_large_midfield = 1007;
+ optional SeqLarge optional_seq_large_hifield = 1000007;
+ repeated SeqLarge repeated_seq_large_lowfield = 8;
+ repeated SeqLarge repeated_seq_large_midfield = 1008;
+ repeated SeqLarge repeated_seq_large_hifield = 1000008;
+ repeated SeqLarge packed_seq_large_lowfield = 9 [packed = true];
+ repeated SeqLarge packed_seq_large_midfield = 1009 [packed = true];
+ repeated SeqLarge packed_seq_large_hifield = 1000009 [packed = true];
+
+ enum Arbitrary {
+ ARBITRARY_DEFAULT = -123123;
+ ARBITRARY_1 = -123;
+ ARBITRARY_2 = 213;
+ ARBITRARY_3 = 213213;
+ ARBITRARY_MIN = -2147483648;
+ ARBITRARY_MAX = 2147483647;
+ };
+ optional Arbitrary optional_arbitrary_lowfield = 10;
+ optional Arbitrary optional_arbitrary_midfield = 1010;
+ optional Arbitrary optional_arbitrary_hifield = 1000010;
+ repeated Arbitrary repeated_arbitrary_lowfield = 11;
+ repeated Arbitrary repeated_arbitrary_midfield = 1011;
+ repeated Arbitrary repeated_arbitrary_hifield = 1000011;
+ repeated Arbitrary packed_arbitrary_lowfield = 12 [packed = true];
+ repeated Arbitrary packed_arbitrary_midfield = 1012 [packed = true];
+ repeated Arbitrary packed_arbitrary_hifield = 1000012 [packed = true];
+
+ // An arbitrary field we can append to to break the runs of repeated fields.
+ optional int32 other_field = 99;
+};
+
+// This message contains different kind of bool fields to exercise the different
+// parsers in table-drived.
+message BoolParseTester {
+ optional bool optional_bool_lowfield = 1;
+ optional bool optional_bool_midfield = 1001;
+ optional bool optional_bool_hifield = 1000001;
+ repeated bool repeated_bool_lowfield = 2;
+ repeated bool repeated_bool_midfield = 1002;
+ repeated bool repeated_bool_hifield = 1000002;
+ repeated bool packed_bool_lowfield = 3 [packed = true];
+ repeated bool packed_bool_midfield = 1003 [packed = true];
+ repeated bool packed_bool_hifield = 1000003 [packed = true];
+
+ // An arbitrary field we can append to to break the runs of repeated fields.
+ optional int32 other_field = 99;
+};
+
```
Contributor guide
Assessment
This issue has not been assessed yet.