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
35package protobuf_unittest;
36
37import "google/protobuf/unittest_import_lite.proto";
38
39option optimize_for = LITE_RUNTIME;
40
41option java_package = "com.google.protobuf";
42
43// Same as TestAllTypes but with the lite runtime.
44message TestAllTypesLite {
45  message NestedMessage {
46    optional int32 bb = 1;
47  }
48
49  enum NestedEnum {
50    FOO = 1;
51    BAR = 2;
52    BAZ = 3;
53  }
54
55  // Singular
56  optional    int32 optional_int32    =  1;
57  optional    int64 optional_int64    =  2;
58  optional   uint32 optional_uint32   =  3;
59  optional   uint64 optional_uint64   =  4;
60  optional   sint32 optional_sint32   =  5;
61  optional   sint64 optional_sint64   =  6;
62  optional  fixed32 optional_fixed32  =  7;
63  optional  fixed64 optional_fixed64  =  8;
64  optional sfixed32 optional_sfixed32 =  9;
65  optional sfixed64 optional_sfixed64 = 10;
66  optional    float optional_float    = 11;
67  optional   double optional_double   = 12;
68  optional     bool optional_bool     = 13;
69  optional   string optional_string   = 14;
70  optional    bytes optional_bytes    = 15;
71
72  optional group OptionalGroup = 16 {
73    optional int32 a = 17;
74  }
75
76  optional NestedMessage      optional_nested_message  = 18;
77  optional ForeignMessageLite optional_foreign_message = 19;
78  optional protobuf_unittest_import.ImportMessageLite
79    optional_import_message = 20;
80
81  optional NestedEnum      optional_nested_enum     = 21;
82  optional ForeignEnumLite optional_foreign_enum    = 22;
83  optional protobuf_unittest_import.ImportEnumLite optional_import_enum = 23;
84
85  optional string optional_string_piece = 24 [ctype=STRING_PIECE];
86  optional string optional_cord = 25 [ctype=CORD];
87
88  // Defined in unittest_import_public.proto
89  optional protobuf_unittest_import.PublicImportMessageLite
90      optional_public_import_message = 26;
91
92  optional NestedMessage optional_lazy_message = 27 [lazy=true];
93
94  // Repeated
95  repeated    int32 repeated_int32    = 31;
96  repeated    int64 repeated_int64    = 32;
97  repeated   uint32 repeated_uint32   = 33;
98  repeated   uint64 repeated_uint64   = 34;
99  repeated   sint32 repeated_sint32   = 35;
100  repeated   sint64 repeated_sint64   = 36;
101  repeated  fixed32 repeated_fixed32  = 37;
102  repeated  fixed64 repeated_fixed64  = 38;
103  repeated sfixed32 repeated_sfixed32 = 39;
104  repeated sfixed64 repeated_sfixed64 = 40;
105  repeated    float repeated_float    = 41;
106  repeated   double repeated_double   = 42;
107  repeated     bool repeated_bool     = 43;
108  repeated   string repeated_string   = 44;
109  repeated    bytes repeated_bytes    = 45;
110
111  repeated group RepeatedGroup = 46 {
112    optional int32 a = 47;
113  }
114
115  repeated NestedMessage      repeated_nested_message  = 48;
116  repeated ForeignMessageLite repeated_foreign_message = 49;
117  repeated protobuf_unittest_import.ImportMessageLite
118    repeated_import_message = 50;
119
120  repeated NestedEnum      repeated_nested_enum  = 51;
121  repeated ForeignEnumLite repeated_foreign_enum = 52;
122  repeated protobuf_unittest_import.ImportEnumLite repeated_import_enum = 53;
123
124  repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
125  repeated string repeated_cord = 55 [ctype=CORD];
126
127  repeated NestedMessage repeated_lazy_message = 57 [lazy=true];
128
129  // Singular with defaults
130  optional    int32 default_int32    = 61 [default =  41    ];
131  optional    int64 default_int64    = 62 [default =  42    ];
132  optional   uint32 default_uint32   = 63 [default =  43    ];
133  optional   uint64 default_uint64   = 64 [default =  44    ];
134  optional   sint32 default_sint32   = 65 [default = -45    ];
135  optional   sint64 default_sint64   = 66 [default =  46    ];
136  optional  fixed32 default_fixed32  = 67 [default =  47    ];
137  optional  fixed64 default_fixed64  = 68 [default =  48    ];
138  optional sfixed32 default_sfixed32 = 69 [default =  49    ];
139  optional sfixed64 default_sfixed64 = 70 [default = -50    ];
140  optional    float default_float    = 71 [default =  51.5  ];
141  optional   double default_double   = 72 [default =  52e3  ];
142  optional     bool default_bool     = 73 [default = true   ];
143  optional   string default_string   = 74 [default = "hello"];
144  optional    bytes default_bytes    = 75 [default = "world"];
145
146  optional NestedEnum default_nested_enum = 81 [default = BAR];
147  optional ForeignEnumLite default_foreign_enum = 82
148      [default = FOREIGN_LITE_BAR];
149  optional protobuf_unittest_import.ImportEnumLite
150      default_import_enum = 83 [default = IMPORT_LITE_BAR];
151
152  optional string default_string_piece = 84 [ctype=STRING_PIECE,default="abc"];
153  optional string default_cord = 85 [ctype=CORD,default="123"];
154
155  // For oneof test
156  oneof oneof_field {
157    uint32 oneof_uint32 = 111;
158    NestedMessage oneof_nested_message = 112;
159    string oneof_string = 113;
160    bytes oneof_bytes = 114;
161  }
162}
163
164message ForeignMessageLite {
165  optional int32 c = 1;
166}
167
168enum ForeignEnumLite {
169  FOREIGN_LITE_FOO = 4;
170  FOREIGN_LITE_BAR = 5;
171  FOREIGN_LITE_BAZ = 6;
172}
173
174message TestPackedTypesLite {
175  repeated    int32 packed_int32    =  90 [packed = true];
176  repeated    int64 packed_int64    =  91 [packed = true];
177  repeated   uint32 packed_uint32   =  92 [packed = true];
178  repeated   uint64 packed_uint64   =  93 [packed = true];
179  repeated   sint32 packed_sint32   =  94 [packed = true];
180  repeated   sint64 packed_sint64   =  95 [packed = true];
181  repeated  fixed32 packed_fixed32  =  96 [packed = true];
182  repeated  fixed64 packed_fixed64  =  97 [packed = true];
183  repeated sfixed32 packed_sfixed32 =  98 [packed = true];
184  repeated sfixed64 packed_sfixed64 =  99 [packed = true];
185  repeated    float packed_float    = 100 [packed = true];
186  repeated   double packed_double   = 101 [packed = true];
187  repeated     bool packed_bool     = 102 [packed = true];
188  repeated ForeignEnumLite packed_enum  = 103 [packed = true];
189}
190
191message TestAllExtensionsLite {
192  extensions 1 to max;
193}
194
195extend TestAllExtensionsLite {
196  // Singular
197  optional    int32 optional_int32_extension_lite    =  1;
198  optional    int64 optional_int64_extension_lite    =  2;
199  optional   uint32 optional_uint32_extension_lite   =  3;
200  optional   uint64 optional_uint64_extension_lite   =  4;
201  optional   sint32 optional_sint32_extension_lite   =  5;
202  optional   sint64 optional_sint64_extension_lite   =  6;
203  optional  fixed32 optional_fixed32_extension_lite  =  7;
204  optional  fixed64 optional_fixed64_extension_lite  =  8;
205  optional sfixed32 optional_sfixed32_extension_lite =  9;
206  optional sfixed64 optional_sfixed64_extension_lite = 10;
207  optional    float optional_float_extension_lite    = 11;
208  optional   double optional_double_extension_lite   = 12;
209  optional     bool optional_bool_extension_lite     = 13;
210  optional   string optional_string_extension_lite   = 14;
211  optional    bytes optional_bytes_extension_lite    = 15;
212
213  optional group OptionalGroup_extension_lite = 16 {
214    optional int32 a = 17;
215  }
216
217  optional TestAllTypesLite.NestedMessage optional_nested_message_extension_lite
218      = 18;
219  optional ForeignMessageLite optional_foreign_message_extension_lite = 19;
220  optional protobuf_unittest_import.ImportMessageLite
221    optional_import_message_extension_lite = 20;
222
223  optional TestAllTypesLite.NestedEnum optional_nested_enum_extension_lite = 21;
224  optional ForeignEnumLite optional_foreign_enum_extension_lite = 22;
225  optional protobuf_unittest_import.ImportEnumLite
226    optional_import_enum_extension_lite = 23;
227
228  optional string optional_string_piece_extension_lite = 24
229      [ctype=STRING_PIECE];
230  optional string optional_cord_extension_lite = 25 [ctype=CORD];
231
232  optional protobuf_unittest_import.PublicImportMessageLite
233    optional_public_import_message_extension_lite = 26;
234
235  optional TestAllTypesLite.NestedMessage
236    optional_lazy_message_extension_lite = 27 [lazy=true];
237
238  // Repeated
239  repeated    int32 repeated_int32_extension_lite    = 31;
240  repeated    int64 repeated_int64_extension_lite    = 32;
241  repeated   uint32 repeated_uint32_extension_lite   = 33;
242  repeated   uint64 repeated_uint64_extension_lite   = 34;
243  repeated   sint32 repeated_sint32_extension_lite   = 35;
244  repeated   sint64 repeated_sint64_extension_lite   = 36;
245  repeated  fixed32 repeated_fixed32_extension_lite  = 37;
246  repeated  fixed64 repeated_fixed64_extension_lite  = 38;
247  repeated sfixed32 repeated_sfixed32_extension_lite = 39;
248  repeated sfixed64 repeated_sfixed64_extension_lite = 40;
249  repeated    float repeated_float_extension_lite    = 41;
250  repeated   double repeated_double_extension_lite   = 42;
251  repeated     bool repeated_bool_extension_lite     = 43;
252  repeated   string repeated_string_extension_lite   = 44;
253  repeated    bytes repeated_bytes_extension_lite    = 45;
254
255  repeated group RepeatedGroup_extension_lite = 46 {
256    optional int32 a = 47;
257  }
258
259  repeated TestAllTypesLite.NestedMessage repeated_nested_message_extension_lite
260      = 48;
261  repeated ForeignMessageLite repeated_foreign_message_extension_lite = 49;
262  repeated protobuf_unittest_import.ImportMessageLite
263    repeated_import_message_extension_lite = 50;
264
265  repeated TestAllTypesLite.NestedEnum repeated_nested_enum_extension_lite = 51;
266  repeated ForeignEnumLite repeated_foreign_enum_extension_lite = 52;
267  repeated protobuf_unittest_import.ImportEnumLite
268    repeated_import_enum_extension_lite = 53;
269
270  repeated string repeated_string_piece_extension_lite = 54
271      [ctype=STRING_PIECE];
272  repeated string repeated_cord_extension_lite = 55 [ctype=CORD];
273
274  repeated TestAllTypesLite.NestedMessage
275    repeated_lazy_message_extension_lite = 57 [lazy=true];
276
277  // Singular with defaults
278  optional    int32 default_int32_extension_lite    = 61 [default =  41    ];
279  optional    int64 default_int64_extension_lite    = 62 [default =  42    ];
280  optional   uint32 default_uint32_extension_lite   = 63 [default =  43    ];
281  optional   uint64 default_uint64_extension_lite   = 64 [default =  44    ];
282  optional   sint32 default_sint32_extension_lite   = 65 [default = -45    ];
283  optional   sint64 default_sint64_extension_lite   = 66 [default =  46    ];
284  optional  fixed32 default_fixed32_extension_lite  = 67 [default =  47    ];
285  optional  fixed64 default_fixed64_extension_lite  = 68 [default =  48    ];
286  optional sfixed32 default_sfixed32_extension_lite = 69 [default =  49    ];
287  optional sfixed64 default_sfixed64_extension_lite = 70 [default = -50    ];
288  optional    float default_float_extension_lite    = 71 [default =  51.5  ];
289  optional   double default_double_extension_lite   = 72 [default =  52e3  ];
290  optional     bool default_bool_extension_lite     = 73 [default = true   ];
291  optional   string default_string_extension_lite   = 74 [default = "hello"];
292  optional    bytes default_bytes_extension_lite    = 75 [default = "world"];
293
294  optional TestAllTypesLite.NestedEnum
295    default_nested_enum_extension_lite = 81 [default = BAR];
296  optional ForeignEnumLite
297    default_foreign_enum_extension_lite = 82 [default = FOREIGN_LITE_BAR];
298  optional protobuf_unittest_import.ImportEnumLite
299    default_import_enum_extension_lite = 83 [default = IMPORT_LITE_BAR];
300
301  optional string default_string_piece_extension_lite = 84 [ctype=STRING_PIECE,
302                                                            default="abc"];
303  optional string default_cord_extension_lite = 85 [ctype=CORD, default="123"];
304
305  // For oneof test
306  optional uint32 oneof_uint32_extension_lite = 111;
307  optional TestAllTypesLite.NestedMessage oneof_nested_message_extension_lite = 112;
308  optional string oneof_string_extension_lite = 113;
309  optional bytes oneof_bytes_extension_lite = 114;
310}
311
312message TestPackedExtensionsLite {
313  extensions 1 to max;
314}
315
316extend TestPackedExtensionsLite {
317  repeated    int32 packed_int32_extension_lite    =  90 [packed = true];
318  repeated    int64 packed_int64_extension_lite    =  91 [packed = true];
319  repeated   uint32 packed_uint32_extension_lite   =  92 [packed = true];
320  repeated   uint64 packed_uint64_extension_lite   =  93 [packed = true];
321  repeated   sint32 packed_sint32_extension_lite   =  94 [packed = true];
322  repeated   sint64 packed_sint64_extension_lite   =  95 [packed = true];
323  repeated  fixed32 packed_fixed32_extension_lite  =  96 [packed = true];
324  repeated  fixed64 packed_fixed64_extension_lite  =  97 [packed = true];
325  repeated sfixed32 packed_sfixed32_extension_lite =  98 [packed = true];
326  repeated sfixed64 packed_sfixed64_extension_lite =  99 [packed = true];
327  repeated    float packed_float_extension_lite    = 100 [packed = true];
328  repeated   double packed_double_extension_lite   = 101 [packed = true];
329  repeated     bool packed_bool_extension_lite     = 102 [packed = true];
330  repeated ForeignEnumLite packed_enum_extension_lite = 103 [packed = true];
331}
332
333message TestNestedExtensionLite {
334  extend TestAllExtensionsLite {
335    optional int32 nested_extension = 12345;
336  }
337}
338
339// Test that deprecated fields work.  We only verify that they compile (at one
340// point this failed).
341message TestDeprecatedLite {
342  optional int32 deprecated_field = 1 [deprecated = true];
343}
344
345// See the comments of the same type in unittest.proto.
346message TestParsingMergeLite {
347  message RepeatedFieldsGenerator {
348    repeated TestAllTypesLite field1 = 1;
349    repeated TestAllTypesLite field2 = 2;
350    repeated TestAllTypesLite field3 = 3;
351    repeated group Group1 = 10 {
352      optional TestAllTypesLite field1 = 11;
353    }
354    repeated group Group2 = 20 {
355      optional TestAllTypesLite field1 = 21;
356    }
357    repeated TestAllTypesLite ext1 = 1000;
358    repeated TestAllTypesLite ext2 = 1001;
359  }
360  required TestAllTypesLite required_all_types = 1;
361  optional TestAllTypesLite optional_all_types = 2;
362  repeated TestAllTypesLite repeated_all_types = 3;
363  optional group OptionalGroup = 10 {
364    optional TestAllTypesLite optional_group_all_types = 11;
365  }
366  repeated group RepeatedGroup = 20 {
367    optional TestAllTypesLite repeated_group_all_types = 21;
368  }
369  extensions 1000 to max;
370  extend TestParsingMergeLite {
371    optional TestAllTypesLite optional_ext = 1000;
372    repeated TestAllTypesLite repeated_ext = 1001;
373  }
374}
375
376// TestEmptyMessageLite is used to test unknown fields support in lite mode.
377message TestEmptyMessageLite{
378}
379
380// Like above, but declare all field numbers as potential extensions.  No
381// actual extensions should ever be defined for this type.
382message TestEmptyMessageWithExtensionsLite {
383  extensions 1 to max;
384}
385