conformance.proto 7.7 KB

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