1// Protocol Buffers - Google's data interchange format 2// Copyright 2008 Google Inc. All rights reserved. 3// 4// Use of this source code is governed by a BSD-style 5// license that can be found in the LICENSE file or at 6// https://developers.google.com/open-source/licenses/bsd 7 8// Author: kenton@google.com (Kenton Varda) 9// Based on original Protocol Buffers design by 10// Sanjay Ghemawat, Jeff Dean, and others. 11// 12// A proto file we will use for unit testing. 13// 14// LINT: ALLOW_GROUPS, LEGACY_NAMES 15 16edition = "2023"; 17 18// We don't put this in a package within proto2 because we need to make sure 19// that the generated code doesn't depend on being in the proto2 namespace. 20// In test_util.h we do "using namespace unittest = protobuf_unittest". 21package protobuf_unittest; 22 23import "google/protobuf/unittest_import.proto"; 24 25option features = { 26 enum_type: CLOSED 27 repeated_field_encoding: EXPANDED 28 utf8_validation: NONE 29}; 30 31// Some generic_services option(s) added automatically. 32// See: http://go/proto2-generic-services-default 33option cc_generic_services = true; // auto-added 34option java_generic_services = true; // auto-added 35option py_generic_services = true; // auto-added 36option cc_enable_arenas = true; 37 38// Protos optimized for SPEED use a strict superset of the generated code 39// of equivalent ones optimized for CODE_SIZE, so we should optimize all our 40// tests for speed unless explicitly testing code size optimization. 41option optimize_for = SPEED; 42option java_outer_classname = "UnittestProto"; 43 44// This proto includes every type of field in both singular and repeated 45// forms. 46message TestAllTypes { 47 message NestedMessage { 48 // The field name "b" fails to compile in proto1 because it conflicts with 49 // a local variable named "b" in one of the generated methods. Doh. 50 // This file needs to compile in proto1 to test backwards-compatibility. 51 int32 bb = 1; 52 } 53 54 enum NestedEnum { 55 FOO = 1; 56 BAR = 2; 57 BAZ = 3; 58 NEG = -1; // Intentionally negative. 59 } 60 61 // Singular 62 int32 optional_int32 = 1; 63 int64 optional_int64 = 2; 64 uint32 optional_uint32 = 3; 65 uint64 optional_uint64 = 4; 66 sint32 optional_sint32 = 5; 67 sint64 optional_sint64 = 6; 68 fixed32 optional_fixed32 = 7; 69 fixed64 optional_fixed64 = 8; 70 sfixed32 optional_sfixed32 = 9; 71 sfixed64 optional_sfixed64 = 10; 72 float optional_float = 11; 73 double optional_double = 12; 74 bool optional_bool = 13; 75 string optional_string = 14; 76 bytes optional_bytes = 15; 77 78 message OptionalGroup { 79 int32 a = 17; 80 } 81 82 OptionalGroup optionalgroup = 16 [ 83 features.message_encoding = DELIMITED 84 ]; 85 86 NestedMessage optional_nested_message = 18; 87 ForeignMessage optional_foreign_message = 19; 88 protobuf_unittest_import.ImportMessage optional_import_message = 20; 89 NestedEnum optional_nested_enum = 21; 90 ForeignEnum optional_foreign_enum = 22; 91 protobuf_unittest_import.ImportEnum optional_import_enum = 23; 92 string optional_string_piece = 24 [ 93 ctype = STRING_PIECE 94 ]; 95 96 string optional_cord = 25 [ 97 ctype = CORD 98 ]; 99 bytes optional_bytes_cord = 86 [ctype=CORD]; 100 101 // Defined in unittest_import_public.proto 102 protobuf_unittest_import.PublicImportMessage optional_public_import_message = 26; 103 NestedMessage optional_lazy_message = 27 [ 104 lazy = true 105 ]; 106 107 NestedMessage optional_unverified_lazy_message = 28 [ 108 unverified_lazy = true 109 ]; 110 111 // Repeated 112 repeated int32 repeated_int32 = 31; 113 repeated int64 repeated_int64 = 32; 114 repeated uint32 repeated_uint32 = 33; 115 repeated uint64 repeated_uint64 = 34; 116 repeated sint32 repeated_sint32 = 35; 117 repeated sint64 repeated_sint64 = 36; 118 repeated fixed32 repeated_fixed32 = 37; 119 repeated fixed64 repeated_fixed64 = 38; 120 repeated sfixed32 repeated_sfixed32 = 39; 121 repeated sfixed64 repeated_sfixed64 = 40; 122 repeated float repeated_float = 41; 123 repeated double repeated_double = 42; 124 repeated bool repeated_bool = 43; 125 repeated string repeated_string = 44; 126 repeated bytes repeated_bytes = 45; 127 128 message RepeatedGroup { 129 int32 a = 47; 130 } 131 132 repeated RepeatedGroup repeatedgroup = 46 [ 133 features.message_encoding = DELIMITED 134 ]; 135 136 repeated NestedMessage repeated_nested_message = 48; 137 repeated ForeignMessage repeated_foreign_message = 49; 138 repeated protobuf_unittest_import.ImportMessage repeated_import_message = 50; 139 repeated NestedEnum repeated_nested_enum = 51; 140 repeated ForeignEnum repeated_foreign_enum = 52; 141 repeated protobuf_unittest_import.ImportEnum repeated_import_enum = 53; 142 repeated string repeated_string_piece = 54 [ 143 ctype = STRING_PIECE 144 ]; 145 146 repeated string repeated_cord = 55 [ 147 ctype = CORD 148 ]; 149 150 repeated NestedMessage repeated_lazy_message = 57 [ 151 lazy = true 152 ]; 153 154 // Singular with defaults 155 int32 default_int32 = 61 [ 156 default = 41 157 ]; 158 159 int64 default_int64 = 62 [ 160 default = 42 161 ]; 162 163 uint32 default_uint32 = 63 [ 164 default = 43 165 ]; 166 167 uint64 default_uint64 = 64 [ 168 default = 44 169 ]; 170 171 sint32 default_sint32 = 65 [ 172 default = -45 173 ]; 174 175 sint64 default_sint64 = 66 [ 176 default = 46 177 ]; 178 179 fixed32 default_fixed32 = 67 [ 180 default = 47 181 ]; 182 183 fixed64 default_fixed64 = 68 [ 184 default = 48 185 ]; 186 187 sfixed32 default_sfixed32 = 69 [ 188 default = 49 189 ]; 190 191 sfixed64 default_sfixed64 = 70 [ 192 default = -50 193 ]; 194 195 float default_float = 71 [ 196 default = 51.5 197 ]; 198 199 double default_double = 72 [ 200 default = 5.2e4 201 ]; 202 203 bool default_bool = 73 [ 204 default = true 205 ]; 206 207 string default_string = 74 [ 208 default = "hello" 209 ]; 210 211 bytes default_bytes = 75 [ 212 default = "world" 213 ]; 214 215 NestedEnum default_nested_enum = 81 [ 216 default = BAR 217 ]; 218 219 ForeignEnum default_foreign_enum = 82 [ 220 default = FOREIGN_BAR 221 ]; 222 223 protobuf_unittest_import.ImportEnum default_import_enum = 83 [ 224 default = IMPORT_BAR 225 ]; 226 227 string default_string_piece = 84 [ 228 ctype = STRING_PIECE, 229 default = "abc" 230 ]; 231 232 string default_cord = 85 [ 233 ctype = CORD, 234 default = "123" 235 ]; 236 237 // For oneof test 238 oneof oneof_field { 239 uint32 oneof_uint32 = 111; 240 NestedMessage oneof_nested_message = 112; 241 string oneof_string = 113; 242 bytes oneof_bytes = 114; 243 string oneof_cord = 115 [ 244 ctype = CORD 245 ]; 246 247 string oneof_string_piece = 116 [ 248 ctype = STRING_PIECE 249 ]; 250 251 NestedMessage oneof_lazy_nested_message = 117 [ 252 lazy = true 253 ]; 254 } 255} 256 257// This proto includes a recursively nested message. 258message NestedTestAllTypes { 259 NestedTestAllTypes child = 1; 260 TestAllTypes payload = 2; 261 repeated NestedTestAllTypes repeated_child = 3; 262 NestedTestAllTypes lazy_child = 4 [ 263 lazy = true 264 ]; 265 266 TestAllTypes eager_child = 5 [ 267 lazy = false 268 ]; 269} 270 271message TestDeprecatedFields { 272 int32 deprecated_int32 = 1 [ 273 deprecated = true 274 ]; 275 276 repeated string deprecated_repeated_string = 4 [ 277 deprecated = true 278 ]; 279 280 TestAllTypes.NestedMessage deprecated_message = 3 [ 281 deprecated = true 282 ]; 283 284 oneof oneof_fields { 285 int32 deprecated_int32_in_oneof = 2 [ 286 deprecated = true 287 ]; 288 } 289 290 TestDeprecatedFields nested = 5; 291} 292 293message TestDeprecatedMessage { 294 option deprecated = true; 295} 296 297// Define these after TestAllTypes to make sure the compiler can handle 298// that. 299message ForeignMessage { 300 int32 c = 1; 301 int32 d = 2; 302} 303 304enum ForeignEnum { 305 FOREIGN_FOO = 4; 306 FOREIGN_BAR = 5; 307 FOREIGN_BAZ = 6; 308 FOREIGN_BAX = 32; // (1 << 32) to generate a 64b bitmask would be incorrect. 309 FOREIGN_LARGE = 123456; // Large enough to escape the Boxed Integer cache. 310} 311 312message TestReservedFields { 313 reserved 2, 15, 9 to 11; 314 315 reserved bar, baz; 316} 317 318enum TestReservedEnumFields { 319 UNKNOWN = 0; 320 321 reserved 2, 15, 9 to 11; 322 323 reserved bar, baz; 324} 325 326message TestAllExtensions { 327 extensions 1 to max; 328} 329 330extend TestAllExtensions { 331 // Singular 332 int32 optional_int32_extension = 1; 333 int64 optional_int64_extension = 2; 334 uint32 optional_uint32_extension = 3; 335 uint64 optional_uint64_extension = 4; 336 sint32 optional_sint32_extension = 5; 337 sint64 optional_sint64_extension = 6; 338 fixed32 optional_fixed32_extension = 7; 339 fixed64 optional_fixed64_extension = 8; 340 sfixed32 optional_sfixed32_extension = 9; 341 sfixed64 optional_sfixed64_extension = 10; 342 float optional_float_extension = 11; 343 double optional_double_extension = 12; 344 bool optional_bool_extension = 13; 345 string optional_string_extension = 14; 346 bytes optional_bytes_extension = 15; 347 OptionalGroup_extension optionalgroup_extension = 16 [ 348 features.message_encoding = DELIMITED 349 ]; 350 351 TestAllTypes.NestedMessage optional_nested_message_extension = 18; 352 ForeignMessage optional_foreign_message_extension = 19; 353 protobuf_unittest_import.ImportMessage optional_import_message_extension = 20; 354 TestAllTypes.NestedEnum optional_nested_enum_extension = 21; 355 ForeignEnum optional_foreign_enum_extension = 22; 356 protobuf_unittest_import.ImportEnum optional_import_enum_extension = 23; 357 string optional_string_piece_extension = 24 [ 358 ctype = STRING_PIECE 359 ]; 360 361 // TODO: ctype=CORD is not supported for extension. Add 362 // ctype=CORD option back after it is supported. 363 string optional_cord_extension = 25; 364 bytes optional_bytes_cord_extension = 86; 365 366 protobuf_unittest_import.PublicImportMessage 367 optional_public_import_message_extension = 26; 368 TestAllTypes.NestedMessage optional_lazy_message_extension = 27 [ 369 lazy = true 370 ]; 371 372 TestAllTypes.NestedMessage optional_unverified_lazy_message_extension = 28 [ 373 unverified_lazy = true 374 ]; 375 376 // Repeated 377 repeated int32 repeated_int32_extension = 31; 378 repeated int64 repeated_int64_extension = 32; 379 repeated uint32 repeated_uint32_extension = 33; 380 repeated uint64 repeated_uint64_extension = 34; 381 repeated sint32 repeated_sint32_extension = 35; 382 repeated sint64 repeated_sint64_extension = 36; 383 repeated fixed32 repeated_fixed32_extension = 37; 384 repeated fixed64 repeated_fixed64_extension = 38; 385 repeated sfixed32 repeated_sfixed32_extension = 39; 386 repeated sfixed64 repeated_sfixed64_extension = 40; 387 repeated float repeated_float_extension = 41; 388 repeated double repeated_double_extension = 42; 389 repeated bool repeated_bool_extension = 43; 390 repeated string repeated_string_extension = 44; 391 repeated bytes repeated_bytes_extension = 45; 392 repeated RepeatedGroup_extension repeatedgroup_extension = 46 [ 393 features.message_encoding = DELIMITED 394 ]; 395 396 repeated TestAllTypes.NestedMessage repeated_nested_message_extension = 48; 397 repeated ForeignMessage repeated_foreign_message_extension = 49; 398 repeated protobuf_unittest_import.ImportMessage 399 repeated_import_message_extension = 50; 400 repeated TestAllTypes.NestedEnum repeated_nested_enum_extension = 51; 401 repeated ForeignEnum repeated_foreign_enum_extension = 52; 402 repeated protobuf_unittest_import.ImportEnum repeated_import_enum_extension = 53; 403 repeated string repeated_string_piece_extension = 54 [ 404 ctype = STRING_PIECE 405 ]; 406 407 // TODO: ctype=CORD is not supported for extension. Add 408 // ctype=CORD option back after it is supported. 409 repeated string repeated_cord_extension = 55; 410 repeated TestAllTypes.NestedMessage repeated_lazy_message_extension = 57 [ 411 lazy = true 412 ]; 413 414 // Singular with defaults 415 int32 default_int32_extension = 61 [ 416 default = 41 417 ]; 418 419 int64 default_int64_extension = 62 [ 420 default = 42 421 ]; 422 423 uint32 default_uint32_extension = 63 [ 424 default = 43 425 ]; 426 427 uint64 default_uint64_extension = 64 [ 428 default = 44 429 ]; 430 431 sint32 default_sint32_extension = 65 [ 432 default = -45 433 ]; 434 435 sint64 default_sint64_extension = 66 [ 436 default = 46 437 ]; 438 439 fixed32 default_fixed32_extension = 67 [ 440 default = 47 441 ]; 442 443 fixed64 default_fixed64_extension = 68 [ 444 default = 48 445 ]; 446 447 sfixed32 default_sfixed32_extension = 69 [ 448 default = 49 449 ]; 450 451 sfixed64 default_sfixed64_extension = 70 [ 452 default = -50 453 ]; 454 455 float default_float_extension = 71 [ 456 default = 51.5 457 ]; 458 459 double default_double_extension = 72 [ 460 default = 5.2e4 461 ]; 462 463 bool default_bool_extension = 73 [ 464 default = true 465 ]; 466 467 string default_string_extension = 74 [ 468 default = "hello" 469 ]; 470 471 bytes default_bytes_extension = 75 [ 472 default = "world" 473 ]; 474 475 TestAllTypes.NestedEnum default_nested_enum_extension = 81 [ 476 default = BAR 477 ]; 478 479 ForeignEnum default_foreign_enum_extension = 82 [ 480 default = FOREIGN_BAR 481 ]; 482 483 protobuf_unittest_import.ImportEnum default_import_enum_extension = 83 [ 484 default = IMPORT_BAR 485 ]; 486 487 string default_string_piece_extension = 84 [ 488 ctype = STRING_PIECE, 489 default = "abc" 490 ]; 491 492 // TODO: ctype=CORD is not supported for extension. Add 493 // ctype=CORD option back after it is supported. 494 string default_cord_extension = 85 [ 495 default = "123" 496 ]; 497 498 // For oneof test 499 uint32 oneof_uint32_extension = 111; 500 TestAllTypes.NestedMessage oneof_nested_message_extension = 112; 501 string oneof_string_extension = 113; 502 bytes oneof_bytes_extension = 114; 503} 504 505message OptionalGroup_extension { 506 int32 a = 17; 507} 508 509message RepeatedGroup_extension { 510 int32 a = 47; 511} 512 513message TestMixedFieldsAndExtensions { 514 int32 a = 1; 515 repeated fixed32 b = 3; 516 517 extensions 2, 4; 518 519 extend TestMixedFieldsAndExtensions { 520 int32 c = 2; 521 repeated fixed32 d = 4; 522 } 523} 524 525message TestGroup { 526 message OptionalGroup { 527 int32 a = 17; 528 int32 zz = 89; // fast table size must be at least 16, for this 529 // field to be parsed by the fast parser, since 530 // 89 - 17 = 72 is a multiple of 8. 531 } 532 533 OptionalGroup optionalgroup = 16 [ 534 features.message_encoding = DELIMITED 535 ]; 536 537 ForeignEnum optional_foreign_enum = 22; 538} 539 540message TestGroupExtension { 541 extensions 1 to max; 542} 543 544message TestNestedExtension { 545 extend TestAllExtensions { 546 // Check for bug where string extensions declared in tested scope did not 547 // compile. 548 string test = 1002 [ 549 default = "test" 550 ]; 551 552 // Used to test if generated extension name is correct when there are 553 // underscores. 554 string nested_string_extension = 1003; 555 } 556 557 extend TestGroupExtension { 558 OptionalGroup_extension optionalgroup_extension = 16 [ 559 features.message_encoding = DELIMITED 560 ]; 561 562 ForeignEnum optional_foreign_enum_extension = 22; 563 } 564 565 message OptionalGroup_extension { 566 int32 a = 17; 567 } 568} 569 570message TestChildExtension { 571 string a = 1; 572 string b = 2; 573 TestAllExtensions optional_extension = 3; 574} 575 576// Emulates wireformat data of TestChildExtension with dynamic extension 577// (DynamicExtension). 578message TestChildExtensionData { 579 message NestedTestAllExtensionsData { 580 message NestedDynamicExtensions { 581 int32 a = 1; 582 int32 b = 2; 583 } 584 585 NestedDynamicExtensions dynamic = 409707008; 586 } 587 588 string a = 1; 589 string b = 2; 590 NestedTestAllExtensionsData optional_extension = 3; 591} 592 593message TestNestedChildExtension { 594 int32 a = 1; 595 TestChildExtension child = 2; 596} 597 598// Emulates wireformat data of TestNestedChildExtension with dynamic extension 599// (DynamicExtension). 600message TestNestedChildExtensionData { 601 int32 a = 1; 602 TestChildExtensionData child = 2; 603} 604 605// Required and closed enum fields are considered unknown fields if the value is 606// not valid. We need to make sure it functions as expected. 607message TestRequiredEnum { 608 ForeignEnum required_enum = 1 [ 609 features.field_presence = LEGACY_REQUIRED 610 ]; 611 612 // A dummy optional field. 613 int32 a = 2; 614} 615 616// Required and open enum accepts invalid enum values. 617enum ForeignOpenEnum { 618 option features.enum_type = OPEN; 619 620 FOREIGN_OPEN_UNKNOWN = 0; 621 FOREIGN_OPEN_FOO = 4; 622 FOREIGN_OPEN_BAR = 5; 623 FOREIGN_OPEN_BAZ = 6; 624 FOREIGN_OPEN_BAX = 32; // (1 << 32) to generate a 64b bitmask would be 625 // incorrect. 626} 627 628message TestRequiredOpenEnum { 629 ForeignOpenEnum required_enum = 1 [ 630 features.field_presence = LEGACY_REQUIRED 631 ]; 632 633 // A dummy optional field. 634 int32 a = 2; 635} 636 637// TestRequiredEnum + using enum values that won't fit to 64 bitmask. 638message TestRequiredEnumNoMask { 639 enum NestedEnum { 640 UNSPECIFIED = 0; 641 FOO = 2; 642 BAR = 100; 643 BAZ = -1; // Intentionally negative. 644 } 645 646 NestedEnum required_enum = 1 [ 647 features.field_presence = LEGACY_REQUIRED 648 ]; 649 650 // A dummy optional field. 651 int32 a = 2; 652} 653 654message TestRequiredEnumMulti { 655 enum NestedEnum { 656 UNSPECIFIED = 0; 657 FOO = 1; 658 BAR = 2; 659 BAZ = 100; 660 } 661 662 // Intentionally placed in descending field number to force sorting in closed 663 // enum verification. 664 NestedEnum required_enum_4 = 4 [ 665 features.field_presence = LEGACY_REQUIRED 666 ]; 667 668 int32 a_3 = 3; 669 NestedEnum required_enum_2 = 2 [ 670 features.field_presence = LEGACY_REQUIRED 671 ]; 672 673 ForeignEnum required_enum_1 = 1 [ 674 features.field_presence = LEGACY_REQUIRED 675 ]; 676} 677 678message TestRequiredNoMaskMulti { 679 enum NestedEnum { 680 UNSPECIFIED = 0; 681 FOO = 1; 682 BAR = 2; 683 BAZ = 100; 684 } 685 686 // Intentionally placed in descending field number to force sorting in closed 687 // enum verification. Also, using large field numbers to use tag only 688 // matching for required fields. 689 fixed32 required_fixed32_80 = 80 [ 690 features.field_presence = LEGACY_REQUIRED 691 ]; 692 693 fixed32 required_fixed32_70 = 70 [ 694 features.field_presence = LEGACY_REQUIRED 695 ]; 696 697 NestedEnum required_enum_64 = 64 [ 698 features.field_presence = LEGACY_REQUIRED 699 ]; 700 701 NestedEnum required_enum_4 = 4 [ 702 features.field_presence = LEGACY_REQUIRED 703 ]; 704 705 int32 a_3 = 3; 706 NestedEnum required_enum_2 = 2 [ 707 features.field_presence = LEGACY_REQUIRED 708 ]; 709 710 ForeignEnum required_enum_1 = 1 [ 711 features.field_presence = LEGACY_REQUIRED 712 ]; 713} 714 715// We have separate messages for testing required fields because it's 716// annoying to have to fill in required fields in TestProto in order to 717// do anything with it. Note that we don't need to test every type of 718// required filed because the code output is basically identical to 719// optional fields for all types. 720message TestRequired { 721 int32 a = 1 [ 722 features.field_presence = LEGACY_REQUIRED 723 ]; 724 725 int32 dummy2 = 2; 726 int32 b = 3 [ 727 features.field_presence = LEGACY_REQUIRED 728 ]; 729 730 extend TestAllExtensions { 731 TestRequired single = 1000; 732 repeated TestRequired multi = 1001; 733 } 734 735 // Pad the field count to 32 so that we can test that IsInitialized() 736 // properly checks multiple elements of has_bits_. 737 int32 dummy4 = 4; 738 int32 dummy5 = 5; 739 int32 dummy6 = 6; 740 int32 dummy7 = 7; 741 int32 dummy8 = 8; 742 int32 dummy9 = 9; 743 int32 dummy10 = 10; 744 int32 dummy11 = 11; 745 int32 dummy12 = 12; 746 int32 dummy13 = 13; 747 int32 dummy14 = 14; 748 int32 dummy15 = 15; 749 int32 dummy16 = 16; 750 int32 dummy17 = 17; 751 int32 dummy18 = 18; 752 int32 dummy19 = 19; 753 int32 dummy20 = 20; 754 int32 dummy21 = 21; 755 int32 dummy22 = 22; 756 int32 dummy23 = 23; 757 int32 dummy24 = 24; 758 int32 dummy25 = 25; 759 int32 dummy26 = 26; 760 int32 dummy27 = 27; 761 int32 dummy28 = 28; 762 int32 dummy29 = 29; 763 int32 dummy30 = 30; 764 int32 dummy31 = 31; 765 int32 dummy32 = 32; 766 int32 c = 33 [ 767 features.field_presence = LEGACY_REQUIRED 768 ]; 769 770 // Add an optional child message to make this non-trivial for go/pdlazy. 771 ForeignMessage optional_foreign = 34; 772} 773 774message TestRequiredForeign { 775 TestRequired optional_message = 1; 776 repeated TestRequired repeated_message = 2; 777 int32 dummy = 3; 778 779 // Missing required fields must not affect verification of child messages. 780 NestedTestAllTypes optional_lazy_message = 4 [ 781 lazy = true 782 ]; 783} 784 785message TestRequiredMessage { 786 TestRequired optional_message = 1; 787 repeated TestRequired repeated_message = 2; 788 TestRequired required_message = 3 [ 789 features.field_presence = LEGACY_REQUIRED 790 ]; 791} 792 793message TestNestedRequiredForeign { 794 TestNestedRequiredForeign child = 1; 795 TestRequiredForeign payload = 2; 796 int32 dummy = 3; 797 798 // optional message to test required closed enum. 799 TestRequiredEnum required_enum = 5; 800 TestRequiredEnumNoMask required_enum_no_mask = 6; 801 TestRequiredEnumMulti required_enum_multi = 7; 802 TestRequiredNoMaskMulti required_no_mask = 9; 803} 804 805// Test that we can use NestedMessage from outside TestAllTypes. 806message TestForeignNested { 807 TestAllTypes.NestedMessage foreign_nested = 1; 808} 809 810// TestEmptyMessage is used to test unknown field support. 811message TestEmptyMessage { 812} 813 814// Like above, but declare all field numbers as potential extensions. No 815// actual extensions should ever be defined for this type. 816message TestEmptyMessageWithExtensions { 817 extensions 1 to max; 818} 819 820// Needed for a Python test. 821message TestPickleNestedMessage { 822 message NestedMessage { 823 int32 bb = 1; 824 825 message NestedNestedMessage { 826 int32 cc = 1; 827 } 828 } 829} 830 831message TestMultipleExtensionRanges { 832 extensions 42; 833 extensions 4143 to 4243; 834 extensions 65536 to max; 835} 836 837// Test that really large tag numbers don't break anything. 838message TestReallyLargeTagNumber { 839 // The largest possible tag number is 2^28 - 1, since the wire format uses 840 // three bits to communicate wire type. 841 int32 a = 1; 842 int32 bb = 268435455; 843} 844 845message TestRecursiveMessage { 846 TestRecursiveMessage a = 1; 847 int32 i = 2; 848} 849 850// Test that mutual recursion works. 851message TestMutualRecursionA { 852 message SubMessage { 853 TestMutualRecursionB b = 1; 854 } 855 856 TestMutualRecursionB bb = 1; 857 858 message SubGroup { 859 SubMessage sub_message = 3; // Needed because of bug in javatest 860 TestAllTypes not_in_this_scc = 4; 861 } 862 863 SubGroup subgroup = 2 [ 864 features.message_encoding = DELIMITED 865 ]; 866 867 message SubGroupR { 868 TestAllTypes payload = 6; 869 } 870 871 repeated SubGroupR subgroupr = 5 [ 872 features.message_encoding = DELIMITED 873 ]; 874} 875 876message TestMutualRecursionB { 877 TestMutualRecursionA a = 1; 878 int32 optional_int32 = 2; 879} 880 881message TestIsInitialized { 882 message SubMessage { 883 message SubGroup { 884 int32 i = 2 [ 885 features.field_presence = LEGACY_REQUIRED 886 ]; 887 } 888 889 SubGroup subgroup = 1 [ 890 features.message_encoding = DELIMITED 891 ]; 892 } 893 894 SubMessage sub_message = 1; 895} 896 897// Test that groups have disjoint field numbers from their siblings and 898// parents. This is NOT possible in proto1; only google.protobuf. When attempting 899// to compile with proto1, this will emit an error; so we only include it 900// in protobuf_unittest_proto. 901message TestDupFieldNumber {// NO_PROTO1 902 int32 a = 1; // NO_PROTO1 903 message Foo { // NO_PROTO1 904 int32 a = 1; // NO_PROTO1 905 } // NO_PROTO1 906 Foo foo = 2 [features.message_encoding = DELIMITED]; // NO_PROTO1 907 message Bar { // NO_PROTO1 908 int32 a = 1; // NO_PROTO1 909 } // NO_PROTO1 910 Bar bar = 3 [features.message_encoding = DELIMITED]; // NO_PROTO1 911} // NO_PROTO1 912 913// Additional messages for testing lazy fields. 914message TestEagerMessage { 915 TestAllTypes sub_message = 1 [ 916 lazy = false 917 ]; 918} 919 920message TestLazyMessage { 921 TestAllTypes sub_message = 1 [ 922 lazy = true 923 ]; 924} 925 926message TestLazyMessageRepeated { 927 repeated TestLazyMessage repeated_message = 1; 928} 929 930message TestEagerMaybeLazy { 931 message NestedMessage { 932 TestPackedTypes packed = 1; 933 } 934 935 TestAllTypes message_foo = 1; 936 TestAllTypes message_bar = 2; 937 NestedMessage message_baz = 3; 938} 939 940// Needed for a Python test. 941message TestNestedMessageHasBits { 942 message NestedMessage { 943 repeated int32 nestedmessage_repeated_int32 = 1; 944 repeated ForeignMessage nestedmessage_repeated_foreignmessage = 2; 945 } 946 947 NestedMessage optional_nested_message = 1; 948} 949 950// Test an enum that has multiple values with the same number. 951enum TestEnumWithDupValue { 952 option allow_alias = true; 953 954 FOO1 = 1; 955 BAR1 = 2; 956 BAZ = 3; 957 FOO2 = 1; 958 BAR2 = 2; 959} 960 961// Test an enum with large, unordered values. 962enum TestSparseEnum { 963 SPARSE_A = 123; 964 SPARSE_B = 62374; 965 SPARSE_C = 12589234; 966 SPARSE_D = -15; 967 SPARSE_E = -53452; 968 SPARSE_F = 0; 969 SPARSE_G = 2; 970} 971 972// Test message with CamelCase field names. This violates Protocol Buffer 973// standard style. 974message TestCamelCaseFieldNames { 975 int32 PrimitiveField = 1; 976 string StringField = 2; 977 ForeignEnum EnumField = 3; 978 ForeignMessage MessageField = 4; 979 string StringPieceField = 5 [ 980 ctype = STRING_PIECE 981 ]; 982 983 string CordField = 6 [ 984 ctype = CORD 985 ]; 986 987 repeated int32 RepeatedPrimitiveField = 7; 988 repeated string RepeatedStringField = 8; 989 repeated ForeignEnum RepeatedEnumField = 9; 990 repeated ForeignMessage RepeatedMessageField = 10; 991 repeated string RepeatedStringPieceField = 11 [ 992 ctype = STRING_PIECE 993 ]; 994 995 repeated string RepeatedCordField = 12 [ 996 ctype = CORD 997 ]; 998} 999 1000// We list fields out of order, to ensure that we're using field number and not 1001// field index to determine serialization order. 1002message TestFieldOrderings { 1003 string my_string = 11; 1004 1005 extensions 2 to 10; 1006 1007 int64 my_int = 1; 1008 1009 extensions 12 to 100; 1010 1011 float my_float = 101; 1012 1013 message NestedMessage { 1014 int64 oo = 2; 1015 1016 // The field name "b" fails to compile in proto1 because it conflicts with 1017 // a local variable named "b" in one of the generated methods. Doh. 1018 // This file needs to compile in proto1 to test backwards-compatibility. 1019 int32 bb = 1; 1020 } 1021 1022 NestedMessage optional_nested_message = 200; 1023} 1024 1025extend TestFieldOrderings { 1026 string my_extension_string = 50; 1027 int32 my_extension_int = 5; 1028} 1029 1030message TestExtensionOrderings1 { 1031 extend TestFieldOrderings { 1032 TestExtensionOrderings1 test_ext_orderings1 = 13; 1033 } 1034 1035 string my_string = 1; 1036} 1037 1038message TestExtensionOrderings2 { 1039 extend TestFieldOrderings { 1040 TestExtensionOrderings2 test_ext_orderings2 = 12; 1041 } 1042 1043 message TestExtensionOrderings3 { 1044 extend TestFieldOrderings { 1045 TestExtensionOrderings3 test_ext_orderings3 = 14; 1046 } 1047 1048 string my_string = 1; 1049 } 1050 1051 string my_string = 1; 1052} 1053 1054message TestExtremeDefaultValues { 1055 bytes escaped_bytes = 1 [ 1056 default = 1057 "\0\001\a\b\f\n\r\t\v\\\'\"\xfe" 1058 ]; 1059 1060 uint32 large_uint32 = 2 [ 1061 default = 0xFFFFFFFF 1062 ]; 1063 1064 uint64 large_uint64 = 3 [ 1065 default = 0xFFFFFFFFFFFFFFFF 1066 ]; 1067 1068 int32 small_int32 = 4 [ 1069 default = -0x7FFFFFFF 1070 ]; 1071 1072 int64 small_int64 = 5 [ 1073 default = -0x7FFFFFFFFFFFFFFF 1074 ]; 1075 1076 int32 really_small_int32 = 21 [ 1077 default = -0x80000000 1078 ]; 1079 1080 int64 really_small_int64 = 22 [ 1081 default = -0x8000000000000000 1082 ]; 1083 1084 // The default value here is UTF-8 for "\u1234". (We could also just type 1085 // the UTF-8 text directly into this text file rather than escape it, but 1086 // lots of people use editors that would be confused by this.) 1087 string utf8_string = 6 [ 1088 default = "\341\210\264" 1089 ]; 1090 1091 // Tests for single-precision floating-point values. 1092 float zero_float = 7 [ 1093 default = 0 1094 ]; 1095 1096 float one_float = 8 [ 1097 default = 1 1098 ]; 1099 1100 float small_float = 9 [ 1101 default = 1.5 1102 ]; 1103 1104 float negative_one_float = 10 [ 1105 default = -1 1106 ]; 1107 1108 float negative_float = 11 [ 1109 default = -1.5 1110 ]; 1111 1112 // Using exponents 1113 float large_float = 12 [ 1114 default = 2e8 1115 ]; 1116 1117 float small_negative_float = 13 [ 1118 default = -8e-28 1119 ]; 1120 1121 // Text for nonfinite floating-point values. 1122 double inf_double = 14 [ 1123 default = inf 1124 ]; 1125 1126 double neg_inf_double = 15 [ 1127 default = -inf 1128 ]; 1129 1130 double nan_double = 16 [ 1131 default = nan 1132 ]; 1133 1134 float inf_float = 17 [ 1135 default = inf 1136 ]; 1137 1138 float neg_inf_float = 18 [ 1139 default = -inf 1140 ]; 1141 1142 float nan_float = 19 [ 1143 default = nan 1144 ]; 1145 1146 // Tests for C++ trigraphs. 1147 // Trigraphs should be escaped in C++ generated files, but they should not be 1148 // escaped for other languages. 1149 // Note that in .proto file, "\?" is a valid way to escape ? in string 1150 // literals. 1151 string cpp_trigraph = 20 [ 1152 default = "? \? ?? \?? \??? ??/ ?\?-" 1153 ]; 1154 1155 // String defaults containing the character '\000' 1156 string string_with_zero = 23 [ 1157 default = "hel\000lo" 1158 ]; 1159 1160 bytes bytes_with_zero = 24 [ 1161 default = "wor\000ld" 1162 ]; 1163 1164 string string_piece_with_zero = 25 [ 1165 ctype = STRING_PIECE, 1166 default = "ab\000c" 1167 ]; 1168 1169 string cord_with_zero = 26 [ 1170 ctype = CORD, 1171 default = "12\0003" 1172 ]; 1173 1174 string replacement_string = 27 [ 1175 default = "${unknown}" 1176 ]; 1177} 1178 1179message SparseEnumMessage { 1180 TestSparseEnum sparse_enum = 1; 1181} 1182 1183// Test String and Bytes: string is for valid UTF-8 strings 1184message OneString { 1185 string data = 1; 1186} 1187 1188message MoreString { 1189 repeated string data = 1; 1190} 1191 1192message OneBytes { 1193 bytes data = 1; 1194} 1195 1196message MoreBytes { 1197 repeated bytes data = 1; 1198} 1199 1200message ManyOptionalString { 1201 string str1 = 1; 1202 string str2 = 2; 1203 string str3 = 3; 1204 string str4 = 4; 1205 string str5 = 5; 1206 string str6 = 6; 1207 string str7 = 7; 1208 string str8 = 8; 1209 string str9 = 9; 1210 string str10 = 10; 1211 string str11 = 11; 1212 string str12 = 12; 1213 string str13 = 13; 1214 string str14 = 14; 1215 string str15 = 15; 1216 string str16 = 16; 1217 string str17 = 17; 1218 string str18 = 18; 1219 string str19 = 19; 1220 string str20 = 20; 1221 string str21 = 21; 1222 string str22 = 22; 1223 string str23 = 23; 1224 string str24 = 24; 1225 string str25 = 25; 1226 string str26 = 26; 1227 string str27 = 27; 1228 string str28 = 28; 1229 string str29 = 29; 1230 string str30 = 30; 1231 string str31 = 31; 1232 string str32 = 32; 1233} 1234 1235// Test int32, uint32, int64, uint64, and bool are all compatible 1236message Int32Message { 1237 int32 data = 1; 1238} 1239 1240message Uint32Message { 1241 uint32 data = 1; 1242} 1243 1244message Int64Message { 1245 int64 data = 1; 1246} 1247 1248message Uint64Message { 1249 uint64 data = 1; 1250} 1251 1252message BoolMessage { 1253 bool data = 1; 1254} 1255 1256// Test oneofs. 1257message TestOneof { 1258 oneof foo { 1259 int32 foo_int = 1; 1260 string foo_string = 2; 1261 TestAllTypes foo_message = 3; 1262 FooGroup foogroup = 4 [ 1263 features.message_encoding = DELIMITED 1264 ]; 1265 } 1266 1267 message FooGroup { 1268 int32 a = 5; 1269 string b = 6; 1270 } 1271} 1272 1273message TestOneofBackwardsCompatible { 1274 int32 foo_int = 1; 1275 string foo_string = 2; 1276 TestAllTypes foo_message = 3; 1277 1278 message FooGroup { 1279 int32 a = 5; 1280 string b = 6; 1281 } 1282 1283 FooGroup foogroup = 4 [ 1284 features.message_encoding = DELIMITED 1285 ]; 1286} 1287 1288message TestOneof2 { 1289 oneof foo { 1290 int32 foo_int = 1; 1291 string foo_string = 2; 1292 string foo_cord = 3 [ 1293 ctype = CORD 1294 ]; 1295 1296 string foo_string_piece = 4 [ 1297 ctype = STRING_PIECE 1298 ]; 1299 1300 bytes foo_bytes = 5; 1301 NestedEnum foo_enum = 6; 1302 NestedMessage foo_message = 7; 1303 FooGroup foogroup = 8 [ 1304 features.message_encoding = DELIMITED 1305 ]; 1306 1307 NestedMessage foo_lazy_message = 11 [ 1308 lazy = true 1309 ]; 1310 1311 bytes foo_bytes_cord = 30 [ 1312 ctype = CORD 1313 ]; 1314 } 1315 1316 message FooGroup { 1317 int32 a = 9; 1318 string b = 10; 1319 } 1320 1321 oneof bar { 1322 int32 bar_int = 12 [ 1323 default = 5 1324 ]; 1325 1326 string bar_string = 13 [ 1327 default = "STRING" 1328 ]; 1329 1330 string bar_cord = 14 [ 1331 ctype = CORD, 1332 default = "CORD" 1333 ]; 1334 1335 string bar_string_piece = 15 [ 1336 ctype = STRING_PIECE, 1337 default = "SPIECE" 1338 ]; 1339 1340 bytes bar_bytes = 16 [ 1341 default = "BYTES" 1342 ]; 1343 1344 NestedEnum bar_enum = 17 [ 1345 default = BAR 1346 ]; 1347 1348 string bar_string_with_empty_default = 20 [ 1349 default = "" 1350 ]; 1351 1352 string bar_cord_with_empty_default = 21 [ 1353 ctype = CORD, 1354 default = "" 1355 ]; 1356 1357 string bar_string_piece_with_empty_default = 22 [ 1358 ctype = STRING_PIECE, 1359 default = "" 1360 ]; 1361 1362 bytes bar_bytes_with_empty_default = 23 [ 1363 default = "" 1364 ]; 1365 } 1366 1367 int32 baz_int = 18; 1368 string baz_string = 19 [ 1369 default = "BAZ" 1370 ]; 1371 1372 message NestedMessage { 1373 int64 moo_int = 1; 1374 repeated int32 corge_int = 2; 1375 NestedMessage child = 3; 1376 } 1377 1378 enum NestedEnum { 1379 FOO = 1; 1380 BAR = 2; 1381 BAZ = 3; 1382 } 1383} 1384 1385message TestRequiredOneof { 1386 oneof foo { 1387 int32 foo_int = 1; 1388 string foo_string = 2; 1389 NestedMessage foo_message = 3; 1390 NestedMessage foo_lazy_message = 4 [ 1391 lazy = true 1392 ]; 1393 } 1394 1395 message NestedMessage { 1396 double required_double = 1 [ 1397 features.field_presence = LEGACY_REQUIRED 1398 ]; 1399 } 1400} 1401 1402// Test messages for packed fields 1403 1404message TestPackedTypes { 1405 repeated int32 packed_int32 = 90 [ 1406 features.repeated_field_encoding = PACKED 1407 ]; 1408 1409 repeated int64 packed_int64 = 91 [ 1410 features.repeated_field_encoding = PACKED 1411 ]; 1412 1413 repeated uint32 packed_uint32 = 92 [ 1414 features.repeated_field_encoding = PACKED 1415 ]; 1416 1417 repeated uint64 packed_uint64 = 93 [ 1418 features.repeated_field_encoding = PACKED 1419 ]; 1420 1421 repeated sint32 packed_sint32 = 94 [ 1422 features.repeated_field_encoding = PACKED 1423 ]; 1424 1425 repeated sint64 packed_sint64 = 95 [ 1426 features.repeated_field_encoding = PACKED 1427 ]; 1428 1429 repeated fixed32 packed_fixed32 = 96 [ 1430 features.repeated_field_encoding = PACKED 1431 ]; 1432 1433 repeated fixed64 packed_fixed64 = 97 [ 1434 features.repeated_field_encoding = PACKED 1435 ]; 1436 1437 repeated sfixed32 packed_sfixed32 = 98 [ 1438 features.repeated_field_encoding = PACKED 1439 ]; 1440 1441 repeated sfixed64 packed_sfixed64 = 99 [ 1442 features.repeated_field_encoding = PACKED 1443 ]; 1444 1445 repeated float packed_float = 100 [ 1446 features.repeated_field_encoding = PACKED 1447 ]; 1448 1449 repeated double packed_double = 101 [ 1450 features.repeated_field_encoding = PACKED 1451 ]; 1452 1453 repeated bool packed_bool = 102 [ 1454 features.repeated_field_encoding = PACKED 1455 ]; 1456 1457 repeated ForeignEnum packed_enum = 103 [ 1458 features.repeated_field_encoding = PACKED 1459 ]; 1460} 1461 1462// A message with the same fields as TestPackedTypes, but without packing. Used 1463// to test packed <-> unpacked wire compatibility. 1464message TestUnpackedTypes { 1465 repeated int32 unpacked_int32 = 90; 1466 repeated int64 unpacked_int64 = 91; 1467 repeated uint32 unpacked_uint32 = 92; 1468 repeated uint64 unpacked_uint64 = 93; 1469 repeated sint32 unpacked_sint32 = 94; 1470 repeated sint64 unpacked_sint64 = 95; 1471 repeated fixed32 unpacked_fixed32 = 96; 1472 repeated fixed64 unpacked_fixed64 = 97; 1473 repeated sfixed32 unpacked_sfixed32 = 98; 1474 repeated sfixed64 unpacked_sfixed64 = 99; 1475 repeated float unpacked_float = 100; 1476 repeated double unpacked_double = 101; 1477 repeated bool unpacked_bool = 102; 1478 repeated ForeignEnum unpacked_enum = 103; 1479} 1480 1481message TestPackedExtensions { 1482 extensions 1 to max; 1483} 1484 1485extend TestPackedExtensions { 1486 repeated int32 packed_int32_extension = 90 [ 1487 features.repeated_field_encoding = PACKED 1488 ]; 1489 1490 repeated int64 packed_int64_extension = 91 [ 1491 features.repeated_field_encoding = PACKED 1492 ]; 1493 1494 repeated uint32 packed_uint32_extension = 92 [ 1495 features.repeated_field_encoding = PACKED 1496 ]; 1497 1498 repeated uint64 packed_uint64_extension = 93 [ 1499 features.repeated_field_encoding = PACKED 1500 ]; 1501 1502 repeated sint32 packed_sint32_extension = 94 [ 1503 features.repeated_field_encoding = PACKED 1504 ]; 1505 1506 repeated sint64 packed_sint64_extension = 95 [ 1507 features.repeated_field_encoding = PACKED 1508 ]; 1509 1510 repeated fixed32 packed_fixed32_extension = 96 [ 1511 features.repeated_field_encoding = PACKED 1512 ]; 1513 1514 repeated fixed64 packed_fixed64_extension = 97 [ 1515 features.repeated_field_encoding = PACKED 1516 ]; 1517 1518 repeated sfixed32 packed_sfixed32_extension = 98 [ 1519 features.repeated_field_encoding = PACKED 1520 ]; 1521 1522 repeated sfixed64 packed_sfixed64_extension = 99 [ 1523 features.repeated_field_encoding = PACKED 1524 ]; 1525 1526 repeated float packed_float_extension = 100 [ 1527 features.repeated_field_encoding = PACKED 1528 ]; 1529 1530 repeated double packed_double_extension = 101 [ 1531 features.repeated_field_encoding = PACKED 1532 ]; 1533 1534 repeated bool packed_bool_extension = 102 [ 1535 features.repeated_field_encoding = PACKED 1536 ]; 1537 1538 repeated ForeignEnum packed_enum_extension = 103 [ 1539 features.repeated_field_encoding = PACKED 1540 ]; 1541} 1542 1543message TestUnpackedExtensions { 1544 extensions 1 to max; 1545} 1546 1547extend TestUnpackedExtensions { 1548 repeated int32 unpacked_int32_extension = 90; 1549 repeated int64 unpacked_int64_extension = 91; 1550 repeated uint32 unpacked_uint32_extension = 92; 1551 repeated uint64 unpacked_uint64_extension = 93; 1552 repeated sint32 unpacked_sint32_extension = 94; 1553 repeated sint64 unpacked_sint64_extension = 95; 1554 repeated fixed32 unpacked_fixed32_extension = 96; 1555 repeated fixed64 unpacked_fixed64_extension = 97; 1556 repeated sfixed32 unpacked_sfixed32_extension = 98; 1557 repeated sfixed64 unpacked_sfixed64_extension = 99; 1558 repeated float unpacked_float_extension = 100; 1559 repeated double unpacked_double_extension = 101; 1560 repeated bool unpacked_bool_extension = 102; 1561 repeated ForeignEnum unpacked_enum_extension = 103; 1562} 1563 1564// Used by ExtensionSetTest/DynamicExtensions. The test actually builds 1565// a set of extensions to TestAllExtensions dynamically, based on the fields 1566// of this message type. 1567message TestDynamicExtensions { 1568 enum DynamicEnumType { 1569 DYNAMIC_FOO = 2200; 1570 DYNAMIC_BAR = 2201; 1571 DYNAMIC_BAZ = 2202; 1572 } 1573 1574 message DynamicMessageType { 1575 int32 dynamic_field = 2100; 1576 } 1577 1578 fixed32 scalar_extension = 2000; 1579 ForeignEnum enum_extension = 2001; 1580 DynamicEnumType dynamic_enum_extension = 2002; 1581 ForeignMessage message_extension = 2003; 1582 DynamicMessageType dynamic_message_extension = 2004; 1583 repeated string repeated_extension = 2005; 1584 repeated sint32 packed_extension = 2006 [ 1585 features.repeated_field_encoding = PACKED 1586 ]; 1587} 1588 1589message TestRepeatedString { 1590 repeated string repeated_string1 = 1; 1591 repeated string repeated_string2 = 2; 1592 repeated bytes repeated_bytes11 = 11; 1593 repeated bytes repeated_bytes12 = 12; 1594} 1595 1596message TestRepeatedScalarDifferentTagSizes { 1597 // Parsing repeated fixed size values used to fail. This message needs to be 1598 // used in order to get a tag of the right size; all of the repeated fields 1599 // in TestAllTypes didn't trigger the check. 1600 repeated fixed32 repeated_fixed32 = 12; 1601 1602 // Check for a varint type, just for good measure. 1603 repeated int32 repeated_int32 = 13; 1604 1605 // These have two-byte tags. 1606 repeated fixed64 repeated_fixed64 = 2046; 1607 repeated int64 repeated_int64 = 2047; 1608 1609 // Three byte tags. 1610 repeated float repeated_float = 262142; 1611 repeated uint64 repeated_uint64 = 262143; 1612} 1613 1614// Test that if an optional or required message/group field appears multiple 1615// times in the input, they need to be merged. 1616message TestParsingMerge { 1617 // RepeatedFieldsGenerator defines matching field types as TestParsingMerge, 1618 // except that all fields are repeated. In the tests, we will serialize the 1619 // RepeatedFieldsGenerator to bytes, and parse the bytes to TestParsingMerge. 1620 // Repeated fields in RepeatedFieldsGenerator are expected to be merged into 1621 // the corresponding required/optional fields in TestParsingMerge. 1622 message RepeatedFieldsGenerator { 1623 repeated TestAllTypes field1 = 1; 1624 repeated TestAllTypes field2 = 2; 1625 repeated TestAllTypes field3 = 3; 1626 1627 message Group1 { 1628 TestAllTypes field1 = 11; 1629 } 1630 1631 repeated Group1 group1 = 10 [ 1632 features.message_encoding = DELIMITED 1633 ]; 1634 1635 message Group2 { 1636 TestAllTypes field1 = 21; 1637 } 1638 1639 repeated Group2 group2 = 20 [ 1640 features.message_encoding = DELIMITED 1641 ]; 1642 1643 repeated TestAllTypes ext1 = 1000; 1644 repeated TestAllTypes ext2 = 1001; 1645 } 1646 1647 TestAllTypes required_all_types = 1 [ 1648 features.field_presence = LEGACY_REQUIRED 1649 ]; 1650 1651 TestAllTypes optional_all_types = 2; 1652 repeated TestAllTypes repeated_all_types = 3; 1653 1654 message OptionalGroup { 1655 TestAllTypes optional_group_all_types = 11; 1656 } 1657 1658 OptionalGroup optionalgroup = 10 [ 1659 features.message_encoding = DELIMITED 1660 ]; 1661 1662 message RepeatedGroup { 1663 TestAllTypes repeated_group_all_types = 21; 1664 } 1665 1666 repeated RepeatedGroup repeatedgroup = 20 [ 1667 features.message_encoding = DELIMITED 1668 ]; 1669 1670 extensions 1000 to max; 1671 1672 extend TestParsingMerge { 1673 TestAllTypes optional_ext = 1000; 1674 repeated TestAllTypes repeated_ext = 1001; 1675 } 1676} 1677 1678// Test that the correct exception is thrown by parseFrom in a corner case 1679// involving merging, extensions, and required fields. 1680message TestMergeException { 1681 TestAllExtensions all_extensions = 1; 1682} 1683 1684message TestCommentInjectionMessage { 1685 // */ <- This should not close the generated doc comment 1686 string a = 1 [ 1687 default = "*/ <- Neither should this." 1688 ]; 1689} 1690 1691// Used to check that the c++ code generator re-orders messages to reduce 1692// padding. 1693message TestMessageSize { 1694 bool m1 = 1; 1695 int64 m2 = 2; 1696 bool m3 = 3; 1697 string m4 = 4; 1698 int32 m5 = 5; 1699 int64 m6 = 6; 1700} 1701 1702message OpenEnumMessage { 1703 enum TestEnum { 1704 option features.enum_type = OPEN; 1705 1706 UNKNOWN = 0; 1707 FOO = 1; 1708 BAR = 2; 1709 BAZ = 3; 1710 } 1711 1712 TestEnum opt_open = 1; 1713 1714 ForeignEnum opt_closed = 2; 1715 repeated TestEnum repeated_open = 3; 1716 1717 repeated ForeignEnum repeated_closed = 4; 1718} 1719 1720// Test that RPC services work. 1721message FooRequest { 1722} 1723 1724message FooResponse { 1725} 1726 1727message FooClientMessage { 1728} 1729 1730message FooServerMessage { 1731} 1732 1733service TestService { 1734 rpc Foo(FooRequest) returns (FooResponse); 1735 1736 rpc Bar(BarRequest) returns (BarResponse); 1737} 1738 1739message BarRequest { 1740} 1741 1742message BarResponse { 1743} 1744 1745message TestJsonName { 1746 int32 field_name1 = 1; 1747 int32 fieldName2 = 2; 1748 int32 FieldName3 = 3; 1749 int32 _field_name4 = 4; 1750 int32 FIELD_NAME5 = 5; 1751 int32 field_name6 = 6 [ 1752 json_name = "@type" 1753 ]; 1754 1755 int32 fieldname7 = 7; 1756} 1757 1758message TestHugeFieldNumbers { 1759 int32 optional_int32 = 536870000; 1760 int32 fixed_32 = 536870001; 1761 repeated int32 repeated_int32 = 536870002; 1762 repeated int32 packed_int32 = 536870003 [ 1763 features.repeated_field_encoding = PACKED 1764 ]; 1765 1766 ForeignEnum optional_enum = 536870004; 1767 string optional_string = 536870005; 1768 bytes optional_bytes = 536870006; 1769 ForeignMessage optional_message = 536870007; 1770 1771 message OptionalGroup { 1772 int32 group_a = 536870009; 1773 } 1774 1775 OptionalGroup optionalgroup = 536870008 [ 1776 features.message_encoding = DELIMITED 1777 ]; 1778 1779 map<string, string> string_string_map = 536870010; 1780 1781 oneof oneof_field { 1782 uint32 oneof_uint32 = 536870011; 1783 TestAllTypes oneof_test_all_types = 536870012; 1784 string oneof_string = 536870013; 1785 bytes oneof_bytes = 536870014; 1786 } 1787 1788 extensions 536860000 to 536869999 [ 1789 declaration = { 1790 number: 536860000 1791 full_name: ".protobuf_unittest.test_all_types" 1792 type: ".protobuf_unittest.TestAllTypes" 1793 } 1794 ]; 1795} 1796 1797extend TestHugeFieldNumbers { 1798 TestAllTypes test_all_types = 536860000; 1799} 1800 1801message TestExtensionInsideTable { 1802 int32 field1 = 1; 1803 int32 field2 = 2; 1804 int32 field3 = 3; 1805 int32 field4 = 4; 1806 1807 extensions 5; 1808 1809 int32 field6 = 6; 1810 int32 field7 = 7; 1811 int32 field8 = 8; 1812 int32 field9 = 9; 1813 int32 field10 = 10; 1814} 1815 1816extend TestExtensionInsideTable { 1817 int32 test_extension_inside_table_extension = 5; 1818} 1819 1820// NOTE: Intentionally nested to mirror go/glep. 1821message TestNestedGroupExtensionOuter { 1822 message Layer1OptionalGroup { 1823 message Layer2RepeatedGroup { 1824 extensions 3 1825 // NOTE: extension metadata is not supported due to targets such as 1826 // `//google/protobuf_legacy_opensource/src:shell_scripts_test`, 1827 // eee https://screenshot.googleplex.com/Axz2QD8nxjdpyFF 1828 // [metadata = { 1829 // NOTE: can't write type there due to some clever build gen code at 1830 // http://google3/google/protobuf/BUILD;l=1247;rcl=411090862 1831 // type: "protobuf_unittest.TestNestedGroupExtensionInnerExtension", 1832 // name: "inner", 1833 // }] 1834 ; 1835 1836 string another_field = 6; 1837 } 1838 1839 repeated Layer2RepeatedGroup layer2repeatedgroup = 2 [ 1840 features.message_encoding = DELIMITED 1841 ]; 1842 1843 message Layer2AnotherOptionalRepeatedGroup { 1844 string but_why_tho = 5; 1845 } 1846 1847 repeated Layer2AnotherOptionalRepeatedGroup 1848 layer2anotheroptionalrepeatedgroup = 4 [ 1849 features.message_encoding = DELIMITED 1850 ]; 1851 } 1852 1853 Layer1OptionalGroup layer1optionalgroup = 1 [ 1854 features.message_encoding = DELIMITED 1855 ]; 1856} 1857 1858message TestNestedGroupExtensionInnerExtension { 1859 string inner_name = 1; 1860} 1861 1862extend TestNestedGroupExtensionOuter.Layer1OptionalGroup.Layer2RepeatedGroup { 1863 TestNestedGroupExtensionInnerExtension inner = 3; 1864} 1865 1866enum VeryLargeEnum { 1867 ENUM_LABEL_DEFAULT = 0; 1868 ENUM_LABEL_1 = 1; 1869 ENUM_LABEL_2 = 2; 1870 ENUM_LABEL_3 = 3; 1871 ENUM_LABEL_4 = 4; 1872 ENUM_LABEL_5 = 5; 1873 ENUM_LABEL_6 = 6; 1874 ENUM_LABEL_7 = 7; 1875 ENUM_LABEL_8 = 8; 1876 ENUM_LABEL_9 = 9; 1877 ENUM_LABEL_10 = 10; 1878 ENUM_LABEL_11 = 11; 1879 ENUM_LABEL_12 = 12; 1880 ENUM_LABEL_13 = 13; 1881 ENUM_LABEL_14 = 14; 1882 ENUM_LABEL_15 = 15; 1883 ENUM_LABEL_16 = 16; 1884 ENUM_LABEL_17 = 17; 1885 ENUM_LABEL_18 = 18; 1886 ENUM_LABEL_19 = 19; 1887 ENUM_LABEL_20 = 20; 1888 ENUM_LABEL_21 = 21; 1889 ENUM_LABEL_22 = 22; 1890 ENUM_LABEL_23 = 23; 1891 ENUM_LABEL_24 = 24; 1892 ENUM_LABEL_25 = 25; 1893 ENUM_LABEL_26 = 26; 1894 ENUM_LABEL_27 = 27; 1895 ENUM_LABEL_28 = 28; 1896 ENUM_LABEL_29 = 29; 1897 ENUM_LABEL_30 = 30; 1898 ENUM_LABEL_31 = 31; 1899 ENUM_LABEL_32 = 32; 1900 ENUM_LABEL_33 = 33; 1901 ENUM_LABEL_34 = 34; 1902 ENUM_LABEL_35 = 35; 1903 ENUM_LABEL_36 = 36; 1904 ENUM_LABEL_37 = 37; 1905 ENUM_LABEL_38 = 38; 1906 ENUM_LABEL_39 = 39; 1907 ENUM_LABEL_40 = 40; 1908 ENUM_LABEL_41 = 41; 1909 ENUM_LABEL_42 = 42; 1910 ENUM_LABEL_43 = 43; 1911 ENUM_LABEL_44 = 44; 1912 ENUM_LABEL_45 = 45; 1913 ENUM_LABEL_46 = 46; 1914 ENUM_LABEL_47 = 47; 1915 ENUM_LABEL_48 = 48; 1916 ENUM_LABEL_49 = 49; 1917 ENUM_LABEL_50 = 50; 1918 ENUM_LABEL_51 = 51; 1919 ENUM_LABEL_52 = 52; 1920 ENUM_LABEL_53 = 53; 1921 ENUM_LABEL_54 = 54; 1922 ENUM_LABEL_55 = 55; 1923 ENUM_LABEL_56 = 56; 1924 ENUM_LABEL_57 = 57; 1925 ENUM_LABEL_58 = 58; 1926 ENUM_LABEL_59 = 59; 1927 ENUM_LABEL_60 = 60; 1928 ENUM_LABEL_61 = 61; 1929 ENUM_LABEL_62 = 62; 1930 ENUM_LABEL_63 = 63; 1931 ENUM_LABEL_64 = 64; 1932 ENUM_LABEL_65 = 65; 1933 ENUM_LABEL_66 = 66; 1934 ENUM_LABEL_67 = 67; 1935 ENUM_LABEL_68 = 68; 1936 ENUM_LABEL_69 = 69; 1937 ENUM_LABEL_70 = 70; 1938 ENUM_LABEL_71 = 71; 1939 ENUM_LABEL_72 = 72; 1940 ENUM_LABEL_73 = 73; 1941 ENUM_LABEL_74 = 74; 1942 ENUM_LABEL_75 = 75; 1943 ENUM_LABEL_76 = 76; 1944 ENUM_LABEL_77 = 77; 1945 ENUM_LABEL_78 = 78; 1946 ENUM_LABEL_79 = 79; 1947 ENUM_LABEL_80 = 80; 1948 ENUM_LABEL_81 = 81; 1949 ENUM_LABEL_82 = 82; 1950 ENUM_LABEL_83 = 83; 1951 ENUM_LABEL_84 = 84; 1952 ENUM_LABEL_85 = 85; 1953 ENUM_LABEL_86 = 86; 1954 ENUM_LABEL_87 = 87; 1955 ENUM_LABEL_88 = 88; 1956 ENUM_LABEL_89 = 89; 1957 ENUM_LABEL_90 = 90; 1958 ENUM_LABEL_91 = 91; 1959 ENUM_LABEL_92 = 92; 1960 ENUM_LABEL_93 = 93; 1961 ENUM_LABEL_94 = 94; 1962 ENUM_LABEL_95 = 95; 1963 ENUM_LABEL_96 = 96; 1964 ENUM_LABEL_97 = 97; 1965 ENUM_LABEL_98 = 98; 1966 ENUM_LABEL_99 = 99; 1967 ENUM_LABEL_100 = 100; 1968} 1969 1970message TestExtensionRangeSerialize { 1971 int32 foo_one = 1; 1972 1973 extensions 2; 1974 extensions 3 to 4; 1975 1976 int32 foo_two = 6; 1977 int32 foo_three = 7; 1978 1979 extensions 9 to 10; 1980 1981 int32 foo_four = 13; 1982 1983 extensions 15 to 15; 1984 extensions 17 to 17; 1985 extensions 19 to 19; 1986 1987 extend TestExtensionRangeSerialize { 1988 int32 bar_one = 2; 1989 int32 bar_two = 4; 1990 int32 bar_three = 10; 1991 int32 bar_four = 15; 1992 int32 bar_five = 19; 1993 } 1994} 1995 1996message TestVerifyInt32Simple { 1997 int32 optional_int32_1 = 1; 1998 int32 optional_int32_2 = 2; 1999 int32 optional_int32_63 = 63; 2000 int32 optional_int32_64 = 64; 2001} 2002 2003message TestVerifyInt32 { 2004 int32 optional_int32_1 = 1; 2005 int32 optional_int32_2 = 2; 2006 int32 optional_int32_63 = 63; 2007 int32 optional_int32_64 = 64; 2008 TestAllTypes optional_all_types = 9; 2009 repeated TestAllTypes repeated_all_types = 10; 2010} 2011 2012message TestVerifyMostlyInt32 { 2013 int64 optional_int64_30 = 30; 2014 int32 optional_int32_1 = 1; 2015 int32 optional_int32_2 = 2; 2016 int32 optional_int32_3 = 3; 2017 int32 optional_int32_4 = 4; 2018 int32 optional_int32_63 = 63; 2019 int32 optional_int32_64 = 64; 2020 TestAllTypes optional_all_types = 9; 2021 repeated TestAllTypes repeated_all_types = 10; 2022} 2023 2024message TestVerifyMostlyInt32BigFieldNumber { 2025 int64 optional_int64_30 = 30; 2026 int32 optional_int32_300 = 300; 2027 int32 optional_int32_1 = 1; 2028 int32 optional_int32_2 = 2; 2029 int32 optional_int32_3 = 3; 2030 int32 optional_int32_4 = 4; 2031 int32 optional_int32_63 = 63; 2032 int32 optional_int32_64 = 64; 2033 TestAllTypes optional_all_types = 9; 2034 repeated TestAllTypes repeated_all_types = 10; 2035} 2036 2037message TestVerifyUint32Simple { 2038 uint32 optional_uint32_1 = 1; 2039 uint32 optional_uint32_2 = 2; 2040 uint32 optional_uint32_63 = 63; 2041 uint32 optional_uint32_64 = 64; 2042} 2043 2044message TestVerifyUint32 { 2045 uint32 optional_uint32_1 = 1; 2046 uint32 optional_uint32_2 = 2; 2047 uint32 optional_uint32_63 = 63; 2048 uint32 optional_uint32_64 = 64; 2049 TestAllTypes optional_all_types = 9; 2050 repeated TestAllTypes repeated_all_types = 10; 2051} 2052 2053message TestVerifyOneUint32 { 2054 uint32 optional_uint32_1 = 1; 2055 int32 optional_int32_2 = 2; 2056 int32 optional_int32_63 = 63; 2057 int32 optional_int32_64 = 64; 2058 TestAllTypes optional_all_types = 9; 2059 repeated TestAllTypes repeated_all_types = 10; 2060} 2061 2062message TestVerifyOneInt32BigFieldNumber { 2063 int32 optional_int32_65 = 65; 2064 int64 optional_int64_1 = 1; 2065 int64 optional_int64_2 = 2; 2066 int64 optional_int64_63 = 63; 2067 int64 optional_int64_64 = 64; 2068 TestAllTypes optional_all_types = 9; 2069 repeated TestAllTypes repeated_all_types = 10; 2070} 2071 2072message TestVerifyInt32BigFieldNumber { 2073 int32 optional_int32_1000 = 1000; 2074 int32 optional_int32_65 = 65; 2075 int32 optional_int32_1 = 1; 2076 int32 optional_int32_2 = 2; 2077 int32 optional_int32_63 = 63; 2078 int32 optional_int32_64 = 64; 2079 TestAllTypes optional_all_types = 9; 2080 repeated TestAllTypes repeated_all_types = 10; 2081} 2082 2083message TestVerifyUint32BigFieldNumber { 2084 uint32 optional_uint32_1000 = 1000; 2085 uint32 optional_uint32_65 = 65; 2086 uint32 optional_uint32_1 = 1; 2087 uint32 optional_uint32_2 = 2; 2088 uint32 optional_uint32_63 = 63; 2089 uint32 optional_uint32_64 = 64; 2090 TestAllTypes optional_all_types = 9; 2091 repeated TestAllTypes repeated_all_types = 10; 2092} 2093 2094message TestVerifyBigFieldNumberUint32 { 2095 message Nested { 2096 uint32 optional_uint32_5000 = 5000; 2097 uint32 optional_uint32_1000 = 1000; 2098 uint32 optional_uint32_66 = 66; 2099 uint32 optional_uint32_65 = 65; 2100 uint32 optional_uint32_1 = 1; 2101 uint32 optional_uint32_2 = 2; 2102 uint32 optional_uint32_63 = 63; 2103 uint32 optional_uint32_64 = 64; 2104 Nested optional_nested = 9; 2105 repeated Nested repeated_nested = 10; 2106 } 2107 2108 Nested optional_nested = 1; 2109} 2110 2111// This message contains different kind of enums to exercise the different 2112// parsers in table-driven. 2113message EnumParseTester { 2114 enum SeqSmall0 { 2115 SEQ_SMALL_0_DEFAULT = 0; 2116 SEQ_SMALL_0_1 = 1; 2117 SEQ_SMALL_0_2 = 2; 2118 } 2119 2120 SeqSmall0 optional_seq_small_0_lowfield = 1; 2121 SeqSmall0 optional_seq_small_0_midfield = 1001; 2122 SeqSmall0 optional_seq_small_0_hifield = 1000001; 2123 repeated SeqSmall0 repeated_seq_small_0_lowfield = 2; 2124 repeated SeqSmall0 repeated_seq_small_0_midfield = 1002; 2125 repeated SeqSmall0 repeated_seq_small_0_hifield = 1000002; 2126 repeated SeqSmall0 packed_seq_small_0_lowfield = 3 [ 2127 features.repeated_field_encoding = PACKED 2128 ]; 2129 2130 repeated SeqSmall0 packed_seq_small_0_midfield = 1003 [ 2131 features.repeated_field_encoding = PACKED 2132 ]; 2133 2134 repeated SeqSmall0 packed_seq_small_0_hifield = 1000003 [ 2135 features.repeated_field_encoding = PACKED 2136 ]; 2137 2138 enum SeqSmall1 { 2139 SEQ_SMALL_1_DEFAULT = 1; 2140 SEQ_SMALL_1_2 = 2; 2141 SEQ_SMALL_1_3 = 3; 2142 } 2143 2144 SeqSmall1 optional_seq_small_1_lowfield = 4; 2145 SeqSmall1 optional_seq_small_1_midfield = 1004; 2146 SeqSmall1 optional_seq_small_1_hifield = 1000004; 2147 repeated SeqSmall1 repeated_seq_small_1_lowfield = 5; 2148 repeated SeqSmall1 repeated_seq_small_1_midfield = 1005; 2149 repeated SeqSmall1 repeated_seq_small_1_hifield = 1000005; 2150 repeated SeqSmall1 packed_seq_small_1_lowfield = 6 [ 2151 features.repeated_field_encoding = PACKED 2152 ]; 2153 2154 repeated SeqSmall1 packed_seq_small_1_midfield = 1006 [ 2155 features.repeated_field_encoding = PACKED 2156 ]; 2157 2158 repeated SeqSmall1 packed_seq_small_1_hifield = 1000006 [ 2159 features.repeated_field_encoding = PACKED 2160 ]; 2161 2162 enum SeqLarge { 2163 SEQ_LARGE_DEFAULT = -1; 2164 SEQ_LARGE_0 = 0; 2165 SEQ_LARGE_1 = 1; 2166 SEQ_LARGE_2 = 2; 2167 SEQ_LARGE_3 = 3; 2168 SEQ_LARGE_4 = 4; 2169 SEQ_LARGE_5 = 5; 2170 SEQ_LARGE_6 = 6; 2171 SEQ_LARGE_7 = 7; 2172 SEQ_LARGE_8 = 8; 2173 SEQ_LARGE_9 = 9; 2174 SEQ_LARGE_10 = 10; 2175 SEQ_LARGE_11 = 11; 2176 SEQ_LARGE_12 = 12; 2177 SEQ_LARGE_13 = 13; 2178 SEQ_LARGE_14 = 14; 2179 SEQ_LARGE_15 = 15; 2180 SEQ_LARGE_16 = 16; 2181 SEQ_LARGE_17 = 17; 2182 SEQ_LARGE_18 = 18; 2183 SEQ_LARGE_19 = 19; 2184 SEQ_LARGE_20 = 20; 2185 SEQ_LARGE_21 = 21; 2186 SEQ_LARGE_22 = 22; 2187 SEQ_LARGE_23 = 23; 2188 SEQ_LARGE_24 = 24; 2189 SEQ_LARGE_25 = 25; 2190 SEQ_LARGE_26 = 26; 2191 SEQ_LARGE_27 = 27; 2192 SEQ_LARGE_28 = 28; 2193 SEQ_LARGE_29 = 29; 2194 SEQ_LARGE_30 = 30; 2195 SEQ_LARGE_31 = 31; 2196 SEQ_LARGE_32 = 32; 2197 SEQ_LARGE_33 = 33; 2198 } 2199 2200 SeqLarge optional_seq_large_lowfield = 7; 2201 SeqLarge optional_seq_large_midfield = 1007; 2202 SeqLarge optional_seq_large_hifield = 1000007; 2203 repeated SeqLarge repeated_seq_large_lowfield = 8; 2204 repeated SeqLarge repeated_seq_large_midfield = 1008; 2205 repeated SeqLarge repeated_seq_large_hifield = 1000008; 2206 repeated SeqLarge packed_seq_large_lowfield = 9 [ 2207 features.repeated_field_encoding = PACKED 2208 ]; 2209 2210 repeated SeqLarge packed_seq_large_midfield = 1009 [ 2211 features.repeated_field_encoding = PACKED 2212 ]; 2213 2214 repeated SeqLarge packed_seq_large_hifield = 1000009 [ 2215 features.repeated_field_encoding = PACKED 2216 ]; 2217 2218 enum Arbitrary { 2219 ARBITRARY_DEFAULT = -123123; 2220 ARBITRARY_1 = -123; 2221 ARBITRARY_2 = 213; 2222 ARBITRARY_3 = 213213; 2223 ARBITRARY_MIN = -2147483648; 2224 ARBITRARY_MAX = 2147483647; 2225 } 2226 2227 Arbitrary optional_arbitrary_lowfield = 10; 2228 Arbitrary optional_arbitrary_midfield = 1010; 2229 Arbitrary optional_arbitrary_hifield = 1000010; 2230 repeated Arbitrary repeated_arbitrary_lowfield = 11; 2231 repeated Arbitrary repeated_arbitrary_midfield = 1011; 2232 repeated Arbitrary repeated_arbitrary_hifield = 1000011; 2233 repeated Arbitrary packed_arbitrary_lowfield = 12 [ 2234 features.repeated_field_encoding = PACKED 2235 ]; 2236 2237 repeated Arbitrary packed_arbitrary_midfield = 1012 [ 2238 features.repeated_field_encoding = PACKED 2239 ]; 2240 2241 repeated Arbitrary packed_arbitrary_hifield = 1000012 [ 2242 features.repeated_field_encoding = PACKED 2243 ]; 2244 2245 extensions 2000000 to max; 2246 2247 extend EnumParseTester { 2248 Arbitrary optional_arbitrary_ext = 2000000; 2249 repeated Arbitrary repeated_arbitrary_ext = 2000001; 2250 repeated Arbitrary packed_arbitrary_ext = 2000002 [ 2251 features.repeated_field_encoding = PACKED 2252 ]; 2253 } 2254 2255 // An arbitrary field we can append to to break the runs of repeated fields. 2256 int32 other_field = 99; 2257} 2258 2259// This message contains different kind of bool fields to exercise the different 2260// parsers in table-drived. 2261message BoolParseTester { 2262 bool optional_bool_lowfield = 1; 2263 bool optional_bool_midfield = 1001; 2264 bool optional_bool_hifield = 1000001; 2265 repeated bool repeated_bool_lowfield = 2; 2266 repeated bool repeated_bool_midfield = 1002; 2267 repeated bool repeated_bool_hifield = 1000002; 2268 repeated bool packed_bool_lowfield = 3 [ 2269 features.repeated_field_encoding = PACKED 2270 ]; 2271 2272 repeated bool packed_bool_midfield = 1003 [ 2273 features.repeated_field_encoding = PACKED 2274 ]; 2275 2276 repeated bool packed_bool_hifield = 1000003 [ 2277 features.repeated_field_encoding = PACKED 2278 ]; 2279 2280 extensions 2000000 to max; 2281 2282 extend BoolParseTester { 2283 bool optional_bool_ext = 2000000; 2284 repeated bool repeated_bool_ext = 2000001; 2285 repeated bool packed_bool_ext = 2000002 [ 2286 features.repeated_field_encoding = PACKED 2287 ]; 2288 } 2289 2290 // An arbitrary field we can append to to break the runs of repeated fields. 2291 int32 other_field = 99; 2292} 2293 2294message Int32ParseTester { 2295 int32 optional_int32_lowfield = 1; 2296 int32 optional_int32_midfield = 1001; 2297 int32 optional_int32_hifield = 1000001; 2298 repeated int32 repeated_int32_lowfield = 2; 2299 repeated int32 repeated_int32_midfield = 1002; 2300 repeated int32 repeated_int32_hifield = 1000002; 2301 repeated int32 packed_int32_lowfield = 3 [ 2302 features.repeated_field_encoding = PACKED 2303 ]; 2304 2305 repeated int32 packed_int32_midfield = 1003 [ 2306 features.repeated_field_encoding = PACKED 2307 ]; 2308 2309 repeated int32 packed_int32_hifield = 1000003 [ 2310 features.repeated_field_encoding = PACKED 2311 ]; 2312 2313 extensions 2000000 to max; 2314 2315 extend Int32ParseTester { 2316 int32 optional_int32_ext = 2000000; 2317 repeated int32 repeated_int32_ext = 2000001; 2318 repeated int32 packed_int32_ext = 2000002 [ 2319 features.repeated_field_encoding = PACKED 2320 ]; 2321 } 2322 2323 // An arbitrary field we can append to to break the runs of repeated fields. 2324 int32 other_field = 99; 2325} 2326 2327message Int64ParseTester { 2328 int64 optional_int64_lowfield = 1; 2329 int64 optional_int64_midfield = 1001; 2330 int64 optional_int64_hifield = 1000001; 2331 repeated int64 repeated_int64_lowfield = 2; 2332 repeated int64 repeated_int64_midfield = 1002; 2333 repeated int64 repeated_int64_hifield = 1000002; 2334 repeated int64 packed_int64_lowfield = 3 [ 2335 features.repeated_field_encoding = PACKED 2336 ]; 2337 2338 repeated int64 packed_int64_midfield = 1003 [ 2339 features.repeated_field_encoding = PACKED 2340 ]; 2341 2342 repeated int64 packed_int64_hifield = 1000003 [ 2343 features.repeated_field_encoding = PACKED 2344 ]; 2345 2346 extensions 2000000 to max; 2347 2348 extend Int64ParseTester { 2349 int64 optional_int64_ext = 2000000; 2350 repeated int64 repeated_int64_ext = 2000001; 2351 repeated int64 packed_int64_ext = 2000002 [ 2352 features.repeated_field_encoding = PACKED 2353 ]; 2354 } 2355 2356 // An arbitrary field we can append to to break the runs of repeated fields. 2357 int32 other_field = 99; 2358} 2359 2360message InlinedStringIdxRegressionProto { 2361 // We mix data to make sure aux ids and inlined string idx do not match. 2362 // aux_idx == inlined_string_idx == 1 2363 string str1 = 1; 2364 2365 // aux_idx == 2 2366 InlinedStringIdxRegressionProto sub = 2; 2367 2368 // aux_idx == 3, inlined_string_idx == 2 2369 string str2 = 3; 2370 2371 // aux_idx == 4, inlined_string_idx == 3 2372 bytes str3 = 4; 2373} 2374 2375message StringParseTester { 2376 string optional_string_lowfield = 1; 2377 string optional_string_midfield = 1001; 2378 string optional_string_hifield = 1000001; 2379 repeated string repeated_string_lowfield = 2; 2380 repeated string repeated_string_midfield = 1002; 2381 repeated string repeated_string_hifield = 1000002; 2382 2383 extensions 2000000 to max; 2384 2385 extend StringParseTester { 2386 string optional_string_ext = 2000000; 2387 repeated string repeated_string_ext = 2000001; 2388 } 2389} 2390 2391message BadFieldNames { 2392 int32 OptionalInt32 = 1; 2393 int32 for = 2; 2394} 2395 2396message TestNestedMessageRedaction { 2397 string optional_unredacted_nested_string = 1; 2398 string optional_redacted_nested_string = 2 [ 2399 debug_redact = true 2400 ]; 2401} 2402 2403message RedactedFields { 2404 string optional_redacted_string = 1 [ 2405 debug_redact = true 2406 ]; 2407 2408 string optional_unredacted_string = 2; 2409 repeated string repeated_redacted_string = 3 [ 2410 debug_redact = true 2411 ]; 2412 2413 repeated string repeated_unredacted_string = 4; 2414 TestNestedMessageRedaction optional_redacted_message = 5 [ 2415 debug_redact = true 2416 ]; 2417 2418 TestNestedMessageRedaction optional_unredacted_message = 6; 2419 repeated TestNestedMessageRedaction repeated_redacted_message = 7 [ 2420 debug_redact = true 2421 ]; 2422 2423 repeated TestNestedMessageRedaction repeated_unredacted_message = 8; 2424 map<string, string> map_redacted_string = 9 [ 2425 debug_redact = true 2426 ]; 2427 2428 map<string, string> map_unredacted_string = 10; 2429 string optional_redacted_false_string = 11 [ 2430 debug_redact = false 2431 ]; 2432 2433 extensions 20 to 30; 2434} 2435 2436extend RedactedFields { 2437 string redacted_extension = 20 [ 2438 debug_redact = true 2439 ]; 2440} 2441 2442message TestCord { 2443 bytes optional_bytes_cord = 1 [ 2444 ctype = CORD 2445 ]; 2446 2447 bytes optional_bytes_cord_default = 2 [ 2448 ctype = CORD, 2449 default = "hello" 2450 ]; 2451} 2452 2453message TestPackedEnumSmallRange { 2454 enum NestedEnum { 2455 UNSPECIFIED = 0; 2456 FOO = 1; 2457 BAR = 2; 2458 BAZ = 3; 2459 } 2460 2461 repeated NestedEnum vals = 1 [ 2462 features.repeated_field_encoding = PACKED 2463 ]; 2464} 2465 2466message EnumsForBenchmark { 2467 enum Flat { 2468 A0 = 0; 2469 A1 = 1; 2470 A2 = 2; 2471 A3 = 3; 2472 A4 = 4; 2473 A5 = 5; 2474 A6 = 6; 2475 A7 = 7; 2476 A8 = 8; 2477 A9 = 9; 2478 A10 = 10; 2479 A11 = 11; 2480 A12 = 12; 2481 A13 = 13; 2482 A14 = 14; 2483 A15 = 15; 2484 } 2485 2486 // Has a few holes, bitmap can be used. 2487 enum AlmostFlat { 2488 B0 = 0; 2489 B1 = 1; 2490 B2 = 2; 2491 B3 = 3; 2492 B5 = 5; 2493 B6 = 6; 2494 B7 = 7; 2495 B8 = 8; 2496 B9 = 9; 2497 B11 = 11; 2498 B12 = 12; 2499 B13 = 13; 2500 B14 = 14; 2501 B15 = 15; 2502 B17 = 17; 2503 B19 = 19; 2504 } 2505 2506 enum Sparse { 2507 C536 = 536; 2508 C8387 = 8387; 2509 C9673 = 9673; 2510 C10285 = 10285; 2511 C13318 = 13318; 2512 C15963 = 15963; 2513 C16439 = 16439; 2514 C18197 = 18197; 2515 C19430 = 19430; 2516 C20361 = 20361; 2517 C20706 = 20706; 2518 C21050 = 21050; 2519 C21906 = 21906; 2520 C27265 = 27265; 2521 C30109 = 30109; 2522 C31670 = 31670; 2523 } 2524} 2525 2526message TestMessageWithManyRepeatedPtrFields { 2527 repeated string repeated_string_1 = 1; 2528 repeated string repeated_string_2 = 2; 2529 repeated string repeated_string_3 = 3; 2530 repeated string repeated_string_4 = 4; 2531 repeated string repeated_string_5 = 5; 2532 repeated string repeated_string_6 = 6; 2533 repeated string repeated_string_7 = 7; 2534 repeated string repeated_string_8 = 8; 2535 repeated string repeated_string_9 = 9; 2536 repeated string repeated_string_10 = 10; 2537 repeated string repeated_string_11 = 11; 2538 repeated string repeated_string_12 = 12; 2539 repeated string repeated_string_13 = 13; 2540 repeated string repeated_string_14 = 14; 2541 repeated string repeated_string_15 = 15; 2542 repeated string repeated_string_16 = 16; 2543 repeated string repeated_string_17 = 17; 2544 repeated string repeated_string_18 = 18; 2545 repeated string repeated_string_19 = 19; 2546 repeated string repeated_string_20 = 20; 2547 repeated string repeated_string_21 = 21; 2548 repeated string repeated_string_22 = 22; 2549 repeated string repeated_string_23 = 23; 2550 repeated string repeated_string_24 = 24; 2551 repeated string repeated_string_25 = 25; 2552 repeated string repeated_string_26 = 26; 2553 repeated string repeated_string_27 = 27; 2554 repeated string repeated_string_28 = 28; 2555 repeated string repeated_string_29 = 29; 2556 repeated string repeated_string_30 = 30; 2557 repeated string repeated_string_31 = 31; 2558 repeated string repeated_string_32 = 32; 2559} 2560 2561message MessageCreatorZeroInit { 2562 int32 i = 1; 2563 double d = 2; 2564 MessageCreatorZeroInit m = 3; 2565 2566 oneof one { 2567 string os = 10; 2568 string oc = 11 [ 2569 ctype = CORD 2570 ]; 2571 2572 fixed64 of = 12; 2573 MessageCreatorZeroInit ol = 13 [ 2574 lazy = true 2575 ]; 2576 } 2577} 2578 2579message MessageCreatorMemcpy { 2580 string s = 1; 2581 repeated int32 i = 2 [ 2582 features.repeated_field_encoding = PACKED 2583 ]; 2584 2585 MessageCreatorMemcpy m = 3 [ 2586 lazy = true 2587 ]; 2588 2589 map<int32, int32> m2 = 4; 2590} 2591 2592message MessageCreatorFunc { 2593 // This one is ArenaDtorNeeds::kRequired so we must run the constructor. 2594 string c = 3 [ 2595 ctype = CORD 2596 ]; 2597} 2598