| OLD | NEW |
| 1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
| 2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
| 3 // http://code.google.com/p/protobuf/ | 3 // https://developers.google.com/protocol-buffers/ |
| 4 // | 4 // |
| 5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
| 6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
| 7 // met: | 7 // met: |
| 8 // | 8 // |
| 9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
| 10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
| 11 // * Redistributions in binary form must reproduce the above | 11 // * Redistributions in binary form must reproduce the above |
| 12 // copyright notice, this list of conditions and the following disclaimer | 12 // copyright notice, this list of conditions and the following disclaimer |
| 13 // in the documentation and/or other materials provided with the | 13 // in the documentation and/or other materials provided with the |
| (...skipping 13 matching lines...) Expand all Loading... |
| 27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | 30 |
| 31 // Author: kenton@google.com (Kenton Varda) | 31 // Author: kenton@google.com (Kenton Varda) |
| 32 // Based on original Protocol Buffers design by | 32 // Based on original Protocol Buffers design by |
| 33 // Sanjay Ghemawat, Jeff Dean, and others. | 33 // Sanjay Ghemawat, Jeff Dean, and others. |
| 34 // | 34 // |
| 35 // A proto file we will use for unit testing. | 35 // A proto file we will use for unit testing. |
| 36 | 36 |
| 37 syntax = "proto2"; |
| 37 | 38 |
| 38 // Some generic_services option(s) added automatically. | 39 // Some generic_services option(s) added automatically. |
| 39 // See: http://go/proto2-generic-services-default | 40 // See: http://go/proto2-generic-services-default |
| 40 option cc_generic_services = true; // auto-added | 41 option cc_generic_services = true; // auto-added |
| 41 option java_generic_services = true; // auto-added | 42 option java_generic_services = true; // auto-added |
| 42 option py_generic_services = true; // auto-added | 43 option py_generic_services = true; // auto-added |
| 44 option cc_enable_arenas = true; |
| 43 | 45 |
| 44 import "google/protobuf/unittest_import.proto"; | 46 import "google/protobuf/unittest_import.proto"; |
| 45 | 47 |
| 46 // We don't put this in a package within proto2 because we need to make sure | 48 // We don't put this in a package within proto2 because we need to make sure |
| 47 // that the generated code doesn't depend on being in the proto2 namespace. | 49 // that the generated code doesn't depend on being in the proto2 namespace. |
| 48 // In test_util.h we do "using namespace unittest = protobuf_unittest". | 50 // In test_util.h we do "using namespace unittest = protobuf_unittest". |
| 49 package protobuf_unittest; | 51 package protobuf_unittest; |
| 50 | 52 |
| 51 // Protos optimized for SPEED use a strict superset of the generated code | 53 // Protos optimized for SPEED use a strict superset of the generated code |
| 52 // of equivalent ones optimized for CODE_SIZE, so we should optimize all our | 54 // of equivalent ones optimized for CODE_SIZE, so we should optimize all our |
| 53 // tests for speed unless explicitly testing code size optimization. | 55 // tests for speed unless explicitly testing code size optimization. |
| 54 option optimize_for = SPEED; | 56 option optimize_for = SPEED; |
| 55 | 57 |
| 56 option java_outer_classname = "UnittestProto"; | 58 option java_outer_classname = "UnittestProto"; |
| 57 | 59 |
| 58 // This proto includes every type of field in both singular and repeated | 60 // This proto includes every type of field in both singular and repeated |
| 59 // forms. | 61 // forms. |
| 60 message TestAllTypes { | 62 message TestAllTypes { |
| 61 message NestedMessage { | 63 message NestedMessage { |
| 62 // The field name "b" fails to compile in proto1 because it conflicts with | 64 // The field name "b" fails to compile in proto1 because it conflicts with |
| 63 // a local variable named "b" in one of the generated methods. Doh. | 65 // a local variable named "b" in one of the generated methods. Doh. |
| 64 // This file needs to compile in proto1 to test backwards-compatibility. | 66 // This file needs to compile in proto1 to test backwards-compatibility. |
| 65 optional int32 bb = 1; | 67 optional int32 bb = 1; |
| 66 } | 68 } |
| 67 | 69 |
| 68 enum NestedEnum { | 70 enum NestedEnum { |
| 69 FOO = 1; | 71 FOO = 1; |
| 70 BAR = 2; | 72 BAR = 2; |
| 71 BAZ = 3; | 73 BAZ = 3; |
| 74 NEG = -1; // Intentionally negative. |
| 72 } | 75 } |
| 73 | 76 |
| 74 // Singular | 77 // Singular |
| 75 optional int32 optional_int32 = 1; | 78 optional int32 optional_int32 = 1; |
| 76 optional int64 optional_int64 = 2; | 79 optional int64 optional_int64 = 2; |
| 77 optional uint32 optional_uint32 = 3; | 80 optional uint32 optional_uint32 = 3; |
| 78 optional uint64 optional_uint64 = 4; | 81 optional uint64 optional_uint64 = 4; |
| 79 optional sint32 optional_sint32 = 5; | 82 optional sint32 optional_sint32 = 5; |
| 80 optional sint64 optional_sint64 = 6; | 83 optional sint64 optional_sint64 = 6; |
| 81 optional fixed32 optional_fixed32 = 7; | 84 optional fixed32 optional_fixed32 = 7; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 optional string default_string = 74 [default = "hello"]; | 163 optional string default_string = 74 [default = "hello"]; |
| 161 optional bytes default_bytes = 75 [default = "world"]; | 164 optional bytes default_bytes = 75 [default = "world"]; |
| 162 | 165 |
| 163 optional NestedEnum default_nested_enum = 81 [default = BAR ]; | 166 optional NestedEnum default_nested_enum = 81 [default = BAR ]; |
| 164 optional ForeignEnum default_foreign_enum = 82 [default = FOREIGN_BAR]; | 167 optional ForeignEnum default_foreign_enum = 82 [default = FOREIGN_BAR]; |
| 165 optional protobuf_unittest_import.ImportEnum | 168 optional protobuf_unittest_import.ImportEnum |
| 166 default_import_enum = 83 [default = IMPORT_BAR]; | 169 default_import_enum = 83 [default = IMPORT_BAR]; |
| 167 | 170 |
| 168 optional string default_string_piece = 84 [ctype=STRING_PIECE,default="abc"]; | 171 optional string default_string_piece = 84 [ctype=STRING_PIECE,default="abc"]; |
| 169 optional string default_cord = 85 [ctype=CORD,default="123"]; | 172 optional string default_cord = 85 [ctype=CORD,default="123"]; |
| 173 |
| 174 // For oneof test |
| 175 oneof oneof_field { |
| 176 uint32 oneof_uint32 = 111; |
| 177 NestedMessage oneof_nested_message = 112; |
| 178 string oneof_string = 113; |
| 179 bytes oneof_bytes = 114; |
| 180 } |
| 181 } |
| 182 |
| 183 // This proto includes a recusively nested message. |
| 184 message NestedTestAllTypes { |
| 185 optional NestedTestAllTypes child = 1; |
| 186 optional TestAllTypes payload = 2; |
| 187 repeated NestedTestAllTypes repeated_child = 3; |
| 170 } | 188 } |
| 171 | 189 |
| 172 message TestDeprecatedFields { | 190 message TestDeprecatedFields { |
| 173 optional int32 deprecated_int32 = 1 [deprecated=true]; | 191 optional int32 deprecated_int32 = 1 [deprecated=true]; |
| 174 } | 192 } |
| 175 | 193 |
| 176 // Define these after TestAllTypes to make sure the compiler can handle | 194 // Define these after TestAllTypes to make sure the compiler can handle |
| 177 // that. | 195 // that. |
| 178 message ForeignMessage { | 196 message ForeignMessage { |
| 179 optional int32 c = 1; | 197 optional int32 c = 1; |
| 180 } | 198 } |
| 181 | 199 |
| 182 enum ForeignEnum { | 200 enum ForeignEnum { |
| 183 FOREIGN_FOO = 4; | 201 FOREIGN_FOO = 4; |
| 184 FOREIGN_BAR = 5; | 202 FOREIGN_BAR = 5; |
| 185 FOREIGN_BAZ = 6; | 203 FOREIGN_BAZ = 6; |
| 186 } | 204 } |
| 187 | 205 |
| 206 message TestReservedFields { |
| 207 reserved 2, 15, 9 to 11; |
| 208 reserved "bar", "baz"; |
| 209 } |
| 210 |
| 188 message TestAllExtensions { | 211 message TestAllExtensions { |
| 189 extensions 1 to max; | 212 extensions 1 to max; |
| 190 } | 213 } |
| 191 | 214 |
| 192 extend TestAllExtensions { | 215 extend TestAllExtensions { |
| 193 // Singular | 216 // Singular |
| 194 optional int32 optional_int32_extension = 1; | 217 optional int32 optional_int32_extension = 1; |
| 195 optional int64 optional_int64_extension = 2; | 218 optional int64 optional_int64_extension = 2; |
| 196 optional uint32 optional_uint32_extension = 3; | 219 optional uint32 optional_uint32_extension = 3; |
| 197 optional uint64 optional_uint64_extension = 4; | 220 optional uint64 optional_uint64_extension = 4; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 optional TestAllTypes.NestedEnum | 310 optional TestAllTypes.NestedEnum |
| 288 default_nested_enum_extension = 81 [default = BAR]; | 311 default_nested_enum_extension = 81 [default = BAR]; |
| 289 optional ForeignEnum | 312 optional ForeignEnum |
| 290 default_foreign_enum_extension = 82 [default = FOREIGN_BAR]; | 313 default_foreign_enum_extension = 82 [default = FOREIGN_BAR]; |
| 291 optional protobuf_unittest_import.ImportEnum | 314 optional protobuf_unittest_import.ImportEnum |
| 292 default_import_enum_extension = 83 [default = IMPORT_BAR]; | 315 default_import_enum_extension = 83 [default = IMPORT_BAR]; |
| 293 | 316 |
| 294 optional string default_string_piece_extension = 84 [ctype=STRING_PIECE, | 317 optional string default_string_piece_extension = 84 [ctype=STRING_PIECE, |
| 295 default="abc"]; | 318 default="abc"]; |
| 296 optional string default_cord_extension = 85 [ctype=CORD, default="123"]; | 319 optional string default_cord_extension = 85 [ctype=CORD, default="123"]; |
| 320 |
| 321 // For oneof test |
| 322 optional uint32 oneof_uint32_extension = 111; |
| 323 optional TestAllTypes.NestedMessage oneof_nested_message_extension = 112; |
| 324 optional string oneof_string_extension = 113; |
| 325 optional bytes oneof_bytes_extension = 114; |
| 297 } | 326 } |
| 298 | 327 |
| 299 message TestNestedExtension { | 328 message TestNestedExtension { |
| 300 extend TestAllExtensions { | 329 extend TestAllExtensions { |
| 301 // Check for bug where string extensions declared in tested scope did not | 330 // Check for bug where string extensions declared in tested scope did not |
| 302 // compile. | 331 // compile. |
| 303 optional string test = 1002 [default="test"]; | 332 optional string test = 1002 [default="test"]; |
| 333 // Used to test if generated extension name is correct when there are |
| 334 // underscores. |
| 335 optional string nested_string_extension = 1003; |
| 304 } | 336 } |
| 305 } | 337 } |
| 306 | 338 |
| 307 // We have separate messages for testing required fields because it's | 339 // We have separate messages for testing required fields because it's |
| 308 // annoying to have to fill in required fields in TestProto in order to | 340 // annoying to have to fill in required fields in TestProto in order to |
| 309 // do anything with it. Note that we don't need to test every type of | 341 // do anything with it. Note that we don't need to test every type of |
| 310 // required filed because the code output is basically identical to | 342 // required filed because the code output is basically identical to |
| 311 // optional fields for all types. | 343 // optional fields for all types. |
| 312 message TestRequired { | 344 message TestRequired { |
| 313 required int32 a = 1; | 345 required int32 a = 1; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 message TestMutualRecursionA { | 430 message TestMutualRecursionA { |
| 399 optional TestMutualRecursionB bb = 1; | 431 optional TestMutualRecursionB bb = 1; |
| 400 } | 432 } |
| 401 | 433 |
| 402 message TestMutualRecursionB { | 434 message TestMutualRecursionB { |
| 403 optional TestMutualRecursionA a = 1; | 435 optional TestMutualRecursionA a = 1; |
| 404 optional int32 optional_int32 = 2; | 436 optional int32 optional_int32 = 2; |
| 405 } | 437 } |
| 406 | 438 |
| 407 // Test that groups have disjoint field numbers from their siblings and | 439 // Test that groups have disjoint field numbers from their siblings and |
| 408 // parents. This is NOT possible in proto1; only proto2. When attempting | 440 // parents. This is NOT possible in proto1; only google.protobuf. When attempt
ing |
| 409 // to compile with proto1, this will emit an error; so we only include it | 441 // to compile with proto1, this will emit an error; so we only include it |
| 410 // in protobuf_unittest_proto. | 442 // in protobuf_unittest_proto. |
| 411 message TestDupFieldNumber { // NO_PROTO1 | 443 message TestDupFieldNumber { // NO_PROTO1 |
| 412 optional int32 a = 1; // NO_PROTO1 | 444 optional int32 a = 1; // NO_PROTO1 |
| 413 optional group Foo = 2 { optional int32 a = 1; } // NO_PROTO1 | 445 optional group Foo = 2 { optional int32 a = 1; } // NO_PROTO1 |
| 414 optional group Bar = 3 { optional int32 a = 1; } // NO_PROTO1 | 446 optional group Bar = 3 { optional int32 a = 1; } // NO_PROTO1 |
| 415 } // NO_PROTO1 | 447 } // NO_PROTO1 |
| 416 | 448 |
| 417 // Additional messages for testing lazy fields. | 449 // Additional messages for testing lazy fields. |
| 418 message TestEagerMessage { | 450 message TestEagerMessage { |
| 419 optional TestAllTypes sub_message = 1 [lazy=false]; | 451 optional TestAllTypes sub_message = 1 [lazy=false]; |
| 420 } | 452 } |
| 421 message TestLazyMessage { | 453 message TestLazyMessage { |
| 422 optional TestAllTypes sub_message = 1 [lazy=true]; | 454 optional TestAllTypes sub_message = 1 [lazy=true]; |
| 423 } | 455 } |
| 424 | 456 |
| 425 // Needed for a Python test. | 457 // Needed for a Python test. |
| 426 message TestNestedMessageHasBits { | 458 message TestNestedMessageHasBits { |
| 427 message NestedMessage { | 459 message NestedMessage { |
| 428 repeated int32 nestedmessage_repeated_int32 = 1; | 460 repeated int32 nestedmessage_repeated_int32 = 1; |
| 429 repeated ForeignMessage nestedmessage_repeated_foreignmessage = 2; | 461 repeated ForeignMessage nestedmessage_repeated_foreignmessage = 2; |
| 430 } | 462 } |
| 431 optional NestedMessage optional_nested_message = 1; | 463 optional NestedMessage optional_nested_message = 1; |
| 432 } | 464 } |
| 433 | 465 |
| 434 | 466 |
| 435 // Test an enum that has multiple values with the same number. | 467 // Test an enum that has multiple values with the same number. |
| 436 enum TestEnumWithDupValue { | 468 enum TestEnumWithDupValue { |
| 437 option allow_alias = true; | 469 option allow_alias = true; |
| 470 |
| 438 FOO1 = 1; | 471 FOO1 = 1; |
| 439 BAR1 = 2; | 472 BAR1 = 2; |
| 440 BAZ = 3; | 473 BAZ = 3; |
| 441 FOO2 = 1; | 474 FOO2 = 1; |
| 442 BAR2 = 2; | 475 BAR2 = 2; |
| 443 } | 476 } |
| 444 | 477 |
| 445 // Test an enum with large, unordered values. | 478 // Test an enum with large, unordered values. |
| 446 enum TestSparseEnum { | 479 enum TestSparseEnum { |
| 447 SPARSE_A = 123; | 480 SPARSE_A = 123; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 473 | 506 |
| 474 | 507 |
| 475 // We list fields out of order, to ensure that we're using field number and not | 508 // We list fields out of order, to ensure that we're using field number and not |
| 476 // field index to determine serialization order. | 509 // field index to determine serialization order. |
| 477 message TestFieldOrderings { | 510 message TestFieldOrderings { |
| 478 optional string my_string = 11; | 511 optional string my_string = 11; |
| 479 extensions 2 to 10; | 512 extensions 2 to 10; |
| 480 optional int64 my_int = 1; | 513 optional int64 my_int = 1; |
| 481 extensions 12 to 100; | 514 extensions 12 to 100; |
| 482 optional float my_float = 101; | 515 optional float my_float = 101; |
| 516 message NestedMessage { |
| 517 optional int64 oo = 2; |
| 518 // The field name "b" fails to compile in proto1 because it conflicts with |
| 519 // a local variable named "b" in one of the generated methods. Doh. |
| 520 // This file needs to compile in proto1 to test backwards-compatibility. |
| 521 optional int32 bb = 1; |
| 522 } |
| 523 |
| 524 optional NestedMessage optional_nested_message = 200; |
| 483 } | 525 } |
| 484 | 526 |
| 485 | 527 |
| 486 extend TestFieldOrderings { | 528 extend TestFieldOrderings { |
| 487 optional string my_extension_string = 50; | 529 optional string my_extension_string = 50; |
| 488 optional int32 my_extension_int = 5; | 530 optional int32 my_extension_int = 5; |
| 489 } | 531 } |
| 490 | 532 |
| 491 | 533 |
| 492 message TestExtremeDefaultValues { | 534 message TestExtremeDefaultValues { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 // literals. | 570 // literals. |
| 529 optional string cpp_trigraph = 20 [default = "? \? ?? \?? \??? ??/ ?\?-"]; | 571 optional string cpp_trigraph = 20 [default = "? \? ?? \?? \??? ??/ ?\?-"]; |
| 530 | 572 |
| 531 // String defaults containing the character '\000' | 573 // String defaults containing the character '\000' |
| 532 optional string string_with_zero = 23 [default = "hel\000lo"]; | 574 optional string string_with_zero = 23 [default = "hel\000lo"]; |
| 533 optional bytes bytes_with_zero = 24 [default = "wor\000ld"]; | 575 optional bytes bytes_with_zero = 24 [default = "wor\000ld"]; |
| 534 optional string string_piece_with_zero = 25 [ctype=STRING_PIECE, | 576 optional string string_piece_with_zero = 25 [ctype=STRING_PIECE, |
| 535 default="ab\000c"]; | 577 default="ab\000c"]; |
| 536 optional string cord_with_zero = 26 [ctype=CORD, | 578 optional string cord_with_zero = 26 [ctype=CORD, |
| 537 default="12\0003"]; | 579 default="12\0003"]; |
| 580 optional string replacement_string = 27 [default="${unknown}"]; |
| 538 } | 581 } |
| 539 | 582 |
| 540 message SparseEnumMessage { | 583 message SparseEnumMessage { |
| 541 optional TestSparseEnum sparse_enum = 1; | 584 optional TestSparseEnum sparse_enum = 1; |
| 542 } | 585 } |
| 543 | 586 |
| 544 // Test String and Bytes: string is for valid UTF-8 strings | 587 // Test String and Bytes: string is for valid UTF-8 strings |
| 545 message OneString { | 588 message OneString { |
| 546 optional string data = 1; | 589 optional string data = 1; |
| 547 } | 590 } |
| 548 | 591 |
| 549 message MoreString { | 592 message MoreString { |
| 550 repeated string data = 1; | 593 repeated string data = 1; |
| 551 } | 594 } |
| 552 | 595 |
| 553 message OneBytes { | 596 message OneBytes { |
| 554 optional bytes data = 1; | 597 optional bytes data = 1; |
| 555 } | 598 } |
| 556 | 599 |
| 557 message MoreBytes { | 600 message MoreBytes { |
| 558 repeated bytes data = 1; | 601 repeated bytes data = 1; |
| 559 } | 602 } |
| 560 | 603 |
| 604 // Test int32, uint32, int64, uint64, and bool are all compatible |
| 605 message Int32Message { |
| 606 optional int32 data = 1; |
| 607 } |
| 608 |
| 609 message Uint32Message { |
| 610 optional uint32 data = 1; |
| 611 } |
| 612 |
| 613 message Int64Message { |
| 614 optional int64 data = 1; |
| 615 } |
| 616 |
| 617 message Uint64Message { |
| 618 optional uint64 data = 1; |
| 619 } |
| 620 |
| 621 message BoolMessage { |
| 622 optional bool data = 1; |
| 623 } |
| 624 |
| 625 // Test oneofs. |
| 626 message TestOneof { |
| 627 oneof foo { |
| 628 int32 foo_int = 1; |
| 629 string foo_string = 2; |
| 630 TestAllTypes foo_message = 3; |
| 631 group FooGroup = 4 { |
| 632 optional int32 a = 5; |
| 633 optional string b = 6; |
| 634 } |
| 635 } |
| 636 } |
| 637 |
| 638 message TestOneofBackwardsCompatible { |
| 639 optional int32 foo_int = 1; |
| 640 optional string foo_string = 2; |
| 641 optional TestAllTypes foo_message = 3; |
| 642 optional group FooGroup = 4 { |
| 643 optional int32 a = 5; |
| 644 optional string b = 6; |
| 645 } |
| 646 } |
| 647 |
| 648 message TestOneof2 { |
| 649 oneof foo { |
| 650 int32 foo_int = 1; |
| 651 string foo_string = 2; |
| 652 string foo_cord = 3 [ctype=CORD]; |
| 653 string foo_string_piece = 4 [ctype=STRING_PIECE]; |
| 654 bytes foo_bytes = 5; |
| 655 NestedEnum foo_enum = 6; |
| 656 NestedMessage foo_message = 7; |
| 657 group FooGroup = 8 { |
| 658 optional int32 a = 9; |
| 659 optional string b = 10; |
| 660 } |
| 661 NestedMessage foo_lazy_message = 11 [lazy=true]; |
| 662 } |
| 663 |
| 664 oneof bar { |
| 665 int32 bar_int = 12 [default = 5]; |
| 666 string bar_string = 13 [default = "STRING"]; |
| 667 string bar_cord = 14 [ctype=CORD, default = "CORD"]; |
| 668 string bar_string_piece = 15 [ctype=STRING_PIECE, default = "SPIECE"]; |
| 669 bytes bar_bytes = 16 [default = "BYTES"]; |
| 670 NestedEnum bar_enum = 17 [default = BAR]; |
| 671 } |
| 672 |
| 673 optional int32 baz_int = 18; |
| 674 optional string baz_string = 19 [default = "BAZ"]; |
| 675 |
| 676 message NestedMessage { |
| 677 optional int64 qux_int = 1; |
| 678 repeated int32 corge_int = 2; |
| 679 } |
| 680 |
| 681 enum NestedEnum { |
| 682 FOO = 1; |
| 683 BAR = 2; |
| 684 BAZ = 3; |
| 685 } |
| 686 } |
| 687 |
| 688 message TestRequiredOneof { |
| 689 oneof foo { |
| 690 int32 foo_int = 1; |
| 691 string foo_string = 2; |
| 692 NestedMessage foo_message = 3; |
| 693 } |
| 694 message NestedMessage { |
| 695 required double required_double = 1; |
| 696 } |
| 697 } |
| 561 | 698 |
| 562 // Test messages for packed fields | 699 // Test messages for packed fields |
| 563 | 700 |
| 564 message TestPackedTypes { | 701 message TestPackedTypes { |
| 565 repeated int32 packed_int32 = 90 [packed = true]; | 702 repeated int32 packed_int32 = 90 [packed = true]; |
| 566 repeated int64 packed_int64 = 91 [packed = true]; | 703 repeated int64 packed_int64 = 91 [packed = true]; |
| 567 repeated uint32 packed_uint32 = 92 [packed = true]; | 704 repeated uint32 packed_uint32 = 92 [packed = true]; |
| 568 repeated uint64 packed_uint64 = 93 [packed = true]; | 705 repeated uint64 packed_uint64 = 93 [packed = true]; |
| 569 repeated sint32 packed_sint32 = 94 [packed = true]; | 706 repeated sint32 packed_sint32 = 94 [packed = true]; |
| 570 repeated sint64 packed_sint64 = 95 [packed = true]; | 707 repeated sint64 packed_sint64 = 95 [packed = true]; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 repeated fixed32 packed_fixed32_extension = 96 [packed = true]; | 748 repeated fixed32 packed_fixed32_extension = 96 [packed = true]; |
| 612 repeated fixed64 packed_fixed64_extension = 97 [packed = true]; | 749 repeated fixed64 packed_fixed64_extension = 97 [packed = true]; |
| 613 repeated sfixed32 packed_sfixed32_extension = 98 [packed = true]; | 750 repeated sfixed32 packed_sfixed32_extension = 98 [packed = true]; |
| 614 repeated sfixed64 packed_sfixed64_extension = 99 [packed = true]; | 751 repeated sfixed64 packed_sfixed64_extension = 99 [packed = true]; |
| 615 repeated float packed_float_extension = 100 [packed = true]; | 752 repeated float packed_float_extension = 100 [packed = true]; |
| 616 repeated double packed_double_extension = 101 [packed = true]; | 753 repeated double packed_double_extension = 101 [packed = true]; |
| 617 repeated bool packed_bool_extension = 102 [packed = true]; | 754 repeated bool packed_bool_extension = 102 [packed = true]; |
| 618 repeated ForeignEnum packed_enum_extension = 103 [packed = true]; | 755 repeated ForeignEnum packed_enum_extension = 103 [packed = true]; |
| 619 } | 756 } |
| 620 | 757 |
| 758 message TestUnpackedExtensions { |
| 759 extensions 1 to max; |
| 760 } |
| 761 |
| 762 extend TestUnpackedExtensions { |
| 763 repeated int32 unpacked_int32_extension = 90 [packed = false]; |
| 764 repeated int64 unpacked_int64_extension = 91 [packed = false]; |
| 765 repeated uint32 unpacked_uint32_extension = 92 [packed = false]; |
| 766 repeated uint64 unpacked_uint64_extension = 93 [packed = false]; |
| 767 repeated sint32 unpacked_sint32_extension = 94 [packed = false]; |
| 768 repeated sint64 unpacked_sint64_extension = 95 [packed = false]; |
| 769 repeated fixed32 unpacked_fixed32_extension = 96 [packed = false]; |
| 770 repeated fixed64 unpacked_fixed64_extension = 97 [packed = false]; |
| 771 repeated sfixed32 unpacked_sfixed32_extension = 98 [packed = false]; |
| 772 repeated sfixed64 unpacked_sfixed64_extension = 99 [packed = false]; |
| 773 repeated float unpacked_float_extension = 100 [packed = false]; |
| 774 repeated double unpacked_double_extension = 101 [packed = false]; |
| 775 repeated bool unpacked_bool_extension = 102 [packed = false]; |
| 776 repeated ForeignEnum unpacked_enum_extension = 103 [packed = false]; |
| 777 } |
| 778 |
| 621 // Used by ExtensionSetTest/DynamicExtensions. The test actually builds | 779 // Used by ExtensionSetTest/DynamicExtensions. The test actually builds |
| 622 // a set of extensions to TestAllExtensions dynamically, based on the fields | 780 // a set of extensions to TestAllExtensions dynamically, based on the fields |
| 623 // of this message type. | 781 // of this message type. |
| 624 message TestDynamicExtensions { | 782 message TestDynamicExtensions { |
| 625 enum DynamicEnumType { | 783 enum DynamicEnumType { |
| 626 DYNAMIC_FOO = 2200; | 784 DYNAMIC_FOO = 2200; |
| 627 DYNAMIC_BAR = 2201; | 785 DYNAMIC_BAR = 2201; |
| 628 DYNAMIC_BAZ = 2202; | 786 DYNAMIC_BAZ = 2202; |
| 629 } | 787 } |
| 630 message DynamicMessageType { | 788 message DynamicMessageType { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 message FooServerMessage{} | 868 message FooServerMessage{} |
| 711 | 869 |
| 712 service TestService { | 870 service TestService { |
| 713 rpc Foo(FooRequest) returns (FooResponse); | 871 rpc Foo(FooRequest) returns (FooResponse); |
| 714 rpc Bar(BarRequest) returns (BarResponse); | 872 rpc Bar(BarRequest) returns (BarResponse); |
| 715 } | 873 } |
| 716 | 874 |
| 717 | 875 |
| 718 message BarRequest {} | 876 message BarRequest {} |
| 719 message BarResponse {} | 877 message BarResponse {} |
| 878 |
| OLD | NEW |