xref: /aosp_15_r20/external/protobuf/ruby/tests/basic_test_proto2.proto (revision 1b3f573f81763fcece89efc2b6a5209149e44ab8)
1syntax = "proto2";
2
3package basic_test_proto2;
4
5import "google/protobuf/wrappers.proto";
6import "google/protobuf/timestamp.proto";
7import "google/protobuf/duration.proto";
8import "google/protobuf/struct.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 TestMessage2 {
50  optional int32 foo = 1;
51}
52
53message TestMessageDefaults {
54  optional int32 optional_int32 = 1 [default = 1];
55  optional int64 optional_int64 = 2 [default = 2];
56  optional uint32 optional_uint32 = 3 [default = 3];
57  optional uint64 optional_uint64 = 4 [default = 4];
58  optional bool optional_bool = 5 [default = true];
59  optional float optional_float = 6 [default = 6];
60  optional double optional_double = 7 [default = 7];
61  optional string optional_string = 8 [default = "Default Str"];
62  optional bytes optional_bytes = 9 [default = "\xCF\xA5s\xBD\xBA\xE6fubar"];
63  optional TestMessage2 optional_msg = 10;
64  optional TestNonZeroEnum optional_enum = 11 [default = B2];
65}
66
67enum TestEnum {
68  Default = 0;
69  A = 1;
70  B = 2;
71  C = 3;
72  v0 = 4;
73}
74
75enum TestNonZeroEnum {
76  A2 = 1;
77  B2 = 2;
78  C2 = 3;
79}
80
81message TestEmbeddedMessageParent {
82  optional TestEmbeddedMessageChild child_msg = 1;
83  optional int32 number = 2;
84
85  repeated TestEmbeddedMessageChild repeated_msg = 3;
86  repeated int32 repeated_number = 4;
87}
88
89message TestEmbeddedMessageChild {
90  optional TestMessage sub_child = 1;
91}
92
93message Recursive1 {
94  optional Recursive2 foo = 1;
95}
96
97message Recursive2 {
98  optional Recursive1 foo = 1;
99}
100
101message MapMessageWireEquiv {
102  repeated MapMessageWireEquiv_entry1 map_string_int32 = 1;
103  repeated MapMessageWireEquiv_entry2 map_string_msg = 2;
104}
105
106message MapMessageWireEquiv_entry1 {
107  optional string key = 1;
108  optional int32 value = 2;
109}
110
111message MapMessageWireEquiv_entry2 {
112  optional string key = 1;
113  optional TestMessage2 value = 2;
114}
115
116message OneofMessage {
117  oneof my_oneof {
118    string a = 1;
119    int32 b = 2;
120    TestMessage2 c = 3;
121    TestEnum d = 4;
122  }
123}
124
125message Wrapper {
126  optional google.protobuf.DoubleValue double = 1;
127  optional google.protobuf.FloatValue float = 2;
128  optional google.protobuf.Int32Value int32 = 3;
129  optional google.protobuf.Int64Value int64 = 4;
130  optional google.protobuf.UInt32Value uint32 = 5;
131  optional google.protobuf.UInt64Value uint64 = 6;
132  optional google.protobuf.BoolValue bool = 7;
133  optional google.protobuf.StringValue string = 8;
134  optional google.protobuf.BytesValue bytes = 9;
135  optional string real_string = 100;
136  oneof a_oneof {
137    string string_in_oneof = 10;
138  }
139
140  // Repeated wrappers don't really make sense, but we still need to make sure
141  // they work and don't crash.
142  repeated google.protobuf.DoubleValue repeated_double = 11;
143  repeated google.protobuf.FloatValue repeated_float = 12;
144  repeated google.protobuf.Int32Value repeated_int32 = 13;
145  repeated google.protobuf.Int64Value repeated_int64 = 14;
146  repeated google.protobuf.UInt32Value repeated_uint32 = 15;
147  repeated google.protobuf.UInt64Value repeated_uint64 = 16;
148  repeated google.protobuf.BoolValue repeated_bool = 17;
149  repeated google.protobuf.StringValue repeated_string = 18;
150  repeated google.protobuf.BytesValue repeated_bytes = 19;
151
152  // Wrappers in oneofs don't make sense, but we still need to make sure they
153  // work and don't crash.
154  oneof wrapper_oneof {
155    google.protobuf.DoubleValue oneof_double = 31;
156    google.protobuf.FloatValue oneof_float = 32;
157    google.protobuf.Int32Value oneof_int32 = 33;
158    google.protobuf.Int64Value oneof_int64 = 34;
159    google.protobuf.UInt32Value oneof_uint32 = 35;
160    google.protobuf.UInt64Value oneof_uint64 = 36;
161    google.protobuf.BoolValue oneof_bool = 37;
162    google.protobuf.StringValue oneof_string = 38;
163    google.protobuf.BytesValue oneof_bytes = 39;
164    string oneof_plain_string = 101;
165  }
166}
167
168message TimeMessage {
169  optional google.protobuf.Timestamp timestamp = 1;
170  optional google.protobuf.Duration duration = 2;
171}
172
173message Enumer {
174  optional TestEnum optional_enum = 11;
175  repeated TestEnum repeated_enum = 22;
176  optional string a_const = 3;
177  oneof a_oneof {
178    string str = 100;
179    TestEnum const = 101;
180  }
181}
182
183message MyRepeatedStruct {
184  repeated MyStruct structs = 1;
185}
186
187message MyStruct {
188  optional string string = 1;
189  optional google.protobuf.Struct struct = 2;
190}
191