• 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
8syntax = "proto3";
9
10option cc_enable_arenas = true;
11
12import "google/protobuf/unittest_import.proto";
13
14package proto3_arena_unittest;
15
16// This proto includes every type of field in both singular and repeated
17// forms.
18message TestAllTypes {
19  message NestedMessage {
20    // The field name "b" fails to compile in proto1 because it conflicts with
21    // a local variable named "b" in one of the generated methods.  Doh.
22    // This file needs to compile in proto1 to test backwards-compatibility.
23    int32 bb = 1;
24  }
25
26  enum NestedEnum {
27    ZERO = 0;
28    FOO = 1;
29    BAR = 2;
30    BAZ = 3;
31    NEG = -1;  // Intentionally negative.
32  }
33
34  // Singular
35     int32 optional_int32    =  1;
36     int64 optional_int64    =  2;
37    uint32 optional_uint32   =  3;
38    uint64 optional_uint64   =  4;
39    sint32 optional_sint32   =  5;
40    sint64 optional_sint64   =  6;
41   fixed32 optional_fixed32  =  7;
42   fixed64 optional_fixed64  =  8;
43  sfixed32 optional_sfixed32 =  9;
44  sfixed64 optional_sfixed64 = 10;
45     float optional_float    = 11;
46    double optional_double   = 12;
47      bool optional_bool     = 13;
48    string optional_string   = 14;
49     bytes optional_bytes    = 15;
50
51  // Groups are not allowed in proto3.
52  // optional group OptionalGroup = 16 {
53  //   optional int32 a = 17;
54  // }
55
56  NestedMessage                        optional_nested_message  = 18;
57  ForeignMessage                       optional_foreign_message = 19;
58  protobuf_unittest_import.ImportMessage optional_import_message  = 20;
59
60  NestedEnum                           optional_nested_enum     = 21;
61  ForeignEnum                          optional_foreign_enum    = 22;
62
63  // Omitted (compared to unittest.proto) because proto2 enums are not allowed
64  // inside proto2 messages.
65  //
66  // optional protobuf_unittest_import.ImportEnum    optional_import_enum  = 23;
67
68  string optional_string_piece = 24 [ctype=STRING_PIECE];
69  string optional_cord = 25 [ctype=CORD];
70  bytes optional_bytes_cord = 86 [ctype=CORD];
71
72  // Defined in unittest_import_public.proto
73  protobuf_unittest_import.PublicImportMessage
74      optional_public_import_message = 26;
75
76  NestedMessage optional_lazy_message = 27 [lazy=true];
77  NestedMessage optional_unverified_lazy_message = 28 [unverified_lazy=true];
78  protobuf_unittest_import.ImportMessage optional_lazy_import_message = 115
79      [lazy = true];
80
81  // Repeated
82  repeated    int32 repeated_int32    = 31;
83  repeated    int64 repeated_int64    = 32;
84  repeated   uint32 repeated_uint32   = 33;
85  repeated   uint64 repeated_uint64   = 34;
86  repeated   sint32 repeated_sint32   = 35;
87  repeated   sint64 repeated_sint64   = 36;
88  repeated  fixed32 repeated_fixed32  = 37;
89  repeated  fixed64 repeated_fixed64  = 38;
90  repeated sfixed32 repeated_sfixed32 = 39;
91  repeated sfixed64 repeated_sfixed64 = 40;
92  repeated    float repeated_float    = 41;
93  repeated   double repeated_double   = 42;
94  repeated     bool repeated_bool     = 43;
95  repeated   string repeated_string   = 44;
96  repeated    bytes repeated_bytes    = 45;
97
98  // Optional
99  optional    int32 proto3_optional_int32    = 116;
100  optional    int64 proto3_optional_int64    = 117;
101  optional   uint32 proto3_optional_uint32   = 118;
102  optional   uint64 proto3_optional_uint64   = 119;
103  optional   sint32 proto3_optional_sint32   = 120;
104  optional   sint64 proto3_optional_sint64   = 121;
105  optional  fixed32 proto3_optional_fixed32  = 122;
106  optional  fixed64 proto3_optional_fixed64  = 123;
107  optional sfixed32 proto3_optional_sfixed32 = 124;
108  optional sfixed64 proto3_optional_sfixed64 = 125;
109  optional    float proto3_optional_float    = 126;
110  optional   double proto3_optional_double   = 127;
111  optional     bool proto3_optional_bool     = 128;
112  optional   string proto3_optional_string   = 129;
113  optional    bytes proto3_optional_bytes    = 130;
114
115  // Groups are not allowed in proto3.
116  // repeated group RepeatedGroup = 46 {
117  //   optional int32 a = 47;
118  // }
119
120  repeated NestedMessage                        repeated_nested_message  = 48;
121  repeated ForeignMessage                       repeated_foreign_message = 49;
122  repeated protobuf_unittest_import.ImportMessage repeated_import_message  = 50;
123
124  repeated NestedEnum                           repeated_nested_enum     = 51;
125  repeated ForeignEnum                          repeated_foreign_enum    = 52;
126
127  // Omitted (compared to unittest.proto) because proto2 enums are not allowed
128  // inside proto2 messages.
129  //
130  // repeated protobuf_unittest_import.ImportEnum    repeated_import_enum  = 53;
131
132  repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
133  repeated string repeated_cord = 55 [ctype=CORD];
134
135  repeated NestedMessage repeated_lazy_message = 57 ;
136
137  oneof oneof_field {
138    uint32 oneof_uint32 = 111;
139    NestedMessage oneof_nested_message = 112;
140    string oneof_string = 113;
141    bytes oneof_bytes = 114;
142  }
143}
144
145// Test messages for packed fields
146
147message TestPackedTypes {
148  repeated    int32 packed_int32    =  90 [packed = true];
149  repeated    int64 packed_int64    =  91 [packed = true];
150  repeated   uint32 packed_uint32   =  92 [packed = true];
151  repeated   uint64 packed_uint64   =  93 [packed = true];
152  repeated   sint32 packed_sint32   =  94 [packed = true];
153  repeated   sint64 packed_sint64   =  95 [packed = true];
154  repeated  fixed32 packed_fixed32  =  96 [packed = true];
155  repeated  fixed64 packed_fixed64  =  97 [packed = true];
156  repeated sfixed32 packed_sfixed32 =  98 [packed = true];
157  repeated sfixed64 packed_sfixed64 =  99 [packed = true];
158  repeated    float packed_float    = 100 [packed = true];
159  repeated   double packed_double   = 101 [packed = true];
160  repeated     bool packed_bool     = 102 [packed = true];
161  repeated ForeignEnum packed_enum  = 103 [packed = true];
162}
163
164// Explicitly set packed to false
165message TestUnpackedTypes {
166  repeated    int32 repeated_int32    =  1 [packed = false];
167  repeated    int64 repeated_int64    =  2 [packed = false];
168  repeated   uint32 repeated_uint32   =  3 [packed = false];
169  repeated   uint64 repeated_uint64   =  4 [packed = false];
170  repeated   sint32 repeated_sint32   =  5 [packed = false];
171  repeated   sint64 repeated_sint64   =  6 [packed = false];
172  repeated  fixed32 repeated_fixed32  =  7 [packed = false];
173  repeated  fixed64 repeated_fixed64  =  8 [packed = false];
174  repeated sfixed32 repeated_sfixed32 =  9 [packed = false];
175  repeated sfixed64 repeated_sfixed64 = 10 [packed = false];
176  repeated    float repeated_float    = 11 [packed = false];
177  repeated   double repeated_double   = 12 [packed = false];
178  repeated     bool repeated_bool     = 13 [packed = false];
179  repeated TestAllTypes.NestedEnum repeated_nested_enum = 14 [packed = false];
180}
181
182// This proto includes a recursively nested message.
183message NestedTestAllTypes {
184  NestedTestAllTypes child = 1;
185  TestAllTypes payload = 2;
186  repeated NestedTestAllTypes repeated_child = 3;
187  TestAllTypes lazy_payload = 4 [lazy = true];
188}
189
190// Define these after TestAllTypes to make sure the compiler can handle
191// that.
192message ForeignMessage {
193  int32 c = 1;
194}
195
196enum ForeignEnum {
197  FOREIGN_ZERO = 0;
198  FOREIGN_FOO = 4;
199  FOREIGN_BAR = 5;
200  FOREIGN_BAZ = 6;
201  FOREIGN_LARGE = 123456;  // Large enough to escape the Boxed Integer cache.
202}
203
204// TestEmptyMessage is used to test behavior of unknown fields.
205message TestEmptyMessage {
206}
207
208// Needed for a Python test.
209message TestPickleNestedMessage {
210  message NestedMessage {
211    int32 bb = 1;
212    message NestedNestedMessage {
213      int32 cc = 1;
214    }
215  }
216}
217