• 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
168message ForeignMessageLite {
169  optional int32 c = 1;
170}
171
172enum ForeignEnumLite {
173  FOREIGN_LITE_FOO = 4;
174  FOREIGN_LITE_BAR = 5;
175  FOREIGN_LITE_BAZ = 6;
176}
177
178message TestPackedTypesLite {
179  repeated    int32 packed_int32    =  90 [packed = true];
180  repeated    int64 packed_int64    =  91 [packed = true];
181  repeated   uint32 packed_uint32   =  92 [packed = true];
182  repeated   uint64 packed_uint64   =  93 [packed = true];
183  repeated   sint32 packed_sint32   =  94 [packed = true];
184  repeated   sint64 packed_sint64   =  95 [packed = true];
185  repeated  fixed32 packed_fixed32  =  96 [packed = true];
186  repeated  fixed64 packed_fixed64  =  97 [packed = true];
187  repeated sfixed32 packed_sfixed32 =  98 [packed = true];
188  repeated sfixed64 packed_sfixed64 =  99 [packed = true];
189  repeated    float packed_float    = 100 [packed = true];
190  repeated   double packed_double   = 101 [packed = true];
191  repeated     bool packed_bool     = 102 [packed = true];
192  repeated ForeignEnumLite packed_enum  = 103 [packed = true];
193}
194
195message TestAllExtensionsLite {
196  extensions 1 to max;
197}
198
199extend TestAllExtensionsLite {
200  // Singular
201  optional    int32 optional_int32_extension_lite    =  1;
202  optional    int64 optional_int64_extension_lite    =  2;
203  optional   uint32 optional_uint32_extension_lite   =  3;
204  optional   uint64 optional_uint64_extension_lite   =  4;
205  optional   sint32 optional_sint32_extension_lite   =  5;
206  optional   sint64 optional_sint64_extension_lite   =  6;
207  optional  fixed32 optional_fixed32_extension_lite  =  7;
208  optional  fixed64 optional_fixed64_extension_lite  =  8;
209  optional sfixed32 optional_sfixed32_extension_lite =  9;
210  optional sfixed64 optional_sfixed64_extension_lite = 10;
211  optional    float optional_float_extension_lite    = 11;
212  optional   double optional_double_extension_lite   = 12;
213  optional     bool optional_bool_extension_lite     = 13;
214  optional   string optional_string_extension_lite   = 14;
215  optional    bytes optional_bytes_extension_lite    = 15;
216
217  optional group OptionalGroup_extension_lite = 16 {
218    optional int32 a = 17;
219  }
220
221  optional TestAllTypesLite.NestedMessage optional_nested_message_extension_lite
222      = 18;
223  optional ForeignMessageLite optional_foreign_message_extension_lite = 19;
224  optional protobuf_unittest_import.ImportMessageLite
225    optional_import_message_extension_lite = 20;
226
227  optional TestAllTypesLite.NestedEnum optional_nested_enum_extension_lite = 21;
228  optional ForeignEnumLite optional_foreign_enum_extension_lite = 22;
229  optional protobuf_unittest_import.ImportEnumLite
230    optional_import_enum_extension_lite = 23;
231
232  optional string optional_string_piece_extension_lite = 24
233      [ctype=STRING_PIECE];
234  optional string optional_cord_extension_lite = 25 [ctype=CORD];
235
236  optional protobuf_unittest_import.PublicImportMessageLite
237    optional_public_import_message_extension_lite = 26;
238
239  optional TestAllTypesLite.NestedMessage
240    optional_lazy_message_extension_lite = 27 [lazy=true];
241
242  // Repeated
243  repeated    int32 repeated_int32_extension_lite    = 31;
244  repeated    int64 repeated_int64_extension_lite    = 32;
245  repeated   uint32 repeated_uint32_extension_lite   = 33;
246  repeated   uint64 repeated_uint64_extension_lite   = 34;
247  repeated   sint32 repeated_sint32_extension_lite   = 35;
248  repeated   sint64 repeated_sint64_extension_lite   = 36;
249  repeated  fixed32 repeated_fixed32_extension_lite  = 37;
250  repeated  fixed64 repeated_fixed64_extension_lite  = 38;
251  repeated sfixed32 repeated_sfixed32_extension_lite = 39;
252  repeated sfixed64 repeated_sfixed64_extension_lite = 40;
253  repeated    float repeated_float_extension_lite    = 41;
254  repeated   double repeated_double_extension_lite   = 42;
255  repeated     bool repeated_bool_extension_lite     = 43;
256  repeated   string repeated_string_extension_lite   = 44;
257  repeated    bytes repeated_bytes_extension_lite    = 45;
258
259  repeated group RepeatedGroup_extension_lite = 46 {
260    optional int32 a = 47;
261  }
262
263  repeated TestAllTypesLite.NestedMessage repeated_nested_message_extension_lite
264      = 48;
265  repeated ForeignMessageLite repeated_foreign_message_extension_lite = 49;
266  repeated protobuf_unittest_import.ImportMessageLite
267    repeated_import_message_extension_lite = 50;
268
269  repeated TestAllTypesLite.NestedEnum repeated_nested_enum_extension_lite = 51;
270  repeated ForeignEnumLite repeated_foreign_enum_extension_lite = 52;
271  repeated protobuf_unittest_import.ImportEnumLite
272    repeated_import_enum_extension_lite = 53;
273
274  repeated string repeated_string_piece_extension_lite = 54
275      [ctype=STRING_PIECE];
276  repeated string repeated_cord_extension_lite = 55 [ctype=CORD];
277
278  repeated TestAllTypesLite.NestedMessage
279    repeated_lazy_message_extension_lite = 57 [lazy=true];
280
281  // Singular with defaults
282  optional    int32 default_int32_extension_lite    = 61 [default =  41    ];
283  optional    int64 default_int64_extension_lite    = 62 [default =  42    ];
284  optional   uint32 default_uint32_extension_lite   = 63 [default =  43    ];
285  optional   uint64 default_uint64_extension_lite   = 64 [default =  44    ];
286  optional   sint32 default_sint32_extension_lite   = 65 [default = -45    ];
287  optional   sint64 default_sint64_extension_lite   = 66 [default =  46    ];
288  optional  fixed32 default_fixed32_extension_lite  = 67 [default =  47    ];
289  optional  fixed64 default_fixed64_extension_lite  = 68 [default =  48    ];
290  optional sfixed32 default_sfixed32_extension_lite = 69 [default =  49    ];
291  optional sfixed64 default_sfixed64_extension_lite = 70 [default = -50    ];
292  optional    float default_float_extension_lite    = 71 [default =  51.5  ];
293  optional   double default_double_extension_lite   = 72 [default =  52e3  ];
294  optional     bool default_bool_extension_lite     = 73 [default = true   ];
295  optional   string default_string_extension_lite   = 74 [default = "hello"];
296  optional    bytes default_bytes_extension_lite    = 75 [default = "world"];
297
298  optional TestAllTypesLite.NestedEnum
299    default_nested_enum_extension_lite = 81 [default = BAR];
300  optional ForeignEnumLite
301    default_foreign_enum_extension_lite = 82 [default = FOREIGN_LITE_BAR];
302  optional protobuf_unittest_import.ImportEnumLite
303    default_import_enum_extension_lite = 83 [default = IMPORT_LITE_BAR];
304
305  optional string default_string_piece_extension_lite = 84 [ctype=STRING_PIECE,
306                                                            default="abc"];
307  optional string default_cord_extension_lite = 85 [ctype=CORD, default="123"];
308
309  // For oneof test
310  optional uint32 oneof_uint32_extension_lite = 111;
311  optional TestAllTypesLite.NestedMessage oneof_nested_message_extension_lite = 112;
312  optional string oneof_string_extension_lite = 113;
313  optional bytes oneof_bytes_extension_lite = 114;
314}
315
316message TestPackedExtensionsLite {
317  extensions 1 to max;
318}
319
320extend TestPackedExtensionsLite {
321  repeated    int32 packed_int32_extension_lite    =  90 [packed = true];
322  repeated    int64 packed_int64_extension_lite    =  91 [packed = true];
323  repeated   uint32 packed_uint32_extension_lite   =  92 [packed = true];
324  repeated   uint64 packed_uint64_extension_lite   =  93 [packed = true];
325  repeated   sint32 packed_sint32_extension_lite   =  94 [packed = true];
326  repeated   sint64 packed_sint64_extension_lite   =  95 [packed = true];
327  repeated  fixed32 packed_fixed32_extension_lite  =  96 [packed = true];
328  repeated  fixed64 packed_fixed64_extension_lite  =  97 [packed = true];
329  repeated sfixed32 packed_sfixed32_extension_lite =  98 [packed = true];
330  repeated sfixed64 packed_sfixed64_extension_lite =  99 [packed = true];
331  repeated    float packed_float_extension_lite    = 100 [packed = true];
332  repeated   double packed_double_extension_lite   = 101 [packed = true];
333  repeated     bool packed_bool_extension_lite     = 102 [packed = true];
334  repeated ForeignEnumLite packed_enum_extension_lite = 103 [packed = true];
335}
336
337message TestNestedExtensionLite {
338  extend TestAllExtensionsLite {
339    optional int32 nested_extension = 12345;
340  }
341}
342
343// Test that deprecated fields work.  We only verify that they compile (at one
344// point this failed).
345message TestDeprecatedLite {
346  optional int32 deprecated_field = 1 [deprecated = true];
347}
348
349// See the comments of the same type in unittest.proto.
350message TestParsingMergeLite {
351  message RepeatedFieldsGenerator {
352    repeated TestAllTypesLite field1 = 1;
353    repeated TestAllTypesLite field2 = 2;
354    repeated TestAllTypesLite field3 = 3;
355    repeated group Group1 = 10 {
356      optional TestAllTypesLite field1 = 11;
357    }
358    repeated group Group2 = 20 {
359      optional TestAllTypesLite field1 = 21;
360    }
361    repeated TestAllTypesLite ext1 = 1000;
362    repeated TestAllTypesLite ext2 = 1001;
363  }
364  required TestAllTypesLite required_all_types = 1;
365  optional TestAllTypesLite optional_all_types = 2;
366  repeated TestAllTypesLite repeated_all_types = 3;
367  optional group OptionalGroup = 10 {
368    optional TestAllTypesLite optional_group_all_types = 11;
369  }
370  repeated group RepeatedGroup = 20 {
371    optional TestAllTypesLite repeated_group_all_types = 21;
372  }
373  extensions 1000 to max;
374  extend TestParsingMergeLite {
375    optional TestAllTypesLite optional_ext = 1000;
376    repeated TestAllTypesLite repeated_ext = 1001;
377  }
378}
379
380// TestEmptyMessageLite is used to test unknown fields support in lite mode.
381message TestEmptyMessageLite{
382}
383
384// Like above, but declare all field numbers as potential extensions.  No
385// actual extensions should ever be defined for this type.
386message TestEmptyMessageWithExtensionsLite {
387  extensions 1 to max;
388}
389
390enum V1EnumLite {
391    V1_FIRST = 1;
392}
393
394enum V2EnumLite {
395    V2_FIRST = 1;
396    V2_SECOND = 2;
397}
398
399message V1MessageLite {
400    required int32 int_field = 1;
401    optional V1EnumLite enum_field = 2 [ default = V1_FIRST ];
402}
403
404message V2MessageLite {
405    required int32 int_field = 1;
406    optional V2EnumLite enum_field = 2 [ default = V2_FIRST ];
407}
408