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