test_messages_proto2.proto 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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 proto2 messages. This test schema is used by:
  32. //
  33. // - conformance tests
  34. //
  35. syntax = "proto2";
  36. package protobuf_test_messages.proto2;
  37. option java_package = "com.google.protobuf_test_messages.proto2";
  38. // This is the default, but we specify it here explicitly.
  39. option optimize_for = SPEED;
  40. option cc_enable_arenas = true;
  41. // This proto includes every type of field in both singular and repeated
  42. // forms.
  43. //
  44. // Also, crucially, all messages and enums in this file are eventually
  45. // submessages of this message. So for example, a fuzz test of TestAllTypes
  46. // could trigger bugs that occur in any message type in this file. We verify
  47. // this stays true in a unit test.
  48. message TestAllTypesProto2 {
  49. message NestedMessage {
  50. optional int32 a = 1;
  51. optional TestAllTypesProto2 corecursive = 2;
  52. }
  53. enum NestedEnum {
  54. FOO = 0;
  55. BAR = 1;
  56. BAZ = 2;
  57. NEG = -1; // Intentionally negative.
  58. }
  59. // Singular
  60. optional int32 optional_int32 = 1;
  61. optional int64 optional_int64 = 2;
  62. optional uint32 optional_uint32 = 3;
  63. optional uint64 optional_uint64 = 4;
  64. optional sint32 optional_sint32 = 5;
  65. optional sint64 optional_sint64 = 6;
  66. optional fixed32 optional_fixed32 = 7;
  67. optional fixed64 optional_fixed64 = 8;
  68. optional sfixed32 optional_sfixed32 = 9;
  69. optional sfixed64 optional_sfixed64 = 10;
  70. optional float optional_float = 11;
  71. optional double optional_double = 12;
  72. optional bool optional_bool = 13;
  73. optional string optional_string = 14;
  74. optional bytes optional_bytes = 15;
  75. optional NestedMessage optional_nested_message = 18;
  76. optional ForeignMessageProto2 optional_foreign_message = 19;
  77. optional NestedEnum optional_nested_enum = 21;
  78. optional ForeignEnumProto2 optional_foreign_enum = 22;
  79. optional string optional_string_piece = 24 [ctype=STRING_PIECE];
  80. optional string optional_cord = 25 [ctype=CORD];
  81. optional TestAllTypesProto2 recursive_message = 27;
  82. // Repeated
  83. repeated int32 repeated_int32 = 31;
  84. repeated int64 repeated_int64 = 32;
  85. repeated uint32 repeated_uint32 = 33;
  86. repeated uint64 repeated_uint64 = 34;
  87. repeated sint32 repeated_sint32 = 35;
  88. repeated sint64 repeated_sint64 = 36;
  89. repeated fixed32 repeated_fixed32 = 37;
  90. repeated fixed64 repeated_fixed64 = 38;
  91. repeated sfixed32 repeated_sfixed32 = 39;
  92. repeated sfixed64 repeated_sfixed64 = 40;
  93. repeated float repeated_float = 41;
  94. repeated double repeated_double = 42;
  95. repeated bool repeated_bool = 43;
  96. repeated string repeated_string = 44;
  97. repeated bytes repeated_bytes = 45;
  98. repeated NestedMessage repeated_nested_message = 48;
  99. repeated ForeignMessageProto2 repeated_foreign_message = 49;
  100. repeated NestedEnum repeated_nested_enum = 51;
  101. repeated ForeignEnumProto2 repeated_foreign_enum = 52;
  102. repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
  103. repeated string repeated_cord = 55 [ctype=CORD];
  104. // Map
  105. map < int32, int32> map_int32_int32 = 56;
  106. map < int64, int64> map_int64_int64 = 57;
  107. map < uint32, uint32> map_uint32_uint32 = 58;
  108. map < uint64, uint64> map_uint64_uint64 = 59;
  109. map < sint32, sint32> map_sint32_sint32 = 60;
  110. map < sint64, sint64> map_sint64_sint64 = 61;
  111. map < fixed32, fixed32> map_fixed32_fixed32 = 62;
  112. map < fixed64, fixed64> map_fixed64_fixed64 = 63;
  113. map <sfixed32, sfixed32> map_sfixed32_sfixed32 = 64;
  114. map <sfixed64, sfixed64> map_sfixed64_sfixed64 = 65;
  115. map < int32, float> map_int32_float = 66;
  116. map < int32, double> map_int32_double = 67;
  117. map < bool, bool> map_bool_bool = 68;
  118. map < string, string> map_string_string = 69;
  119. map < string, bytes> map_string_bytes = 70;
  120. map < string, NestedMessage> map_string_nested_message = 71;
  121. map < string, ForeignMessageProto2> map_string_foreign_message = 72;
  122. map < string, NestedEnum> map_string_nested_enum = 73;
  123. map < string, ForeignEnumProto2> map_string_foreign_enum = 74;
  124. oneof oneof_field {
  125. uint32 oneof_uint32 = 111;
  126. NestedMessage oneof_nested_message = 112;
  127. string oneof_string = 113;
  128. bytes oneof_bytes = 114;
  129. bool oneof_bool = 115;
  130. uint64 oneof_uint64 = 116;
  131. float oneof_float = 117;
  132. double oneof_double = 118;
  133. NestedEnum oneof_enum = 119;
  134. }
  135. // extensions
  136. extensions 120 to 200;
  137. // groups
  138. optional group Data = 201 {
  139. optional int32 group_int32 = 202;
  140. optional uint32 group_uint32 = 203;
  141. };
  142. // Test field-name-to-JSON-name convention.
  143. // (protobuf says names can be any valid C/C++ identifier.)
  144. optional int32 fieldname1 = 401;
  145. optional int32 field_name2 = 402;
  146. optional int32 _field_name3 = 403;
  147. optional int32 field__name4_ = 404;
  148. optional int32 field0name5 = 405;
  149. optional int32 field_0_name6 = 406;
  150. optional int32 fieldName7 = 407;
  151. optional int32 FieldName8 = 408;
  152. optional int32 field_Name9 = 409;
  153. optional int32 Field_Name10 = 410;
  154. optional int32 FIELD_NAME11 = 411;
  155. optional int32 FIELD_name12 = 412;
  156. optional int32 __field_name13 = 413;
  157. optional int32 __Field_name14 = 414;
  158. optional int32 field__name15 = 415;
  159. optional int32 field__Name16 = 416;
  160. optional int32 field_name17__ = 417;
  161. optional int32 Field_name18__ = 418;
  162. // message_set test case.
  163. message MessageSetCorrect {
  164. option message_set_wire_format = true;
  165. extensions 4 to max;
  166. }
  167. message MessageSetCorrectExtension1 {
  168. extend MessageSetCorrect {
  169. optional MessageSetCorrectExtension1 message_set_extension = 1547769;
  170. }
  171. optional string str = 25;
  172. }
  173. message MessageSetCorrectExtension2 {
  174. extend MessageSetCorrect {
  175. optional MessageSetCorrectExtension2 message_set_extension = 4135312;
  176. }
  177. optional int32 i = 9;
  178. }
  179. }
  180. message ForeignMessageProto2 {
  181. optional int32 c = 1;
  182. }
  183. enum ForeignEnumProto2 {
  184. FOREIGN_FOO = 0;
  185. FOREIGN_BAR = 1;
  186. FOREIGN_BAZ = 2;
  187. }
  188. extend TestAllTypesProto2 {
  189. optional int32 extension_int32 = 120;
  190. }