test_messages_proto3.proto 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 Google Inc. All rights reserved.
  3. // https://developers.google.com/protocol-buffers/
  4. //
  5. // Redistribution and use in source and binary forms, with or without
  6. // modification, are permitted provided that the following conditions are
  7. // met:
  8. //
  9. // * Redistributions of source code must retain the above copyright
  10. // notice, this list of conditions and the following disclaimer.
  11. // * Redistributions in binary form must reproduce the above
  12. // copyright notice, this list of conditions and the following disclaimer
  13. // in the documentation and/or other materials provided with the
  14. // distribution.
  15. // * Neither the name of Google Inc. nor the names of its
  16. // contributors may be used to endorse or promote products derived from
  17. // this software without specific prior written permission.
  18. //
  19. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. //
  31. // Test schema for proto3 messages. This test schema is used by:
  32. //
  33. // - benchmarks
  34. // - fuzz tests
  35. // - conformance tests
  36. //
  37. syntax = "proto3";
  38. package protobuf_test_messages.proto3;
  39. option java_package = "com.google.protobuf_test_messages.proto3";
  40. option objc_class_prefix = "Proto3";
  41. // This is the default, but we specify it here explicitly.
  42. option optimize_for = SPEED;
  43. import "google/protobuf/any.proto";
  44. import "google/protobuf/duration.proto";
  45. import "google/protobuf/field_mask.proto";
  46. import "google/protobuf/struct.proto";
  47. import "google/protobuf/timestamp.proto";
  48. import "google/protobuf/wrappers.proto";
  49. option cc_enable_arenas = true;
  50. // This proto includes every type of field in both singular and repeated
  51. // forms.
  52. //
  53. // Also, crucially, all messages and enums in this file are eventually
  54. // submessages of this message. So for example, a fuzz test of TestAllTypes
  55. // could trigger bugs that occur in any message type in this file. We verify
  56. // this stays true in a unit test.
  57. message TestAllTypesProto3 {
  58. message NestedMessage {
  59. int32 a = 1;
  60. TestAllTypesProto3 corecursive = 2;
  61. }
  62. enum NestedEnum {
  63. FOO = 0;
  64. BAR = 1;
  65. BAZ = 2;
  66. NEG = -1; // Intentionally negative.
  67. }
  68. // Singular
  69. int32 optional_int32 = 1;
  70. int64 optional_int64 = 2;
  71. uint32 optional_uint32 = 3;
  72. uint64 optional_uint64 = 4;
  73. sint32 optional_sint32 = 5;
  74. sint64 optional_sint64 = 6;
  75. fixed32 optional_fixed32 = 7;
  76. fixed64 optional_fixed64 = 8;
  77. sfixed32 optional_sfixed32 = 9;
  78. sfixed64 optional_sfixed64 = 10;
  79. float optional_float = 11;
  80. double optional_double = 12;
  81. bool optional_bool = 13;
  82. string optional_string = 14;
  83. bytes optional_bytes = 15;
  84. NestedMessage optional_nested_message = 18;
  85. ForeignMessage optional_foreign_message = 19;
  86. NestedEnum optional_nested_enum = 21;
  87. ForeignEnum optional_foreign_enum = 22;
  88. string optional_string_piece = 24 [ctype=STRING_PIECE];
  89. string optional_cord = 25 [ctype=CORD];
  90. TestAllTypesProto3 recursive_message = 27;
  91. // Repeated
  92. repeated int32 repeated_int32 = 31;
  93. repeated int64 repeated_int64 = 32;
  94. repeated uint32 repeated_uint32 = 33;
  95. repeated uint64 repeated_uint64 = 34;
  96. repeated sint32 repeated_sint32 = 35;
  97. repeated sint64 repeated_sint64 = 36;
  98. repeated fixed32 repeated_fixed32 = 37;
  99. repeated fixed64 repeated_fixed64 = 38;
  100. repeated sfixed32 repeated_sfixed32 = 39;
  101. repeated sfixed64 repeated_sfixed64 = 40;
  102. repeated float repeated_float = 41;
  103. repeated double repeated_double = 42;
  104. repeated bool repeated_bool = 43;
  105. repeated string repeated_string = 44;
  106. repeated bytes repeated_bytes = 45;
  107. repeated NestedMessage repeated_nested_message = 48;
  108. repeated ForeignMessage repeated_foreign_message = 49;
  109. repeated NestedEnum repeated_nested_enum = 51;
  110. repeated ForeignEnum repeated_foreign_enum = 52;
  111. repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
  112. repeated string repeated_cord = 55 [ctype=CORD];
  113. // Map
  114. map < int32, int32> map_int32_int32 = 56;
  115. map < int64, int64> map_int64_int64 = 57;
  116. map < uint32, uint32> map_uint32_uint32 = 58;
  117. map < uint64, uint64> map_uint64_uint64 = 59;
  118. map < sint32, sint32> map_sint32_sint32 = 60;
  119. map < sint64, sint64> map_sint64_sint64 = 61;
  120. map < fixed32, fixed32> map_fixed32_fixed32 = 62;
  121. map < fixed64, fixed64> map_fixed64_fixed64 = 63;
  122. map <sfixed32, sfixed32> map_sfixed32_sfixed32 = 64;
  123. map <sfixed64, sfixed64> map_sfixed64_sfixed64 = 65;
  124. map < int32, float> map_int32_float = 66;
  125. map < int32, double> map_int32_double = 67;
  126. map < bool, bool> map_bool_bool = 68;
  127. map < string, string> map_string_string = 69;
  128. map < string, bytes> map_string_bytes = 70;
  129. map < string, NestedMessage> map_string_nested_message = 71;
  130. map < string, ForeignMessage> map_string_foreign_message = 72;
  131. map < string, NestedEnum> map_string_nested_enum = 73;
  132. map < string, ForeignEnum> map_string_foreign_enum = 74;
  133. oneof oneof_field {
  134. uint32 oneof_uint32 = 111;
  135. NestedMessage oneof_nested_message = 112;
  136. string oneof_string = 113;
  137. bytes oneof_bytes = 114;
  138. bool oneof_bool = 115;
  139. uint64 oneof_uint64 = 116;
  140. float oneof_float = 117;
  141. double oneof_double = 118;
  142. NestedEnum oneof_enum = 119;
  143. }
  144. // Well-known types
  145. google.protobuf.BoolValue optional_bool_wrapper = 201;
  146. google.protobuf.Int32Value optional_int32_wrapper = 202;
  147. google.protobuf.Int64Value optional_int64_wrapper = 203;
  148. google.protobuf.UInt32Value optional_uint32_wrapper = 204;
  149. google.protobuf.UInt64Value optional_uint64_wrapper = 205;
  150. google.protobuf.FloatValue optional_float_wrapper = 206;
  151. google.protobuf.DoubleValue optional_double_wrapper = 207;
  152. google.protobuf.StringValue optional_string_wrapper = 208;
  153. google.protobuf.BytesValue optional_bytes_wrapper = 209;
  154. repeated google.protobuf.BoolValue repeated_bool_wrapper = 211;
  155. repeated google.protobuf.Int32Value repeated_int32_wrapper = 212;
  156. repeated google.protobuf.Int64Value repeated_int64_wrapper = 213;
  157. repeated google.protobuf.UInt32Value repeated_uint32_wrapper = 214;
  158. repeated google.protobuf.UInt64Value repeated_uint64_wrapper = 215;
  159. repeated google.protobuf.FloatValue repeated_float_wrapper = 216;
  160. repeated google.protobuf.DoubleValue repeated_double_wrapper = 217;
  161. repeated google.protobuf.StringValue repeated_string_wrapper = 218;
  162. repeated google.protobuf.BytesValue repeated_bytes_wrapper = 219;
  163. google.protobuf.Duration optional_duration = 301;
  164. google.protobuf.Timestamp optional_timestamp = 302;
  165. google.protobuf.FieldMask optional_field_mask = 303;
  166. google.protobuf.Struct optional_struct = 304;
  167. google.protobuf.Any optional_any = 305;
  168. google.protobuf.Value optional_value = 306;
  169. repeated google.protobuf.Duration repeated_duration = 311;
  170. repeated google.protobuf.Timestamp repeated_timestamp = 312;
  171. repeated google.protobuf.FieldMask repeated_fieldmask = 313;
  172. repeated google.protobuf.Struct repeated_struct = 324;
  173. repeated google.protobuf.Any repeated_any = 315;
  174. repeated google.protobuf.Value repeated_value = 316;
  175. // Test field-name-to-JSON-name convention.
  176. // (protobuf says names can be any valid C/C++ identifier.)
  177. int32 fieldname1 = 401;
  178. int32 field_name2 = 402;
  179. int32 _field_name3 = 403;
  180. int32 field__name4_ = 404;
  181. int32 field0name5 = 405;
  182. int32 field_0_name6 = 406;
  183. int32 fieldName7 = 407;
  184. int32 FieldName8 = 408;
  185. int32 field_Name9 = 409;
  186. int32 Field_Name10 = 410;
  187. int32 FIELD_NAME11 = 411;
  188. int32 FIELD_name12 = 412;
  189. int32 __field_name13 = 413;
  190. int32 __Field_name14 = 414;
  191. int32 field__name15 = 415;
  192. int32 field__Name16 = 416;
  193. int32 field_name17__ = 417;
  194. int32 Field_name18__ = 418;
  195. // Reserved for testing unknown fields
  196. reserved 501 to 510;
  197. }
  198. message ForeignMessage {
  199. int32 c = 1;
  200. }
  201. enum ForeignEnum {
  202. FOREIGN_FOO = 0;
  203. FOREIGN_BAR = 1;
  204. FOREIGN_BAZ = 2;
  205. }