test_messages_proto3.proto 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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. // Test schema for proto3 messages. This test schema is used by:
  9. //
  10. // - benchmarks
  11. // - fuzz tests
  12. // - conformance tests
  13. //
  14. syntax = "proto3";
  15. package protobuf_test_messages.proto3;
  16. option java_package = "com.google.protobuf_test_messages.proto3";
  17. option objc_class_prefix = "Proto3";
  18. // This is the default, but we specify it here explicitly.
  19. option optimize_for = SPEED;
  20. import "google/protobuf/any.proto";
  21. import "google/protobuf/duration.proto";
  22. import "google/protobuf/field_mask.proto";
  23. import "google/protobuf/struct.proto";
  24. import "google/protobuf/timestamp.proto";
  25. import "google/protobuf/wrappers.proto";
  26. option cc_enable_arenas = true;
  27. // This proto includes every type of field in both singular and repeated
  28. // forms.
  29. //
  30. // Also, crucially, all messages and enums in this file are eventually
  31. // submessages of this message. So for example, a fuzz test of TestAllTypes
  32. // could trigger bugs that occur in any message type in this file. We verify
  33. // this stays true in a unit test.
  34. message TestAllTypesProto3 {
  35. message NestedMessage {
  36. int32 a = 1;
  37. TestAllTypesProto3 corecursive = 2;
  38. }
  39. enum NestedEnum {
  40. FOO = 0;
  41. BAR = 1;
  42. BAZ = 2;
  43. NEG = -1; // Intentionally negative.
  44. }
  45. enum AliasedEnum {
  46. option allow_alias = true;
  47. ALIAS_FOO = 0;
  48. ALIAS_BAR = 1;
  49. ALIAS_BAZ = 2;
  50. MOO = 2;
  51. moo = 2;
  52. bAz = 2;
  53. }
  54. // Singular
  55. int32 optional_int32 = 1;
  56. int64 optional_int64 = 2;
  57. uint32 optional_uint32 = 3;
  58. uint64 optional_uint64 = 4;
  59. sint32 optional_sint32 = 5;
  60. sint64 optional_sint64 = 6;
  61. fixed32 optional_fixed32 = 7;
  62. fixed64 optional_fixed64 = 8;
  63. sfixed32 optional_sfixed32 = 9;
  64. sfixed64 optional_sfixed64 = 10;
  65. float optional_float = 11;
  66. double optional_double = 12;
  67. bool optional_bool = 13;
  68. string optional_string = 14;
  69. bytes optional_bytes = 15;
  70. NestedMessage optional_nested_message = 18;
  71. ForeignMessage optional_foreign_message = 19;
  72. NestedEnum optional_nested_enum = 21;
  73. ForeignEnum optional_foreign_enum = 22;
  74. AliasedEnum optional_aliased_enum = 23;
  75. string optional_string_piece = 24 [ctype = STRING_PIECE];
  76. string optional_cord = 25 [ctype = CORD];
  77. TestAllTypesProto3 recursive_message = 27;
  78. // Repeated
  79. repeated int32 repeated_int32 = 31;
  80. repeated int64 repeated_int64 = 32;
  81. repeated uint32 repeated_uint32 = 33;
  82. repeated uint64 repeated_uint64 = 34;
  83. repeated sint32 repeated_sint32 = 35;
  84. repeated sint64 repeated_sint64 = 36;
  85. repeated fixed32 repeated_fixed32 = 37;
  86. repeated fixed64 repeated_fixed64 = 38;
  87. repeated sfixed32 repeated_sfixed32 = 39;
  88. repeated sfixed64 repeated_sfixed64 = 40;
  89. repeated float repeated_float = 41;
  90. repeated double repeated_double = 42;
  91. repeated bool repeated_bool = 43;
  92. repeated string repeated_string = 44;
  93. repeated bytes repeated_bytes = 45;
  94. repeated NestedMessage repeated_nested_message = 48;
  95. repeated ForeignMessage repeated_foreign_message = 49;
  96. repeated NestedEnum repeated_nested_enum = 51;
  97. repeated ForeignEnum repeated_foreign_enum = 52;
  98. repeated string repeated_string_piece = 54 [ctype = STRING_PIECE];
  99. repeated string repeated_cord = 55 [ctype = CORD];
  100. // Packed
  101. repeated int32 packed_int32 = 75 [packed = true];
  102. repeated int64 packed_int64 = 76 [packed = true];
  103. repeated uint32 packed_uint32 = 77 [packed = true];
  104. repeated uint64 packed_uint64 = 78 [packed = true];
  105. repeated sint32 packed_sint32 = 79 [packed = true];
  106. repeated sint64 packed_sint64 = 80 [packed = true];
  107. repeated fixed32 packed_fixed32 = 81 [packed = true];
  108. repeated fixed64 packed_fixed64 = 82 [packed = true];
  109. repeated sfixed32 packed_sfixed32 = 83 [packed = true];
  110. repeated sfixed64 packed_sfixed64 = 84 [packed = true];
  111. repeated float packed_float = 85 [packed = true];
  112. repeated double packed_double = 86 [packed = true];
  113. repeated bool packed_bool = 87 [packed = true];
  114. repeated NestedEnum packed_nested_enum = 88 [packed = true];
  115. // Unpacked
  116. repeated int32 unpacked_int32 = 89 [packed = false];
  117. repeated int64 unpacked_int64 = 90 [packed = false];
  118. repeated uint32 unpacked_uint32 = 91 [packed = false];
  119. repeated uint64 unpacked_uint64 = 92 [packed = false];
  120. repeated sint32 unpacked_sint32 = 93 [packed = false];
  121. repeated sint64 unpacked_sint64 = 94 [packed = false];
  122. repeated fixed32 unpacked_fixed32 = 95 [packed = false];
  123. repeated fixed64 unpacked_fixed64 = 96 [packed = false];
  124. repeated sfixed32 unpacked_sfixed32 = 97 [packed = false];
  125. repeated sfixed64 unpacked_sfixed64 = 98 [packed = false];
  126. repeated float unpacked_float = 99 [packed = false];
  127. repeated double unpacked_double = 100 [packed = false];
  128. repeated bool unpacked_bool = 101 [packed = false];
  129. repeated NestedEnum unpacked_nested_enum = 102 [packed = false];
  130. // Map
  131. map<int32, int32> map_int32_int32 = 56;
  132. map<int64, int64> map_int64_int64 = 57;
  133. map<uint32, uint32> map_uint32_uint32 = 58;
  134. map<uint64, uint64> map_uint64_uint64 = 59;
  135. map<sint32, sint32> map_sint32_sint32 = 60;
  136. map<sint64, sint64> map_sint64_sint64 = 61;
  137. map<fixed32, fixed32> map_fixed32_fixed32 = 62;
  138. map<fixed64, fixed64> map_fixed64_fixed64 = 63;
  139. map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 64;
  140. map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 65;
  141. map<int32, float> map_int32_float = 66;
  142. map<int32, double> map_int32_double = 67;
  143. map<bool, bool> map_bool_bool = 68;
  144. map<string, string> map_string_string = 69;
  145. map<string, bytes> map_string_bytes = 70;
  146. map<string, NestedMessage> map_string_nested_message = 71;
  147. map<string, ForeignMessage> map_string_foreign_message = 72;
  148. map<string, NestedEnum> map_string_nested_enum = 73;
  149. map<string, ForeignEnum> map_string_foreign_enum = 74;
  150. oneof oneof_field {
  151. uint32 oneof_uint32 = 111;
  152. NestedMessage oneof_nested_message = 112;
  153. string oneof_string = 113;
  154. bytes oneof_bytes = 114;
  155. bool oneof_bool = 115;
  156. uint64 oneof_uint64 = 116;
  157. float oneof_float = 117;
  158. double oneof_double = 118;
  159. NestedEnum oneof_enum = 119;
  160. google.protobuf.NullValue oneof_null_value = 120;
  161. }
  162. // Well-known types
  163. google.protobuf.BoolValue optional_bool_wrapper = 201;
  164. google.protobuf.Int32Value optional_int32_wrapper = 202;
  165. google.protobuf.Int64Value optional_int64_wrapper = 203;
  166. google.protobuf.UInt32Value optional_uint32_wrapper = 204;
  167. google.protobuf.UInt64Value optional_uint64_wrapper = 205;
  168. google.protobuf.FloatValue optional_float_wrapper = 206;
  169. google.protobuf.DoubleValue optional_double_wrapper = 207;
  170. google.protobuf.StringValue optional_string_wrapper = 208;
  171. google.protobuf.BytesValue optional_bytes_wrapper = 209;
  172. repeated google.protobuf.BoolValue repeated_bool_wrapper = 211;
  173. repeated google.protobuf.Int32Value repeated_int32_wrapper = 212;
  174. repeated google.protobuf.Int64Value repeated_int64_wrapper = 213;
  175. repeated google.protobuf.UInt32Value repeated_uint32_wrapper = 214;
  176. repeated google.protobuf.UInt64Value repeated_uint64_wrapper = 215;
  177. repeated google.protobuf.FloatValue repeated_float_wrapper = 216;
  178. repeated google.protobuf.DoubleValue repeated_double_wrapper = 217;
  179. repeated google.protobuf.StringValue repeated_string_wrapper = 218;
  180. repeated google.protobuf.BytesValue repeated_bytes_wrapper = 219;
  181. google.protobuf.Duration optional_duration = 301;
  182. google.protobuf.Timestamp optional_timestamp = 302;
  183. google.protobuf.FieldMask optional_field_mask = 303;
  184. google.protobuf.Struct optional_struct = 304;
  185. google.protobuf.Any optional_any = 305;
  186. google.protobuf.Value optional_value = 306;
  187. google.protobuf.NullValue optional_null_value = 307;
  188. repeated google.protobuf.Duration repeated_duration = 311;
  189. repeated google.protobuf.Timestamp repeated_timestamp = 312;
  190. repeated google.protobuf.FieldMask repeated_fieldmask = 313;
  191. repeated google.protobuf.Struct repeated_struct = 324;
  192. repeated google.protobuf.Any repeated_any = 315;
  193. repeated google.protobuf.Value repeated_value = 316;
  194. repeated google.protobuf.ListValue repeated_list_value = 317;
  195. // Test field-name-to-JSON-name convention.
  196. // (protobuf says names can be any valid C/C++ identifier.)
  197. int32 fieldname1 = 401;
  198. int32 field_name2 = 402;
  199. int32 _field_name3 = 403;
  200. int32 field__name4_ = 404;
  201. int32 field0name5 = 405;
  202. int32 field_0_name6 = 406;
  203. int32 fieldName7 = 407;
  204. int32 FieldName8 = 408;
  205. int32 field_Name9 = 409;
  206. int32 Field_Name10 = 410;
  207. int32 FIELD_NAME11 = 411;
  208. int32 FIELD_name12 = 412;
  209. int32 __field_name13 = 413;
  210. int32 __Field_name14 = 414;
  211. int32 field__name15 = 415;
  212. int32 field__Name16 = 416;
  213. int32 field_name17__ = 417;
  214. int32 Field_name18__ = 418;
  215. // Reserved for testing unknown fields
  216. reserved 501 to 510;
  217. }
  218. message ForeignMessage {
  219. int32 c = 1;
  220. }
  221. enum ForeignEnum {
  222. FOREIGN_FOO = 0;
  223. FOREIGN_BAR = 1;
  224. FOREIGN_BAZ = 2;
  225. }
  226. message NullHypothesisProto3 {}
  227. message EnumOnlyProto3 {
  228. enum Bool {
  229. kFalse = 0;
  230. kTrue = 1;
  231. }
  232. }