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