conformance.proto 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. package conformance;
  32. option java_package = "com.google.protobuf.conformance";
  33. import "google/protobuf/any.proto";
  34. import "google/protobuf/duration.proto";
  35. import "google/protobuf/field_mask.proto";
  36. import "google/protobuf/struct.proto";
  37. import "google/protobuf/timestamp.proto";
  38. import "google/protobuf/wrappers.proto";
  39. // This defines the conformance testing protocol. This protocol exists between
  40. // the conformance test suite itself and the code being tested. For each test,
  41. // the suite will send a ConformanceRequest message and expect a
  42. // ConformanceResponse message.
  43. //
  44. // You can either run the tests in two different ways:
  45. //
  46. // 1. in-process (using the interface in conformance_test.h).
  47. //
  48. // 2. as a sub-process communicating over a pipe. Information about how to
  49. // do this is in conformance_test_runner.cc.
  50. //
  51. // Pros/cons of the two approaches:
  52. //
  53. // - running as a sub-process is much simpler for languages other than C/C++.
  54. //
  55. // - running as a sub-process may be more tricky in unusual environments like
  56. // iOS apps, where fork/stdin/stdout are not available.
  57. enum WireFormat {
  58. UNSPECIFIED = 0;
  59. PROTOBUF = 1;
  60. JSON = 2;
  61. }
  62. // Represents a single test case's input. The testee should:
  63. //
  64. // 1. parse this proto (which should always succeed)
  65. // 2. parse the protobuf or JSON payload in "payload" (which may fail)
  66. // 3. if the parse succeeded, serialize the message in the requested format.
  67. message ConformanceRequest {
  68. // The payload (whether protobuf of JSON) is always for a TestAllTypes proto
  69. // (see below).
  70. oneof payload {
  71. bytes protobuf_payload = 1;
  72. string json_payload = 2;
  73. }
  74. // Which format should the testee serialize its message to?
  75. WireFormat requested_output_format = 3;
  76. }
  77. // Represents a single test case's output.
  78. message ConformanceResponse {
  79. oneof result {
  80. // This string should be set to indicate parsing failed. The string can
  81. // provide more information about the parse error if it is available.
  82. //
  83. // Setting this string does not necessarily mean the testee failed the
  84. // test. Some of the test cases are intentionally invalid input.
  85. string parse_error = 1;
  86. // If the input was successfully parsed but errors occurred when
  87. // serializing it to the requested output format, set the error message in
  88. // this field.
  89. string serialize_error = 6;
  90. // This should be set if some other error occurred. This will always
  91. // indicate that the test failed. The string can provide more information
  92. // about the failure.
  93. string runtime_error = 2;
  94. // If the input was successfully parsed and the requested output was
  95. // protobuf, serialize it to protobuf and set it in this field.
  96. bytes protobuf_payload = 3;
  97. // If the input was successfully parsed and the requested output was JSON,
  98. // serialize to JSON and set it in this field.
  99. string json_payload = 4;
  100. // For when the testee skipped the test, likely because a certain feature
  101. // wasn't supported, like JSON input/output.
  102. string skipped = 5;
  103. }
  104. }
  105. // This proto includes every type of field in both singular and repeated
  106. // forms.
  107. message TestAllTypes {
  108. message NestedMessage {
  109. int32 a = 1;
  110. TestAllTypes corecursive = 2;
  111. }
  112. enum NestedEnum {
  113. FOO = 0;
  114. BAR = 1;
  115. BAZ = 2;
  116. NEG = -1; // Intentionally negative.
  117. }
  118. // Singular
  119. int32 optional_int32 = 1;
  120. int64 optional_int64 = 2;
  121. uint32 optional_uint32 = 3;
  122. uint64 optional_uint64 = 4;
  123. sint32 optional_sint32 = 5;
  124. sint64 optional_sint64 = 6;
  125. fixed32 optional_fixed32 = 7;
  126. fixed64 optional_fixed64 = 8;
  127. sfixed32 optional_sfixed32 = 9;
  128. sfixed64 optional_sfixed64 = 10;
  129. float optional_float = 11;
  130. double optional_double = 12;
  131. bool optional_bool = 13;
  132. string optional_string = 14;
  133. bytes optional_bytes = 15;
  134. NestedMessage optional_nested_message = 18;
  135. ForeignMessage optional_foreign_message = 19;
  136. NestedEnum optional_nested_enum = 21;
  137. ForeignEnum optional_foreign_enum = 22;
  138. string optional_string_piece = 24 [ctype=STRING_PIECE];
  139. string optional_cord = 25 [ctype=CORD];
  140. TestAllTypes recursive_message = 27;
  141. // Repeated
  142. repeated int32 repeated_int32 = 31;
  143. repeated int64 repeated_int64 = 32;
  144. repeated uint32 repeated_uint32 = 33;
  145. repeated uint64 repeated_uint64 = 34;
  146. repeated sint32 repeated_sint32 = 35;
  147. repeated sint64 repeated_sint64 = 36;
  148. repeated fixed32 repeated_fixed32 = 37;
  149. repeated fixed64 repeated_fixed64 = 38;
  150. repeated sfixed32 repeated_sfixed32 = 39;
  151. repeated sfixed64 repeated_sfixed64 = 40;
  152. repeated float repeated_float = 41;
  153. repeated double repeated_double = 42;
  154. repeated bool repeated_bool = 43;
  155. repeated string repeated_string = 44;
  156. repeated bytes repeated_bytes = 45;
  157. repeated NestedMessage repeated_nested_message = 48;
  158. repeated ForeignMessage repeated_foreign_message = 49;
  159. repeated NestedEnum repeated_nested_enum = 51;
  160. repeated ForeignEnum repeated_foreign_enum = 52;
  161. repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
  162. repeated string repeated_cord = 55 [ctype=CORD];
  163. // Map
  164. map < int32, int32> map_int32_int32 = 56;
  165. map < int64, int64> map_int64_int64 = 57;
  166. map < uint32, uint32> map_uint32_uint32 = 58;
  167. map < uint64, uint64> map_uint64_uint64 = 59;
  168. map < sint32, sint32> map_sint32_sint32 = 60;
  169. map < sint64, sint64> map_sint64_sint64 = 61;
  170. map < fixed32, fixed32> map_fixed32_fixed32 = 62;
  171. map < fixed64, fixed64> map_fixed64_fixed64 = 63;
  172. map <sfixed32, sfixed32> map_sfixed32_sfixed32 = 64;
  173. map <sfixed64, sfixed64> map_sfixed64_sfixed64 = 65;
  174. map < int32, float> map_int32_float = 66;
  175. map < int32, double> map_int32_double = 67;
  176. map < bool, bool> map_bool_bool = 68;
  177. map < string, string> map_string_string = 69;
  178. map < string, bytes> map_string_bytes = 70;
  179. map < string, NestedMessage> map_string_nested_message = 71;
  180. map < string, ForeignMessage> map_string_foreign_message = 72;
  181. map < string, NestedEnum> map_string_nested_enum = 73;
  182. map < string, ForeignEnum> map_string_foreign_enum = 74;
  183. oneof oneof_field {
  184. uint32 oneof_uint32 = 111;
  185. NestedMessage oneof_nested_message = 112;
  186. string oneof_string = 113;
  187. bytes oneof_bytes = 114;
  188. bool oneof_bool = 115;
  189. uint64 oneof_uint64 = 116;
  190. float oneof_float = 117;
  191. double oneof_double = 118;
  192. NestedEnum oneof_enum = 119;
  193. }
  194. // Well-known types
  195. google.protobuf.BoolValue optional_bool_wrapper = 201;
  196. google.protobuf.Int32Value optional_int32_wrapper = 202;
  197. google.protobuf.Int64Value optional_int64_wrapper = 203;
  198. google.protobuf.UInt32Value optional_uint32_wrapper = 204;
  199. google.protobuf.UInt64Value optional_uint64_wrapper = 205;
  200. google.protobuf.FloatValue optional_float_wrapper = 206;
  201. google.protobuf.DoubleValue optional_double_wrapper = 207;
  202. google.protobuf.StringValue optional_string_wrapper = 208;
  203. google.protobuf.BytesValue optional_bytes_wrapper = 209;
  204. repeated google.protobuf.BoolValue repeated_bool_wrapper = 211;
  205. repeated google.protobuf.Int32Value repeated_int32_wrapper = 212;
  206. repeated google.protobuf.Int64Value repeated_int64_wrapper = 213;
  207. repeated google.protobuf.UInt32Value repeated_uint32_wrapper = 214;
  208. repeated google.protobuf.UInt64Value repeated_uint64_wrapper = 215;
  209. repeated google.protobuf.FloatValue repeated_float_wrapper = 216;
  210. repeated google.protobuf.DoubleValue repeated_double_wrapper = 217;
  211. repeated google.protobuf.StringValue repeated_string_wrapper = 218;
  212. repeated google.protobuf.BytesValue repeated_bytes_wrapper = 219;
  213. google.protobuf.Duration optional_duration = 301;
  214. google.protobuf.Timestamp optional_timestamp = 302;
  215. google.protobuf.FieldMask optional_field_mask = 303;
  216. google.protobuf.Struct optional_struct = 304;
  217. google.protobuf.Any optional_any = 305;
  218. google.protobuf.Value optional_value = 306;
  219. repeated google.protobuf.Duration repeated_duration = 311;
  220. repeated google.protobuf.Timestamp repeated_timestamp = 312;
  221. repeated google.protobuf.FieldMask repeated_fieldmask = 313;
  222. repeated google.protobuf.Struct repeated_struct = 324;
  223. repeated google.protobuf.Any repeated_any = 315;
  224. repeated google.protobuf.Value repeated_value = 316;
  225. // Test field-name-to-JSON-name convention.
  226. // (protobuf says names can be any valid C/C++ identifier.)
  227. int32 fieldname1 = 401;
  228. int32 field_name2 = 402;
  229. int32 _field_name3 = 403;
  230. int32 field__name4_ = 404;
  231. int32 field0name5 = 405;
  232. int32 field_0_name6 = 406;
  233. int32 fieldName7 = 407;
  234. int32 FieldName8 = 408;
  235. int32 field_Name9 = 409;
  236. int32 Field_Name10 = 410;
  237. int32 FIELD_NAME11 = 411;
  238. int32 FIELD_name12 = 412;
  239. int32 __field_name13 = 413;
  240. int32 __Field_name14 = 414;
  241. int32 field__name15 = 415;
  242. int32 field__Name16 = 416;
  243. int32 field_name17__ = 417;
  244. int32 Field_name18__ = 418;
  245. }
  246. message ForeignMessage {
  247. int32 c = 1;
  248. }
  249. enum ForeignEnum {
  250. FOREIGN_FOO = 0;
  251. FOREIGN_BAR = 1;
  252. FOREIGN_BAZ = 2;
  253. }