• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Protocol Buffers - Google's data interchange format
2// Copyright 2008 Google Inc.  All rights reserved.
3//
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file or at
6// https://developers.google.com/open-source/licenses/bsd
7
8// LINT: ALLOW_GROUPS, LEGACY_NAMES
9
10syntax = "proto2";
11
12import "objectivec/Tests/unittest_import.proto";
13
14// Explicit empty prefix, tests some validations code paths also.
15option objc_class_prefix = "";
16
17package objc.protobuf.tests;
18
19// This proto includes every type of field in both singular and repeated
20// forms.
21message TestAllTypes {
22  message NestedMessage {
23    // The field name "b" fails to compile in proto1 because it conflicts with
24    // a local variable named "b" in one of the generated methods.  Doh.
25    // This file needs to compile in proto1 to test backwards-compatibility.
26    optional int32 bb = 1;
27  }
28
29  enum NestedEnum {
30    FOO = 1;
31    BAR = 2;
32    BAZ = 3;
33    NEG = -1;  // Intentionally negative.
34  }
35
36  // Singular
37  optional    int32 optional_int32    =  1;
38  optional    int64 optional_int64    =  2;
39  optional   uint32 optional_uint32   =  3;
40  optional   uint64 optional_uint64   =  4;
41  optional   sint32 optional_sint32   =  5;
42  optional   sint64 optional_sint64   =  6;
43  optional  fixed32 optional_fixed32  =  7;
44  optional  fixed64 optional_fixed64  =  8;
45  optional sfixed32 optional_sfixed32 =  9;
46  optional sfixed64 optional_sfixed64 = 10;
47  optional    float optional_float    = 11;
48  optional   double optional_double   = 12;
49  optional     bool optional_bool     = 13;
50  optional   string optional_string   = 14;
51  optional    bytes optional_bytes    = 15;
52
53  optional group OptionalGroup = 16 {
54    optional int32 a = 17;
55  }
56
57  optional NestedMessage                        optional_nested_message  = 18;
58  optional ForeignMessage                       optional_foreign_message = 19;
59  optional objc.protobuf.tests.import.Message   optional_import_message  = 20;
60
61  optional NestedEnum                           optional_nested_enum     = 21;
62  optional ForeignEnum                          optional_foreign_enum    = 22;
63  optional objc.protobuf.tests.import.Enum      optional_import_enum     = 23;
64
65  optional string optional_string_piece = 24 [ctype=STRING_PIECE];
66  optional string optional_cord = 25 [ctype=CORD];
67
68  // Defined in unittest_import_public.proto
69  optional objc.protobuf.tests.public_import.Message
70      optional_public_import_message = 26;
71
72  optional NestedMessage optional_lazy_message = 27 [lazy=true];
73  optional NestedMessage optional_unverified_lazy_message = 28 [unverified_lazy=true];
74
75  // Repeated
76  repeated    int32 repeated_int32    = 31;
77  repeated    int64 repeated_int64    = 32;
78  repeated   uint32 repeated_uint32   = 33;
79  repeated   uint64 repeated_uint64   = 34;
80  repeated   sint32 repeated_sint32   = 35;
81  repeated   sint64 repeated_sint64   = 36;
82  repeated  fixed32 repeated_fixed32  = 37;
83  repeated  fixed64 repeated_fixed64  = 38;
84  repeated sfixed32 repeated_sfixed32 = 39;
85  repeated sfixed64 repeated_sfixed64 = 40;
86  repeated    float repeated_float    = 41;
87  repeated   double repeated_double   = 42;
88  repeated     bool repeated_bool     = 43;
89  repeated   string repeated_string   = 44;
90  repeated    bytes repeated_bytes    = 45;
91
92  repeated group RepeatedGroup = 46 {
93    optional int32 a = 47;
94  }
95
96  repeated NestedMessage                        repeated_nested_message  = 48;
97  repeated ForeignMessage                       repeated_foreign_message = 49;
98  repeated objc.protobuf.tests.import.Message   repeated_import_message  = 50;
99
100  repeated NestedEnum                           repeated_nested_enum     = 51;
101  repeated ForeignEnum                          repeated_foreign_enum    = 52;
102  repeated objc.protobuf.tests.import.Enum      repeated_import_enum     = 53;
103
104  repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
105  repeated string repeated_cord = 55 [ctype=CORD];
106
107  repeated NestedMessage repeated_lazy_message = 57 ;
108
109  // Singular with defaults
110  optional    int32 default_int32    = 61 [default =  41    ];
111  optional    int64 default_int64    = 62 [default =  42    ];
112  optional   uint32 default_uint32   = 63 [default =  43    ];
113  optional   uint64 default_uint64   = 64 [default =  44    ];
114  optional   sint32 default_sint32   = 65 [default = -45    ];
115  optional   sint64 default_sint64   = 66 [default =  46    ];
116  optional  fixed32 default_fixed32  = 67 [default =  47    ];
117  optional  fixed64 default_fixed64  = 68 [default =  48    ];
118  optional sfixed32 default_sfixed32 = 69 [default =  49    ];
119  optional sfixed64 default_sfixed64 = 70 [default = -50    ];
120  optional    float default_float    = 71 [default =  51.5  ];
121  optional   double default_double   = 72 [default =  52e3  ];
122  optional     bool default_bool     = 73 [default = true   ];
123  optional   string default_string   = 74 [default = "hello"];
124  optional    bytes default_bytes    = 75 [default = "world"];
125
126  optional NestedEnum  default_nested_enum  = 81 [default = BAR        ];
127  optional ForeignEnum default_foreign_enum = 82 [default = FOREIGN_BAR];
128  optional objc.protobuf.tests.import.Enum
129      default_import_enum = 83 [default = IMPORT_BAR];
130
131  optional string default_string_piece = 84 [ctype=STRING_PIECE,default="abc"];
132  optional string default_cord = 85 [ctype=CORD,default="123"];
133
134  // For oneof test
135  oneof oneof_field {
136    uint32 oneof_uint32 = 111;
137    NestedMessage oneof_nested_message = 112;
138    string oneof_string = 113;
139    bytes oneof_bytes = 114;
140  }
141}
142
143// This proto includes a recursively nested message.
144message NestedTestAllTypes {
145  optional NestedTestAllTypes child = 1;
146  optional TestAllTypes payload = 2;
147  repeated NestedTestAllTypes repeated_child = 3;
148  optional NestedTestAllTypes lazy_child = 4 [lazy=true];
149  optional TestAllTypes eager_child = 5 [lazy=false];
150}
151
152message TestDeprecatedFields {
153  optional int32 deprecated_int32 = 1 [deprecated=true];
154  oneof oneof_fields {
155    int32 deprecated_int32_in_oneof = 2 [deprecated=true];
156  }
157}
158
159message TestDeprecatedMessage {
160  option deprecated = true;
161}
162
163// Define these after TestAllTypes to make sure the compiler can handle
164// that.
165message ForeignMessage {
166  optional int32 c = 1;
167  optional int32 d = 2;
168}
169
170enum ForeignEnum {
171  FOREIGN_FOO = 4;
172  FOREIGN_BAR = 5;
173  FOREIGN_BAZ = 6;
174}
175
176message TestReservedFields {
177  reserved 2, 15, 9 to 11;
178  reserved "bar", "baz";
179}
180
181enum TestReservedEnumFields {
182  UNKNOWN = 0;
183  reserved 2, 15, 9 to 11;
184  reserved "bar", "baz";
185}
186
187message TestAllExtensions {
188  extensions 1 to max;
189}
190
191extend TestAllExtensions {
192  // Singular
193  optional    int32 optional_int32_extension    =  1;
194  optional    int64 optional_int64_extension    =  2;
195  optional   uint32 optional_uint32_extension   =  3;
196  optional   uint64 optional_uint64_extension   =  4;
197  optional   sint32 optional_sint32_extension   =  5;
198  optional   sint64 optional_sint64_extension   =  6;
199  optional  fixed32 optional_fixed32_extension  =  7;
200  optional  fixed64 optional_fixed64_extension  =  8;
201  optional sfixed32 optional_sfixed32_extension =  9;
202  optional sfixed64 optional_sfixed64_extension = 10;
203  optional    float optional_float_extension    = 11;
204  optional   double optional_double_extension   = 12;
205  optional     bool optional_bool_extension     = 13;
206  optional   string optional_string_extension   = 14;
207  optional    bytes optional_bytes_extension    = 15;
208
209  optional group OptionalGroup_extension = 16 {
210    optional int32 a = 17;
211  }
212
213  optional TestAllTypes.NestedMessage optional_nested_message_extension = 18;
214  optional ForeignMessage optional_foreign_message_extension = 19;
215  optional objc.protobuf.tests.import.Message
216    optional_import_message_extension = 20;
217
218  optional TestAllTypes.NestedEnum optional_nested_enum_extension = 21;
219  optional ForeignEnum optional_foreign_enum_extension = 22;
220  optional objc.protobuf.tests.import.Enum
221    optional_import_enum_extension = 23;
222
223  optional string optional_string_piece_extension = 24 [ctype=STRING_PIECE];
224  optional string optional_cord_extension = 25;
225
226  optional objc.protobuf.tests.public_import.Message
227    optional_public_import_message_extension = 26;
228
229  optional TestAllTypes.NestedMessage
230    optional_lazy_message_extension = 27 [lazy=true];
231  optional TestAllTypes.NestedMessage
232    optional_unverified_lazy_message_extension = 28 [unverified_lazy=true];
233
234  // Repeated
235  repeated    int32 repeated_int32_extension    = 31;
236  repeated    int64 repeated_int64_extension    = 32;
237  repeated   uint32 repeated_uint32_extension   = 33;
238  repeated   uint64 repeated_uint64_extension   = 34;
239  repeated   sint32 repeated_sint32_extension   = 35;
240  repeated   sint64 repeated_sint64_extension   = 36;
241  repeated  fixed32 repeated_fixed32_extension  = 37;
242  repeated  fixed64 repeated_fixed64_extension  = 38;
243  repeated sfixed32 repeated_sfixed32_extension = 39;
244  repeated sfixed64 repeated_sfixed64_extension = 40;
245  repeated    float repeated_float_extension    = 41;
246  repeated   double repeated_double_extension   = 42;
247  repeated     bool repeated_bool_extension     = 43;
248  repeated   string repeated_string_extension   = 44;
249  repeated    bytes repeated_bytes_extension    = 45;
250
251  repeated group RepeatedGroup_extension = 46 {
252    optional int32 a = 47;
253  }
254
255  repeated TestAllTypes.NestedMessage repeated_nested_message_extension = 48;
256  repeated ForeignMessage repeated_foreign_message_extension = 49;
257  repeated objc.protobuf.tests.import.Message
258    repeated_import_message_extension = 50;
259
260  repeated TestAllTypes.NestedEnum repeated_nested_enum_extension = 51;
261  repeated ForeignEnum repeated_foreign_enum_extension = 52;
262  repeated objc.protobuf.tests.import.Enum
263    repeated_import_enum_extension = 53;
264
265  repeated string repeated_string_piece_extension = 54 [ctype=STRING_PIECE];
266  repeated string repeated_cord_extension = 55;
267
268  repeated TestAllTypes.NestedMessage
269    repeated_lazy_message_extension = 57 [lazy=true];
270
271  // Singular with defaults
272  optional    int32 default_int32_extension    = 61 [default =  41    ];
273  optional    int64 default_int64_extension    = 62 [default =  42    ];
274  optional   uint32 default_uint32_extension   = 63 [default =  43    ];
275  optional   uint64 default_uint64_extension   = 64 [default =  44    ];
276  optional   sint32 default_sint32_extension   = 65 [default = -45    ];
277  optional   sint64 default_sint64_extension   = 66 [default =  46    ];
278  optional  fixed32 default_fixed32_extension  = 67 [default =  47    ];
279  optional  fixed64 default_fixed64_extension  = 68 [default =  48    ];
280  optional sfixed32 default_sfixed32_extension = 69 [default =  49    ];
281  optional sfixed64 default_sfixed64_extension = 70 [default = -50    ];
282  optional    float default_float_extension    = 71 [default =  51.5  ];
283  optional   double default_double_extension   = 72 [default =  52e3  ];
284  optional     bool default_bool_extension     = 73 [default = true   ];
285  optional   string default_string_extension   = 74 [default = "hello"];
286  optional    bytes default_bytes_extension    = 75 [default = "world"];
287
288  optional TestAllTypes.NestedEnum
289    default_nested_enum_extension = 81 [default = BAR];
290  optional ForeignEnum
291    default_foreign_enum_extension = 82 [default = FOREIGN_BAR];
292  optional objc.protobuf.tests.import.Enum
293    default_import_enum_extension = 83 [default = IMPORT_BAR];
294
295  optional string default_string_piece_extension = 84 [ctype=STRING_PIECE,
296                                                       default="abc"];
297  optional string default_cord_extension = 85 [default="123"];
298
299  // For oneof test
300  optional uint32 oneof_uint32_extension = 111;
301  optional TestAllTypes.NestedMessage oneof_nested_message_extension = 112;
302  optional string oneof_string_extension = 113;
303  optional bytes oneof_bytes_extension = 114;
304}
305
306message TestMixedFieldsAndExtensions {
307  optional int32 a = 1;
308  repeated fixed32 b = 3;
309  extensions 2, 4;
310  extend TestMixedFieldsAndExtensions {
311    optional int32 c = 2;
312    repeated fixed32 d = 4;
313  }
314}
315
316message TestGroup {
317  optional group OptionalGroup = 16 {
318    optional int32 a = 17;
319  }
320  optional ForeignEnum optional_foreign_enum = 22;
321}
322
323message TestGroupExtension {
324  extensions 1 to max;
325}
326
327message TestNestedExtension {
328  extend TestAllExtensions {
329    // Check for bug where string extensions declared in tested scope did not
330    // compile.
331    optional string test = 1002 [default="test"];
332    // Used to test if generated extension name is correct when there are
333    // underscores.
334    optional string nested_string_extension = 1003;
335  }
336
337  extend TestGroupExtension {
338    optional group OptionalGroup_extension = 16 {
339      optional int32 a = 17;
340    }
341    optional ForeignEnum optional_foreign_enum_extension = 22;
342  }
343}
344
345message TestChildExtension {
346  optional string a = 1;
347  optional string b = 2;
348  optional TestAllExtensions optional_extension = 3;
349}
350
351// Emulates wireformat data of TestChildExtension with dynamic extension
352// (DynamicExtension).
353message TestChildExtensionData {
354  message NestedTestAllExtensionsData {
355    message NestedDynamicExtensions {
356      optional int32 a = 1;
357      optional int32 b = 2;
358    }
359    optional NestedDynamicExtensions dynamic = 409707008;
360  }
361  optional string a = 1;
362  optional string b = 2;
363  optional NestedTestAllExtensionsData optional_extension = 3;
364}
365
366message TestNestedChildExtension {
367  optional int32 a = 1;
368  optional TestChildExtension child = 2;
369}
370
371// Emulates wireformat data of TestNestedChildExtension with dynamic extension
372// (DynamicExtension).
373message TestNestedChildExtensionData {
374  optional int32 a = 1;
375  optional TestChildExtensionData child = 2;
376}
377
378// We have separate messages for testing required fields because it's
379// annoying to have to fill in required fields in TestProto in order to
380// do anything with it.  Note that we don't need to test every type of
381// required filed because the code output is basically identical to
382// optional fields for all types.
383message TestRequired {
384  required int32 a = 1;
385  optional int32 dummy2 = 2;
386  required int32 b = 3;
387
388  extend TestAllExtensions {
389    optional TestRequired single = 1000;
390    repeated TestRequired multi  = 1001;
391  }
392
393  // Pad the field count to 32 so that we can test that IsInitialized()
394  // properly checks multiple elements of has_bits_.
395  optional int32 dummy4  =  4;
396  optional int32 dummy5  =  5;
397  optional int32 dummy6  =  6;
398  optional int32 dummy7  =  7;
399  optional int32 dummy8  =  8;
400  optional int32 dummy9  =  9;
401  optional int32 dummy10 = 10;
402  optional int32 dummy11 = 11;
403  optional int32 dummy12 = 12;
404  optional int32 dummy13 = 13;
405  optional int32 dummy14 = 14;
406  optional int32 dummy15 = 15;
407  optional int32 dummy16 = 16;
408  optional int32 dummy17 = 17;
409  optional int32 dummy18 = 18;
410  optional int32 dummy19 = 19;
411  optional int32 dummy20 = 20;
412  optional int32 dummy21 = 21;
413  optional int32 dummy22 = 22;
414  optional int32 dummy23 = 23;
415  optional int32 dummy24 = 24;
416  optional int32 dummy25 = 25;
417  optional int32 dummy26 = 26;
418  optional int32 dummy27 = 27;
419  optional int32 dummy28 = 28;
420  optional int32 dummy29 = 29;
421  optional int32 dummy30 = 30;
422  optional int32 dummy31 = 31;
423  optional int32 dummy32 = 32;
424
425  required int32 c = 33;
426
427  // Add an optional child message to make this non-trivial for go/pdlazy.
428  optional ForeignMessage optional_foreign = 34;
429}
430
431message TestRequiredForeign {
432  optional TestRequired optional_message = 1;
433  repeated TestRequired repeated_message = 2;
434  optional int32 dummy = 3;
435
436  // Missing required fields must not affect verification of child messages.
437  optional NestedTestAllTypes optional_lazy_message = 4 [lazy = true];
438}
439
440message TestRequiredMessage {
441  optional TestRequired optional_message = 1;
442  repeated TestRequired repeated_message = 2;
443  required TestRequired required_message = 3;
444}
445
446message TestNestedRequiredForeign {
447  optional TestNestedRequiredForeign child = 1;
448  optional TestRequiredForeign payload = 2;
449  optional int32 dummy = 3;
450}
451
452// Test that we can use NestedMessage from outside TestAllTypes.
453message TestForeignNested {
454  optional TestAllTypes.NestedMessage foreign_nested = 1;
455}
456
457// TestEmptyMessage is used to test unknown field support.
458message TestEmptyMessage {
459}
460
461// Like above, but declare all field numbers as potential extensions.  No
462// actual extensions should ever be defined for this type.
463message TestEmptyMessageWithExtensions {
464  extensions 1 to max;
465}
466
467// Needed for a Python test.
468message TestPickleNestedMessage {
469  message NestedMessage {
470    optional int32 bb = 1;
471    message NestedNestedMessage {
472      optional int32 cc = 1;
473    }
474  }
475}
476
477message TestMultipleExtensionRanges {
478  extensions 42;
479  extensions 4143 to 4243;
480  extensions 65536 to max;
481}
482
483// Test that really large tag numbers don't break anything.
484message TestReallyLargeTagNumber {
485  // The largest possible tag number is 2^28 - 1, since the wire format uses
486  // three bits to communicate wire type.
487  optional int32 a = 1;
488  optional int32 bb = 268435455;
489}
490
491message TestRecursiveMessage {
492  optional TestRecursiveMessage a = 1;
493  optional int32 i = 2;
494}
495
496// Test that mutual recursion works.
497message TestMutualRecursionA {
498  message SubMessage {
499    optional TestMutualRecursionB b = 1;
500  }
501  optional TestMutualRecursionB bb = 1;
502  optional group SubGroup = 2 {
503    optional SubMessage sub_message = 3;  // Needed because of bug in javatest
504    optional TestAllTypes not_in_this_scc = 4;
505  }
506}
507
508message TestMutualRecursionB {
509  optional TestMutualRecursionA a = 1;
510  optional int32 optional_int32 = 2;
511}
512
513message TestIsInitialized {
514  message SubMessage {
515    optional group SubGroup = 1 {
516      required int32 i = 2;
517    }
518  }
519  optional SubMessage sub_message = 1;
520}
521
522// Test that groups have disjoint field numbers from their siblings and
523// parents.  This is NOT possible in proto1; only google.protobuf.  When attempting
524// to compile with proto1, this will emit an error; so we only include it
525// in objc.protobuf.tests_proto.
526message TestDupFieldNumber {                        // NO_PROTO1
527  optional int32 a = 1;                             // NO_PROTO1
528  optional group Foo = 2 { optional int32 a = 1; }  // NO_PROTO1
529  optional group Bar = 3 { optional int32 a = 1; }  // NO_PROTO1
530}                                                   // NO_PROTO1
531
532// Additional messages for testing lazy fields.
533message TestEagerMessage {
534  optional TestAllTypes sub_message = 1 [lazy=false];
535}
536message TestLazyMessage {
537  optional TestAllTypes sub_message = 1 [lazy=true];
538}
539message TestEagerMaybeLazy {
540  message NestedMessage {
541    optional TestPackedTypes packed = 1;
542  }
543  optional TestAllTypes message_foo = 1;
544  optional TestAllTypes message_bar = 2;
545  optional NestedMessage message_baz = 3;
546}
547// Needed for a Python test.
548message TestNestedMessageHasBits {
549  message NestedMessage {
550    repeated int32 nestedmessage_repeated_int32 = 1;
551    repeated ForeignMessage nestedmessage_repeated_foreignmessage = 2;
552  }
553  optional NestedMessage optional_nested_message = 1;
554}
555
556
557// Test an enum that has multiple values with the same number.
558enum TestEnumWithDupValue {
559  option allow_alias = true;
560
561  FOO1 = 1;
562  BAR1 = 2;
563  BAZ = 3;
564  FOO2 = 1;
565  BAR2 = 2;
566}
567
568// Test an enum with large, unordered values.
569enum TestSparseEnum {
570  SPARSE_A = 123;
571  SPARSE_B = 62374;
572  SPARSE_C = 12589234;
573  SPARSE_D = -15;
574  SPARSE_E = -53452;
575  SPARSE_F = 0;
576  SPARSE_G = 2;
577}
578
579// Test message with CamelCase field names.  This violates Protocol Buffer
580// standard style.
581message TestCamelCaseFieldNames {
582  optional int32 PrimitiveField = 1;
583  optional string StringField = 2;
584  optional ForeignEnum EnumField = 3;
585  optional ForeignMessage MessageField = 4;
586  optional string StringPieceField = 5 [ctype=STRING_PIECE];
587  optional string CordField = 6 [ctype=CORD];
588
589  repeated int32 RepeatedPrimitiveField = 7;
590  repeated string RepeatedStringField = 8;
591  repeated ForeignEnum RepeatedEnumField = 9;
592  repeated ForeignMessage RepeatedMessageField = 10;
593  repeated string RepeatedStringPieceField = 11 [ctype=STRING_PIECE];
594  repeated string RepeatedCordField = 12 [ctype=CORD];
595}
596
597
598// We list fields out of order, to ensure that we're using field number and not
599// field index to determine serialization order.
600message TestFieldOrderings {
601  optional string my_string = 11;
602  extensions 2 to 10;
603  optional int64 my_int = 1;
604  extensions 12 to 100;
605  optional float my_float = 101;
606  message NestedMessage {
607    optional int64 oo = 2;
608    // The field name "b" fails to compile in proto1 because it conflicts with
609    // a local variable named "b" in one of the generated methods.  Doh.
610    // This file needs to compile in proto1 to test backwards-compatibility.
611    optional int32 bb = 1;
612  }
613
614  optional NestedMessage optional_nested_message  = 200;
615}
616
617extend TestFieldOrderings {
618  optional string my_extension_string = 50;
619  optional int32 my_extension_int = 5;
620}
621
622message TestExtensionOrderings1 {
623  extend TestFieldOrderings {
624    optional TestExtensionOrderings1 test_ext_orderings1 = 13;
625  }
626  optional string my_string = 1;
627}
628
629message TestExtensionOrderings2 {
630  extend TestFieldOrderings {
631    optional TestExtensionOrderings2 test_ext_orderings2 = 12;
632  }
633  message TestExtensionOrderings3 {
634    extend TestFieldOrderings {
635      optional TestExtensionOrderings3 test_ext_orderings3 = 14;
636    }
637    optional string my_string = 1;
638  }
639  optional string my_string = 1;
640}
641
642message TestExtremeDefaultValues {
643  optional bytes escaped_bytes = 1 [default = "\0\001\a\b\f\n\r\t\v\\\'\"\xfe"];
644  optional uint32 large_uint32 = 2 [default = 0xFFFFFFFF];
645  optional uint64 large_uint64 = 3 [default = 0xFFFFFFFFFFFFFFFF];
646  optional  int32 small_int32  = 4 [default = -0x7FFFFFFF];
647  optional  int64 small_int64  = 5 [default = -0x7FFFFFFFFFFFFFFF];
648  optional  int32 really_small_int32 = 21 [default = -0x80000000];
649  optional  int64 really_small_int64 = 22 [default = -0x8000000000000000];
650
651  // The default value here is UTF-8 for "\u1234".  (We could also just type
652  // the UTF-8 text directly into this text file rather than escape it, but
653  // lots of people use editors that would be confused by this.)
654  optional string utf8_string = 6 [default = "\341\210\264"];
655
656  // Tests for single-precision floating-point values.
657  optional float zero_float = 7 [default = 0];
658  optional float one_float = 8 [default = 1];
659  optional float small_float = 9 [default = 1.5];
660  optional float negative_one_float = 10 [default = -1];
661  optional float negative_float = 11 [default = -1.5];
662  // Using exponents
663  optional float large_float = 12 [default = 2E8];
664  optional float small_negative_float = 13 [default = -8e-28];
665
666  // Text for nonfinite floating-point values.
667  optional double inf_double = 14 [default = inf];
668  optional double neg_inf_double = 15 [default = -inf];
669  optional double nan_double = 16 [default = nan];
670  optional float inf_float = 17 [default = inf];
671  optional float neg_inf_float = 18 [default = -inf];
672  optional float nan_float = 19 [default = nan];
673
674  // Tests for C++ trigraphs.
675  // Trigraphs should be escaped in C++ generated files, but they should not be
676  // escaped for other languages.
677  // Note that in .proto file, "\?" is a valid way to escape ? in string
678  // literals.
679  optional string cpp_trigraph = 20 [default = "? \? ?? \?? \??? ??/ ?\?-"];
680
681  // String defaults containing the character '\000'
682  optional string string_with_zero       = 23 [default = "hel\000lo"];
683  optional  bytes bytes_with_zero        = 24 [default = "wor\000ld"];
684  optional string string_piece_with_zero = 25 [ctype=STRING_PIECE,
685                                               default="ab\000c"];
686  optional string cord_with_zero         = 26 [ctype=CORD,
687                                               default="12\0003"];
688  optional string replacement_string     = 27 [default="${unknown}"];
689}
690
691message SparseEnumMessage {
692  optional TestSparseEnum sparse_enum = 1;
693}
694
695// Test String and Bytes: string is for valid UTF-8 strings
696message OneString {
697  optional string data = 1;
698}
699
700message MoreString {
701  repeated string data = 1;
702}
703
704message OneBytes {
705  optional bytes data = 1;
706}
707
708message MoreBytes {
709  repeated bytes data = 1;
710}
711
712message ManyOptionalString {
713  optional string str1 = 1;
714  optional string str2 = 2;
715  optional string str3 = 3;
716  optional string str4 = 4;
717  optional string str5 = 5;
718  optional string str6 = 6;
719  optional string str7 = 7;
720  optional string str8 = 8;
721  optional string str9 = 9;
722  optional string str10 = 10;
723  optional string str11 = 11;
724  optional string str12 = 12;
725  optional string str13 = 13;
726  optional string str14 = 14;
727  optional string str15 = 15;
728  optional string str16 = 16;
729  optional string str17 = 17;
730  optional string str18 = 18;
731  optional string str19 = 19;
732  optional string str20 = 20;
733  optional string str21 = 21;
734  optional string str22 = 22;
735  optional string str23 = 23;
736  optional string str24 = 24;
737  optional string str25 = 25;
738  optional string str26 = 26;
739  optional string str27 = 27;
740  optional string str28 = 28;
741  optional string str29 = 29;
742  optional string str30 = 30;
743  optional string str31 = 31;
744  optional string str32 = 32;
745}
746
747// Test int32, uint32, int64, uint64, and bool are all compatible
748message Int32Message {
749  optional int32 data = 1;
750}
751
752message Uint32Message {
753  optional uint32 data = 1;
754}
755
756message Int64Message {
757  optional int64 data = 1;
758}
759
760message Uint64Message {
761  optional uint64 data = 1;
762}
763
764message BoolMessage {
765  optional bool data = 1;
766}
767
768// Test oneofs.
769message TestOneof {
770  oneof foo {
771    int32 foo_int = 1;
772    string foo_string = 2;
773    TestAllTypes foo_message = 3;
774    group FooGroup = 4 {
775      optional int32 a = 5;
776      optional string b = 6;
777    }
778  }
779}
780
781message TestOneofBackwardsCompatible {
782  optional int32 foo_int = 1;
783  optional string foo_string = 2;
784  optional TestAllTypes foo_message = 3;
785  optional group FooGroup = 4 {
786    optional int32 a = 5;
787    optional string b = 6;
788  }
789}
790
791message TestOneof2 {
792  oneof foo {
793    int32 foo_int = 1;
794    string foo_string = 2;
795    string foo_cord = 3 [ctype=CORD];
796    string foo_string_piece = 4 [ctype=STRING_PIECE];
797    bytes foo_bytes = 5;
798    NestedEnum foo_enum = 6;
799    NestedMessage foo_message = 7;
800    group FooGroup = 8 {
801      optional int32 a = 9;
802      optional string b = 10;
803    }
804    NestedMessage foo_lazy_message = 11 [lazy=true];
805  }
806
807  oneof bar {
808    int32 bar_int = 12 [default = 5];
809    string bar_string = 13 [default = "STRING"];
810    string bar_cord = 14 [ctype=CORD, default = "CORD"];
811    string bar_string_piece = 15 [ctype=STRING_PIECE, default = "SPIECE"];
812    bytes bar_bytes = 16 [default = "BYTES"];
813    NestedEnum bar_enum = 17 [default = BAR];
814    string bar_string_with_empty_default = 20 [default = ""];
815    string bar_cord_with_empty_default = 21 [ctype=CORD, default = ""];
816    string bar_string_piece_with_empty_default = 22 [ctype=STRING_PIECE, default = ""];
817    bytes bar_bytes_with_empty_default = 23 [default = ""];
818  }
819
820  optional int32 baz_int = 18;
821  optional string baz_string = 19 [default = "BAZ"];
822
823  message NestedMessage {
824    optional int64 moo_int = 1;
825    repeated int32 corge_int = 2;
826  }
827
828  enum NestedEnum {
829    FOO = 1;
830    BAR = 2;
831    BAZ = 3;
832  }
833}
834
835message TestRequiredOneof {
836  oneof foo {
837    int32 foo_int = 1;
838    string foo_string = 2;
839    NestedMessage foo_message = 3;
840  }
841  message NestedMessage {
842    required double required_double = 1;
843  }
844}
845
846
847// Test messages for packed fields
848
849message TestPackedTypes {
850  repeated    int32 packed_int32    =  90 [packed = true];
851  repeated    int64 packed_int64    =  91 [packed = true];
852  repeated   uint32 packed_uint32   =  92 [packed = true];
853  repeated   uint64 packed_uint64   =  93 [packed = true];
854  repeated   sint32 packed_sint32   =  94 [packed = true];
855  repeated   sint64 packed_sint64   =  95 [packed = true];
856  repeated  fixed32 packed_fixed32  =  96 [packed = true];
857  repeated  fixed64 packed_fixed64  =  97 [packed = true];
858  repeated sfixed32 packed_sfixed32 =  98 [packed = true];
859  repeated sfixed64 packed_sfixed64 =  99 [packed = true];
860  repeated    float packed_float    = 100 [packed = true];
861  repeated   double packed_double   = 101 [packed = true];
862  repeated     bool packed_bool     = 102 [packed = true];
863  repeated ForeignEnum packed_enum  = 103 [packed = true];
864}
865
866// A message with the same fields as TestPackedTypes, but without packing. Used
867// to test packed <-> unpacked wire compatibility.
868message TestUnpackedTypes {
869  repeated    int32 unpacked_int32    =  90 [packed = false];
870  repeated    int64 unpacked_int64    =  91 [packed = false];
871  repeated   uint32 unpacked_uint32   =  92 [packed = false];
872  repeated   uint64 unpacked_uint64   =  93 [packed = false];
873  repeated   sint32 unpacked_sint32   =  94 [packed = false];
874  repeated   sint64 unpacked_sint64   =  95 [packed = false];
875  repeated  fixed32 unpacked_fixed32  =  96 [packed = false];
876  repeated  fixed64 unpacked_fixed64  =  97 [packed = false];
877  repeated sfixed32 unpacked_sfixed32 =  98 [packed = false];
878  repeated sfixed64 unpacked_sfixed64 =  99 [packed = false];
879  repeated    float unpacked_float    = 100 [packed = false];
880  repeated   double unpacked_double   = 101 [packed = false];
881  repeated     bool unpacked_bool     = 102 [packed = false];
882  repeated ForeignEnum unpacked_enum  = 103 [packed = false];
883}
884
885message TestPackedExtensions {
886  extensions 1 to max;
887}
888
889extend TestPackedExtensions {
890  repeated    int32 packed_int32_extension    =  90 [packed = true];
891  repeated    int64 packed_int64_extension    =  91 [packed = true];
892  repeated   uint32 packed_uint32_extension   =  92 [packed = true];
893  repeated   uint64 packed_uint64_extension   =  93 [packed = true];
894  repeated   sint32 packed_sint32_extension   =  94 [packed = true];
895  repeated   sint64 packed_sint64_extension   =  95 [packed = true];
896  repeated  fixed32 packed_fixed32_extension  =  96 [packed = true];
897  repeated  fixed64 packed_fixed64_extension  =  97 [packed = true];
898  repeated sfixed32 packed_sfixed32_extension =  98 [packed = true];
899  repeated sfixed64 packed_sfixed64_extension =  99 [packed = true];
900  repeated    float packed_float_extension    = 100 [packed = true];
901  repeated   double packed_double_extension   = 101 [packed = true];
902  repeated     bool packed_bool_extension     = 102 [packed = true];
903  repeated ForeignEnum packed_enum_extension  = 103 [packed = true];
904}
905
906message TestUnpackedExtensions {
907  extensions 1 to max;
908}
909
910extend TestUnpackedExtensions {
911  repeated    int32 unpacked_int32_extension    =  90 [packed = false];
912  repeated    int64 unpacked_int64_extension    =  91 [packed = false];
913  repeated   uint32 unpacked_uint32_extension   =  92 [packed = false];
914  repeated   uint64 unpacked_uint64_extension   =  93 [packed = false];
915  repeated   sint32 unpacked_sint32_extension   =  94 [packed = false];
916  repeated   sint64 unpacked_sint64_extension   =  95 [packed = false];
917  repeated  fixed32 unpacked_fixed32_extension  =  96 [packed = false];
918  repeated  fixed64 unpacked_fixed64_extension  =  97 [packed = false];
919  repeated sfixed32 unpacked_sfixed32_extension =  98 [packed = false];
920  repeated sfixed64 unpacked_sfixed64_extension =  99 [packed = false];
921  repeated    float unpacked_float_extension    = 100 [packed = false];
922  repeated   double unpacked_double_extension   = 101 [packed = false];
923  repeated     bool unpacked_bool_extension     = 102 [packed = false];
924  repeated ForeignEnum unpacked_enum_extension  = 103 [packed = false];
925}
926
927// Used by ExtensionSetTest/DynamicExtensions.  The test actually builds
928// a set of extensions to TestAllExtensions dynamically, based on the fields
929// of this message type.
930message TestDynamicExtensions {
931  enum DynamicEnumType {
932    DYNAMIC_FOO = 2200;
933    DYNAMIC_BAR = 2201;
934    DYNAMIC_BAZ = 2202;
935  }
936  message DynamicMessageType {
937    optional int32 dynamic_field = 2100;
938  }
939
940  optional fixed32 scalar_extension = 2000;
941  optional ForeignEnum enum_extension = 2001;
942  optional DynamicEnumType dynamic_enum_extension = 2002;
943
944  optional ForeignMessage message_extension = 2003;
945  optional DynamicMessageType dynamic_message_extension = 2004;
946
947  repeated string repeated_extension = 2005;
948  repeated sint32 packed_extension = 2006 [packed = true];
949}
950
951message TestRepeatedScalarDifferentTagSizes {
952  // Parsing repeated fixed size values used to fail. This message needs to be
953  // used in order to get a tag of the right size; all of the repeated fields
954  // in TestAllTypes didn't trigger the check.
955  repeated fixed32 repeated_fixed32 = 12;
956  // Check for a varint type, just for good measure.
957  repeated int32   repeated_int32   = 13;
958
959  // These have two-byte tags.
960  repeated fixed64 repeated_fixed64 = 2046;
961  repeated int64   repeated_int64   = 2047;
962
963  // Three byte tags.
964  repeated float   repeated_float   = 262142;
965  repeated uint64  repeated_uint64  = 262143;
966}
967
968// Test that if an optional or required message/group field appears multiple
969// times in the input, they need to be merged.
970message TestParsingMerge {
971  // RepeatedFieldsGenerator defines matching field types as TestParsingMerge,
972  // except that all fields are repeated. In the tests, we will serialize the
973  // RepeatedFieldsGenerator to bytes, and parse the bytes to TestParsingMerge.
974  // Repeated fields in RepeatedFieldsGenerator are expected to be merged into
975  // the corresponding required/optional fields in TestParsingMerge.
976  message RepeatedFieldsGenerator {
977    repeated TestAllTypes field1 = 1;
978    repeated TestAllTypes field2 = 2;
979    repeated TestAllTypes field3 = 3;
980    repeated group Group1 = 10 {
981      optional TestAllTypes field1 = 11;
982    }
983    repeated group Group2 = 20 {
984      optional TestAllTypes field1 = 21;
985    }
986    repeated TestAllTypes ext1 = 1000;
987    repeated TestAllTypes ext2 = 1001;
988  }
989  required TestAllTypes required_all_types = 1;
990  optional TestAllTypes optional_all_types = 2;
991  repeated TestAllTypes repeated_all_types = 3;
992  optional group OptionalGroup = 10 {
993    optional TestAllTypes optional_group_all_types = 11;
994  }
995  repeated group RepeatedGroup = 20 {
996    optional TestAllTypes repeated_group_all_types = 21;
997  }
998  extensions 1000 to max;
999  extend TestParsingMerge {
1000    optional TestAllTypes optional_ext = 1000;
1001    repeated TestAllTypes repeated_ext = 1001;
1002  }
1003}
1004
1005// Test that the correct exception is thrown by parseFrom in a corner case
1006// involving merging, extensions, and required fields.
1007message TestMergeException {
1008  optional TestAllExtensions all_extensions = 1;
1009}
1010
1011message TestCommentInjectionMessage {
1012  // */ <- This should not close the generated doc comment
1013  optional string a = 1 [default="*/ <- Neither should this."];
1014}
1015
1016// Used to check that the c++ code generator re-orders messages to reduce
1017// padding.
1018message TestMessageSize {
1019  optional bool m1 = 1;
1020  optional int64 m2 = 2;
1021  optional bool m3 = 3;
1022  optional string m4 = 4;
1023  optional int32 m5 = 5;
1024  optional int64 m6 = 6;
1025}
1026
1027
1028// Test that RPC services work.
1029message FooRequest  {}
1030message FooResponse {}
1031
1032message FooClientMessage {}
1033message FooServerMessage{}
1034
1035service TestService {
1036  rpc Foo(FooRequest) returns (FooResponse);
1037  rpc Bar(BarRequest) returns (BarResponse);
1038}
1039
1040
1041message BarRequest  {}
1042message BarResponse {}
1043
1044message TestJsonName {
1045  optional int32 field_name1 = 1;
1046  optional int32 fieldName2 = 2;
1047  optional int32 FieldName3 = 3;
1048  optional int32 _field_name4 = 4;
1049  optional int32 FIELD_NAME5 = 5;
1050  optional int32 field_name6 = 6 [json_name = "@type"];
1051  optional int32 fieldname7 = 7;
1052}
1053
1054message TestHugeFieldNumbers {
1055  optional int32 optional_int32 = 536870000;
1056  optional int32 fixed_32 = 536870001;
1057  repeated int32 repeated_int32 = 536870002 [packed = false];
1058  repeated int32 packed_int32 = 536870003 [packed = true];
1059
1060  optional ForeignEnum optional_enum = 536870004;
1061  optional string optional_string = 536870005;
1062  optional bytes optional_bytes = 536870006;
1063  optional ForeignMessage optional_message = 536870007;
1064
1065  optional group OptionalGroup = 536870008 {
1066    optional int32 group_a = 536870009;
1067  }
1068
1069  map<string, string> string_string_map = 536870010;
1070
1071  oneof oneof_field {
1072    uint32 oneof_uint32 = 536870011;
1073    TestAllTypes oneof_test_all_types = 536870012;
1074    string oneof_string = 536870013;
1075    bytes oneof_bytes = 536870014;
1076  }
1077
1078  extensions 530000000 to 536869999 [declaration = {
1079    number: 536860000
1080    full_name: ".objc.protobuf.tests.test_all_types"
1081    type: ".objc.protobuf.tests.TestAllTypes"
1082  }];
1083}
1084
1085extend TestHugeFieldNumbers {
1086  optional TestAllTypes test_all_types = 536860000;
1087}
1088
1089message TestExtensionInsideTable {
1090  optional int32 field1 = 1;
1091  optional int32 field2 = 2;
1092  optional int32 field3 = 3;
1093  optional int32 field4 = 4;
1094  extensions 5 to 5;
1095  optional int32 field6 = 6;
1096  optional int32 field7 = 7;
1097  optional int32 field8 = 8;
1098  optional int32 field9 = 9;
1099  optional int32 field10 = 10;
1100}
1101
1102extend TestExtensionInsideTable {
1103  optional int32 test_extension_inside_table_extension = 5;
1104}
1105
1106// NOTE: Intentionally nested to mirror go/glep.
1107message TestNestedGroupExtensionOuter {
1108  optional group Layer1OptionalGroup = 1 {
1109    repeated group Layer2RepeatedGroup = 2 {
1110      extensions 3
1111        // NOTE: extension metadata is not supported due to targets such as
1112        // `//google/protobuf_legacy_opensource/src:shell_scripts_test`,
1113        // eee https://screenshot.googleplex.com/Axz2QD8nxjdpyFF
1114        //[metadata = {
1115        // NOTE: can't write type there due to some clever build gen code at
1116        // http://google3/google/protobuf/BUILD;l=1247;rcl=411090862
1117        // type: "objc.protobuf.tests.TestNestedGroupExtensionInnerExtension",
1118        // name: "inner",
1119        // }]
1120        ;
1121      optional string another_field = 6;
1122    }
1123    repeated group Layer2AnotherOptionalRepeatedGroup = 4 {
1124      optional string but_why_tho = 5;
1125    }
1126  }
1127}
1128
1129message TestNestedGroupExtensionInnerExtension {
1130  optional string inner_name= 1;
1131}
1132
1133extend TestNestedGroupExtensionOuter.Layer1OptionalGroup.Layer2RepeatedGroup {
1134  optional TestNestedGroupExtensionInnerExtension inner = 3;
1135}
1136
1137enum VeryLargeEnum {
1138  ENUM_LABEL_DEFAULT = 0;
1139  ENUM_LABEL_1 = 1;
1140  ENUM_LABEL_2 = 2;
1141  ENUM_LABEL_3 = 3;
1142  ENUM_LABEL_4 = 4;
1143  ENUM_LABEL_5 = 5;
1144  ENUM_LABEL_6 = 6;
1145  ENUM_LABEL_7 = 7;
1146  ENUM_LABEL_8 = 8;
1147  ENUM_LABEL_9 = 9;
1148  ENUM_LABEL_10 = 10;
1149  ENUM_LABEL_11 = 11;
1150  ENUM_LABEL_12 = 12;
1151  ENUM_LABEL_13 = 13;
1152  ENUM_LABEL_14 = 14;
1153  ENUM_LABEL_15 = 15;
1154  ENUM_LABEL_16 = 16;
1155  ENUM_LABEL_17 = 17;
1156  ENUM_LABEL_18 = 18;
1157  ENUM_LABEL_19 = 19;
1158  ENUM_LABEL_20 = 20;
1159  ENUM_LABEL_21 = 21;
1160  ENUM_LABEL_22 = 22;
1161  ENUM_LABEL_23 = 23;
1162  ENUM_LABEL_24 = 24;
1163  ENUM_LABEL_25 = 25;
1164  ENUM_LABEL_26 = 26;
1165  ENUM_LABEL_27 = 27;
1166  ENUM_LABEL_28 = 28;
1167  ENUM_LABEL_29 = 29;
1168  ENUM_LABEL_30 = 30;
1169  ENUM_LABEL_31 = 31;
1170  ENUM_LABEL_32 = 32;
1171  ENUM_LABEL_33 = 33;
1172  ENUM_LABEL_34 = 34;
1173  ENUM_LABEL_35 = 35;
1174  ENUM_LABEL_36 = 36;
1175  ENUM_LABEL_37 = 37;
1176  ENUM_LABEL_38 = 38;
1177  ENUM_LABEL_39 = 39;
1178  ENUM_LABEL_40 = 40;
1179  ENUM_LABEL_41 = 41;
1180  ENUM_LABEL_42 = 42;
1181  ENUM_LABEL_43 = 43;
1182  ENUM_LABEL_44 = 44;
1183  ENUM_LABEL_45 = 45;
1184  ENUM_LABEL_46 = 46;
1185  ENUM_LABEL_47 = 47;
1186  ENUM_LABEL_48 = 48;
1187  ENUM_LABEL_49 = 49;
1188  ENUM_LABEL_50 = 50;
1189  ENUM_LABEL_51 = 51;
1190  ENUM_LABEL_52 = 52;
1191  ENUM_LABEL_53 = 53;
1192  ENUM_LABEL_54 = 54;
1193  ENUM_LABEL_55 = 55;
1194  ENUM_LABEL_56 = 56;
1195  ENUM_LABEL_57 = 57;
1196  ENUM_LABEL_58 = 58;
1197  ENUM_LABEL_59 = 59;
1198  ENUM_LABEL_60 = 60;
1199  ENUM_LABEL_61 = 61;
1200  ENUM_LABEL_62 = 62;
1201  ENUM_LABEL_63 = 63;
1202  ENUM_LABEL_64 = 64;
1203  ENUM_LABEL_65 = 65;
1204  ENUM_LABEL_66 = 66;
1205  ENUM_LABEL_67 = 67;
1206  ENUM_LABEL_68 = 68;
1207  ENUM_LABEL_69 = 69;
1208  ENUM_LABEL_70 = 70;
1209  ENUM_LABEL_71 = 71;
1210  ENUM_LABEL_72 = 72;
1211  ENUM_LABEL_73 = 73;
1212  ENUM_LABEL_74 = 74;
1213  ENUM_LABEL_75 = 75;
1214  ENUM_LABEL_76 = 76;
1215  ENUM_LABEL_77 = 77;
1216  ENUM_LABEL_78 = 78;
1217  ENUM_LABEL_79 = 79;
1218  ENUM_LABEL_80 = 80;
1219  ENUM_LABEL_81 = 81;
1220  ENUM_LABEL_82 = 82;
1221  ENUM_LABEL_83 = 83;
1222  ENUM_LABEL_84 = 84;
1223  ENUM_LABEL_85 = 85;
1224  ENUM_LABEL_86 = 86;
1225  ENUM_LABEL_87 = 87;
1226  ENUM_LABEL_88 = 88;
1227  ENUM_LABEL_89 = 89;
1228  ENUM_LABEL_90 = 90;
1229  ENUM_LABEL_91 = 91;
1230  ENUM_LABEL_92 = 92;
1231  ENUM_LABEL_93 = 93;
1232  ENUM_LABEL_94 = 94;
1233  ENUM_LABEL_95 = 95;
1234  ENUM_LABEL_96 = 96;
1235  ENUM_LABEL_97 = 97;
1236  ENUM_LABEL_98 = 98;
1237  ENUM_LABEL_99 = 99;
1238  ENUM_LABEL_100 = 100;
1239};
1240
1241message TestExtensionRangeSerialize {
1242  optional int32 foo_one = 1;
1243
1244  extensions 2 to 2;
1245  extensions 3 to 4;
1246
1247  optional int32 foo_two = 6;
1248  optional int32 foo_three = 7;
1249
1250  extensions 9 to 10;
1251
1252  optional int32 foo_four = 13;
1253
1254  extensions 15 to 15;
1255  extensions 17 to 17;
1256  extensions 19 to 19;
1257
1258  extend TestExtensionRangeSerialize {
1259    optional int32 bar_one = 2;
1260    optional int32 bar_two = 4;
1261
1262    optional int32 bar_three = 10;
1263
1264    optional int32 bar_four = 15;
1265    optional int32 bar_five = 19;
1266  }
1267}
1268
1269message TestVerifyInt32Simple {
1270    optional int32 optional_int32_1 = 1;
1271    optional int32 optional_int32_2 = 2;
1272    optional int32 optional_int32_63 = 63;
1273    optional int32 optional_int32_64 = 64;
1274}
1275
1276message TestVerifyInt32 {
1277    optional int32 optional_int32_1 = 1;
1278    optional int32 optional_int32_2 = 2;
1279    optional int32 optional_int32_63 = 63;
1280    optional int32 optional_int32_64 = 64;
1281
1282    optional TestAllTypes optional_all_types = 9;
1283    repeated TestAllTypes repeated_all_types = 10;
1284}
1285
1286message TestVerifyMostlyInt32 {
1287    optional int64 optional_int64_30 = 30;
1288
1289    optional int32 optional_int32_1 = 1;
1290    optional int32 optional_int32_2 = 2;
1291    optional int32 optional_int32_3 = 3;
1292    optional int32 optional_int32_4 = 4;
1293    optional int32 optional_int32_63 = 63;
1294    optional int32 optional_int32_64 = 64;
1295
1296    optional TestAllTypes optional_all_types = 9;
1297    repeated TestAllTypes repeated_all_types = 10;
1298}
1299
1300message TestVerifyMostlyInt32BigFieldNumber {
1301    optional int64 optional_int64_30 = 30;
1302    optional int32 optional_int32_300 = 300;
1303
1304    optional int32 optional_int32_1 = 1;
1305    optional int32 optional_int32_2 = 2;
1306    optional int32 optional_int32_3 = 3;
1307    optional int32 optional_int32_4 = 4;
1308    optional int32 optional_int32_63 = 63;
1309    optional int32 optional_int32_64 = 64;
1310
1311    optional TestAllTypes optional_all_types = 9;
1312    repeated TestAllTypes repeated_all_types = 10;
1313}
1314
1315message TestVerifyUint32Simple {
1316    optional uint32 optional_uint32_1 = 1;
1317    optional uint32 optional_uint32_2 = 2;
1318    optional uint32 optional_uint32_63 = 63;
1319    optional uint32 optional_uint32_64 = 64;
1320}
1321
1322message TestVerifyUint32 {
1323    optional uint32 optional_uint32_1 = 1;
1324    optional uint32 optional_uint32_2 = 2;
1325    optional uint32 optional_uint32_63 = 63;
1326    optional uint32 optional_uint32_64 = 64;
1327
1328    optional TestAllTypes optional_all_types = 9;
1329    repeated TestAllTypes repeated_all_types = 10;
1330}
1331
1332message TestVerifyOneUint32 {
1333    optional uint32 optional_uint32_1 = 1;
1334    optional int32 optional_int32_2 = 2;
1335    optional int32 optional_int32_63 = 63;
1336    optional int32 optional_int32_64 = 64;
1337
1338    optional TestAllTypes optional_all_types = 9;
1339    repeated TestAllTypes repeated_all_types = 10;
1340}
1341
1342message TestVerifyOneInt32BigFieldNumber {
1343    optional int32 optional_int32_65 = 65;
1344
1345    optional int64 optional_int64_1 = 1;
1346    optional int64 optional_int64_2 = 2;
1347    optional int64 optional_int64_63 = 63;
1348    optional int64 optional_int64_64 = 64;
1349
1350    optional TestAllTypes optional_all_types = 9;
1351    repeated TestAllTypes repeated_all_types = 10;
1352}
1353
1354message TestVerifyInt32BigFieldNumber {
1355    optional int32 optional_int32_1000 = 1000;
1356    optional int32 optional_int32_65 = 65;
1357
1358    optional int32 optional_int32_1 = 1;
1359    optional int32 optional_int32_2 = 2;
1360    optional int32 optional_int32_63 = 63;
1361    optional int32 optional_int32_64 = 64;
1362
1363    optional TestAllTypes optional_all_types = 9;
1364    repeated TestAllTypes repeated_all_types = 10;
1365}
1366
1367message TestVerifyUint32BigFieldNumber {
1368    optional uint32 optional_uint32_1000 = 1000;
1369    optional uint32 optional_uint32_65 = 65;
1370
1371    optional uint32 optional_uint32_1 = 1;
1372    optional uint32 optional_uint32_2 = 2;
1373    optional uint32 optional_uint32_63 = 63;
1374    optional uint32 optional_uint32_64 = 64;
1375
1376    optional TestAllTypes optional_all_types = 9;
1377    repeated TestAllTypes repeated_all_types = 10;
1378}
1379
1380message TestVerifyBigFieldNumberUint32 {
1381  message Nested {
1382    optional uint32 optional_uint32_5000 = 5000;
1383    optional uint32 optional_uint32_1000 = 1000;
1384    optional uint32 optional_uint32_66 = 66;
1385    optional uint32 optional_uint32_65 = 65;
1386
1387    optional uint32 optional_uint32_1 = 1;
1388    optional uint32 optional_uint32_2 = 2;
1389    optional uint32 optional_uint32_63 = 63;
1390    optional uint32 optional_uint32_64 = 64;
1391
1392    optional Nested optional_nested = 9;
1393    repeated Nested repeated_nested = 10;
1394  }
1395  optional Nested optional_nested = 1;
1396}
1397
1398
1399// This message contains different kind of enums to exercise the different
1400// parsers in table-driven.
1401message EnumParseTester {
1402  enum SeqSmall0 {
1403    SEQ_SMALL_0_DEFAULT = 0;
1404    SEQ_SMALL_0_1 = 1;
1405    SEQ_SMALL_0_2 = 2;
1406  };
1407  optional SeqSmall0 optional_seq_small_0_lowfield = 1;
1408  optional SeqSmall0 optional_seq_small_0_midfield = 1001;
1409  optional SeqSmall0 optional_seq_small_0_hifield = 1000001;
1410  repeated SeqSmall0 repeated_seq_small_0_lowfield = 2;
1411  repeated SeqSmall0 repeated_seq_small_0_midfield = 1002;
1412  repeated SeqSmall0 repeated_seq_small_0_hifield = 1000002;
1413  repeated SeqSmall0 packed_seq_small_0_lowfield = 3 [packed = true];
1414  repeated SeqSmall0 packed_seq_small_0_midfield = 1003 [packed = true];
1415  repeated SeqSmall0 packed_seq_small_0_hifield = 1000003 [packed = true];
1416
1417  enum SeqSmall1 {
1418    SEQ_SMALL_1_DEFAULT = 1;
1419    SEQ_SMALL_1_2 = 2;
1420    SEQ_SMALL_1_3 = 3;
1421  };
1422  optional SeqSmall1 optional_seq_small_1_lowfield = 4;
1423  optional SeqSmall1 optional_seq_small_1_midfield = 1004;
1424  optional SeqSmall1 optional_seq_small_1_hifield = 1000004;
1425  repeated SeqSmall1 repeated_seq_small_1_lowfield = 5;
1426  repeated SeqSmall1 repeated_seq_small_1_midfield = 1005;
1427  repeated SeqSmall1 repeated_seq_small_1_hifield = 1000005;
1428  repeated SeqSmall1 packed_seq_small_1_lowfield = 6 [packed = true];
1429  repeated SeqSmall1 packed_seq_small_1_midfield = 1006 [packed = true];
1430  repeated SeqSmall1 packed_seq_small_1_hifield = 1000006 [packed = true];
1431
1432  enum SeqLarge {
1433    SEQ_LARGE_DEFAULT = -1;
1434    SEQ_LARGE_0 = 0;
1435    SEQ_LARGE_1 = 1;
1436    SEQ_LARGE_2 = 2;
1437    SEQ_LARGE_3 = 3;
1438    SEQ_LARGE_4 = 4;
1439    SEQ_LARGE_5 = 5;
1440    SEQ_LARGE_6 = 6;
1441    SEQ_LARGE_7 = 7;
1442    SEQ_LARGE_8 = 8;
1443    SEQ_LARGE_9 = 9;
1444    SEQ_LARGE_10 = 10;
1445    SEQ_LARGE_11 = 11;
1446    SEQ_LARGE_12 = 12;
1447    SEQ_LARGE_13 = 13;
1448    SEQ_LARGE_14 = 14;
1449    SEQ_LARGE_15 = 15;
1450    SEQ_LARGE_16 = 16;
1451    SEQ_LARGE_17 = 17;
1452    SEQ_LARGE_18 = 18;
1453    SEQ_LARGE_19 = 19;
1454    SEQ_LARGE_20 = 20;
1455    SEQ_LARGE_21 = 21;
1456    SEQ_LARGE_22 = 22;
1457    SEQ_LARGE_23 = 23;
1458    SEQ_LARGE_24 = 24;
1459    SEQ_LARGE_25 = 25;
1460    SEQ_LARGE_26 = 26;
1461    SEQ_LARGE_27 = 27;
1462    SEQ_LARGE_28 = 28;
1463    SEQ_LARGE_29 = 29;
1464    SEQ_LARGE_30 = 30;
1465    SEQ_LARGE_31 = 31;
1466    SEQ_LARGE_32 = 32;
1467    SEQ_LARGE_33 = 33;
1468  };
1469  optional SeqLarge optional_seq_large_lowfield = 7;
1470  optional SeqLarge optional_seq_large_midfield = 1007;
1471  optional SeqLarge optional_seq_large_hifield = 1000007;
1472  repeated SeqLarge repeated_seq_large_lowfield = 8;
1473  repeated SeqLarge repeated_seq_large_midfield = 1008;
1474  repeated SeqLarge repeated_seq_large_hifield = 1000008;
1475  repeated SeqLarge packed_seq_large_lowfield = 9 [packed = true];
1476  repeated SeqLarge packed_seq_large_midfield = 1009 [packed = true];
1477  repeated SeqLarge packed_seq_large_hifield = 1000009 [packed = true];
1478
1479  enum Arbitrary {
1480    ARBITRARY_DEFAULT = -123123;
1481    ARBITRARY_1 = -123;
1482    ARBITRARY_2 = 213;
1483    ARBITRARY_3 = 213213;
1484    ARBITRARY_MIN = -2147483648;
1485    ARBITRARY_MAX = 2147483647;
1486  };
1487  optional Arbitrary optional_arbitrary_lowfield = 10;
1488  optional Arbitrary optional_arbitrary_midfield = 1010;
1489  optional Arbitrary optional_arbitrary_hifield = 1000010;
1490  repeated Arbitrary repeated_arbitrary_lowfield = 11;
1491  repeated Arbitrary repeated_arbitrary_midfield = 1011;
1492  repeated Arbitrary repeated_arbitrary_hifield = 1000011;
1493  repeated Arbitrary packed_arbitrary_lowfield = 12 [packed = true];
1494  repeated Arbitrary packed_arbitrary_midfield = 1012 [packed = true];
1495  repeated Arbitrary packed_arbitrary_hifield = 1000012 [packed = true];
1496
1497  // An arbitrary field we can append to to break the runs of repeated fields.
1498  optional int32 other_field = 99;
1499};
1500
1501// This message contains different kind of bool fields to exercise the different
1502// parsers in table-drived.
1503message BoolParseTester {
1504  optional bool optional_bool_lowfield = 1;
1505  optional bool optional_bool_midfield = 1001;
1506  optional bool optional_bool_hifield = 1000001;
1507  repeated bool repeated_bool_lowfield = 2;
1508  repeated bool repeated_bool_midfield = 1002;
1509  repeated bool repeated_bool_hifield = 1000002;
1510  repeated bool packed_bool_lowfield = 3 [packed = true];
1511  repeated bool packed_bool_midfield = 1003 [packed = true];
1512  repeated bool packed_bool_hifield = 1000003 [packed = true];
1513
1514  // An arbitrary field we can append to to break the runs of repeated fields.
1515  optional int32 other_field = 99;
1516};
1517
1518