• 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// Test schema for proto3 messages.  This test schema is used by:
9//
10// - benchmarks
11// - fuzz tests
12// - conformance tests
13
14edition = "2023";
15
16package protobuf_test_messages.editions.proto3;
17
18import "google/protobuf/any.proto";
19import "google/protobuf/duration.proto";
20import "google/protobuf/field_mask.proto";
21import "google/protobuf/struct.proto";
22import "google/protobuf/timestamp.proto";
23import "google/protobuf/wrappers.proto";
24
25option features.field_presence = IMPLICIT;
26option java_package = "com.google.protobuf_test_messages.editions.proto3";
27option objc_class_prefix = "EditionsProto3";
28
29// This is the default, but we specify it here explicitly.
30option optimize_for = SPEED;
31option cc_enable_arenas = true;
32
33// This proto includes every type of field in both singular and repeated
34// forms.
35//
36// Also, crucially, all messages and enums in this file are eventually
37// submessages of this message.  So for example, a fuzz test of TestAllTypes
38// could trigger bugs that occur in any message type in this file.  We verify
39// this stays true in a unit test.
40message TestAllTypesProto3 {
41  message NestedMessage {
42    int32 a = 1;
43    TestAllTypesProto3 corecursive = 2;
44  }
45
46  enum NestedEnum {
47    FOO = 0;
48    BAR = 1;
49    BAZ = 2;
50    NEG = -1; // Intentionally negative.
51  }
52
53  enum AliasedEnum {
54    option allow_alias = true;
55
56    ALIAS_FOO = 0;
57    ALIAS_BAR = 1;
58    ALIAS_BAZ = 2;
59    MOO = 2;
60    moo = 2;
61    bAz = 2;
62  }
63
64  // Singular
65  int32 optional_int32 = 1;
66  int64 optional_int64 = 2;
67  uint32 optional_uint32 = 3;
68  uint64 optional_uint64 = 4;
69  sint32 optional_sint32 = 5;
70  sint64 optional_sint64 = 6;
71  fixed32 optional_fixed32 = 7;
72  fixed64 optional_fixed64 = 8;
73  sfixed32 optional_sfixed32 = 9;
74  sfixed64 optional_sfixed64 = 10;
75  float optional_float = 11;
76  double optional_double = 12;
77  bool optional_bool = 13;
78  string optional_string = 14;
79  bytes optional_bytes = 15;
80  NestedMessage optional_nested_message = 18;
81  ForeignMessage optional_foreign_message = 19;
82  NestedEnum optional_nested_enum = 21;
83  ForeignEnum optional_foreign_enum = 22;
84  AliasedEnum optional_aliased_enum = 23;
85  string optional_string_piece = 24 [
86    ctype = STRING_PIECE
87  ];
88
89  string optional_cord = 25 [
90    ctype = CORD
91  ];
92
93  TestAllTypesProto3 recursive_message = 27;
94
95  // Repeated
96  repeated int32 repeated_int32 = 31;
97  repeated int64 repeated_int64 = 32;
98  repeated uint32 repeated_uint32 = 33;
99  repeated uint64 repeated_uint64 = 34;
100  repeated sint32 repeated_sint32 = 35;
101  repeated sint64 repeated_sint64 = 36;
102  repeated fixed32 repeated_fixed32 = 37;
103  repeated fixed64 repeated_fixed64 = 38;
104  repeated sfixed32 repeated_sfixed32 = 39;
105  repeated sfixed64 repeated_sfixed64 = 40;
106  repeated float repeated_float = 41;
107  repeated double repeated_double = 42;
108  repeated bool repeated_bool = 43;
109  repeated string repeated_string = 44;
110  repeated bytes repeated_bytes = 45;
111  repeated NestedMessage repeated_nested_message = 48;
112  repeated ForeignMessage repeated_foreign_message = 49;
113  repeated NestedEnum repeated_nested_enum = 51;
114  repeated ForeignEnum repeated_foreign_enum = 52;
115  repeated string repeated_string_piece = 54 [
116    ctype = STRING_PIECE
117  ];
118
119  repeated string repeated_cord = 55 [
120    ctype = CORD
121  ];
122
123  // Packed
124  repeated int32 packed_int32 = 75;
125  repeated int64 packed_int64 = 76;
126  repeated uint32 packed_uint32 = 77;
127  repeated uint64 packed_uint64 = 78;
128  repeated sint32 packed_sint32 = 79;
129  repeated sint64 packed_sint64 = 80;
130  repeated fixed32 packed_fixed32 = 81;
131  repeated fixed64 packed_fixed64 = 82;
132  repeated sfixed32 packed_sfixed32 = 83;
133  repeated sfixed64 packed_sfixed64 = 84;
134  repeated float packed_float = 85;
135  repeated double packed_double = 86;
136  repeated bool packed_bool = 87;
137  repeated NestedEnum packed_nested_enum = 88;
138
139  // Unpacked
140  repeated int32 unpacked_int32 = 89 [
141    features.repeated_field_encoding = EXPANDED
142  ];
143
144  repeated int64 unpacked_int64 = 90 [
145    features.repeated_field_encoding = EXPANDED
146  ];
147
148  repeated uint32 unpacked_uint32 = 91 [
149    features.repeated_field_encoding = EXPANDED
150  ];
151
152  repeated uint64 unpacked_uint64 = 92 [
153    features.repeated_field_encoding = EXPANDED
154  ];
155
156  repeated sint32 unpacked_sint32 = 93 [
157    features.repeated_field_encoding = EXPANDED
158  ];
159
160  repeated sint64 unpacked_sint64 = 94 [
161    features.repeated_field_encoding = EXPANDED
162  ];
163
164  repeated fixed32 unpacked_fixed32 = 95 [
165    features.repeated_field_encoding = EXPANDED
166  ];
167
168  repeated fixed64 unpacked_fixed64 = 96 [
169    features.repeated_field_encoding = EXPANDED
170  ];
171
172  repeated sfixed32 unpacked_sfixed32 = 97 [
173    features.repeated_field_encoding = EXPANDED
174  ];
175
176  repeated sfixed64 unpacked_sfixed64 = 98 [
177    features.repeated_field_encoding = EXPANDED
178  ];
179
180  repeated float unpacked_float = 99 [
181    features.repeated_field_encoding = EXPANDED
182  ];
183
184  repeated double unpacked_double = 100 [
185    features.repeated_field_encoding = EXPANDED
186  ];
187
188  repeated bool unpacked_bool = 101 [
189    features.repeated_field_encoding = EXPANDED
190  ];
191
192  repeated NestedEnum unpacked_nested_enum = 102 [
193    features.repeated_field_encoding = EXPANDED
194  ];
195
196  // Map
197  map<int32, int32> map_int32_int32 = 56;
198  map<int64, int64> map_int64_int64 = 57;
199  map<uint32, uint32> map_uint32_uint32 = 58;
200  map<uint64, uint64> map_uint64_uint64 = 59;
201  map<sint32, sint32> map_sint32_sint32 = 60;
202  map<sint64, sint64> map_sint64_sint64 = 61;
203  map<fixed32, fixed32> map_fixed32_fixed32 = 62;
204  map<fixed64, fixed64> map_fixed64_fixed64 = 63;
205  map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 64;
206  map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 65;
207  map<int32, float> map_int32_float = 66;
208  map<int32, double> map_int32_double = 67;
209  map<bool, bool> map_bool_bool = 68;
210  map<string, string> map_string_string = 69;
211  map<string, bytes> map_string_bytes = 70;
212  map<string, NestedMessage> map_string_nested_message = 71;
213  map<string, ForeignMessage> map_string_foreign_message = 72;
214  map<string, NestedEnum> map_string_nested_enum = 73;
215  map<string, ForeignEnum> map_string_foreign_enum = 74;
216
217  oneof oneof_field {
218    uint32 oneof_uint32 = 111;
219    NestedMessage oneof_nested_message = 112;
220    string oneof_string = 113;
221    bytes oneof_bytes = 114;
222    bool oneof_bool = 115;
223    uint64 oneof_uint64 = 116;
224    float oneof_float = 117;
225    double oneof_double = 118;
226    NestedEnum oneof_enum = 119;
227    google.protobuf.NullValue oneof_null_value = 120;
228  }
229
230  // Well-known types
231  google.protobuf.BoolValue optional_bool_wrapper = 201;
232  google.protobuf.Int32Value optional_int32_wrapper = 202;
233  google.protobuf.Int64Value optional_int64_wrapper = 203;
234  google.protobuf.UInt32Value optional_uint32_wrapper = 204;
235  google.protobuf.UInt64Value optional_uint64_wrapper = 205;
236  google.protobuf.FloatValue optional_float_wrapper = 206;
237  google.protobuf.DoubleValue optional_double_wrapper = 207;
238  google.protobuf.StringValue optional_string_wrapper = 208;
239  google.protobuf.BytesValue optional_bytes_wrapper = 209;
240  repeated google.protobuf.BoolValue repeated_bool_wrapper = 211;
241  repeated google.protobuf.Int32Value repeated_int32_wrapper = 212;
242  repeated google.protobuf.Int64Value repeated_int64_wrapper = 213;
243  repeated google.protobuf.UInt32Value repeated_uint32_wrapper = 214;
244  repeated google.protobuf.UInt64Value repeated_uint64_wrapper = 215;
245  repeated google.protobuf.FloatValue repeated_float_wrapper = 216;
246  repeated google.protobuf.DoubleValue repeated_double_wrapper = 217;
247  repeated google.protobuf.StringValue repeated_string_wrapper = 218;
248  repeated google.protobuf.BytesValue repeated_bytes_wrapper = 219;
249  google.protobuf.Duration optional_duration = 301;
250  google.protobuf.Timestamp optional_timestamp = 302;
251  google.protobuf.FieldMask optional_field_mask = 303;
252  google.protobuf.Struct optional_struct = 304;
253  google.protobuf.Any optional_any = 305;
254  google.protobuf.Value optional_value = 306;
255  google.protobuf.NullValue optional_null_value = 307;
256  repeated google.protobuf.Duration repeated_duration = 311;
257  repeated google.protobuf.Timestamp repeated_timestamp = 312;
258  repeated google.protobuf.FieldMask repeated_fieldmask = 313;
259  repeated google.protobuf.Struct repeated_struct = 324;
260  repeated google.protobuf.Any repeated_any = 315;
261  repeated google.protobuf.Value repeated_value = 316;
262  repeated google.protobuf.ListValue repeated_list_value = 317;
263
264  // Test field-name-to-JSON-name convention.
265  // (protobuf says names can be any valid C/C++ identifier.)
266  int32 fieldname1 = 401;
267  int32 field_name2 = 402;
268  int32 _field_name3 = 403;
269  int32 field__name4_ = 404;
270  int32 field0name5 = 405;
271  int32 field_0_name6 = 406;
272  int32 fieldName7 = 407;
273  int32 FieldName8 = 408;
274  int32 field_Name9 = 409;
275  int32 Field_Name10 = 410;
276  int32 FIELD_NAME11 = 411;
277  int32 FIELD_name12 = 412;
278  int32 __field_name13 = 413;
279  int32 __Field_name14 = 414;
280  int32 field__name15 = 415;
281  int32 field__Name16 = 416;
282  int32 field_name17__ = 417;
283  int32 Field_name18__ = 418;
284
285  // Reserved for testing unknown fields
286  reserved 501 to 510;
287}
288
289message ForeignMessage {
290  int32 c = 1;
291}
292
293enum ForeignEnum {
294  FOREIGN_FOO = 0;
295  FOREIGN_BAR = 1;
296  FOREIGN_BAZ = 2;
297}
298
299message NullHypothesisProto3 {
300}
301
302message EnumOnlyProto3 {
303  enum Bool {
304    kFalse = 0;
305    kTrue = 1;
306  }
307}
308