unittest_proto3_arena_lite.proto 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. syntax = "proto3";
  31. option cc_enable_arenas = true;
  32. option optimize_for = LITE_RUNTIME;
  33. import "google/protobuf/unittest_import.proto";
  34. package proto3_arena_lite_unittest;
  35. // This proto includes every type of field in both singular and repeated
  36. // forms.
  37. message TestAllTypes {
  38. message NestedMessage {
  39. // The field name "b" fails to compile in proto1 because it conflicts with
  40. // a local variable named "b" in one of the generated methods. Doh.
  41. // This file needs to compile in proto1 to test backwards-compatibility.
  42. int32 bb = 1;
  43. }
  44. enum NestedEnum {
  45. ZERO = 0;
  46. FOO = 1;
  47. BAR = 2;
  48. BAZ = 3;
  49. NEG = -1; // Intentionally negative.
  50. }
  51. // Singular
  52. int32 optional_int32 = 1;
  53. int64 optional_int64 = 2;
  54. uint32 optional_uint32 = 3;
  55. uint64 optional_uint64 = 4;
  56. sint32 optional_sint32 = 5;
  57. sint64 optional_sint64 = 6;
  58. fixed32 optional_fixed32 = 7;
  59. fixed64 optional_fixed64 = 8;
  60. sfixed32 optional_sfixed32 = 9;
  61. sfixed64 optional_sfixed64 = 10;
  62. float optional_float = 11;
  63. double optional_double = 12;
  64. bool optional_bool = 13;
  65. string optional_string = 14;
  66. bytes optional_bytes = 15;
  67. // Groups are not allowed in proto3.
  68. // optional group OptionalGroup = 16 {
  69. // optional int32 a = 17;
  70. // }
  71. NestedMessage optional_nested_message = 18;
  72. ForeignMessage optional_foreign_message = 19;
  73. protobuf_unittest_import.ImportMessage optional_import_message = 20;
  74. NestedEnum optional_nested_enum = 21;
  75. ForeignEnum optional_foreign_enum = 22;
  76. // Omitted (compared to unittest.proto) because proto2 enums are not allowed
  77. // inside proto2 messages.
  78. //
  79. // optional protobuf_unittest_import.ImportEnum optional_import_enum = 23;
  80. string optional_string_piece = 24 [ctype=STRING_PIECE];
  81. string optional_cord = 25 [ctype=CORD];
  82. // Defined in unittest_import_public.proto
  83. protobuf_unittest_import.PublicImportMessage
  84. optional_public_import_message = 26;
  85. NestedMessage optional_lazy_message = 27 [lazy=true];
  86. // Repeated
  87. repeated int32 repeated_int32 = 31;
  88. repeated int64 repeated_int64 = 32;
  89. repeated uint32 repeated_uint32 = 33;
  90. repeated uint64 repeated_uint64 = 34;
  91. repeated sint32 repeated_sint32 = 35;
  92. repeated sint64 repeated_sint64 = 36;
  93. repeated fixed32 repeated_fixed32 = 37;
  94. repeated fixed64 repeated_fixed64 = 38;
  95. repeated sfixed32 repeated_sfixed32 = 39;
  96. repeated sfixed64 repeated_sfixed64 = 40;
  97. repeated float repeated_float = 41;
  98. repeated double repeated_double = 42;
  99. repeated bool repeated_bool = 43;
  100. repeated string repeated_string = 44;
  101. repeated bytes repeated_bytes = 45;
  102. // Groups are not allowed in proto3.
  103. // repeated group RepeatedGroup = 46 {
  104. // optional int32 a = 47;
  105. // }
  106. repeated NestedMessage repeated_nested_message = 48;
  107. repeated ForeignMessage repeated_foreign_message = 49;
  108. repeated protobuf_unittest_import.ImportMessage repeated_import_message = 50;
  109. repeated NestedEnum repeated_nested_enum = 51;
  110. repeated ForeignEnum repeated_foreign_enum = 52;
  111. // Omitted (compared to unittest.proto) because proto2 enums are not allowed
  112. // inside proto2 messages.
  113. //
  114. // repeated protobuf_unittest_import.ImportEnum repeated_import_enum = 53;
  115. repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
  116. repeated string repeated_cord = 55 [ctype=CORD];
  117. repeated NestedMessage repeated_lazy_message = 57 [lazy=true];
  118. oneof oneof_field {
  119. uint32 oneof_uint32 = 111;
  120. NestedMessage oneof_nested_message = 112;
  121. string oneof_string = 113;
  122. bytes oneof_bytes = 114;
  123. }
  124. }
  125. // Test messages for packed fields
  126. message TestPackedTypes {
  127. repeated int32 packed_int32 = 90 [packed = true];
  128. repeated int64 packed_int64 = 91 [packed = true];
  129. repeated uint32 packed_uint32 = 92 [packed = true];
  130. repeated uint64 packed_uint64 = 93 [packed = true];
  131. repeated sint32 packed_sint32 = 94 [packed = true];
  132. repeated sint64 packed_sint64 = 95 [packed = true];
  133. repeated fixed32 packed_fixed32 = 96 [packed = true];
  134. repeated fixed64 packed_fixed64 = 97 [packed = true];
  135. repeated sfixed32 packed_sfixed32 = 98 [packed = true];
  136. repeated sfixed64 packed_sfixed64 = 99 [packed = true];
  137. repeated float packed_float = 100 [packed = true];
  138. repeated double packed_double = 101 [packed = true];
  139. repeated bool packed_bool = 102 [packed = true];
  140. repeated ForeignEnum packed_enum = 103 [packed = true];
  141. }
  142. // Explicitly set packed to false
  143. message TestUnpackedTypes {
  144. repeated int32 repeated_int32 = 1 [packed = false];
  145. repeated int64 repeated_int64 = 2 [packed = false];
  146. repeated uint32 repeated_uint32 = 3 [packed = false];
  147. repeated uint64 repeated_uint64 = 4 [packed = false];
  148. repeated sint32 repeated_sint32 = 5 [packed = false];
  149. repeated sint64 repeated_sint64 = 6 [packed = false];
  150. repeated fixed32 repeated_fixed32 = 7 [packed = false];
  151. repeated fixed64 repeated_fixed64 = 8 [packed = false];
  152. repeated sfixed32 repeated_sfixed32 = 9 [packed = false];
  153. repeated sfixed64 repeated_sfixed64 = 10 [packed = false];
  154. repeated float repeated_float = 11 [packed = false];
  155. repeated double repeated_double = 12 [packed = false];
  156. repeated bool repeated_bool = 13 [packed = false];
  157. repeated TestAllTypes.NestedEnum repeated_nested_enum = 14 [packed = false];
  158. }
  159. // This proto includes a recusively nested message.
  160. message NestedTestAllTypes {
  161. NestedTestAllTypes child = 1;
  162. TestAllTypes payload = 2;
  163. }
  164. // Define these after TestAllTypes to make sure the compiler can handle
  165. // that.
  166. message ForeignMessage {
  167. int32 c = 1;
  168. }
  169. enum ForeignEnum {
  170. FOREIGN_ZERO = 0;
  171. FOREIGN_FOO = 4;
  172. FOREIGN_BAR = 5;
  173. FOREIGN_BAZ = 6;
  174. }
  175. // TestEmptyMessage is used to test behavior of unknown fields.
  176. message TestEmptyMessage {
  177. }