123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475 |
- // Protocol Buffers - Google's data interchange format
- // Copyright 2008 Google Inc. All rights reserved.
- // 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
- // met:
- //
- // * Redistributions of source code must retain the above copyright
- // notice, this list of conditions and the following disclaimer.
- // * Redistributions in binary form must reproduce the above
- // copyright notice, this list of conditions and the following disclaimer
- // in the documentation and/or other materials provided with the
- // distribution.
- // * Neither the name of Google Inc. nor the names of its
- // contributors may be used to endorse or promote products derived from
- // this software without specific prior written permission.
- //
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- // Author: kenton@google.com (Kenton Varda)
- //
- // This is like unittest.proto but with optimize_for = LITE_RUNTIME.
- syntax = "proto2";
- package protobuf_unittest;
- import "google/protobuf/unittest_import_lite.proto";
- option optimize_for = LITE_RUNTIME;
- option java_package = "com.google.protobuf";
- // Same as TestAllTypes but with the lite runtime.
- message TestAllTypesLite {
- message NestedMessage {
- optional int32 bb = 1;
- optional int64 cc = 2;
- }
- enum NestedEnum {
- FOO = 1;
- BAR = 2;
- BAZ = 3;
- }
- // Singular
- optional int32 optional_int32 = 1;
- optional int64 optional_int64 = 2;
- optional uint32 optional_uint32 = 3;
- optional uint64 optional_uint64 = 4;
- optional sint32 optional_sint32 = 5;
- optional sint64 optional_sint64 = 6;
- optional fixed32 optional_fixed32 = 7;
- optional fixed64 optional_fixed64 = 8;
- optional sfixed32 optional_sfixed32 = 9;
- optional sfixed64 optional_sfixed64 = 10;
- optional float optional_float = 11;
- optional double optional_double = 12;
- optional bool optional_bool = 13;
- optional string optional_string = 14;
- optional bytes optional_bytes = 15;
- optional group OptionalGroup = 16 {
- optional int32 a = 17;
- }
- optional NestedMessage optional_nested_message = 18;
- optional ForeignMessageLite optional_foreign_message = 19;
- optional protobuf_unittest_import.ImportMessageLite
- optional_import_message = 20;
- optional NestedEnum optional_nested_enum = 21;
- optional ForeignEnumLite optional_foreign_enum = 22;
- optional protobuf_unittest_import.ImportEnumLite optional_import_enum = 23;
- 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.PublicImportMessageLite
- optional_public_import_message = 26;
- optional NestedMessage optional_lazy_message = 27 [lazy=true];
- // Repeated
- repeated int32 repeated_int32 = 31;
- repeated int64 repeated_int64 = 32;
- repeated uint32 repeated_uint32 = 33;
- repeated uint64 repeated_uint64 = 34;
- repeated sint32 repeated_sint32 = 35;
- repeated sint64 repeated_sint64 = 36;
- repeated fixed32 repeated_fixed32 = 37;
- repeated fixed64 repeated_fixed64 = 38;
- repeated sfixed32 repeated_sfixed32 = 39;
- repeated sfixed64 repeated_sfixed64 = 40;
- repeated float repeated_float = 41;
- repeated double repeated_double = 42;
- repeated bool repeated_bool = 43;
- repeated string repeated_string = 44;
- repeated bytes repeated_bytes = 45;
- repeated group RepeatedGroup = 46 {
- optional int32 a = 47;
- }
- repeated NestedMessage repeated_nested_message = 48;
- repeated ForeignMessageLite repeated_foreign_message = 49;
- repeated protobuf_unittest_import.ImportMessageLite
- repeated_import_message = 50;
- repeated NestedEnum repeated_nested_enum = 51;
- repeated ForeignEnumLite repeated_foreign_enum = 52;
- repeated protobuf_unittest_import.ImportEnumLite repeated_import_enum = 53;
- 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 ];
- optional uint32 default_uint32 = 63 [default = 43 ];
- optional uint64 default_uint64 = 64 [default = 44 ];
- optional sint32 default_sint32 = 65 [default = -45 ];
- optional sint64 default_sint64 = 66 [default = 46 ];
- optional fixed32 default_fixed32 = 67 [default = 47 ];
- optional fixed64 default_fixed64 = 68 [default = 48 ];
- optional sfixed32 default_sfixed32 = 69 [default = 49 ];
- optional sfixed64 default_sfixed64 = 70 [default = -50 ];
- optional float default_float = 71 [default = 51.5 ];
- optional double default_double = 72 [default = 52e3 ];
- optional bool default_bool = 73 [default = true ];
- optional string default_string = 74 [default = "hello"];
- optional bytes default_bytes = 75 [default = "world"];
- optional NestedEnum default_nested_enum = 81 [default = BAR];
- optional ForeignEnumLite default_foreign_enum = 82
- [default = FOREIGN_LITE_BAR];
- optional protobuf_unittest_import.ImportEnumLite
- default_import_enum = 83 [default = IMPORT_LITE_BAR];
- 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;
- NestedMessage oneof_lazy_nested_message = 115 [lazy = true];
- }
- // Tests toString for non-repeated fields with a list suffix
- optional int32 deceptively_named_list = 116;
- }
- message ForeignMessageLite {
- optional int32 c = 1;
- }
- enum ForeignEnumLite {
- FOREIGN_LITE_FOO = 4;
- FOREIGN_LITE_BAR = 5;
- FOREIGN_LITE_BAZ = 6;
- }
- message TestPackedTypesLite {
- repeated int32 packed_int32 = 90 [packed = true];
- repeated int64 packed_int64 = 91 [packed = true];
- repeated uint32 packed_uint32 = 92 [packed = true];
- repeated uint64 packed_uint64 = 93 [packed = true];
- repeated sint32 packed_sint32 = 94 [packed = true];
- repeated sint64 packed_sint64 = 95 [packed = true];
- repeated fixed32 packed_fixed32 = 96 [packed = true];
- repeated fixed64 packed_fixed64 = 97 [packed = true];
- repeated sfixed32 packed_sfixed32 = 98 [packed = true];
- repeated sfixed64 packed_sfixed64 = 99 [packed = true];
- repeated float packed_float = 100 [packed = true];
- repeated double packed_double = 101 [packed = true];
- repeated bool packed_bool = 102 [packed = true];
- repeated ForeignEnumLite packed_enum = 103 [packed = true];
- }
- message TestAllExtensionsLite {
- extensions 1 to max;
- }
- extend TestAllExtensionsLite {
- // Singular
- optional int32 optional_int32_extension_lite = 1;
- optional int64 optional_int64_extension_lite = 2;
- optional uint32 optional_uint32_extension_lite = 3;
- optional uint64 optional_uint64_extension_lite = 4;
- optional sint32 optional_sint32_extension_lite = 5;
- optional sint64 optional_sint64_extension_lite = 6;
- optional fixed32 optional_fixed32_extension_lite = 7;
- optional fixed64 optional_fixed64_extension_lite = 8;
- optional sfixed32 optional_sfixed32_extension_lite = 9;
- optional sfixed64 optional_sfixed64_extension_lite = 10;
- optional float optional_float_extension_lite = 11;
- optional double optional_double_extension_lite = 12;
- optional bool optional_bool_extension_lite = 13;
- optional string optional_string_extension_lite = 14;
- optional bytes optional_bytes_extension_lite = 15;
- optional group OptionalGroup_extension_lite = 16 {
- optional int32 a = 17;
- }
- optional TestAllTypesLite.NestedMessage optional_nested_message_extension_lite
- = 18;
- optional ForeignMessageLite optional_foreign_message_extension_lite = 19;
- optional protobuf_unittest_import.ImportMessageLite
- optional_import_message_extension_lite = 20;
- optional TestAllTypesLite.NestedEnum optional_nested_enum_extension_lite = 21;
- optional ForeignEnumLite optional_foreign_enum_extension_lite = 22;
- optional protobuf_unittest_import.ImportEnumLite
- optional_import_enum_extension_lite = 23;
- optional string optional_string_piece_extension_lite = 24
- [ctype=STRING_PIECE];
- optional string optional_cord_extension_lite = 25 [ctype=CORD];
- optional protobuf_unittest_import.PublicImportMessageLite
- optional_public_import_message_extension_lite = 26;
- optional TestAllTypesLite.NestedMessage
- optional_lazy_message_extension_lite = 27 [lazy=true];
- // Repeated
- repeated int32 repeated_int32_extension_lite = 31;
- repeated int64 repeated_int64_extension_lite = 32;
- repeated uint32 repeated_uint32_extension_lite = 33;
- repeated uint64 repeated_uint64_extension_lite = 34;
- repeated sint32 repeated_sint32_extension_lite = 35;
- repeated sint64 repeated_sint64_extension_lite = 36;
- repeated fixed32 repeated_fixed32_extension_lite = 37;
- repeated fixed64 repeated_fixed64_extension_lite = 38;
- repeated sfixed32 repeated_sfixed32_extension_lite = 39;
- repeated sfixed64 repeated_sfixed64_extension_lite = 40;
- repeated float repeated_float_extension_lite = 41;
- repeated double repeated_double_extension_lite = 42;
- repeated bool repeated_bool_extension_lite = 43;
- repeated string repeated_string_extension_lite = 44;
- repeated bytes repeated_bytes_extension_lite = 45;
- repeated group RepeatedGroup_extension_lite = 46 {
- optional int32 a = 47;
- }
- repeated TestAllTypesLite.NestedMessage repeated_nested_message_extension_lite
- = 48;
- repeated ForeignMessageLite repeated_foreign_message_extension_lite = 49;
- repeated protobuf_unittest_import.ImportMessageLite
- repeated_import_message_extension_lite = 50;
- repeated TestAllTypesLite.NestedEnum repeated_nested_enum_extension_lite = 51;
- repeated ForeignEnumLite repeated_foreign_enum_extension_lite = 52;
- repeated protobuf_unittest_import.ImportEnumLite
- repeated_import_enum_extension_lite = 53;
- repeated string repeated_string_piece_extension_lite = 54
- [ctype=STRING_PIECE];
- repeated string repeated_cord_extension_lite = 55 [ctype=CORD];
- repeated TestAllTypesLite.NestedMessage
- repeated_lazy_message_extension_lite = 57 [lazy=true];
- // Singular with defaults
- optional int32 default_int32_extension_lite = 61 [default = 41 ];
- optional int64 default_int64_extension_lite = 62 [default = 42 ];
- optional uint32 default_uint32_extension_lite = 63 [default = 43 ];
- optional uint64 default_uint64_extension_lite = 64 [default = 44 ];
- optional sint32 default_sint32_extension_lite = 65 [default = -45 ];
- optional sint64 default_sint64_extension_lite = 66 [default = 46 ];
- optional fixed32 default_fixed32_extension_lite = 67 [default = 47 ];
- optional fixed64 default_fixed64_extension_lite = 68 [default = 48 ];
- optional sfixed32 default_sfixed32_extension_lite = 69 [default = 49 ];
- optional sfixed64 default_sfixed64_extension_lite = 70 [default = -50 ];
- optional float default_float_extension_lite = 71 [default = 51.5 ];
- optional double default_double_extension_lite = 72 [default = 52e3 ];
- optional bool default_bool_extension_lite = 73 [default = true ];
- optional string default_string_extension_lite = 74 [default = "hello"];
- optional bytes default_bytes_extension_lite = 75 [default = "world"];
- optional TestAllTypesLite.NestedEnum
- default_nested_enum_extension_lite = 81 [default = BAR];
- optional ForeignEnumLite
- default_foreign_enum_extension_lite = 82 [default = FOREIGN_LITE_BAR];
- optional protobuf_unittest_import.ImportEnumLite
- default_import_enum_extension_lite = 83 [default = IMPORT_LITE_BAR];
- optional string default_string_piece_extension_lite = 84 [ctype=STRING_PIECE,
- default="abc"];
- optional string default_cord_extension_lite = 85 [ctype=CORD, default="123"];
- // For oneof test
- optional uint32 oneof_uint32_extension_lite = 111;
- optional TestAllTypesLite.NestedMessage oneof_nested_message_extension_lite = 112;
- optional string oneof_string_extension_lite = 113;
- optional bytes oneof_bytes_extension_lite = 114;
- }
- message TestPackedExtensionsLite {
- extensions 1 to max;
- }
- extend TestPackedExtensionsLite {
- repeated int32 packed_int32_extension_lite = 90 [packed = true];
- repeated int64 packed_int64_extension_lite = 91 [packed = true];
- repeated uint32 packed_uint32_extension_lite = 92 [packed = true];
- repeated uint64 packed_uint64_extension_lite = 93 [packed = true];
- repeated sint32 packed_sint32_extension_lite = 94 [packed = true];
- repeated sint64 packed_sint64_extension_lite = 95 [packed = true];
- repeated fixed32 packed_fixed32_extension_lite = 96 [packed = true];
- repeated fixed64 packed_fixed64_extension_lite = 97 [packed = true];
- repeated sfixed32 packed_sfixed32_extension_lite = 98 [packed = true];
- repeated sfixed64 packed_sfixed64_extension_lite = 99 [packed = true];
- repeated float packed_float_extension_lite = 100 [packed = true];
- repeated double packed_double_extension_lite = 101 [packed = true];
- repeated bool packed_bool_extension_lite = 102 [packed = true];
- repeated ForeignEnumLite packed_enum_extension_lite = 103 [packed = true];
- }
- message TestNestedExtensionLite {
- extend TestAllExtensionsLite {
- optional int32 nested_extension = 12345;
- }
- }
- // Test that deprecated fields work. We only verify that they compile (at one
- // point this failed).
- message TestDeprecatedLite {
- optional int32 deprecated_field = 1 [deprecated = true];
- }
- // See the comments of the same type in unittest.proto.
- message TestParsingMergeLite {
- message RepeatedFieldsGenerator {
- repeated TestAllTypesLite field1 = 1;
- repeated TestAllTypesLite field2 = 2;
- repeated TestAllTypesLite field3 = 3;
- repeated group Group1 = 10 {
- optional TestAllTypesLite field1 = 11;
- }
- repeated group Group2 = 20 {
- optional TestAllTypesLite field1 = 21;
- }
- repeated TestAllTypesLite ext1 = 1000;
- repeated TestAllTypesLite ext2 = 1001;
- }
- required TestAllTypesLite required_all_types = 1;
- optional TestAllTypesLite optional_all_types = 2;
- repeated TestAllTypesLite repeated_all_types = 3;
- optional group OptionalGroup = 10 {
- optional TestAllTypesLite optional_group_all_types = 11;
- }
- repeated group RepeatedGroup = 20 {
- optional TestAllTypesLite repeated_group_all_types = 21;
- }
- extensions 1000 to max;
- extend TestParsingMergeLite {
- optional TestAllTypesLite optional_ext = 1000;
- repeated TestAllTypesLite repeated_ext = 1001;
- }
- }
- // TestEmptyMessageLite is used to test unknown fields support in lite mode.
- message TestEmptyMessageLite{
- }
- // Like above, but declare all field numbers as potential extensions. No
- // actual extensions should ever be defined for this type.
- message TestEmptyMessageWithExtensionsLite {
- extensions 1 to max;
- }
- enum V1EnumLite {
- V1_FIRST = 1;
- }
- enum V2EnumLite {
- V2_FIRST = 1;
- V2_SECOND = 2;
- }
- message V1MessageLite {
- required int32 int_field = 1;
- optional V1EnumLite enum_field = 2 [ default = V1_FIRST ];
- }
- message V2MessageLite {
- required int32 int_field = 1;
- optional V2EnumLite enum_field = 2 [ default = V2_FIRST ];
- }
- message TestHugeFieldNumbersLite {
- 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 ForeignEnumLite optional_enum = 536870004;
- optional string optional_string = 536870005;
- optional bytes optional_bytes = 536870006;
- optional ForeignMessageLite optional_message = 536870007;
- optional group OptionalGroup = 536870008 {
- optional int32 group_a = 536870009;
- }
- map<string, string> string_string_map = 536870010;
- oneof oneof_field {
- uint32 oneof_uint32 = 536870011;
- TestAllTypesLite oneof_test_all_types = 536870012;
- string oneof_string = 536870013;
- bytes oneof_bytes = 536870014;
- }
- extensions 536860000 to 536869999;
- }
- extend TestHugeFieldNumbersLite {
- optional TestAllTypesLite test_all_types_lite = 536860000;
- }
- message TestOneofParsingLite {
- oneof oneof_field {
- int32 oneof_int32 = 1;
- TestAllTypesLite oneof_submessage = 2;
- string oneof_string = 3;
- bytes oneof_bytes = 4 [default = "default bytes"];
- string oneof_string_cord = 5 [ctype = CORD, default = "default Cord"];
- bytes oneof_bytes_cord = 6 [ctype = CORD];
- string oneof_string_string_piece = 7 [ctype = STRING_PIECE];
- bytes oneof_bytes_string_piece = 8
- [ctype = STRING_PIECE, default = "default StringPiece"];
- V2EnumLite oneof_enum = 9;
- }
- }
- // The following four messages are set up to test for wire compatibility between
- // packed and non-packed repeated fields. We use the field number 2048, because
- // that is large enough to require a 3-byte varint for the tag.
- message PackedInt32 {
- repeated int32 repeated_int32 = 2048 [packed = true];
- }
- message NonPackedInt32 {
- repeated int32 repeated_int32 = 2048;
- }
- message PackedFixed32 {
- repeated fixed32 repeated_fixed32 = 2048 [packed = true];
- }
- message NonPackedFixed32 {
- repeated fixed32 repeated_fixed32 = 2048;
- }
|