conformance.proto 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. // This defines the conformance testing protocol. This protocol exists between
  33. // the conformance test suite itself and the code being tested. For each test,
  34. // the suite will send a ConformanceRequest message and expect a
  35. // ConformanceResponse message.
  36. //
  37. // You can either run the tests in two different ways:
  38. //
  39. // 1. in-process (using the interface in conformance_test.h).
  40. //
  41. // 2. as a sub-process communicating over a pipe. Information about how to
  42. // do this is in conformance_test_runner.cc.
  43. //
  44. // Pros/cons of the two approaches:
  45. //
  46. // - running as a sub-process is much simpler for languages other than C/C++.
  47. //
  48. // - running as a sub-process may be more tricky in unusual environments like
  49. // iOS apps, where fork/stdin/stdout are not available.
  50. // Represents a single test case's input. The testee should:
  51. //
  52. // 1. parse this proto (which should always succeed)
  53. // 2. parse the protobuf or JSON payload in "payload" (which may fail)
  54. // 3. if the parse succeeded, serialize the message in the requested format.
  55. message ConformanceRequest {
  56. // The payload (whether protobuf of JSON) is always for a TestAllTypes proto
  57. // (see below).
  58. oneof payload {
  59. bytes protobuf_payload = 1;
  60. string json_payload = 2;
  61. }
  62. enum RequestedOutput {
  63. UNSPECIFIED = 0;
  64. PROTOBUF = 1;
  65. JSON = 2;
  66. }
  67. // Which format should the testee serialize its message to?
  68. optional RequestedOutput requested_output = 3;
  69. }
  70. // Represents a single test case's output.
  71. message ConformanceResponse {
  72. oneof result {
  73. // This string should be set to indicate parsing failed. The string can
  74. // provide more information about the parse error if it is available.
  75. //
  76. // Setting this string does not necessarily mean the testee failed the
  77. // test. Some of the test cases are intentionally invalid input.
  78. string parse_error = 1;
  79. // This should be set if some other error occurred. This will always
  80. // indicate that the test failed. The string can provide more information
  81. // about the failure.
  82. string runtime_error = 2;
  83. // If the input was successfully parsed and the requested output was
  84. // protobuf, serialize it to protobuf and set it in this field.
  85. bytes protobuf_payload = 3;
  86. // If the input was successfully parsed and the requested output was JSON,
  87. // serialize to JSON and set it in this field.
  88. string json_payload = 4;
  89. }
  90. }
  91. // This proto includes every type of field in both singular and repeated
  92. // forms.
  93. message TestAllTypes {
  94. message NestedMessage {
  95. optional int32 a = 1;
  96. optional TestAllTypes corecursive = 2;
  97. }
  98. enum NestedEnum {
  99. FOO = 0;
  100. BAR = 1;
  101. BAZ = 2;
  102. NEG = -1; // Intentionally negative.
  103. }
  104. // Singular
  105. optional int32 optional_int32 = 1;
  106. optional int64 optional_int64 = 2;
  107. optional uint32 optional_uint32 = 3;
  108. optional uint64 optional_uint64 = 4;
  109. optional sint32 optional_sint32 = 5;
  110. optional sint64 optional_sint64 = 6;
  111. optional fixed32 optional_fixed32 = 7;
  112. optional fixed64 optional_fixed64 = 8;
  113. optional sfixed32 optional_sfixed32 = 9;
  114. optional sfixed64 optional_sfixed64 = 10;
  115. optional float optional_float = 11;
  116. optional double optional_double = 12;
  117. optional bool optional_bool = 13;
  118. optional string optional_string = 14;
  119. optional bytes optional_bytes = 15;
  120. optional group OptionalGroup = 16 {
  121. optional int32 a = 17;
  122. }
  123. optional NestedMessage optional_nested_message = 18;
  124. optional ForeignMessage optional_foreign_message = 19;
  125. optional NestedEnum optional_nested_enum = 21;
  126. optional ForeignEnum optional_foreign_enum = 22;
  127. optional string optional_string_piece = 24 [ctype=STRING_PIECE];
  128. optional string optional_cord = 25 [ctype=CORD];
  129. optional TestAllTypes recursive_message = 27;
  130. // Repeated
  131. repeated int32 repeated_int32 = 31;
  132. repeated int64 repeated_int64 = 32;
  133. repeated uint32 repeated_uint32 = 33;
  134. repeated uint64 repeated_uint64 = 34;
  135. repeated sint32 repeated_sint32 = 35;
  136. repeated sint64 repeated_sint64 = 36;
  137. repeated fixed32 repeated_fixed32 = 37;
  138. repeated fixed64 repeated_fixed64 = 38;
  139. repeated sfixed32 repeated_sfixed32 = 39;
  140. repeated sfixed64 repeated_sfixed64 = 40;
  141. repeated float repeated_float = 41;
  142. repeated double repeated_double = 42;
  143. repeated bool repeated_bool = 43;
  144. repeated string repeated_string = 44;
  145. repeated bytes repeated_bytes = 45;
  146. repeated group RepeatedGroup = 46 {
  147. optional int32 a = 47;
  148. }
  149. repeated NestedMessage repeated_nested_message = 48;
  150. repeated ForeignMessage repeated_foreign_message = 49;
  151. repeated NestedEnum repeated_nested_enum = 51;
  152. repeated ForeignEnum repeated_foreign_enum = 52;
  153. repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
  154. repeated string repeated_cord = 55 [ctype=CORD];
  155. // Map
  156. map < int32, int32> map_int32_int32 = 56;
  157. map < int64, int64> map_int64_int64 = 57;
  158. map < uint32, uint32> map_uint32_uint32 = 58;
  159. map < uint64, uint64> map_uint64_uint64 = 59;
  160. map < sint32, sint32> map_sint32_sint32 = 60;
  161. map < sint64, sint64> map_sint64_sint64 = 61;
  162. map < fixed32, fixed32> map_fixed32_fixed32 = 62;
  163. map < fixed64, fixed64> map_fixed64_fixed64 = 63;
  164. map <sfixed32, sfixed32> map_sfixed32_sfixed32 = 64;
  165. map <sfixed64, sfixed64> map_sfixed64_sfixed64 = 65;
  166. map < int32, float> map_int32_float = 66;
  167. map < int32, double> map_int32_double = 67;
  168. map < bool, bool> map_bool_bool = 68;
  169. map < string, string> map_string_string = 69;
  170. map < string, bytes> map_string_bytes = 70;
  171. map < string, NestedMessage> map_string_nested_message = 71;
  172. map < string, ForeignMessage> map_string_foreign_message = 72;
  173. map < string, NestedEnum> map_string_nested_enum = 73;
  174. map < string, ForeignEnum> map_string_foreign_enum = 74;
  175. oneof oneof_field {
  176. uint32 oneof_uint32 = 111;
  177. NestedMessage oneof_nested_message = 112;
  178. string oneof_string = 113;
  179. bytes oneof_bytes = 114;
  180. }
  181. }
  182. message ForeignMessage {
  183. optional int32 c = 1;
  184. }
  185. enum ForeignEnum {
  186. FOREIGN_FOO = 0;
  187. FOREIGN_BAR = 1;
  188. FOREIGN_BAZ = 2;
  189. }