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