• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1syntax = "proto2";
2
3package basic_test_proto2;
4
5import "google/protobuf/duration.proto";
6import "google/protobuf/struct.proto";
7import "google/protobuf/timestamp.proto";
8import "google/protobuf/wrappers.proto";
9
10message Foo {
11  optional Bar bar = 1;
12  repeated Baz baz = 2;
13}
14
15message Bar {
16  optional string msg = 1;
17}
18
19message Baz {
20  optional string msg = 1;
21}
22
23message TestMessage {
24  optional int32 optional_int32 = 1;
25  optional int64 optional_int64 = 2;
26  optional uint32 optional_uint32 = 3;
27  optional uint64 optional_uint64 = 4;
28  optional bool optional_bool = 5;
29  optional float optional_float = 6;
30  optional double optional_double = 7;
31  optional string optional_string = 8;
32  optional bytes optional_bytes = 9;
33  optional TestMessage2 optional_msg = 10;
34  optional TestEnum optional_enum = 11;
35
36  repeated int32 repeated_int32 = 12;
37  repeated int64 repeated_int64 = 13;
38  repeated uint32 repeated_uint32 = 14;
39  repeated uint64 repeated_uint64 = 15;
40  repeated bool repeated_bool = 16;
41  repeated float repeated_float = 17;
42  repeated double repeated_double = 18;
43  repeated string repeated_string = 19;
44  repeated bytes repeated_bytes = 20;
45  repeated TestMessage2 repeated_msg = 21;
46  repeated TestEnum repeated_enum = 22;
47}
48
49message TestPackedMessage {
50  repeated int32 repeated_int32 = 12 [packed = true];
51}
52
53message TestGroupMessage {
54  optional group GroupField = 1 {
55    optional int32 a = 1;
56  }
57}
58
59message TestRequiredMessage {
60  required int32 required_int32 = 1;
61}
62
63message TestMessage2 {
64  optional int32 foo = 1;
65}
66
67message TestMessageDefaults {
68  optional int32 optional_int32 = 1 [default = 1];
69  optional int64 optional_int64 = 2 [default = 2];
70  optional uint32 optional_uint32 = 3 [default = 3];
71  optional uint64 optional_uint64 = 4 [default = 4];
72  optional bool optional_bool = 5 [default = true];
73  optional float optional_float = 6 [default = 6];
74  optional double optional_double = 7 [default = 7];
75  optional string optional_string = 8 [default = "Default Str"];
76  optional bytes optional_bytes = 9 [default = "\xCF\xA5s\xBD\xBA\xE6fubar"];
77  optional TestMessage2 optional_msg = 10;
78  optional TestNonZeroEnum optional_enum = 11 [default = B2];
79}
80
81enum TestEnum {
82  Default = 0;
83  A = 1;
84  B = 2;
85  C = 3;
86  v0 = 4;
87}
88
89enum TestNonZeroEnum {
90  A2 = 1;
91  B2 = 2;
92  C2 = 3;
93}
94
95message TestEmbeddedMessageParent {
96  optional TestEmbeddedMessageChild child_msg = 1;
97  optional int32 number = 2;
98
99  repeated TestEmbeddedMessageChild repeated_msg = 3;
100  repeated int32 repeated_number = 4;
101}
102
103message TestEmbeddedMessageChild {
104  optional TestMessage sub_child = 1;
105}
106
107message Recursive1 {
108  optional Recursive2 foo = 1;
109}
110
111message Recursive2 {
112  optional Recursive1 foo = 1;
113}
114
115message MapMessageWireEquiv {
116  repeated MapMessageWireEquiv_entry1 map_string_int32 = 1;
117  repeated MapMessageWireEquiv_entry2 map_string_msg = 2;
118}
119
120message MapMessageWireEquiv_entry1 {
121  optional string key = 1;
122  optional int32 value = 2;
123}
124
125message MapMessageWireEquiv_entry2 {
126  optional string key = 1;
127  optional TestMessage2 value = 2;
128}
129
130message OneofMessage {
131  oneof my_oneof {
132    string a = 1;
133    int32 b = 2;
134    TestMessage2 c = 3;
135    TestEnum d = 4;
136  }
137}
138
139message Wrapper {
140  optional google.protobuf.DoubleValue double = 1;
141  optional google.protobuf.FloatValue float = 2;
142  optional google.protobuf.Int32Value int32 = 3;
143  optional google.protobuf.Int64Value int64 = 4;
144  optional google.protobuf.UInt32Value uint32 = 5;
145  optional google.protobuf.UInt64Value uint64 = 6;
146  optional google.protobuf.BoolValue bool = 7;
147  optional google.protobuf.StringValue string = 8;
148  optional google.protobuf.BytesValue bytes = 9;
149  optional string real_string = 100;
150  oneof a_oneof {
151    string string_in_oneof = 10;
152  }
153
154  // Repeated wrappers don't really make sense, but we still need to make sure
155  // they work and don't crash.
156  repeated google.protobuf.DoubleValue repeated_double = 11;
157  repeated google.protobuf.FloatValue repeated_float = 12;
158  repeated google.protobuf.Int32Value repeated_int32 = 13;
159  repeated google.protobuf.Int64Value repeated_int64 = 14;
160  repeated google.protobuf.UInt32Value repeated_uint32 = 15;
161  repeated google.protobuf.UInt64Value repeated_uint64 = 16;
162  repeated google.protobuf.BoolValue repeated_bool = 17;
163  repeated google.protobuf.StringValue repeated_string = 18;
164  repeated google.protobuf.BytesValue repeated_bytes = 19;
165
166  // Wrappers in oneofs don't make sense, but we still need to make sure they
167  // work and don't crash.
168  oneof wrapper_oneof {
169    google.protobuf.DoubleValue oneof_double = 31;
170    google.protobuf.FloatValue oneof_float = 32;
171    google.protobuf.Int32Value oneof_int32 = 33;
172    google.protobuf.Int64Value oneof_int64 = 34;
173    google.protobuf.UInt32Value oneof_uint32 = 35;
174    google.protobuf.UInt64Value oneof_uint64 = 36;
175    google.protobuf.BoolValue oneof_bool = 37;
176    google.protobuf.StringValue oneof_string = 38;
177    google.protobuf.BytesValue oneof_bytes = 39;
178    string oneof_plain_string = 101;
179  }
180}
181
182message TimeMessage {
183  optional google.protobuf.Timestamp timestamp = 1;
184  optional google.protobuf.Duration duration = 2;
185}
186
187message Enumer {
188  optional TestEnum optional_enum = 11;
189  repeated TestEnum repeated_enum = 22;
190  optional string a_const = 3;
191  oneof a_oneof {
192    string str = 100;
193    TestEnum const = 101;
194  }
195}
196
197message MyRepeatedStruct {
198  repeated MyStruct structs = 1;
199}
200
201message MyStruct {
202  optional string string = 1;
203  optional google.protobuf.Struct struct = 2;
204}
205
206message TestExtensions {
207  extensions 1 to max;
208}
209
210message TestNestedExtension {
211  extend TestExtensions {
212    optional string test = 1002 [default = "test"];
213  }
214}
215
216extend TestExtensions {
217  optional int32 optional_int32_extension = 1;
218}
219
220// A message with message_set_wire_format.
221message TestMessageSet {
222  option message_set_wire_format = true;
223
224  extensions 4 to max;
225}
226
227message TestMessageSetExtension1 {
228  extend TestMessageSet {
229    optional TestMessageSetExtension1 message_set_extension = 98418603;
230  }
231  optional int32 i = 15;
232}
233
234message TestMessageSetExtension2 {
235  extend TestMessageSet {
236    optional TestMessageSetExtension2 message_set_extension = 98418634;
237  }
238  optional string str = 25;
239}
240
241message TestMessageSetExtension3 {
242  optional string text = 35;
243}
244
245extend TestMessageSet {
246  optional TestMessageSetExtension3 message_set_extension3 = 98418655;
247}
248
249message BadFieldNames {
250  optional int32 dup = 1;
251  optional int32 class = 2;
252}
253