...
1// Copyright 2018 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5syntax = "proto2";
6
7package goproto.proto.test;
8
9import "internal/testprotos/enums/enums.proto";
10import "internal/testprotos/test/test_import.proto";
11import public "internal/testprotos/test/test_public.proto";
12import weak "internal/testprotos/test/weak1/test_weak.proto";
13import weak "internal/testprotos/test/weak2/test_weak.proto";
14
15option go_package = "google.golang.org/protobuf/internal/testprotos/test";
16
17message TestAllTypes {
18 message NestedMessage {
19 optional int32 a = 1;
20 optional TestAllTypes corecursive = 2;
21 }
22
23 enum NestedEnum {
24 FOO = 0;
25 BAR = 1;
26 BAZ = 2;
27 NEG = -1; // Intentionally negative.
28 }
29
30 optional int32 optional_int32 = 1;
31 optional int64 optional_int64 = 2;
32 optional uint32 optional_uint32 = 3;
33 optional uint64 optional_uint64 = 4;
34 optional sint32 optional_sint32 = 5;
35 optional sint64 optional_sint64 = 6;
36 optional fixed32 optional_fixed32 = 7;
37 optional fixed64 optional_fixed64 = 8;
38 optional sfixed32 optional_sfixed32 = 9;
39 optional sfixed64 optional_sfixed64 = 10;
40 optional float optional_float = 11;
41 optional double optional_double = 12;
42 optional bool optional_bool = 13;
43 optional string optional_string = 14;
44 optional bytes optional_bytes = 15;
45 optional group OptionalGroup = 16 {
46 optional int32 a = 17;
47 optional NestedMessage optional_nested_message = 1000;
48 optional int32 same_field_number = 16;
49 }
50 optional NestedMessage optional_nested_message = 18;
51 optional ForeignMessage optional_foreign_message = 19;
52 optional ImportMessage optional_import_message = 20;
53 optional NestedEnum optional_nested_enum = 21;
54 optional ForeignEnum optional_foreign_enum = 22;
55 optional ImportEnum optional_import_enum = 23;
56
57 repeated int32 repeated_int32 = 31;
58 repeated int64 repeated_int64 = 32;
59 repeated uint32 repeated_uint32 = 33;
60 repeated uint64 repeated_uint64 = 34;
61 repeated sint32 repeated_sint32 = 35;
62 repeated sint64 repeated_sint64 = 36;
63 repeated fixed32 repeated_fixed32 = 37;
64 repeated fixed64 repeated_fixed64 = 38;
65 repeated sfixed32 repeated_sfixed32 = 39;
66 repeated sfixed64 repeated_sfixed64 = 40;
67 repeated float repeated_float = 41;
68 repeated double repeated_double = 42;
69 repeated bool repeated_bool = 43;
70 repeated string repeated_string = 44;
71 repeated bytes repeated_bytes = 45;
72 repeated group RepeatedGroup = 46 {
73 optional int32 a = 47;
74 optional NestedMessage optional_nested_message = 1001;
75 }
76 repeated NestedMessage repeated_nested_message = 48;
77 repeated ForeignMessage repeated_foreign_message = 49;
78 repeated ImportMessage repeated_importmessage = 50;
79 repeated NestedEnum repeated_nested_enum = 51;
80 repeated ForeignEnum repeated_foreign_enum = 52;
81 repeated ImportEnum repeated_importenum = 53;
82
83 map < int32, int32> map_int32_int32 = 56;
84 map < int64, int64> map_int64_int64 = 57;
85 map < uint32, uint32> map_uint32_uint32 = 58;
86 map < uint64, uint64> map_uint64_uint64 = 59;
87 map < sint32, sint32> map_sint32_sint32 = 60;
88 map < sint64, sint64> map_sint64_sint64 = 61;
89 map < fixed32, fixed32> map_fixed32_fixed32 = 62;
90 map < fixed64, fixed64> map_fixed64_fixed64 = 63;
91 map <sfixed32, sfixed32> map_sfixed32_sfixed32 = 64;
92 map <sfixed64, sfixed64> map_sfixed64_sfixed64 = 65;
93 map < int32, float> map_int32_float = 66;
94 map < int32, double> map_int32_double = 67;
95 map < bool, bool> map_bool_bool = 68;
96 map < string, string> map_string_string = 69;
97 map < string, bytes> map_string_bytes = 70;
98 map < string, NestedMessage> map_string_nested_message = 71;
99 map < string, NestedEnum> map_string_nested_enum = 73;
100
101 // Singular with defaults
102 optional int32 default_int32 = 81 [default = 81 ];
103 optional int64 default_int64 = 82 [default = 82 ];
104 optional uint32 default_uint32 = 83 [default = 83 ];
105 optional uint64 default_uint64 = 84 [default = 84 ];
106 optional sint32 default_sint32 = 85 [default = -85 ];
107 optional sint64 default_sint64 = 86 [default = 86 ];
108 optional fixed32 default_fixed32 = 87 [default = 87 ];
109 optional fixed64 default_fixed64 = 88 [default = 88 ];
110 optional sfixed32 default_sfixed32 = 89 [default = 89 ];
111 optional sfixed64 default_sfixed64 = 80 [default = -90 ];
112 optional float default_float = 91 [default = 91.5 ];
113 optional double default_double = 92 [default = 92e3 ];
114 optional bool default_bool = 93 [default = true ];
115 optional string default_string = 94 [default = "hello"];
116 optional bytes default_bytes = 95 [default = "world"];
117 optional NestedEnum default_nested_enum = 96 [default = BAR ];
118 optional ForeignEnum default_foreign_enum = 97 [default = FOREIGN_BAR];
119
120 oneof oneof_field {
121 uint32 oneof_uint32 = 111;
122 NestedMessage oneof_nested_message = 112;
123 string oneof_string = 113;
124 bytes oneof_bytes = 114;
125 bool oneof_bool = 115;
126 uint64 oneof_uint64 = 116;
127 float oneof_float = 117;
128 double oneof_double = 118;
129 NestedEnum oneof_enum = 119;
130 group OneofGroup = 121 {
131 optional int32 a = 1;
132 optional int32 b = 2;
133 }
134 }
135
136 // A oneof with exactly one field.
137 oneof oneof_optional {
138 uint32 oneof_optional_uint32 = 120;
139 }
140}
141
142message TestDeprecatedMessage {
143 option deprecated = true;
144 optional int32 deprecated_int32 = 1 [deprecated=true];
145 enum DeprecatedEnum {
146 option deprecated = true;
147 DEPRECATED = 0 [deprecated=true];
148 }
149 oneof deprecated_oneof {
150 int32 deprecated_oneof_field = 2 [deprecated = true];
151 }
152}
153
154message ForeignMessage {
155 optional int32 c = 1;
156 optional int32 d = 2;
157}
158
159enum ForeignEnum {
160 FOREIGN_FOO = 4;
161 FOREIGN_BAR = 5;
162 FOREIGN_BAZ = 6;
163}
164
165message TestReservedFields {
166 reserved 2, 15, 9 to 11;
167 reserved "bar", "baz";
168}
169
170enum TestReservedEnumFields {
171 RESERVED_ENUM = 0;
172 reserved 2, 15, 9 to 11;
173 reserved "BAR", "BAZ";
174}
175
176message TestAllExtensions {
177 message NestedMessage {
178 optional int32 a = 1;
179 optional TestAllExtensions corecursive = 2;
180 }
181
182 extensions 1 to max;
183}
184
185extend TestAllExtensions {
186 optional int32 optional_int32 = 1;
187 optional int64 optional_int64 = 2;
188 optional uint32 optional_uint32 = 3;
189 optional uint64 optional_uint64 = 4;
190 optional sint32 optional_sint32 = 5;
191 optional sint64 optional_sint64 = 6;
192 optional fixed32 optional_fixed32 = 7;
193 optional fixed64 optional_fixed64 = 8;
194 optional sfixed32 optional_sfixed32 = 9;
195 optional sfixed64 optional_sfixed64 = 10;
196 optional float optional_float = 11;
197 optional double optional_double = 12;
198 optional bool optional_bool = 13;
199 optional string optional_string = 14;
200 optional bytes optional_bytes = 15;
201
202 optional group OptionalGroup = 16 {
203 optional int32 a = 17;
204 optional int32 same_field_number = 16;
205 optional TestAllExtensions.NestedMessage optional_nested_message = 1000;
206 }
207
208 optional TestAllExtensions.NestedMessage optional_nested_message = 18;
209 optional TestAllTypes.NestedEnum optional_nested_enum = 21;
210
211 repeated int32 repeated_int32 = 31;
212 repeated int64 repeated_int64 = 32;
213 repeated uint32 repeated_uint32 = 33;
214 repeated uint64 repeated_uint64 = 34;
215 repeated sint32 repeated_sint32 = 35;
216 repeated sint64 repeated_sint64 = 36;
217 repeated fixed32 repeated_fixed32 = 37;
218 repeated fixed64 repeated_fixed64 = 38;
219 repeated sfixed32 repeated_sfixed32 = 39;
220 repeated sfixed64 repeated_sfixed64 = 40;
221 repeated float repeated_float = 41;
222 repeated double repeated_double = 42;
223 repeated bool repeated_bool = 43;
224 repeated string repeated_string = 44;
225 repeated bytes repeated_bytes = 45;
226
227 repeated group RepeatedGroup = 46 {
228 optional int32 a = 47;
229 optional TestAllExtensions.NestedMessage optional_nested_message = 1001;
230 }
231
232 repeated TestAllExtensions.NestedMessage repeated_nested_message = 48;
233 repeated TestAllTypes.NestedEnum repeated_nested_enum = 51;
234
235 optional int32 default_int32 = 81 [default = 81 ];
236 optional int64 default_int64 = 82 [default = 82 ];
237 optional uint32 default_uint32 = 83 [default = 83 ];
238 optional uint64 default_uint64 = 84 [default = 84 ];
239 optional sint32 default_sint32 = 85 [default = -85 ];
240 optional sint64 default_sint64 = 86 [default = 86 ];
241 optional fixed32 default_fixed32 = 87 [default = 87 ];
242 optional fixed64 default_fixed64 = 88 [default = 88 ];
243 optional sfixed32 default_sfixed32 = 89 [default = 89 ];
244 optional sfixed64 default_sfixed64 = 80 [default = -90 ];
245 optional float default_float = 91 [default = 91.5 ];
246 optional double default_double = 92 [default = 92e3 ];
247 optional bool default_bool = 93 [default = true ];
248 optional string default_string = 94 [default = "hello"];
249 optional bytes default_bytes = 95 [default = "world"];
250}
251
252message TestNestedExtension {
253 extend TestAllExtensions {
254 optional string nested_string_extension = 1003;
255 }
256}
257
258message TestRequired {
259 required int32 required_field = 1;
260
261 extend TestAllExtensions {
262 optional TestRequired single = 1000;
263 repeated TestRequired multi = 1001;
264 }
265}
266
267message TestRequiredForeign {
268 optional TestRequired optional_message = 1;
269 repeated TestRequired repeated_message = 2;
270 map<int32, TestRequired> map_message = 3;
271 oneof oneof_field {
272 TestRequired oneof_message = 4;
273 }
274}
275
276message TestRequiredGroupFields {
277 optional group OptionalGroup = 1 {
278 required int32 a = 2;
279 }
280 repeated group RepeatedGroup = 3 {
281 required int32 a = 4;
282 }
283}
284
285message TestWeak {
286 optional goproto.proto.test.weak.WeakImportMessage1 weak_message1 = 1 [weak=true];
287 optional goproto.proto.test.weak.WeakImportMessage2 weak_message2 = 2 [weak=true];
288}
289
290message TestPackedTypes {
291 repeated int32 packed_int32 = 90 [packed = true];
292 repeated int64 packed_int64 = 91 [packed = true];
293 repeated uint32 packed_uint32 = 92 [packed = true];
294 repeated uint64 packed_uint64 = 93 [packed = true];
295 repeated sint32 packed_sint32 = 94 [packed = true];
296 repeated sint64 packed_sint64 = 95 [packed = true];
297 repeated fixed32 packed_fixed32 = 96 [packed = true];
298 repeated fixed64 packed_fixed64 = 97 [packed = true];
299 repeated sfixed32 packed_sfixed32 = 98 [packed = true];
300 repeated sfixed64 packed_sfixed64 = 99 [packed = true];
301 repeated float packed_float = 100 [packed = true];
302 repeated double packed_double = 101 [packed = true];
303 repeated bool packed_bool = 102 [packed = true];
304 repeated ForeignEnum packed_enum = 103 [packed = true];
305}
306
307message TestUnpackedTypes {
308 repeated int32 unpacked_int32 = 90 [packed = false];
309 repeated int64 unpacked_int64 = 91 [packed = false];
310 repeated uint32 unpacked_uint32 = 92 [packed = false];
311 repeated uint64 unpacked_uint64 = 93 [packed = false];
312 repeated sint32 unpacked_sint32 = 94 [packed = false];
313 repeated sint64 unpacked_sint64 = 95 [packed = false];
314 repeated fixed32 unpacked_fixed32 = 96 [packed = false];
315 repeated fixed64 unpacked_fixed64 = 97 [packed = false];
316 repeated sfixed32 unpacked_sfixed32 = 98 [packed = false];
317 repeated sfixed64 unpacked_sfixed64 = 99 [packed = false];
318 repeated float unpacked_float = 100 [packed = false];
319 repeated double unpacked_double = 101 [packed = false];
320 repeated bool unpacked_bool = 102 [packed = false];
321 repeated ForeignEnum unpacked_enum = 103 [packed = false];
322}
323
324message TestPackedExtensions {
325 extensions 1 to max;
326}
327
328extend TestPackedExtensions {
329 repeated int32 packed_int32 = 90 [packed = true];
330 repeated int64 packed_int64 = 91 [packed = true];
331 repeated uint32 packed_uint32 = 92 [packed = true];
332 repeated uint64 packed_uint64 = 93 [packed = true];
333 repeated sint32 packed_sint32 = 94 [packed = true];
334 repeated sint64 packed_sint64 = 95 [packed = true];
335 repeated fixed32 packed_fixed32 = 96 [packed = true];
336 repeated fixed64 packed_fixed64 = 97 [packed = true];
337 repeated sfixed32 packed_sfixed32 = 98 [packed = true];
338 repeated sfixed64 packed_sfixed64 = 99 [packed = true];
339 repeated float packed_float = 100 [packed = true];
340 repeated double packed_double = 101 [packed = true];
341 repeated bool packed_bool = 102 [packed = true];
342 repeated ForeignEnum packed_enum = 103 [packed = true];
343}
344
345message TestUnpackedExtensions {
346 extensions 1 to max;
347}
348
349extend TestUnpackedExtensions {
350 repeated int32 unpacked_int32 = 90 [packed = false];
351 repeated int64 unpacked_int64 = 91 [packed = false];
352 repeated uint32 unpacked_uint32 = 92 [packed = false];
353 repeated uint64 unpacked_uint64 = 93 [packed = false];
354 repeated sint32 unpacked_sint32 = 94 [packed = false];
355 repeated sint64 unpacked_sint64 = 95 [packed = false];
356 repeated fixed32 unpacked_fixed32 = 96 [packed = false];
357 repeated fixed64 unpacked_fixed64 = 97 [packed = false];
358 repeated sfixed32 unpacked_sfixed32 = 98 [packed = false];
359 repeated sfixed64 unpacked_sfixed64 = 99 [packed = false];
360 repeated float unpacked_float = 100 [packed = false];
361 repeated double unpacked_double = 101 [packed = false];
362 repeated bool unpacked_bool = 102 [packed = false];
363 repeated ForeignEnum unpacked_enum = 103 [packed = false];
364}
365
366// Test that RPC services work.
367message FooRequest {}
368message FooResponse {}
369
370service TestService {
371 rpc Foo(FooRequest) returns (FooResponse);
372 rpc TestStream(stream FooRequest) returns (stream FooResponse);
373}
374
375service TestDeprecatedService {
376 option deprecated = true;
377 rpc Deprecated(TestDeprecatedMessage) returns (TestDeprecatedMessage) {
378 option deprecated = true;
379 }
380}
381
382message WeirdDefault {
383 optional bytes weird_default = 1 [default = "hello, \"world!\"\ndead\xde\xad\xbe\xefbeef`"];
384}
385
386message RemoteDefault {
387 optional goproto.proto.enums.Enum default = 1;
388 optional goproto.proto.enums.Enum zero = 2 [default = ZERO];
389 optional goproto.proto.enums.Enum one = 3 [default = ONE];
390 optional goproto.proto.enums.Enum elevent = 4 [default = ELEVENT];
391 optional goproto.proto.enums.Enum seventeen = 5 [default = SEVENTEEN];
392 optional goproto.proto.enums.Enum thirtyseven = 6 [default = THIRTYSEVEN];
393 optional goproto.proto.enums.Enum sixtyseven = 7 [default = SIXTYSEVEN];
394 optional goproto.proto.enums.Enum negative = 8 [default = NEGATIVE];
395}
View as plain text