unittest_no_field_presence.proto 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 Google Inc. All rights reserved.
  3. // https://developers.google.com/protocol-buffers/
  4. //
  5. // Redistribution and use in source and binary forms, with or without
  6. // modification, are permitted provided that the following conditions are
  7. // met:
  8. //
  9. // * Redistributions of source code must retain the above copyright
  10. // notice, this list of conditions and the following disclaimer.
  11. // * Redistributions in binary form must reproduce the above
  12. // copyright notice, this list of conditions and the following disclaimer
  13. // in the documentation and/or other materials provided with the
  14. // distribution.
  15. // * Neither the name of Google Inc. nor the names of its
  16. // contributors may be used to endorse or promote products derived from
  17. // this software without specific prior written permission.
  18. //
  19. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. // A proto file used to test a message type with no explicit field presence.
  31. syntax = "proto3";
  32. // We want to test embedded proto2 messages, so include some proto2 types.
  33. import "google/protobuf/unittest.proto";
  34. package proto2_nofieldpresence_unittest;
  35. // This proto includes every type of field in both singular and repeated
  36. // forms.
  37. message TestAllTypes {
  38. message NestedMessage {
  39. int32 bb = 1;
  40. }
  41. enum NestedEnum {
  42. FOO = 0;
  43. BAR = 1;
  44. BAZ = 2;
  45. }
  46. // Singular
  47. // TODO: remove 'optional' labels as soon as CL 69188077 is LGTM'd to make
  48. // 'optional' optional.
  49. int32 optional_int32 = 1;
  50. int64 optional_int64 = 2;
  51. uint32 optional_uint32 = 3;
  52. uint64 optional_uint64 = 4;
  53. sint32 optional_sint32 = 5;
  54. sint64 optional_sint64 = 6;
  55. fixed32 optional_fixed32 = 7;
  56. fixed64 optional_fixed64 = 8;
  57. sfixed32 optional_sfixed32 = 9;
  58. sfixed64 optional_sfixed64 = 10;
  59. float optional_float = 11;
  60. double optional_double = 12;
  61. bool optional_bool = 13;
  62. string optional_string = 14;
  63. bytes optional_bytes = 15;
  64. NestedMessage optional_nested_message = 18;
  65. ForeignMessage optional_foreign_message = 19;
  66. protobuf_unittest.TestAllTypes optional_proto2_message = 20;
  67. NestedEnum optional_nested_enum = 21;
  68. ForeignEnum optional_foreign_enum = 22;
  69. // N.B.: proto2-enum-type fields not allowed, because their default values
  70. // might not be zero.
  71. //optional protobuf_unittest.ForeignEnum optional_proto2_enum = 23;
  72. string optional_string_piece = 24 [ctype=STRING_PIECE];
  73. string optional_cord = 25 [ctype=CORD];
  74. NestedMessage optional_lazy_message = 30 [lazy=true];
  75. // Repeated
  76. repeated int32 repeated_int32 = 31;
  77. repeated int64 repeated_int64 = 32;
  78. repeated uint32 repeated_uint32 = 33;
  79. repeated uint64 repeated_uint64 = 34;
  80. repeated sint32 repeated_sint32 = 35;
  81. repeated sint64 repeated_sint64 = 36;
  82. repeated fixed32 repeated_fixed32 = 37;
  83. repeated fixed64 repeated_fixed64 = 38;
  84. repeated sfixed32 repeated_sfixed32 = 39;
  85. repeated sfixed64 repeated_sfixed64 = 40;
  86. repeated float repeated_float = 41;
  87. repeated double repeated_double = 42;
  88. repeated bool repeated_bool = 43;
  89. repeated string repeated_string = 44;
  90. repeated bytes repeated_bytes = 45;
  91. repeated NestedMessage repeated_nested_message = 48;
  92. repeated ForeignMessage repeated_foreign_message = 49;
  93. repeated protobuf_unittest.TestAllTypes repeated_proto2_message = 50;
  94. repeated NestedEnum repeated_nested_enum = 51;
  95. repeated ForeignEnum repeated_foreign_enum = 52;
  96. repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
  97. repeated string repeated_cord = 55 [ctype=CORD];
  98. repeated NestedMessage repeated_lazy_message = 57 [lazy=true];
  99. oneof oneof_field {
  100. uint32 oneof_uint32 = 111;
  101. NestedMessage oneof_nested_message = 112;
  102. string oneof_string = 113;
  103. NestedEnum oneof_enum = 114;
  104. }
  105. }
  106. message TestProto2Required {
  107. protobuf_unittest.TestRequired proto2 = 1;
  108. }
  109. // Define these after TestAllTypes to make sure the compiler can handle
  110. // that.
  111. message ForeignMessage {
  112. int32 c = 1;
  113. }
  114. enum ForeignEnum {
  115. FOREIGN_FOO = 0;
  116. FOREIGN_BAR = 1;
  117. FOREIGN_BAZ = 2;
  118. }