1// Protocol Buffers - Google's data interchange format 2// Copyright 2008 Google Inc. All rights reserved. 3// https://developers.google.com/protocol-buffers/ 4// 5// Redistribution and use in source and binary forms, with or without 6// modification, are permitted provided that the following conditions are 7// met: 8// 9// * Redistributions of source code must retain the above copyright 10// notice, this list of conditions and the following disclaimer. 11// * Redistributions in binary form must reproduce the above 12// copyright notice, this list of conditions and the following disclaimer 13// in the documentation and/or other materials provided with the 14// distribution. 15// * Neither the name of Google Inc. nor the names of its 16// contributors may be used to endorse or promote products derived from 17// this software without specific prior written permission. 18// 19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 31// Author: kenton@google.com (Kenton Varda) 32// 33// This is like unittest.proto but with optimize_for = LITE_RUNTIME. 34 35syntax = "proto2"; 36 37package protobuf_unittest; 38 39import "google/protobuf/unittest_import_lite.proto"; 40 41option cc_enable_arenas = true; 42option optimize_for = LITE_RUNTIME; 43option java_package = "com.google.protobuf"; 44 45// Same as TestAllTypes but with the lite runtime. 46message TestAllTypesLite { 47 message NestedMessage { 48 optional int32 bb = 1; 49 optional int64 cc = 2; 50 } 51 52 message NestedMessage2 { 53 optional int32 dd = 1; 54 } 55 56 enum NestedEnum { 57 FOO = 1; 58 BAR = 2; 59 BAZ = 3; 60 } 61 62 // Singular 63 optional int32 optional_int32 = 1; 64 optional int64 optional_int64 = 2; 65 optional uint32 optional_uint32 = 3; 66 optional uint64 optional_uint64 = 4; 67 optional sint32 optional_sint32 = 5; 68 optional sint64 optional_sint64 = 6; 69 optional fixed32 optional_fixed32 = 7; 70 optional fixed64 optional_fixed64 = 8; 71 optional sfixed32 optional_sfixed32 = 9; 72 optional sfixed64 optional_sfixed64 = 10; 73 optional float optional_float = 11; 74 optional double optional_double = 12; 75 optional bool optional_bool = 13; 76 optional string optional_string = 14; 77 optional bytes optional_bytes = 15; 78 79 optional group OptionalGroup = 16 { 80 optional int32 a = 17; 81 } 82 83 optional NestedMessage optional_nested_message = 18; 84 optional ForeignMessageLite optional_foreign_message = 19; 85 optional protobuf_unittest_import.ImportMessageLite optional_import_message = 86 20; 87 88 optional NestedEnum optional_nested_enum = 21; 89 optional ForeignEnumLite optional_foreign_enum = 22; 90 optional protobuf_unittest_import.ImportEnumLite optional_import_enum = 23; 91 92 optional string optional_string_piece = 24 [ctype = STRING_PIECE]; 93 optional string optional_cord = 25 [ctype = CORD]; 94 95 // Defined in unittest_import_public.proto 96 optional protobuf_unittest_import.PublicImportMessageLite 97 optional_public_import_message = 26; 98 99 optional NestedMessage optional_lazy_message = 27 [lazy = true]; 100 101 // Repeated 102 repeated int32 repeated_int32 = 31; 103 repeated int64 repeated_int64 = 32; 104 repeated uint32 repeated_uint32 = 33; 105 repeated uint64 repeated_uint64 = 34; 106 repeated sint32 repeated_sint32 = 35; 107 repeated sint64 repeated_sint64 = 36; 108 repeated fixed32 repeated_fixed32 = 37; 109 repeated fixed64 repeated_fixed64 = 38; 110 repeated sfixed32 repeated_sfixed32 = 39; 111 repeated sfixed64 repeated_sfixed64 = 40; 112 repeated float repeated_float = 41; 113 repeated double repeated_double = 42; 114 repeated bool repeated_bool = 43; 115 repeated string repeated_string = 44; 116 repeated bytes repeated_bytes = 45; 117 118 repeated group RepeatedGroup = 46 { 119 optional int32 a = 47; 120 } 121 122 repeated NestedMessage repeated_nested_message = 48; 123 repeated ForeignMessageLite repeated_foreign_message = 49; 124 repeated protobuf_unittest_import.ImportMessageLite repeated_import_message = 125 50; 126 127 repeated NestedEnum repeated_nested_enum = 51; 128 repeated ForeignEnumLite repeated_foreign_enum = 52; 129 repeated protobuf_unittest_import.ImportEnumLite repeated_import_enum = 53; 130 131 repeated string repeated_string_piece = 54 [ctype = STRING_PIECE]; 132 repeated string repeated_cord = 55 [ctype = CORD]; 133 134 repeated NestedMessage repeated_lazy_message = 57 [lazy = true]; 135 136 // Singular with defaults 137 optional int32 default_int32 = 61 [default = 41]; 138 optional int64 default_int64 = 62 [default = 42]; 139 optional uint32 default_uint32 = 63 [default = 43]; 140 optional uint64 default_uint64 = 64 [default = 44]; 141 optional sint32 default_sint32 = 65 [default = -45]; 142 optional sint64 default_sint64 = 66 [default = 46]; 143 optional fixed32 default_fixed32 = 67 [default = 47]; 144 optional fixed64 default_fixed64 = 68 [default = 48]; 145 optional sfixed32 default_sfixed32 = 69 [default = 49]; 146 optional sfixed64 default_sfixed64 = 70 [default = -50]; 147 optional float default_float = 71 [default = 51.5]; 148 optional double default_double = 72 [default = 52e3]; 149 optional bool default_bool = 73 [default = true]; 150 optional string default_string = 74 [default = "hello"]; 151 optional bytes default_bytes = 75 [default = "world"]; 152 153 optional NestedEnum default_nested_enum = 81 [default = BAR]; 154 optional ForeignEnumLite default_foreign_enum = 82 155 [default = FOREIGN_LITE_BAR]; 156 optional protobuf_unittest_import.ImportEnumLite default_import_enum = 83 157 [default = IMPORT_LITE_BAR]; 158 159 optional string default_string_piece = 84 160 [ctype = STRING_PIECE, default = "abc"]; 161 optional string default_cord = 85 [ctype = CORD, default = "123"]; 162 163 // For oneof test 164 oneof oneof_field { 165 uint32 oneof_uint32 = 111; 166 NestedMessage oneof_nested_message = 112; 167 string oneof_string = 113; 168 bytes oneof_bytes = 114; 169 NestedMessage oneof_lazy_nested_message = 115 [lazy = true]; 170 NestedMessage2 oneof_nested_message2 = 117; 171 } 172 173 // Tests toString for non-repeated fields with a list suffix 174 optional int32 deceptively_named_list = 116; 175} 176 177message ForeignMessageLite { 178 optional int32 c = 1; 179} 180 181enum ForeignEnumLite { 182 FOREIGN_LITE_FOO = 4; 183 FOREIGN_LITE_BAZ = 6; 184 FOREIGN_LITE_BAR = 5; 185} 186 187message TestPackedTypesLite { 188 repeated int32 packed_int32 = 90 [packed = true]; 189 repeated int64 packed_int64 = 91 [packed = true]; 190 repeated uint32 packed_uint32 = 92 [packed = true]; 191 repeated uint64 packed_uint64 = 93 [packed = true]; 192 repeated sint32 packed_sint32 = 94 [packed = true]; 193 repeated sint64 packed_sint64 = 95 [packed = true]; 194 repeated fixed32 packed_fixed32 = 96 [packed = true]; 195 repeated fixed64 packed_fixed64 = 97 [packed = true]; 196 repeated sfixed32 packed_sfixed32 = 98 [packed = true]; 197 repeated sfixed64 packed_sfixed64 = 99 [packed = true]; 198 repeated float packed_float = 100 [packed = true]; 199 repeated double packed_double = 101 [packed = true]; 200 repeated bool packed_bool = 102 [packed = true]; 201 repeated ForeignEnumLite packed_enum = 103 [packed = true]; 202} 203 204message TestAllExtensionsLite { 205 extensions 1 to max; 206} 207 208extend TestAllExtensionsLite { 209 // Singular 210 optional int32 optional_int32_extension_lite = 1; 211 optional int64 optional_int64_extension_lite = 2; 212 optional uint32 optional_uint32_extension_lite = 3; 213 optional uint64 optional_uint64_extension_lite = 4; 214 optional sint32 optional_sint32_extension_lite = 5; 215 optional sint64 optional_sint64_extension_lite = 6; 216 optional fixed32 optional_fixed32_extension_lite = 7; 217 optional fixed64 optional_fixed64_extension_lite = 8; 218 optional sfixed32 optional_sfixed32_extension_lite = 9; 219 optional sfixed64 optional_sfixed64_extension_lite = 10; 220 optional float optional_float_extension_lite = 11; 221 optional double optional_double_extension_lite = 12; 222 optional bool optional_bool_extension_lite = 13; 223 optional string optional_string_extension_lite = 14; 224 optional bytes optional_bytes_extension_lite = 15; 225 226 optional group OptionalGroup_extension_lite = 16 { 227 optional int32 a = 17; 228 } 229 230 optional TestAllTypesLite.NestedMessage 231 optional_nested_message_extension_lite = 18; 232 optional ForeignMessageLite optional_foreign_message_extension_lite = 19; 233 optional protobuf_unittest_import.ImportMessageLite 234 optional_import_message_extension_lite = 20; 235 236 optional TestAllTypesLite.NestedEnum optional_nested_enum_extension_lite = 21; 237 optional ForeignEnumLite optional_foreign_enum_extension_lite = 22; 238 optional protobuf_unittest_import.ImportEnumLite 239 optional_import_enum_extension_lite = 23; 240 241 optional string optional_string_piece_extension_lite = 24 242 [ctype = STRING_PIECE]; 243 optional string optional_cord_extension_lite = 25 [ctype = CORD]; 244 245 optional protobuf_unittest_import.PublicImportMessageLite 246 optional_public_import_message_extension_lite = 26; 247 248 optional TestAllTypesLite.NestedMessage optional_lazy_message_extension_lite = 249 27 [lazy = true]; 250 251 // Repeated 252 repeated int32 repeated_int32_extension_lite = 31; 253 repeated int64 repeated_int64_extension_lite = 32; 254 repeated uint32 repeated_uint32_extension_lite = 33; 255 repeated uint64 repeated_uint64_extension_lite = 34; 256 repeated sint32 repeated_sint32_extension_lite = 35; 257 repeated sint64 repeated_sint64_extension_lite = 36; 258 repeated fixed32 repeated_fixed32_extension_lite = 37; 259 repeated fixed64 repeated_fixed64_extension_lite = 38; 260 repeated sfixed32 repeated_sfixed32_extension_lite = 39; 261 repeated sfixed64 repeated_sfixed64_extension_lite = 40; 262 repeated float repeated_float_extension_lite = 41; 263 repeated double repeated_double_extension_lite = 42; 264 repeated bool repeated_bool_extension_lite = 43; 265 repeated string repeated_string_extension_lite = 44; 266 repeated bytes repeated_bytes_extension_lite = 45; 267 268 repeated group RepeatedGroup_extension_lite = 46 { 269 optional int32 a = 47; 270 } 271 272 repeated TestAllTypesLite.NestedMessage 273 repeated_nested_message_extension_lite = 48; 274 repeated ForeignMessageLite repeated_foreign_message_extension_lite = 49; 275 repeated protobuf_unittest_import.ImportMessageLite 276 repeated_import_message_extension_lite = 50; 277 278 repeated TestAllTypesLite.NestedEnum repeated_nested_enum_extension_lite = 51; 279 repeated ForeignEnumLite repeated_foreign_enum_extension_lite = 52; 280 repeated protobuf_unittest_import.ImportEnumLite 281 repeated_import_enum_extension_lite = 53; 282 283 repeated string repeated_string_piece_extension_lite = 54 284 [ctype = STRING_PIECE]; 285 repeated string repeated_cord_extension_lite = 55 [ctype = CORD]; 286 287 repeated TestAllTypesLite.NestedMessage repeated_lazy_message_extension_lite = 288 57 [lazy = true]; 289 290 // Singular with defaults 291 optional int32 default_int32_extension_lite = 61 [default = 41]; 292 optional int64 default_int64_extension_lite = 62 [default = 42]; 293 optional uint32 default_uint32_extension_lite = 63 [default = 43]; 294 optional uint64 default_uint64_extension_lite = 64 [default = 44]; 295 optional sint32 default_sint32_extension_lite = 65 [default = -45]; 296 optional sint64 default_sint64_extension_lite = 66 [default = 46]; 297 optional fixed32 default_fixed32_extension_lite = 67 [default = 47]; 298 optional fixed64 default_fixed64_extension_lite = 68 [default = 48]; 299 optional sfixed32 default_sfixed32_extension_lite = 69 [default = 49]; 300 optional sfixed64 default_sfixed64_extension_lite = 70 [default = -50]; 301 optional float default_float_extension_lite = 71 [default = 51.5]; 302 optional double default_double_extension_lite = 72 [default = 52e3]; 303 optional bool default_bool_extension_lite = 73 [default = true]; 304 optional string default_string_extension_lite = 74 [default = "hello"]; 305 optional bytes default_bytes_extension_lite = 75 [default = "world"]; 306 307 optional TestAllTypesLite.NestedEnum default_nested_enum_extension_lite = 81 308 [default = BAR]; 309 optional ForeignEnumLite default_foreign_enum_extension_lite = 82 310 [default = FOREIGN_LITE_BAR]; 311 optional protobuf_unittest_import.ImportEnumLite 312 default_import_enum_extension_lite = 83 [default = IMPORT_LITE_BAR]; 313 314 optional string default_string_piece_extension_lite = 84 315 [ctype = STRING_PIECE, default = "abc"]; 316 optional string default_cord_extension_lite = 85 317 [ctype = CORD, default = "123"]; 318 319 // For oneof test 320 optional uint32 oneof_uint32_extension_lite = 111; 321 optional TestAllTypesLite.NestedMessage oneof_nested_message_extension_lite = 322 112; 323 optional string oneof_string_extension_lite = 113; 324 optional bytes oneof_bytes_extension_lite = 114; 325} 326 327message TestPackedExtensionsLite { 328 extensions 1 to max; 329} 330 331extend TestPackedExtensionsLite { 332 repeated int32 packed_int32_extension_lite = 90 [packed = true]; 333 repeated int64 packed_int64_extension_lite = 91 [packed = true]; 334 repeated uint32 packed_uint32_extension_lite = 92 [packed = true]; 335 repeated uint64 packed_uint64_extension_lite = 93 [packed = true]; 336 repeated sint32 packed_sint32_extension_lite = 94 [packed = true]; 337 repeated sint64 packed_sint64_extension_lite = 95 [packed = true]; 338 repeated fixed32 packed_fixed32_extension_lite = 96 [packed = true]; 339 repeated fixed64 packed_fixed64_extension_lite = 97 [packed = true]; 340 repeated sfixed32 packed_sfixed32_extension_lite = 98 [packed = true]; 341 repeated sfixed64 packed_sfixed64_extension_lite = 99 [packed = true]; 342 repeated float packed_float_extension_lite = 100 [packed = true]; 343 repeated double packed_double_extension_lite = 101 [packed = true]; 344 repeated bool packed_bool_extension_lite = 102 [packed = true]; 345 repeated ForeignEnumLite packed_enum_extension_lite = 103 [packed = true]; 346} 347 348message TestNestedExtensionLite { 349 extend TestAllExtensionsLite { 350 optional int32 nested_extension = 12345; 351 } 352} 353 354// Test that deprecated fields work. We only verify that they compile (at one 355// point this failed). 356message TestDeprecatedLite { 357 optional int32 deprecated_field = 1 [deprecated = true]; 358 required int32 deprecated_field2 = 2 [deprecated = true]; 359 optional string deprecated_field3 = 3 [deprecated = true]; 360 optional TestDeprecatedLite deprecated_field4 = 4 [deprecated = true]; 361} 362 363// See the comments of the same type in unittest.proto. 364message TestParsingMergeLite { 365 message RepeatedFieldsGenerator { 366 repeated TestAllTypesLite field1 = 1; 367 repeated TestAllTypesLite field2 = 2; 368 repeated TestAllTypesLite field3 = 3; 369 repeated group Group1 = 10 { 370 optional TestAllTypesLite field1 = 11; 371 } 372 repeated group Group2 = 20 { 373 optional TestAllTypesLite field1 = 21; 374 } 375 repeated TestAllTypesLite ext1 = 1000; 376 repeated TestAllTypesLite ext2 = 1001; 377 } 378 required TestAllTypesLite required_all_types = 1; 379 optional TestAllTypesLite optional_all_types = 2; 380 repeated TestAllTypesLite repeated_all_types = 3; 381 optional group OptionalGroup = 10 { 382 optional TestAllTypesLite optional_group_all_types = 11; 383 } 384 repeated group RepeatedGroup = 20 { 385 optional TestAllTypesLite repeated_group_all_types = 21; 386 } 387 extensions 1000 to max; 388 extend TestParsingMergeLite { 389 optional TestAllTypesLite optional_ext = 1000; 390 repeated TestAllTypesLite repeated_ext = 1001; 391 } 392} 393 394// TestEmptyMessageLite is used to test unknown fields support in lite mode. 395message TestEmptyMessageLite {} 396 397// Like above, but declare all field numbers as potential extensions. No 398// actual extensions should ever be defined for this type. 399message TestEmptyMessageWithExtensionsLite { 400 extensions 1 to max; 401} 402 403enum V1EnumLite { V1_FIRST = 1; } 404 405enum V2EnumLite { 406 V2_FIRST = 1; 407 V2_SECOND = 2; 408} 409 410message V1MessageLite { 411 required int32 int_field = 1; 412 optional V1EnumLite enum_field = 2 [default = V1_FIRST]; 413} 414 415message V2MessageLite { 416 required int32 int_field = 1; 417 optional V2EnumLite enum_field = 2 [default = V2_FIRST]; 418} 419 420message TestHugeFieldNumbersLite { 421 optional int32 optional_int32 = 536870000; 422 optional int32 fixed_32 = 536870001; 423 repeated int32 repeated_int32 = 536870002 [packed = false]; 424 repeated int32 packed_int32 = 536870003 [packed = true]; 425 426 optional ForeignEnumLite optional_enum = 536870004; 427 optional string optional_string = 536870005; 428 optional bytes optional_bytes = 536870006; 429 optional ForeignMessageLite optional_message = 536870007; 430 431 optional group OptionalGroup = 536870008 { 432 optional int32 group_a = 536870009; 433 } 434 435 map<string, string> string_string_map = 536870010; 436 437 oneof oneof_field { 438 uint32 oneof_uint32 = 536870011; 439 TestAllTypesLite oneof_test_all_types = 536870012; 440 string oneof_string = 536870013; 441 bytes oneof_bytes = 536870014; 442 } 443 444 extensions 536860000 to 536869999; 445} 446 447extend TestHugeFieldNumbersLite { 448 optional TestAllTypesLite test_all_types_lite = 536860000; 449} 450 451message TestOneofParsingLite { 452 oneof oneof_field { 453 int32 oneof_int32 = 1; 454 TestAllTypesLite oneof_submessage = 2; 455 string oneof_string = 3; 456 bytes oneof_bytes = 4 [default = "default bytes"]; 457 string oneof_string_cord = 5 [ctype = CORD, default = "default Cord"]; 458 bytes oneof_bytes_cord = 6 [ctype = CORD]; 459 string oneof_string_string_piece = 7 [ctype = STRING_PIECE]; 460 bytes oneof_bytes_string_piece = 8 461 [ctype = STRING_PIECE, default = "default StringPiece"]; 462 V2EnumLite oneof_enum = 9; 463 } 464} 465 466// The following four messages are set up to test for wire compatibility between 467// packed and non-packed repeated fields. We use the field number 2048, because 468// that is large enough to require a 3-byte varint for the tag. 469message PackedInt32 { 470 repeated int32 repeated_int32 = 2048 [packed = true]; 471} 472 473message NonPackedInt32 { 474 repeated int32 repeated_int32 = 2048; 475} 476 477message PackedFixed32 { 478 repeated fixed32 repeated_fixed32 = 2048 [packed = true]; 479} 480 481message NonPackedFixed32 { 482 repeated fixed32 repeated_fixed32 = 2048; 483} 484 485// Test an enum that has multiple values with the same number. 486message DupEnum { 487 enum TestEnumWithDupValueLite { 488 option allow_alias = true; 489 490 FOO1 = 1; 491 BAR1 = 2; 492 BAZ = 3; 493 FOO2 = 1; 494 BAR2 = 2; 495 } 496} 497