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// Based on original Protocol Buffers design by 33// Sanjay Ghemawat, Jeff Dean, and others. 34// 35// A proto file we will use for unit testing. 36// 37// LINT: ALLOW_GROUPS, LEGACY_NAMES 38 39syntax = "proto2"; 40 41// Some generic_services option(s) added automatically. 42// See: http://go/proto2-generic-services-default 43option cc_generic_services = true; // auto-added 44option java_generic_services = true; // auto-added 45option py_generic_services = true; // auto-added 46option cc_enable_arenas = true; 47 48import "google/protobuf/unittest_import.proto"; 49 50// We don't put this in a package within proto2 because we need to make sure 51// that the generated code doesn't depend on being in the proto2 namespace. 52// In test_util.h we do "using namespace unittest = protobuf_unittest". 53package protobuf_unittest; 54 55// Protos optimized for SPEED use a strict superset of the generated code 56// of equivalent ones optimized for CODE_SIZE, so we should optimize all our 57// tests for speed unless explicitly testing code size optimization. 58option optimize_for = SPEED; 59 60option java_outer_classname = "UnittestProto"; 61 62// This proto includes every type of field in both singular and repeated 63// forms. 64message TestAllTypes { 65 message NestedMessage { 66 // The field name "b" fails to compile in proto1 because it conflicts with 67 // a local variable named "b" in one of the generated methods. Doh. 68 // This file needs to compile in proto1 to test backwards-compatibility. 69 optional int32 bb = 1; 70 } 71 72 enum NestedEnum { 73 FOO = 1; 74 BAR = 2; 75 BAZ = 3; 76 NEG = -1; // Intentionally negative. 77 } 78 79 // Singular 80 optional int32 optional_int32 = 1; 81 optional int64 optional_int64 = 2; 82 optional uint32 optional_uint32 = 3; 83 optional uint64 optional_uint64 = 4; 84 optional sint32 optional_sint32 = 5; 85 optional sint64 optional_sint64 = 6; 86 optional fixed32 optional_fixed32 = 7; 87 optional fixed64 optional_fixed64 = 8; 88 optional sfixed32 optional_sfixed32 = 9; 89 optional sfixed64 optional_sfixed64 = 10; 90 optional float optional_float = 11; 91 optional double optional_double = 12; 92 optional bool optional_bool = 13; 93 optional string optional_string = 14; 94 optional bytes optional_bytes = 15; 95 96 optional group OptionalGroup = 16 { 97 optional int32 a = 17; 98 } 99 100 optional NestedMessage optional_nested_message = 18; 101 optional ForeignMessage optional_foreign_message = 19; 102 optional protobuf_unittest_import.ImportMessage optional_import_message = 20; 103 104 optional NestedEnum optional_nested_enum = 21; 105 optional ForeignEnum optional_foreign_enum = 22; 106 optional protobuf_unittest_import.ImportEnum optional_import_enum = 23; 107 108 optional string optional_string_piece = 24 [ctype=STRING_PIECE]; 109 optional string optional_cord = 25 [ctype=CORD]; 110 111 // Defined in unittest_import_public.proto 112 optional protobuf_unittest_import.PublicImportMessage 113 optional_public_import_message = 26; 114 115 optional NestedMessage optional_lazy_message = 27 [lazy=true]; 116 optional NestedMessage optional_unverified_lazy_message = 28 [unverified_lazy=true]; 117 118 // Repeated 119 repeated int32 repeated_int32 = 31; 120 repeated int64 repeated_int64 = 32; 121 repeated uint32 repeated_uint32 = 33; 122 repeated uint64 repeated_uint64 = 34; 123 repeated sint32 repeated_sint32 = 35; 124 repeated sint64 repeated_sint64 = 36; 125 repeated fixed32 repeated_fixed32 = 37; 126 repeated fixed64 repeated_fixed64 = 38; 127 repeated sfixed32 repeated_sfixed32 = 39; 128 repeated sfixed64 repeated_sfixed64 = 40; 129 repeated float repeated_float = 41; 130 repeated double repeated_double = 42; 131 repeated bool repeated_bool = 43; 132 repeated string repeated_string = 44; 133 repeated bytes repeated_bytes = 45; 134 135 repeated group RepeatedGroup = 46 { 136 optional int32 a = 47; 137 } 138 139 repeated NestedMessage repeated_nested_message = 48; 140 repeated ForeignMessage repeated_foreign_message = 49; 141 repeated protobuf_unittest_import.ImportMessage repeated_import_message = 50; 142 143 repeated NestedEnum repeated_nested_enum = 51; 144 repeated ForeignEnum repeated_foreign_enum = 52; 145 repeated protobuf_unittest_import.ImportEnum repeated_import_enum = 53; 146 147 repeated string repeated_string_piece = 54 [ctype=STRING_PIECE]; 148 repeated string repeated_cord = 55 [ctype=CORD]; 149 150 repeated NestedMessage repeated_lazy_message = 57 [lazy=true]; 151 152 // Singular with defaults 153 optional int32 default_int32 = 61 [default = 41 ]; 154 optional int64 default_int64 = 62 [default = 42 ]; 155 optional uint32 default_uint32 = 63 [default = 43 ]; 156 optional uint64 default_uint64 = 64 [default = 44 ]; 157 optional sint32 default_sint32 = 65 [default = -45 ]; 158 optional sint64 default_sint64 = 66 [default = 46 ]; 159 optional fixed32 default_fixed32 = 67 [default = 47 ]; 160 optional fixed64 default_fixed64 = 68 [default = 48 ]; 161 optional sfixed32 default_sfixed32 = 69 [default = 49 ]; 162 optional sfixed64 default_sfixed64 = 70 [default = -50 ]; 163 optional float default_float = 71 [default = 51.5 ]; 164 optional double default_double = 72 [default = 52e3 ]; 165 optional bool default_bool = 73 [default = true ]; 166 optional string default_string = 74 [default = "hello"]; 167 optional bytes default_bytes = 75 [default = "world"]; 168 169 optional NestedEnum default_nested_enum = 81 [default = BAR ]; 170 optional ForeignEnum default_foreign_enum = 82 [default = FOREIGN_BAR]; 171 optional protobuf_unittest_import.ImportEnum 172 default_import_enum = 83 [default = IMPORT_BAR]; 173 174 optional string default_string_piece = 84 [ctype=STRING_PIECE,default="abc"]; 175 optional string default_cord = 85 [ctype=CORD,default="123"]; 176 177 // For oneof test 178 oneof oneof_field { 179 uint32 oneof_uint32 = 111; 180 NestedMessage oneof_nested_message = 112; 181 string oneof_string = 113; 182 bytes oneof_bytes = 114; 183 } 184} 185 186// This proto includes a recursively nested message. 187message NestedTestAllTypes { 188 optional NestedTestAllTypes child = 1; 189 optional TestAllTypes payload = 2; 190 repeated NestedTestAllTypes repeated_child = 3; 191 optional NestedTestAllTypes lazy_child = 4 [lazy=true]; 192 optional TestAllTypes eager_child = 5 [lazy=false]; 193} 194 195message TestDeprecatedFields { 196 optional int32 deprecated_int32 = 1 [deprecated=true]; 197 oneof oneof_fields { 198 int32 deprecated_int32_in_oneof = 2 [deprecated=true]; 199 } 200} 201 202message TestDeprecatedMessage { 203 option deprecated = true; 204} 205 206// Define these after TestAllTypes to make sure the compiler can handle 207// that. 208message ForeignMessage { 209 optional int32 c = 1; 210 optional int32 d = 2; 211} 212 213enum ForeignEnum { 214 FOREIGN_FOO = 4; 215 FOREIGN_BAR = 5; 216 FOREIGN_BAZ = 6; 217} 218 219message TestReservedFields { 220 reserved 2, 15, 9 to 11; 221 reserved "bar", "baz"; 222} 223 224message TestAllExtensions { 225 extensions 1 to max; 226} 227 228extend TestAllExtensions { 229 // Singular 230 optional int32 optional_int32_extension = 1; 231 optional int64 optional_int64_extension = 2; 232 optional uint32 optional_uint32_extension = 3; 233 optional uint64 optional_uint64_extension = 4; 234 optional sint32 optional_sint32_extension = 5; 235 optional sint64 optional_sint64_extension = 6; 236 optional fixed32 optional_fixed32_extension = 7; 237 optional fixed64 optional_fixed64_extension = 8; 238 optional sfixed32 optional_sfixed32_extension = 9; 239 optional sfixed64 optional_sfixed64_extension = 10; 240 optional float optional_float_extension = 11; 241 optional double optional_double_extension = 12; 242 optional bool optional_bool_extension = 13; 243 optional string optional_string_extension = 14; 244 optional bytes optional_bytes_extension = 15; 245 246 optional group OptionalGroup_extension = 16 { 247 optional int32 a = 17; 248 } 249 250 optional TestAllTypes.NestedMessage optional_nested_message_extension = 18; 251 optional ForeignMessage optional_foreign_message_extension = 19; 252 optional protobuf_unittest_import.ImportMessage 253 optional_import_message_extension = 20; 254 255 optional TestAllTypes.NestedEnum optional_nested_enum_extension = 21; 256 optional ForeignEnum optional_foreign_enum_extension = 22; 257 optional protobuf_unittest_import.ImportEnum 258 optional_import_enum_extension = 23; 259 260 optional string optional_string_piece_extension = 24 [ctype=STRING_PIECE]; 261 optional string optional_cord_extension = 25 [ctype=CORD]; 262 263 optional protobuf_unittest_import.PublicImportMessage 264 optional_public_import_message_extension = 26; 265 266 optional TestAllTypes.NestedMessage 267 optional_lazy_message_extension = 27 [lazy=true]; 268 optional TestAllTypes.NestedMessage 269 optional_unverified_lazy_message_extension = 28 [unverified_lazy=true]; 270 271 // Repeated 272 repeated int32 repeated_int32_extension = 31; 273 repeated int64 repeated_int64_extension = 32; 274 repeated uint32 repeated_uint32_extension = 33; 275 repeated uint64 repeated_uint64_extension = 34; 276 repeated sint32 repeated_sint32_extension = 35; 277 repeated sint64 repeated_sint64_extension = 36; 278 repeated fixed32 repeated_fixed32_extension = 37; 279 repeated fixed64 repeated_fixed64_extension = 38; 280 repeated sfixed32 repeated_sfixed32_extension = 39; 281 repeated sfixed64 repeated_sfixed64_extension = 40; 282 repeated float repeated_float_extension = 41; 283 repeated double repeated_double_extension = 42; 284 repeated bool repeated_bool_extension = 43; 285 repeated string repeated_string_extension = 44; 286 repeated bytes repeated_bytes_extension = 45; 287 288 repeated group RepeatedGroup_extension = 46 { 289 optional int32 a = 47; 290 } 291 292 repeated TestAllTypes.NestedMessage repeated_nested_message_extension = 48; 293 repeated ForeignMessage repeated_foreign_message_extension = 49; 294 repeated protobuf_unittest_import.ImportMessage 295 repeated_import_message_extension = 50; 296 297 repeated TestAllTypes.NestedEnum repeated_nested_enum_extension = 51; 298 repeated ForeignEnum repeated_foreign_enum_extension = 52; 299 repeated protobuf_unittest_import.ImportEnum 300 repeated_import_enum_extension = 53; 301 302 repeated string repeated_string_piece_extension = 54 [ctype=STRING_PIECE]; 303 repeated string repeated_cord_extension = 55 [ctype=CORD]; 304 305 repeated TestAllTypes.NestedMessage 306 repeated_lazy_message_extension = 57 [lazy=true]; 307 308 // Singular with defaults 309 optional int32 default_int32_extension = 61 [default = 41 ]; 310 optional int64 default_int64_extension = 62 [default = 42 ]; 311 optional uint32 default_uint32_extension = 63 [default = 43 ]; 312 optional uint64 default_uint64_extension = 64 [default = 44 ]; 313 optional sint32 default_sint32_extension = 65 [default = -45 ]; 314 optional sint64 default_sint64_extension = 66 [default = 46 ]; 315 optional fixed32 default_fixed32_extension = 67 [default = 47 ]; 316 optional fixed64 default_fixed64_extension = 68 [default = 48 ]; 317 optional sfixed32 default_sfixed32_extension = 69 [default = 49 ]; 318 optional sfixed64 default_sfixed64_extension = 70 [default = -50 ]; 319 optional float default_float_extension = 71 [default = 51.5 ]; 320 optional double default_double_extension = 72 [default = 52e3 ]; 321 optional bool default_bool_extension = 73 [default = true ]; 322 optional string default_string_extension = 74 [default = "hello"]; 323 optional bytes default_bytes_extension = 75 [default = "world"]; 324 325 optional TestAllTypes.NestedEnum 326 default_nested_enum_extension = 81 [default = BAR]; 327 optional ForeignEnum 328 default_foreign_enum_extension = 82 [default = FOREIGN_BAR]; 329 optional protobuf_unittest_import.ImportEnum 330 default_import_enum_extension = 83 [default = IMPORT_BAR]; 331 332 optional string default_string_piece_extension = 84 [ctype=STRING_PIECE, 333 default="abc"]; 334 optional string default_cord_extension = 85 [ctype=CORD, default="123"]; 335 336 // For oneof test 337 optional uint32 oneof_uint32_extension = 111; 338 optional TestAllTypes.NestedMessage oneof_nested_message_extension = 112; 339 optional string oneof_string_extension = 113; 340 optional bytes oneof_bytes_extension = 114; 341} 342 343message TestGroup { 344 optional group OptionalGroup = 16 { 345 optional int32 a = 17; 346 } 347 optional ForeignEnum optional_foreign_enum = 22; 348} 349 350message TestGroupExtension { 351 extensions 1 to max; 352} 353 354message TestNestedExtension { 355 extend TestAllExtensions { 356 // Check for bug where string extensions declared in tested scope did not 357 // compile. 358 optional string test = 1002 [default="test"]; 359 // Used to test if generated extension name is correct when there are 360 // underscores. 361 optional string nested_string_extension = 1003; 362 } 363 364 extend TestGroupExtension { 365 optional group OptionalGroup_extension = 16 { 366 optional int32 a = 17; 367 } 368 optional ForeignEnum optional_foreign_enum_extension = 22; 369 } 370} 371 372message TestChildExtension { 373 optional string a = 1; 374 optional string b = 2; 375 optional TestAllExtensions optional_extension = 3; 376} 377 378// Emulates wireformat data of TestChildExtension with dynamic extension 379// (DynamicExtension). 380message TestChildExtensionData { 381 message NestedTestAllExtensionsData { 382 message NestedDynamicExtensions { 383 optional int32 a = 1; 384 optional int32 b = 2; 385 } 386 optional NestedDynamicExtensions dynamic = 409707008; 387 } 388 optional string a = 1; 389 optional string b = 2; 390 optional NestedTestAllExtensionsData optional_extension = 3; 391} 392 393message TestNestedChildExtension { 394 optional int32 a = 1; 395 optional TestChildExtension child = 2; 396} 397 398// Emulates wireformat data of TestNestedChildExtension with dynamic extension 399// (DynamicExtension). 400message TestNestedChildExtensionData { 401 optional int32 a = 1; 402 optional TestChildExtensionData child = 2; 403} 404 405// We have separate messages for testing required fields because it's 406// annoying to have to fill in required fields in TestProto in order to 407// do anything with it. Note that we don't need to test every type of 408// required filed because the code output is basically identical to 409// optional fields for all types. 410message TestRequired { 411 required int32 a = 1; 412 optional int32 dummy2 = 2; 413 required int32 b = 3; 414 415 extend TestAllExtensions { 416 optional TestRequired single = 1000; 417 repeated TestRequired multi = 1001; 418 } 419 420 // Pad the field count to 32 so that we can test that IsInitialized() 421 // properly checks multiple elements of has_bits_. 422 optional int32 dummy4 = 4; 423 optional int32 dummy5 = 5; 424 optional int32 dummy6 = 6; 425 optional int32 dummy7 = 7; 426 optional int32 dummy8 = 8; 427 optional int32 dummy9 = 9; 428 optional int32 dummy10 = 10; 429 optional int32 dummy11 = 11; 430 optional int32 dummy12 = 12; 431 optional int32 dummy13 = 13; 432 optional int32 dummy14 = 14; 433 optional int32 dummy15 = 15; 434 optional int32 dummy16 = 16; 435 optional int32 dummy17 = 17; 436 optional int32 dummy18 = 18; 437 optional int32 dummy19 = 19; 438 optional int32 dummy20 = 20; 439 optional int32 dummy21 = 21; 440 optional int32 dummy22 = 22; 441 optional int32 dummy23 = 23; 442 optional int32 dummy24 = 24; 443 optional int32 dummy25 = 25; 444 optional int32 dummy26 = 26; 445 optional int32 dummy27 = 27; 446 optional int32 dummy28 = 28; 447 optional int32 dummy29 = 29; 448 optional int32 dummy30 = 30; 449 optional int32 dummy31 = 31; 450 optional int32 dummy32 = 32; 451 452 required int32 c = 33; 453 454 // Add an optional child message to make this non-trivial for go/pdlazy. 455 optional ForeignMessage optional_foreign = 34; 456} 457 458message TestRequiredForeign { 459 optional TestRequired optional_message = 1; 460 repeated TestRequired repeated_message = 2; 461 optional int32 dummy = 3; 462} 463 464message TestRequiredMessage { 465 optional TestRequired optional_message = 1; 466 repeated TestRequired repeated_message = 2; 467 required TestRequired required_message = 3; 468} 469 470message TestNestedRequiredForeign { 471 optional TestNestedRequiredForeign child = 1; 472 optional TestRequiredForeign payload = 2; 473 optional int32 dummy = 3; 474} 475 476// Test that we can use NestedMessage from outside TestAllTypes. 477message TestForeignNested { 478 optional TestAllTypes.NestedMessage foreign_nested = 1; 479} 480 481// TestEmptyMessage is used to test unknown field support. 482message TestEmptyMessage { 483} 484 485// Like above, but declare all field numbers as potential extensions. No 486// actual extensions should ever be defined for this type. 487message TestEmptyMessageWithExtensions { 488 extensions 1 to max; 489} 490 491// Needed for a Python test. 492message TestPickleNestedMessage { 493 message NestedMessage { 494 optional int32 bb = 1; 495 message NestedNestedMessage { 496 optional int32 cc = 1; 497 } 498 } 499} 500 501message TestMultipleExtensionRanges { 502 extensions 42; 503 extensions 4143 to 4243; 504 extensions 65536 to max; 505} 506 507// Test that really large tag numbers don't break anything. 508message TestReallyLargeTagNumber { 509 // The largest possible tag number is 2^28 - 1, since the wire format uses 510 // three bits to communicate wire type. 511 optional int32 a = 1; 512 optional int32 bb = 268435455; 513} 514 515message TestRecursiveMessage { 516 optional TestRecursiveMessage a = 1; 517 optional int32 i = 2; 518} 519 520// Test that mutual recursion works. 521message TestMutualRecursionA { 522 message SubMessage { 523 optional TestMutualRecursionB b = 1; 524 } 525 optional TestMutualRecursionB bb = 1; 526 optional group SubGroup = 2 { 527 optional SubMessage sub_message = 3; // Needed because of bug in javatest 528 optional TestAllTypes not_in_this_scc = 4; 529 } 530} 531 532message TestMutualRecursionB { 533 optional TestMutualRecursionA a = 1; 534 optional int32 optional_int32 = 2; 535} 536 537message TestIsInitialized { 538 message SubMessage { 539 optional group SubGroup = 1 { 540 required int32 i = 2; 541 } 542 } 543 optional SubMessage sub_message = 1; 544} 545 546// Test that groups have disjoint field numbers from their siblings and 547// parents. This is NOT possible in proto1; only google.protobuf. When attempting 548// to compile with proto1, this will emit an error; so we only include it 549// in protobuf_unittest_proto. 550message TestDupFieldNumber { // NO_PROTO1 551 optional int32 a = 1; // NO_PROTO1 552 optional group Foo = 2 { optional int32 a = 1; } // NO_PROTO1 553 optional group Bar = 3 { optional int32 a = 1; } // NO_PROTO1 554} // NO_PROTO1 555 556// Additional messages for testing lazy fields. 557message TestEagerMessage { 558 optional TestAllTypes sub_message = 1 [lazy=false]; 559} 560message TestLazyMessage { 561 optional TestAllTypes sub_message = 1 [lazy=true]; 562} 563message TestEagerMaybeLazy { 564 message NestedMessage { 565 optional TestPackedTypes packed = 1; 566 } 567 optional TestAllTypes message_foo = 1; 568 optional TestAllTypes message_bar = 2; 569 optional NestedMessage message_baz = 3; 570} 571// Needed for a Python test. 572message TestNestedMessageHasBits { 573 message NestedMessage { 574 repeated int32 nestedmessage_repeated_int32 = 1; 575 repeated ForeignMessage nestedmessage_repeated_foreignmessage = 2; 576 } 577 optional NestedMessage optional_nested_message = 1; 578} 579 580 581// Test an enum that has multiple values with the same number. 582enum TestEnumWithDupValue { 583 option allow_alias = true; 584 585 FOO1 = 1; 586 BAR1 = 2; 587 BAZ = 3; 588 FOO2 = 1; 589 BAR2 = 2; 590} 591 592// Test an enum with large, unordered values. 593enum TestSparseEnum { 594 SPARSE_A = 123; 595 SPARSE_B = 62374; 596 SPARSE_C = 12589234; 597 SPARSE_D = -15; 598 SPARSE_E = -53452; 599 SPARSE_F = 0; 600 SPARSE_G = 2; 601} 602 603// Test message with CamelCase field names. This violates Protocol Buffer 604// standard style. 605message TestCamelCaseFieldNames { 606 optional int32 PrimitiveField = 1; 607 optional string StringField = 2; 608 optional ForeignEnum EnumField = 3; 609 optional ForeignMessage MessageField = 4; 610 optional string StringPieceField = 5 [ctype=STRING_PIECE]; 611 optional string CordField = 6 [ctype=CORD]; 612 613 repeated int32 RepeatedPrimitiveField = 7; 614 repeated string RepeatedStringField = 8; 615 repeated ForeignEnum RepeatedEnumField = 9; 616 repeated ForeignMessage RepeatedMessageField = 10; 617 repeated string RepeatedStringPieceField = 11 [ctype=STRING_PIECE]; 618 repeated string RepeatedCordField = 12 [ctype=CORD]; 619} 620 621 622// We list fields out of order, to ensure that we're using field number and not 623// field index to determine serialization order. 624message TestFieldOrderings { 625 optional string my_string = 11; 626 extensions 2 to 10; 627 optional int64 my_int = 1; 628 extensions 12 to 100; 629 optional float my_float = 101; 630 message NestedMessage { 631 optional int64 oo = 2; 632 // The field name "b" fails to compile in proto1 because it conflicts with 633 // a local variable named "b" in one of the generated methods. Doh. 634 // This file needs to compile in proto1 to test backwards-compatibility. 635 optional int32 bb = 1; 636 } 637 638 optional NestedMessage optional_nested_message = 200; 639} 640 641extend TestFieldOrderings { 642 optional string my_extension_string = 50; 643 optional int32 my_extension_int = 5; 644} 645 646message TestExtensionOrderings1 { 647 extend TestFieldOrderings { 648 optional TestExtensionOrderings1 test_ext_orderings1 = 13; 649 } 650 optional string my_string = 1; 651} 652 653message TestExtensionOrderings2 { 654 extend TestFieldOrderings { 655 optional TestExtensionOrderings2 test_ext_orderings2 = 12; 656 } 657 message TestExtensionOrderings3 { 658 extend TestFieldOrderings { 659 optional TestExtensionOrderings3 test_ext_orderings3 = 14; 660 } 661 optional string my_string = 1; 662 } 663 optional string my_string = 1; 664} 665 666message TestExtremeDefaultValues { 667 optional bytes escaped_bytes = 1 [default = "\0\001\a\b\f\n\r\t\v\\\'\"\xfe"]; 668 optional uint32 large_uint32 = 2 [default = 0xFFFFFFFF]; 669 optional uint64 large_uint64 = 3 [default = 0xFFFFFFFFFFFFFFFF]; 670 optional int32 small_int32 = 4 [default = -0x7FFFFFFF]; 671 optional int64 small_int64 = 5 [default = -0x7FFFFFFFFFFFFFFF]; 672 optional int32 really_small_int32 = 21 [default = -0x80000000]; 673 optional int64 really_small_int64 = 22 [default = -0x8000000000000000]; 674 675 // The default value here is UTF-8 for "\u1234". (We could also just type 676 // the UTF-8 text directly into this text file rather than escape it, but 677 // lots of people use editors that would be confused by this.) 678 optional string utf8_string = 6 [default = "\341\210\264"]; 679 680 // Tests for single-precision floating-point values. 681 optional float zero_float = 7 [default = 0]; 682 optional float one_float = 8 [default = 1]; 683 optional float small_float = 9 [default = 1.5]; 684 optional float negative_one_float = 10 [default = -1]; 685 optional float negative_float = 11 [default = -1.5]; 686 // Using exponents 687 optional float large_float = 12 [default = 2E8]; 688 optional float small_negative_float = 13 [default = -8e-28]; 689 690 // Text for nonfinite floating-point values. 691 optional double inf_double = 14 [default = inf]; 692 optional double neg_inf_double = 15 [default = -inf]; 693 optional double nan_double = 16 [default = nan]; 694 optional float inf_float = 17 [default = inf]; 695 optional float neg_inf_float = 18 [default = -inf]; 696 optional float nan_float = 19 [default = nan]; 697 698 // Tests for C++ trigraphs. 699 // Trigraphs should be escaped in C++ generated files, but they should not be 700 // escaped for other languages. 701 // Note that in .proto file, "\?" is a valid way to escape ? in string 702 // literals. 703 optional string cpp_trigraph = 20 [default = "? \? ?? \?? \??? ??/ ?\?-"]; 704 705 // String defaults containing the character '\000' 706 optional string string_with_zero = 23 [default = "hel\000lo"]; 707 optional bytes bytes_with_zero = 24 [default = "wor\000ld"]; 708 optional string string_piece_with_zero = 25 [ctype=STRING_PIECE, 709 default="ab\000c"]; 710 optional string cord_with_zero = 26 [ctype=CORD, 711 default="12\0003"]; 712 optional string replacement_string = 27 [default="${unknown}"]; 713} 714 715message SparseEnumMessage { 716 optional TestSparseEnum sparse_enum = 1; 717} 718 719// Test String and Bytes: string is for valid UTF-8 strings 720message OneString { 721 optional string data = 1; 722} 723 724message MoreString { 725 repeated string data = 1; 726} 727 728message OneBytes { 729 optional bytes data = 1; 730} 731 732message MoreBytes { 733 repeated bytes data = 1; 734} 735 736message ManyOptionalString { 737 optional string str1 = 1; 738 optional string str2 = 2; 739 optional string str3 = 3; 740 optional string str4 = 4; 741 optional string str5 = 5; 742 optional string str6 = 6; 743 optional string str7 = 7; 744 optional string str8 = 8; 745 optional string str9 = 9; 746 optional string str10 = 10; 747 optional string str11 = 11; 748 optional string str12 = 12; 749 optional string str13 = 13; 750 optional string str14 = 14; 751 optional string str15 = 15; 752 optional string str16 = 16; 753 optional string str17 = 17; 754 optional string str18 = 18; 755 optional string str19 = 19; 756 optional string str20 = 20; 757 optional string str21 = 21; 758 optional string str22 = 22; 759 optional string str23 = 23; 760 optional string str24 = 24; 761 optional string str25 = 25; 762 optional string str26 = 26; 763 optional string str27 = 27; 764 optional string str28 = 28; 765 optional string str29 = 29; 766 optional string str30 = 30; 767 optional string str31 = 31; 768 optional string str32 = 32; 769} 770 771// Test int32, uint32, int64, uint64, and bool are all compatible 772message Int32Message { 773 optional int32 data = 1; 774} 775 776message Uint32Message { 777 optional uint32 data = 1; 778} 779 780message Int64Message { 781 optional int64 data = 1; 782} 783 784message Uint64Message { 785 optional uint64 data = 1; 786} 787 788message BoolMessage { 789 optional bool data = 1; 790} 791 792// Test oneofs. 793message TestOneof { 794 oneof foo { 795 int32 foo_int = 1; 796 string foo_string = 2; 797 TestAllTypes foo_message = 3; 798 group FooGroup = 4 { 799 optional int32 a = 5; 800 optional string b = 6; 801 } 802 } 803} 804 805message TestOneofBackwardsCompatible { 806 optional int32 foo_int = 1; 807 optional string foo_string = 2; 808 optional TestAllTypes foo_message = 3; 809 optional group FooGroup = 4 { 810 optional int32 a = 5; 811 optional string b = 6; 812 } 813} 814 815message TestOneof2 { 816 oneof foo { 817 int32 foo_int = 1; 818 string foo_string = 2; 819 string foo_cord = 3 [ctype=CORD]; 820 string foo_string_piece = 4 [ctype=STRING_PIECE]; 821 bytes foo_bytes = 5; 822 NestedEnum foo_enum = 6; 823 NestedMessage foo_message = 7; 824 group FooGroup = 8 { 825 optional int32 a = 9; 826 optional string b = 10; 827 } 828 NestedMessage foo_lazy_message = 11 [lazy=true]; 829 } 830 831 oneof bar { 832 int32 bar_int = 12 [default = 5]; 833 string bar_string = 13 [default = "STRING"]; 834 string bar_cord = 14 [ctype=CORD, default = "CORD"]; 835 string bar_string_piece = 15 [ctype=STRING_PIECE, default = "SPIECE"]; 836 bytes bar_bytes = 16 [default = "BYTES"]; 837 NestedEnum bar_enum = 17 [default = BAR]; 838 string bar_string_with_empty_default = 20 [default = ""]; 839 string bar_cord_with_empty_default = 21 [ctype=CORD, default = ""]; 840 string bar_string_piece_with_empty_default = 22 [ctype=STRING_PIECE, default = ""]; 841 bytes bar_bytes_with_empty_default = 23 [default = ""]; 842 } 843 844 optional int32 baz_int = 18; 845 optional string baz_string = 19 [default = "BAZ"]; 846 847 message NestedMessage { 848 optional int64 moo_int = 1; 849 repeated int32 corge_int = 2; 850 } 851 852 enum NestedEnum { 853 FOO = 1; 854 BAR = 2; 855 BAZ = 3; 856 } 857} 858 859message TestRequiredOneof { 860 oneof foo { 861 int32 foo_int = 1; 862 string foo_string = 2; 863 NestedMessage foo_message = 3; 864 } 865 message NestedMessage { 866 required double required_double = 1; 867 } 868} 869 870 871// Test messages for packed fields 872 873message TestPackedTypes { 874 repeated int32 packed_int32 = 90 [packed = true]; 875 repeated int64 packed_int64 = 91 [packed = true]; 876 repeated uint32 packed_uint32 = 92 [packed = true]; 877 repeated uint64 packed_uint64 = 93 [packed = true]; 878 repeated sint32 packed_sint32 = 94 [packed = true]; 879 repeated sint64 packed_sint64 = 95 [packed = true]; 880 repeated fixed32 packed_fixed32 = 96 [packed = true]; 881 repeated fixed64 packed_fixed64 = 97 [packed = true]; 882 repeated sfixed32 packed_sfixed32 = 98 [packed = true]; 883 repeated sfixed64 packed_sfixed64 = 99 [packed = true]; 884 repeated float packed_float = 100 [packed = true]; 885 repeated double packed_double = 101 [packed = true]; 886 repeated bool packed_bool = 102 [packed = true]; 887 repeated ForeignEnum packed_enum = 103 [packed = true]; 888} 889 890// A message with the same fields as TestPackedTypes, but without packing. Used 891// to test packed <-> unpacked wire compatibility. 892message TestUnpackedTypes { 893 repeated int32 unpacked_int32 = 90 [packed = false]; 894 repeated int64 unpacked_int64 = 91 [packed = false]; 895 repeated uint32 unpacked_uint32 = 92 [packed = false]; 896 repeated uint64 unpacked_uint64 = 93 [packed = false]; 897 repeated sint32 unpacked_sint32 = 94 [packed = false]; 898 repeated sint64 unpacked_sint64 = 95 [packed = false]; 899 repeated fixed32 unpacked_fixed32 = 96 [packed = false]; 900 repeated fixed64 unpacked_fixed64 = 97 [packed = false]; 901 repeated sfixed32 unpacked_sfixed32 = 98 [packed = false]; 902 repeated sfixed64 unpacked_sfixed64 = 99 [packed = false]; 903 repeated float unpacked_float = 100 [packed = false]; 904 repeated double unpacked_double = 101 [packed = false]; 905 repeated bool unpacked_bool = 102 [packed = false]; 906 repeated ForeignEnum unpacked_enum = 103 [packed = false]; 907} 908 909message TestPackedExtensions { 910 extensions 1 to max; 911} 912 913extend TestPackedExtensions { 914 repeated int32 packed_int32_extension = 90 [packed = true]; 915 repeated int64 packed_int64_extension = 91 [packed = true]; 916 repeated uint32 packed_uint32_extension = 92 [packed = true]; 917 repeated uint64 packed_uint64_extension = 93 [packed = true]; 918 repeated sint32 packed_sint32_extension = 94 [packed = true]; 919 repeated sint64 packed_sint64_extension = 95 [packed = true]; 920 repeated fixed32 packed_fixed32_extension = 96 [packed = true]; 921 repeated fixed64 packed_fixed64_extension = 97 [packed = true]; 922 repeated sfixed32 packed_sfixed32_extension = 98 [packed = true]; 923 repeated sfixed64 packed_sfixed64_extension = 99 [packed = true]; 924 repeated float packed_float_extension = 100 [packed = true]; 925 repeated double packed_double_extension = 101 [packed = true]; 926 repeated bool packed_bool_extension = 102 [packed = true]; 927 repeated ForeignEnum packed_enum_extension = 103 [packed = true]; 928} 929 930message TestUnpackedExtensions { 931 extensions 1 to max; 932} 933 934extend TestUnpackedExtensions { 935 repeated int32 unpacked_int32_extension = 90 [packed = false]; 936 repeated int64 unpacked_int64_extension = 91 [packed = false]; 937 repeated uint32 unpacked_uint32_extension = 92 [packed = false]; 938 repeated uint64 unpacked_uint64_extension = 93 [packed = false]; 939 repeated sint32 unpacked_sint32_extension = 94 [packed = false]; 940 repeated sint64 unpacked_sint64_extension = 95 [packed = false]; 941 repeated fixed32 unpacked_fixed32_extension = 96 [packed = false]; 942 repeated fixed64 unpacked_fixed64_extension = 97 [packed = false]; 943 repeated sfixed32 unpacked_sfixed32_extension = 98 [packed = false]; 944 repeated sfixed64 unpacked_sfixed64_extension = 99 [packed = false]; 945 repeated float unpacked_float_extension = 100 [packed = false]; 946 repeated double unpacked_double_extension = 101 [packed = false]; 947 repeated bool unpacked_bool_extension = 102 [packed = false]; 948 repeated ForeignEnum unpacked_enum_extension = 103 [packed = false]; 949} 950 951// Used by ExtensionSetTest/DynamicExtensions. The test actually builds 952// a set of extensions to TestAllExtensions dynamically, based on the fields 953// of this message type. 954message TestDynamicExtensions { 955 enum DynamicEnumType { 956 DYNAMIC_FOO = 2200; 957 DYNAMIC_BAR = 2201; 958 DYNAMIC_BAZ = 2202; 959 } 960 message DynamicMessageType { 961 optional int32 dynamic_field = 2100; 962 } 963 964 optional fixed32 scalar_extension = 2000; 965 optional ForeignEnum enum_extension = 2001; 966 optional DynamicEnumType dynamic_enum_extension = 2002; 967 968 optional ForeignMessage message_extension = 2003; 969 optional DynamicMessageType dynamic_message_extension = 2004; 970 971 repeated string repeated_extension = 2005; 972 repeated sint32 packed_extension = 2006 [packed = true]; 973} 974 975message TestRepeatedScalarDifferentTagSizes { 976 // Parsing repeated fixed size values used to fail. This message needs to be 977 // used in order to get a tag of the right size; all of the repeated fields 978 // in TestAllTypes didn't trigger the check. 979 repeated fixed32 repeated_fixed32 = 12; 980 // Check for a varint type, just for good measure. 981 repeated int32 repeated_int32 = 13; 982 983 // These have two-byte tags. 984 repeated fixed64 repeated_fixed64 = 2046; 985 repeated int64 repeated_int64 = 2047; 986 987 // Three byte tags. 988 repeated float repeated_float = 262142; 989 repeated uint64 repeated_uint64 = 262143; 990} 991 992// Test that if an optional or required message/group field appears multiple 993// times in the input, they need to be merged. 994message TestParsingMerge { 995 // RepeatedFieldsGenerator defines matching field types as TestParsingMerge, 996 // except that all fields are repeated. In the tests, we will serialize the 997 // RepeatedFieldsGenerator to bytes, and parse the bytes to TestParsingMerge. 998 // Repeated fields in RepeatedFieldsGenerator are expected to be merged into 999 // the corresponding required/optional fields in TestParsingMerge. 1000 message RepeatedFieldsGenerator { 1001 repeated TestAllTypes field1 = 1; 1002 repeated TestAllTypes field2 = 2; 1003 repeated TestAllTypes field3 = 3; 1004 repeated group Group1 = 10 { 1005 optional TestAllTypes field1 = 11; 1006 } 1007 repeated group Group2 = 20 { 1008 optional TestAllTypes field1 = 21; 1009 } 1010 repeated TestAllTypes ext1 = 1000; 1011 repeated TestAllTypes ext2 = 1001; 1012 } 1013 required TestAllTypes required_all_types = 1; 1014 optional TestAllTypes optional_all_types = 2; 1015 repeated TestAllTypes repeated_all_types = 3; 1016 optional group OptionalGroup = 10 { 1017 optional TestAllTypes optional_group_all_types = 11; 1018 } 1019 repeated group RepeatedGroup = 20 { 1020 optional TestAllTypes repeated_group_all_types = 21; 1021 } 1022 extensions 1000 to max; 1023 extend TestParsingMerge { 1024 optional TestAllTypes optional_ext = 1000; 1025 repeated TestAllTypes repeated_ext = 1001; 1026 } 1027} 1028 1029// Test that the correct exception is thrown by parseFrom in a corner case 1030// involving merging, extensions, and required fields. 1031message TestMergeException { 1032 optional TestAllExtensions all_extensions = 1; 1033} 1034 1035message TestCommentInjectionMessage { 1036 // */ <- This should not close the generated doc comment 1037 optional string a = 1 [default="*/ <- Neither should this."]; 1038} 1039 1040// Used to check that the c++ code generator re-orders messages to reduce 1041// padding. 1042message TestMessageSize { 1043 optional bool m1 = 1; 1044 optional int64 m2 = 2; 1045 optional bool m3 = 3; 1046 optional string m4 = 4; 1047 optional int32 m5 = 5; 1048 optional int64 m6 = 6; 1049} 1050 1051 1052// Test that RPC services work. 1053message FooRequest {} 1054message FooResponse {} 1055 1056message FooClientMessage {} 1057message FooServerMessage{} 1058 1059service TestService { 1060 rpc Foo(FooRequest) returns (FooResponse); 1061 rpc Bar(BarRequest) returns (BarResponse); 1062} 1063 1064 1065message BarRequest {} 1066message BarResponse {} 1067 1068message TestJsonName { 1069 optional int32 field_name1 = 1; 1070 optional int32 fieldName2 = 2; 1071 optional int32 FieldName3 = 3; 1072 optional int32 _field_name4 = 4; 1073 optional int32 FIELD_NAME5 = 5; 1074 optional int32 field_name6 = 6 [json_name = "@type"]; 1075 optional int32 fieldname7 = 7; 1076} 1077 1078message TestHugeFieldNumbers { 1079 optional int32 optional_int32 = 536870000; 1080 optional int32 fixed_32 = 536870001; 1081 repeated int32 repeated_int32 = 536870002 [packed = false]; 1082 repeated int32 packed_int32 = 536870003 [packed = true]; 1083 1084 optional ForeignEnum optional_enum = 536870004; 1085 optional string optional_string = 536870005; 1086 optional bytes optional_bytes = 536870006; 1087 optional ForeignMessage optional_message = 536870007; 1088 1089 optional group OptionalGroup = 536870008 { 1090 optional int32 group_a = 536870009; 1091 } 1092 1093 map<string, string> string_string_map = 536870010; 1094 1095 oneof oneof_field { 1096 uint32 oneof_uint32 = 536870011; 1097 TestAllTypes oneof_test_all_types = 536870012; 1098 string oneof_string = 536870013; 1099 bytes oneof_bytes = 536870014; 1100 } 1101 1102 extensions 536860000 to 536869999; 1103} 1104 1105extend TestHugeFieldNumbers { 1106 optional TestAllTypes test_all_types = 536860000; 1107} 1108 1109message TestExtensionInsideTable { 1110 optional int32 field1 = 1; 1111 optional int32 field2 = 2; 1112 optional int32 field3 = 3; 1113 optional int32 field4 = 4; 1114 extensions 5 to 5; 1115 optional int32 field6 = 6; 1116 optional int32 field7 = 7; 1117 optional int32 field8 = 8; 1118 optional int32 field9 = 9; 1119 optional int32 field10 = 10; 1120} 1121 1122extend TestExtensionInsideTable { 1123 optional int32 test_extension_inside_table_extension = 5; 1124} 1125 1126// NOTE(b/202996544): Intentionally nested to mirror go/glep. 1127message TestNestedGroupExtensionOuter { 1128 optional group Layer1OptionalGroup = 1 { 1129 repeated group Layer2RepeatedGroup = 2 { 1130 extensions 3 1131 // NOTE: extension metadata is not supported due to targets such as 1132 // `//third_party/protobuf_legacy_opensource/src:shell_scripts_test`, 1133 // eee https://screenshot.googleplex.com/Axz2QD8nxjdpyFF 1134 //[metadata = { 1135 // NOTE: can't write type there due to some clever build gen code at 1136 // http://google3/net/proto2/internal/BUILD;l=1247;rcl=411090862 1137 // type: "protobuf_unittest.TestNestedGroupExtensionInnerExtension", 1138 // name: "inner", 1139 // }] 1140 ; 1141 optional string another_field = 6; 1142 } 1143 repeated group Layer2AnotherOptionalRepeatedGroup = 4 { 1144 optional string but_why_tho = 5; 1145 } 1146 } 1147} 1148 1149message TestNestedGroupExtensionInnerExtension { 1150 optional string inner_name= 1; 1151} 1152 1153extend TestNestedGroupExtensionOuter.Layer1OptionalGroup.Layer2RepeatedGroup { 1154 optional TestNestedGroupExtensionInnerExtension inner = 3; 1155} 1156 1157enum VeryLargeEnum { 1158 ENUM_LABEL_DEFAULT = 0; 1159 ENUM_LABEL_1 = 1; 1160 ENUM_LABEL_2 = 2; 1161 ENUM_LABEL_3 = 3; 1162 ENUM_LABEL_4 = 4; 1163 ENUM_LABEL_5 = 5; 1164 ENUM_LABEL_6 = 6; 1165 ENUM_LABEL_7 = 7; 1166 ENUM_LABEL_8 = 8; 1167 ENUM_LABEL_9 = 9; 1168 ENUM_LABEL_10 = 10; 1169 ENUM_LABEL_11 = 11; 1170 ENUM_LABEL_12 = 12; 1171 ENUM_LABEL_13 = 13; 1172 ENUM_LABEL_14 = 14; 1173 ENUM_LABEL_15 = 15; 1174 ENUM_LABEL_16 = 16; 1175 ENUM_LABEL_17 = 17; 1176 ENUM_LABEL_18 = 18; 1177 ENUM_LABEL_19 = 19; 1178 ENUM_LABEL_20 = 20; 1179 ENUM_LABEL_21 = 21; 1180 ENUM_LABEL_22 = 22; 1181 ENUM_LABEL_23 = 23; 1182 ENUM_LABEL_24 = 24; 1183 ENUM_LABEL_25 = 25; 1184 ENUM_LABEL_26 = 26; 1185 ENUM_LABEL_27 = 27; 1186 ENUM_LABEL_28 = 28; 1187 ENUM_LABEL_29 = 29; 1188 ENUM_LABEL_30 = 30; 1189 ENUM_LABEL_31 = 31; 1190 ENUM_LABEL_32 = 32; 1191 ENUM_LABEL_33 = 33; 1192 ENUM_LABEL_34 = 34; 1193 ENUM_LABEL_35 = 35; 1194 ENUM_LABEL_36 = 36; 1195 ENUM_LABEL_37 = 37; 1196 ENUM_LABEL_38 = 38; 1197 ENUM_LABEL_39 = 39; 1198 ENUM_LABEL_40 = 40; 1199 ENUM_LABEL_41 = 41; 1200 ENUM_LABEL_42 = 42; 1201 ENUM_LABEL_43 = 43; 1202 ENUM_LABEL_44 = 44; 1203 ENUM_LABEL_45 = 45; 1204 ENUM_LABEL_46 = 46; 1205 ENUM_LABEL_47 = 47; 1206 ENUM_LABEL_48 = 48; 1207 ENUM_LABEL_49 = 49; 1208 ENUM_LABEL_50 = 50; 1209 ENUM_LABEL_51 = 51; 1210 ENUM_LABEL_52 = 52; 1211 ENUM_LABEL_53 = 53; 1212 ENUM_LABEL_54 = 54; 1213 ENUM_LABEL_55 = 55; 1214 ENUM_LABEL_56 = 56; 1215 ENUM_LABEL_57 = 57; 1216 ENUM_LABEL_58 = 58; 1217 ENUM_LABEL_59 = 59; 1218 ENUM_LABEL_60 = 60; 1219 ENUM_LABEL_61 = 61; 1220 ENUM_LABEL_62 = 62; 1221 ENUM_LABEL_63 = 63; 1222 ENUM_LABEL_64 = 64; 1223 ENUM_LABEL_65 = 65; 1224 ENUM_LABEL_66 = 66; 1225 ENUM_LABEL_67 = 67; 1226 ENUM_LABEL_68 = 68; 1227 ENUM_LABEL_69 = 69; 1228 ENUM_LABEL_70 = 70; 1229 ENUM_LABEL_71 = 71; 1230 ENUM_LABEL_72 = 72; 1231 ENUM_LABEL_73 = 73; 1232 ENUM_LABEL_74 = 74; 1233 ENUM_LABEL_75 = 75; 1234 ENUM_LABEL_76 = 76; 1235 ENUM_LABEL_77 = 77; 1236 ENUM_LABEL_78 = 78; 1237 ENUM_LABEL_79 = 79; 1238 ENUM_LABEL_80 = 80; 1239 ENUM_LABEL_81 = 81; 1240 ENUM_LABEL_82 = 82; 1241 ENUM_LABEL_83 = 83; 1242 ENUM_LABEL_84 = 84; 1243 ENUM_LABEL_85 = 85; 1244 ENUM_LABEL_86 = 86; 1245 ENUM_LABEL_87 = 87; 1246 ENUM_LABEL_88 = 88; 1247 ENUM_LABEL_89 = 89; 1248 ENUM_LABEL_90 = 90; 1249 ENUM_LABEL_91 = 91; 1250 ENUM_LABEL_92 = 92; 1251 ENUM_LABEL_93 = 93; 1252 ENUM_LABEL_94 = 94; 1253 ENUM_LABEL_95 = 95; 1254 ENUM_LABEL_96 = 96; 1255 ENUM_LABEL_97 = 97; 1256 ENUM_LABEL_98 = 98; 1257 ENUM_LABEL_99 = 99; 1258 ENUM_LABEL_100 = 100; 1259}; 1260 1261message TestExtensionRangeSerialize { 1262 optional int32 foo_one = 1; 1263 1264 extensions 2 to 2; 1265 extensions 3 to 4; 1266 1267 optional int32 foo_two = 6; 1268 optional int32 foo_three = 7; 1269 1270 extensions 9 to 10; 1271 1272 optional int32 foo_four = 13; 1273 1274 extensions 15 to 15; 1275 extensions 17 to 17; 1276 extensions 19 to 19; 1277 1278 extend TestExtensionRangeSerialize { 1279 optional int32 bar_one = 2; 1280 optional int32 bar_two = 4; 1281 1282 optional int32 bar_three = 10; 1283 1284 optional int32 bar_four = 15; 1285 optional int32 bar_five = 19; 1286 } 1287} 1288 1289message TestVerifyInt32Simple { 1290 optional int32 optional_int32_1 = 1; 1291 optional int32 optional_int32_2 = 2; 1292 optional int32 optional_int32_63 = 63; 1293 optional int32 optional_int32_64 = 64; 1294} 1295 1296message TestVerifyInt32 { 1297 optional int32 optional_int32_1 = 1; 1298 optional int32 optional_int32_2 = 2; 1299 optional int32 optional_int32_63 = 63; 1300 optional int32 optional_int32_64 = 64; 1301 1302 optional TestAllTypes optional_all_types = 9; 1303 repeated TestAllTypes repeated_all_types = 10; 1304} 1305 1306message TestVerifyMostlyInt32 { 1307 optional int64 optional_int64_30 = 30; 1308 1309 optional int32 optional_int32_1 = 1; 1310 optional int32 optional_int32_2 = 2; 1311 optional int32 optional_int32_3 = 3; 1312 optional int32 optional_int32_4 = 4; 1313 optional int32 optional_int32_63 = 63; 1314 optional int32 optional_int32_64 = 64; 1315 1316 optional TestAllTypes optional_all_types = 9; 1317 repeated TestAllTypes repeated_all_types = 10; 1318} 1319 1320message TestVerifyMostlyInt32BigFieldNumber { 1321 optional int64 optional_int64_30 = 30; 1322 optional int32 optional_int32_300 = 300; 1323 1324 optional int32 optional_int32_1 = 1; 1325 optional int32 optional_int32_2 = 2; 1326 optional int32 optional_int32_3 = 3; 1327 optional int32 optional_int32_4 = 4; 1328 optional int32 optional_int32_63 = 63; 1329 optional int32 optional_int32_64 = 64; 1330 1331 optional TestAllTypes optional_all_types = 9; 1332 repeated TestAllTypes repeated_all_types = 10; 1333} 1334 1335message TestVerifyUint32Simple { 1336 optional uint32 optional_uint32_1 = 1; 1337 optional uint32 optional_uint32_2 = 2; 1338 optional uint32 optional_uint32_63 = 63; 1339 optional uint32 optional_uint32_64 = 64; 1340} 1341 1342message TestVerifyUint32 { 1343 optional uint32 optional_uint32_1 = 1; 1344 optional uint32 optional_uint32_2 = 2; 1345 optional uint32 optional_uint32_63 = 63; 1346 optional uint32 optional_uint32_64 = 64; 1347 1348 optional TestAllTypes optional_all_types = 9; 1349 repeated TestAllTypes repeated_all_types = 10; 1350} 1351 1352message TestVerifyOneUint32 { 1353 optional uint32 optional_uint32_1 = 1; 1354 optional int32 optional_int32_2 = 2; 1355 optional int32 optional_int32_63 = 63; 1356 optional int32 optional_int32_64 = 64; 1357 1358 optional TestAllTypes optional_all_types = 9; 1359 repeated TestAllTypes repeated_all_types = 10; 1360} 1361 1362message TestVerifyOneInt32BigFieldNumber { 1363 optional int32 optional_int32_65 = 65; 1364 1365 optional int64 optional_int64_1 = 1; 1366 optional int64 optional_int64_2 = 2; 1367 optional int64 optional_int64_63 = 63; 1368 optional int64 optional_int64_64 = 64; 1369 1370 optional TestAllTypes optional_all_types = 9; 1371 repeated TestAllTypes repeated_all_types = 10; 1372} 1373 1374message TestVerifyInt32BigFieldNumber { 1375 optional int32 optional_int32_1000 = 1000; 1376 optional int32 optional_int32_65 = 65; 1377 1378 optional int32 optional_int32_1 = 1; 1379 optional int32 optional_int32_2 = 2; 1380 optional int32 optional_int32_63 = 63; 1381 optional int32 optional_int32_64 = 64; 1382 1383 optional TestAllTypes optional_all_types = 9; 1384 repeated TestAllTypes repeated_all_types = 10; 1385} 1386 1387message TestVerifyUint32BigFieldNumber { 1388 optional uint32 optional_uint32_1000 = 1000; 1389 optional uint32 optional_uint32_65 = 65; 1390 1391 optional uint32 optional_uint32_1 = 1; 1392 optional uint32 optional_uint32_2 = 2; 1393 optional uint32 optional_uint32_63 = 63; 1394 optional uint32 optional_uint32_64 = 64; 1395 1396 optional TestAllTypes optional_all_types = 9; 1397 repeated TestAllTypes repeated_all_types = 10; 1398} 1399 1400message TestVerifyBigFieldNumberUint32 { 1401 message Nested { 1402 optional uint32 optional_uint32_5000 = 5000; 1403 optional uint32 optional_uint32_1000 = 1000; 1404 optional uint32 optional_uint32_66 = 66; 1405 optional uint32 optional_uint32_65 = 65; 1406 1407 optional uint32 optional_uint32_1 = 1; 1408 optional uint32 optional_uint32_2 = 2; 1409 optional uint32 optional_uint32_63 = 63; 1410 optional uint32 optional_uint32_64 = 64; 1411 1412 optional Nested optional_nested = 9; 1413 repeated Nested repeated_nested = 10; 1414 } 1415 optional Nested optional_nested = 1; 1416} 1417 1418 1419