• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
31// Author: kenton@google.com (Kenton Varda)
32//
33// This is like unittest.proto but with optimize_for = LITE_RUNTIME.
34
35syntax = "proto2";
36package protobuf_unittest;
37
38import "google/protobuf/unittest_import_lite.proto";
39
40option optimize_for = LITE_RUNTIME;
41
42option java_package = "com.google.protobuf";
43
44// Same as TestAllTypes but with the lite runtime.
45message TestAllTypesLite {
46
47  message NestedMessage {
48    optional int32 bb = 1;
49    optional int64 cc = 2;
50  }
51
52  enum NestedEnum {
53    FOO = 1;
54    BAR = 2;
55    BAZ = 3;
56  }
57
58  // Singular
59  optional    int32 optional_int32    =  1;
60  optional    int64 optional_int64    =  2;
61  optional   uint32 optional_uint32   =  3;
62  optional   uint64 optional_uint64   =  4;
63  optional   sint32 optional_sint32   =  5;
64  optional   sint64 optional_sint64   =  6;
65  optional  fixed32 optional_fixed32  =  7;
66  optional  fixed64 optional_fixed64  =  8;
67  optional sfixed32 optional_sfixed32 =  9;
68  optional sfixed64 optional_sfixed64 = 10;
69  optional    float optional_float    = 11;
70  optional   double optional_double   = 12;
71  optional     bool optional_bool     = 13;
72  optional   string optional_string   = 14;
73  optional    bytes optional_bytes    = 15;
74
75  optional group OptionalGroup = 16 {
76    optional int32 a = 17;
77  }
78
79  optional NestedMessage      optional_nested_message  = 18;
80  optional ForeignMessageLite optional_foreign_message = 19;
81  optional protobuf_unittest_import.ImportMessageLite
82    optional_import_message = 20;
83
84  optional NestedEnum      optional_nested_enum     = 21;
85  optional ForeignEnumLite optional_foreign_enum    = 22;
86  optional protobuf_unittest_import.ImportEnumLite optional_import_enum = 23;
87
88  optional string optional_string_piece = 24 [ctype=STRING_PIECE];
89  optional string optional_cord = 25 [ctype=CORD];
90
91  // Defined in unittest_import_public.proto
92  optional protobuf_unittest_import.PublicImportMessageLite
93      optional_public_import_message = 26;
94
95  optional NestedMessage optional_lazy_message = 27 [lazy=true];
96
97  // Repeated
98  repeated    int32 repeated_int32    = 31;
99  repeated    int64 repeated_int64    = 32;
100  repeated   uint32 repeated_uint32   = 33;
101  repeated   uint64 repeated_uint64   = 34;
102  repeated   sint32 repeated_sint32   = 35;
103  repeated   sint64 repeated_sint64   = 36;
104  repeated  fixed32 repeated_fixed32  = 37;
105  repeated  fixed64 repeated_fixed64  = 38;
106  repeated sfixed32 repeated_sfixed32 = 39;
107  repeated sfixed64 repeated_sfixed64 = 40;
108  repeated    float repeated_float    = 41;
109  repeated   double repeated_double   = 42;
110  repeated     bool repeated_bool     = 43;
111  repeated   string repeated_string   = 44;
112  repeated    bytes repeated_bytes    = 45;
113
114  repeated group RepeatedGroup = 46 {
115    optional int32 a = 47;
116  }
117
118  repeated NestedMessage      repeated_nested_message  = 48;
119  repeated ForeignMessageLite repeated_foreign_message = 49;
120  repeated protobuf_unittest_import.ImportMessageLite
121    repeated_import_message = 50;
122
123  repeated NestedEnum      repeated_nested_enum  = 51;
124  repeated ForeignEnumLite repeated_foreign_enum = 52;
125  repeated protobuf_unittest_import.ImportEnumLite repeated_import_enum = 53;
126
127  repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
128  repeated string repeated_cord = 55 [ctype=CORD];
129
130  repeated NestedMessage repeated_lazy_message = 57 [lazy=true];
131
132  // Singular with defaults
133  optional    int32 default_int32    = 61 [default =  41    ];
134  optional    int64 default_int64    = 62 [default =  42    ];
135  optional   uint32 default_uint32   = 63 [default =  43    ];
136  optional   uint64 default_uint64   = 64 [default =  44    ];
137  optional   sint32 default_sint32   = 65 [default = -45    ];
138  optional   sint64 default_sint64   = 66 [default =  46    ];
139  optional  fixed32 default_fixed32  = 67 [default =  47    ];
140  optional  fixed64 default_fixed64  = 68 [default =  48    ];
141  optional sfixed32 default_sfixed32 = 69 [default =  49    ];
142  optional sfixed64 default_sfixed64 = 70 [default = -50    ];
143  optional    float default_float    = 71 [default =  51.5  ];
144  optional   double default_double   = 72 [default =  52e3  ];
145  optional     bool default_bool     = 73 [default = true   ];
146  optional   string default_string   = 74 [default = "hello"];
147  optional    bytes default_bytes    = 75 [default = "world"];
148
149  optional NestedEnum default_nested_enum = 81 [default = BAR];
150  optional ForeignEnumLite default_foreign_enum = 82
151      [default = FOREIGN_LITE_BAR];
152  optional protobuf_unittest_import.ImportEnumLite
153      default_import_enum = 83 [default = IMPORT_LITE_BAR];
154
155  optional string default_string_piece = 84 [ctype=STRING_PIECE,default="abc"];
156  optional string default_cord = 85 [ctype=CORD,default="123"];
157
158  // For oneof test
159  oneof oneof_field {
160    uint32 oneof_uint32 = 111;
161    NestedMessage oneof_nested_message = 112;
162    string oneof_string = 113;
163    bytes oneof_bytes = 114;
164    NestedMessage oneof_lazy_nested_message = 115 [lazy = true];
165  }
166
167  // Tests toString for non-repeated fields with a list suffix
168  optional int32 deceptively_named_list = 116;
169}
170
171message ForeignMessageLite {
172  optional int32 c = 1;
173}
174
175enum ForeignEnumLite {
176  FOREIGN_LITE_FOO = 4;
177  FOREIGN_LITE_BAZ = 6;
178  FOREIGN_LITE_BAR = 5;
179}
180
181message TestPackedTypesLite {
182  repeated    int32 packed_int32    =  90 [packed = true];
183  repeated    int64 packed_int64    =  91 [packed = true];
184  repeated   uint32 packed_uint32   =  92 [packed = true];
185  repeated   uint64 packed_uint64   =  93 [packed = true];
186  repeated   sint32 packed_sint32   =  94 [packed = true];
187  repeated   sint64 packed_sint64   =  95 [packed = true];
188  repeated  fixed32 packed_fixed32  =  96 [packed = true];
189  repeated  fixed64 packed_fixed64  =  97 [packed = true];
190  repeated sfixed32 packed_sfixed32 =  98 [packed = true];
191  repeated sfixed64 packed_sfixed64 =  99 [packed = true];
192  repeated    float packed_float    = 100 [packed = true];
193  repeated   double packed_double   = 101 [packed = true];
194  repeated     bool packed_bool     = 102 [packed = true];
195  repeated ForeignEnumLite packed_enum  = 103 [packed = true];
196}
197
198message TestAllExtensionsLite {
199  extensions 1 to max;
200}
201
202extend TestAllExtensionsLite {
203  // Singular
204  optional    int32 optional_int32_extension_lite    =  1;
205  optional    int64 optional_int64_extension_lite    =  2;
206  optional   uint32 optional_uint32_extension_lite   =  3;
207  optional   uint64 optional_uint64_extension_lite   =  4;
208  optional   sint32 optional_sint32_extension_lite   =  5;
209  optional   sint64 optional_sint64_extension_lite   =  6;
210  optional  fixed32 optional_fixed32_extension_lite  =  7;
211  optional  fixed64 optional_fixed64_extension_lite  =  8;
212  optional sfixed32 optional_sfixed32_extension_lite =  9;
213  optional sfixed64 optional_sfixed64_extension_lite = 10;
214  optional    float optional_float_extension_lite    = 11;
215  optional   double optional_double_extension_lite   = 12;
216  optional     bool optional_bool_extension_lite     = 13;
217  optional   string optional_string_extension_lite   = 14;
218  optional    bytes optional_bytes_extension_lite    = 15;
219
220  optional group OptionalGroup_extension_lite = 16 {
221    optional int32 a = 17;
222  }
223
224  optional TestAllTypesLite.NestedMessage optional_nested_message_extension_lite
225      = 18;
226  optional ForeignMessageLite optional_foreign_message_extension_lite = 19;
227  optional protobuf_unittest_import.ImportMessageLite
228    optional_import_message_extension_lite = 20;
229
230  optional TestAllTypesLite.NestedEnum optional_nested_enum_extension_lite = 21;
231  optional ForeignEnumLite optional_foreign_enum_extension_lite = 22;
232  optional protobuf_unittest_import.ImportEnumLite
233    optional_import_enum_extension_lite = 23;
234
235  optional string optional_string_piece_extension_lite = 24
236      [ctype=STRING_PIECE];
237  optional string optional_cord_extension_lite = 25 [ctype=CORD];
238
239  optional protobuf_unittest_import.PublicImportMessageLite
240    optional_public_import_message_extension_lite = 26;
241
242  optional TestAllTypesLite.NestedMessage
243    optional_lazy_message_extension_lite = 27 [lazy=true];
244
245  // Repeated
246  repeated    int32 repeated_int32_extension_lite    = 31;
247  repeated    int64 repeated_int64_extension_lite    = 32;
248  repeated   uint32 repeated_uint32_extension_lite   = 33;
249  repeated   uint64 repeated_uint64_extension_lite   = 34;
250  repeated   sint32 repeated_sint32_extension_lite   = 35;
251  repeated   sint64 repeated_sint64_extension_lite   = 36;
252  repeated  fixed32 repeated_fixed32_extension_lite  = 37;
253  repeated  fixed64 repeated_fixed64_extension_lite  = 38;
254  repeated sfixed32 repeated_sfixed32_extension_lite = 39;
255  repeated sfixed64 repeated_sfixed64_extension_lite = 40;
256  repeated    float repeated_float_extension_lite    = 41;
257  repeated   double repeated_double_extension_lite   = 42;
258  repeated     bool repeated_bool_extension_lite     = 43;
259  repeated   string repeated_string_extension_lite   = 44;
260  repeated    bytes repeated_bytes_extension_lite    = 45;
261
262  repeated group RepeatedGroup_extension_lite = 46 {
263    optional int32 a = 47;
264  }
265
266  repeated TestAllTypesLite.NestedMessage repeated_nested_message_extension_lite
267      = 48;
268  repeated ForeignMessageLite repeated_foreign_message_extension_lite = 49;
269  repeated protobuf_unittest_import.ImportMessageLite
270    repeated_import_message_extension_lite = 50;
271
272  repeated TestAllTypesLite.NestedEnum repeated_nested_enum_extension_lite = 51;
273  repeated ForeignEnumLite repeated_foreign_enum_extension_lite = 52;
274  repeated protobuf_unittest_import.ImportEnumLite
275    repeated_import_enum_extension_lite = 53;
276
277  repeated string repeated_string_piece_extension_lite = 54
278      [ctype=STRING_PIECE];
279  repeated string repeated_cord_extension_lite = 55 [ctype=CORD];
280
281  repeated TestAllTypesLite.NestedMessage
282    repeated_lazy_message_extension_lite = 57 [lazy=true];
283
284  // Singular with defaults
285  optional    int32 default_int32_extension_lite    = 61 [default =  41    ];
286  optional    int64 default_int64_extension_lite    = 62 [default =  42    ];
287  optional   uint32 default_uint32_extension_lite   = 63 [default =  43    ];
288  optional   uint64 default_uint64_extension_lite   = 64 [default =  44    ];
289  optional   sint32 default_sint32_extension_lite   = 65 [default = -45    ];
290  optional   sint64 default_sint64_extension_lite   = 66 [default =  46    ];
291  optional  fixed32 default_fixed32_extension_lite  = 67 [default =  47    ];
292  optional  fixed64 default_fixed64_extension_lite  = 68 [default =  48    ];
293  optional sfixed32 default_sfixed32_extension_lite = 69 [default =  49    ];
294  optional sfixed64 default_sfixed64_extension_lite = 70 [default = -50    ];
295  optional    float default_float_extension_lite    = 71 [default =  51.5  ];
296  optional   double default_double_extension_lite   = 72 [default =  52e3  ];
297  optional     bool default_bool_extension_lite     = 73 [default = true   ];
298  optional   string default_string_extension_lite   = 74 [default = "hello"];
299  optional    bytes default_bytes_extension_lite    = 75 [default = "world"];
300
301  optional TestAllTypesLite.NestedEnum
302    default_nested_enum_extension_lite = 81 [default = BAR];
303  optional ForeignEnumLite
304    default_foreign_enum_extension_lite = 82 [default = FOREIGN_LITE_BAR];
305  optional protobuf_unittest_import.ImportEnumLite
306    default_import_enum_extension_lite = 83 [default = IMPORT_LITE_BAR];
307
308  optional string default_string_piece_extension_lite = 84 [ctype=STRING_PIECE,
309                                                            default="abc"];
310  optional string default_cord_extension_lite = 85 [ctype=CORD, default="123"];
311
312  // For oneof test
313  optional uint32 oneof_uint32_extension_lite = 111;
314  optional TestAllTypesLite.NestedMessage oneof_nested_message_extension_lite = 112;
315  optional string oneof_string_extension_lite = 113;
316  optional bytes oneof_bytes_extension_lite = 114;
317}
318
319message TestPackedExtensionsLite {
320  extensions 1 to max;
321}
322
323extend TestPackedExtensionsLite {
324  repeated    int32 packed_int32_extension_lite    =  90 [packed = true];
325  repeated    int64 packed_int64_extension_lite    =  91 [packed = true];
326  repeated   uint32 packed_uint32_extension_lite   =  92 [packed = true];
327  repeated   uint64 packed_uint64_extension_lite   =  93 [packed = true];
328  repeated   sint32 packed_sint32_extension_lite   =  94 [packed = true];
329  repeated   sint64 packed_sint64_extension_lite   =  95 [packed = true];
330  repeated  fixed32 packed_fixed32_extension_lite  =  96 [packed = true];
331  repeated  fixed64 packed_fixed64_extension_lite  =  97 [packed = true];
332  repeated sfixed32 packed_sfixed32_extension_lite =  98 [packed = true];
333  repeated sfixed64 packed_sfixed64_extension_lite =  99 [packed = true];
334  repeated    float packed_float_extension_lite    = 100 [packed = true];
335  repeated   double packed_double_extension_lite   = 101 [packed = true];
336  repeated     bool packed_bool_extension_lite     = 102 [packed = true];
337  repeated ForeignEnumLite packed_enum_extension_lite = 103 [packed = true];
338}
339
340message TestNestedExtensionLite {
341  extend TestAllExtensionsLite {
342    optional int32 nested_extension = 12345;
343  }
344}
345
346// Test that deprecated fields work.  We only verify that they compile (at one
347// point this failed).
348message TestDeprecatedLite {
349  optional int32 deprecated_field = 1 [deprecated = true];
350}
351
352// See the comments of the same type in unittest.proto.
353message TestParsingMergeLite {
354  message RepeatedFieldsGenerator {
355    repeated TestAllTypesLite field1 = 1;
356    repeated TestAllTypesLite field2 = 2;
357    repeated TestAllTypesLite field3 = 3;
358    repeated group Group1 = 10 {
359      optional TestAllTypesLite field1 = 11;
360    }
361    repeated group Group2 = 20 {
362      optional TestAllTypesLite field1 = 21;
363    }
364    repeated TestAllTypesLite ext1 = 1000;
365    repeated TestAllTypesLite ext2 = 1001;
366  }
367  required TestAllTypesLite required_all_types = 1;
368  optional TestAllTypesLite optional_all_types = 2;
369  repeated TestAllTypesLite repeated_all_types = 3;
370  optional group OptionalGroup = 10 {
371    optional TestAllTypesLite optional_group_all_types = 11;
372  }
373  repeated group RepeatedGroup = 20 {
374    optional TestAllTypesLite repeated_group_all_types = 21;
375  }
376  extensions 1000 to max;
377  extend TestParsingMergeLite {
378    optional TestAllTypesLite optional_ext = 1000;
379    repeated TestAllTypesLite repeated_ext = 1001;
380  }
381}
382
383// TestEmptyMessageLite is used to test unknown fields support in lite mode.
384message TestEmptyMessageLite{
385}
386
387// Like above, but declare all field numbers as potential extensions.  No
388// actual extensions should ever be defined for this type.
389message TestEmptyMessageWithExtensionsLite {
390  extensions 1 to max;
391}
392
393enum V1EnumLite {
394    V1_FIRST = 1;
395}
396
397enum V2EnumLite {
398    V2_FIRST = 1;
399    V2_SECOND = 2;
400}
401
402message V1MessageLite {
403    required int32 int_field = 1;
404    optional V1EnumLite enum_field = 2 [ default = V1_FIRST ];
405}
406
407message V2MessageLite {
408    required int32 int_field = 1;
409    optional V2EnumLite enum_field = 2 [ default = V2_FIRST ];
410}
411
412message TestHugeFieldNumbersLite {
413  optional int32 optional_int32 = 536870000;
414  optional int32 fixed_32 = 536870001;
415  repeated int32 repeated_int32 = 536870002 [packed = false];
416  repeated int32 packed_int32 = 536870003 [packed = true];
417
418  optional ForeignEnumLite optional_enum = 536870004;
419  optional string optional_string = 536870005;
420  optional bytes optional_bytes = 536870006;
421  optional ForeignMessageLite optional_message = 536870007;
422
423  optional group OptionalGroup = 536870008 {
424    optional int32 group_a = 536870009;
425  }
426
427  map<string, string> string_string_map = 536870010;
428
429  oneof oneof_field {
430    uint32 oneof_uint32 = 536870011;
431    TestAllTypesLite oneof_test_all_types = 536870012;
432    string oneof_string = 536870013;
433    bytes oneof_bytes = 536870014;
434  }
435
436  extensions  536860000 to 536869999;
437}
438
439extend TestHugeFieldNumbersLite {
440  optional TestAllTypesLite test_all_types_lite = 536860000;
441}
442
443message TestOneofParsingLite {
444  oneof oneof_field {
445    int32 oneof_int32 = 1;
446    TestAllTypesLite oneof_submessage = 2;
447    string oneof_string = 3;
448    bytes oneof_bytes = 4 [default = "default bytes"];
449    string oneof_string_cord = 5 [ctype = CORD, default = "default Cord"];
450    bytes oneof_bytes_cord = 6 [ctype = CORD];
451    string oneof_string_string_piece = 7 [ctype = STRING_PIECE];
452    bytes oneof_bytes_string_piece = 8
453        [ctype = STRING_PIECE, default = "default StringPiece"];
454    V2EnumLite oneof_enum = 9;
455  }
456}
457
458// The following four messages are set up to test for wire compatibility between
459// packed and non-packed repeated fields. We use the field number 2048, because
460// that is large enough to require a 3-byte varint for the tag.
461message PackedInt32 {
462  repeated int32 repeated_int32 = 2048 [packed = true];
463}
464
465message NonPackedInt32 {
466  repeated int32 repeated_int32 = 2048;
467}
468
469message PackedFixed32 {
470  repeated fixed32 repeated_fixed32 = 2048 [packed = true];
471}
472
473message NonPackedFixed32 {
474  repeated fixed32 repeated_fixed32 = 2048;
475}
476
477// Test an enum that has multiple values with the same number.
478message DupEnum {
479  enum TestEnumWithDupValueLite {
480    option allow_alias = true;
481
482    FOO1 = 1;
483    BAR1 = 2;
484    BAZ = 3;
485    FOO2 = 1;
486    BAR2 = 2;
487  }
488}
489