1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17syntax = "proto2";
18
19package protozero.test.protos;
20
21import "src/protozero/test/example_proto/library.proto";
22
23// This file contains comprehensive set of supported message structures and
24// data types. Unit tests depends on the plugin-processed version of this file.
25
26// Tests importing message definition from another proto file.
27message TransgalacticParcel {
28  optional TransgalacticMessage message = 1;
29  optional string tracking_code = 2;
30}
31
32enum SmallEnum {
33  TO_BE = 1;
34  NOT_TO_BE = 0;
35}
36
37enum SignedEnum {
38  POSITIVE = 1;
39  NEUTRAL = 0;
40  NEGATIVE = -1;
41}
42
43enum BigEnum {
44  BEGIN = 10;
45  END = 100500;
46}
47
48message EveryField {
49  optional int32 field_int32 = 1;
50  optional int64 field_int64 = 2;
51  optional uint32 field_uint32 = 3;
52  optional uint64 field_uint64 = 4;
53  optional sint32 field_sint32 = 5;
54  optional sint64 field_sint64 = 6;
55  optional fixed32 field_fixed32 = 7;
56  optional fixed64 field_fixed64 = 8;
57  optional sfixed32 field_sfixed32 = 9;
58  optional sfixed64 field_sfixed64 = 10;
59  optional float field_float = 11;
60  optional double field_double = 12;
61  optional bool field_bool = 13;
62  repeated EveryField field_nested = 14;
63
64  optional SmallEnum small_enum = 51;
65  optional SignedEnum signed_enum = 52;
66  optional BigEnum big_enum = 53;
67
68  optional string field_string = 500;
69  optional bytes field_bytes = 505;
70
71  enum NestedEnum {
72    PING = 1;
73    PONG = 2;
74  }
75  optional NestedEnum nested_enum = 600;
76
77  repeated int32 repeated_int32 = 999;
78}
79
80message NestedA {
81  message NestedB {
82    message NestedC { optional int32 value_c = 1; }
83    optional NestedC value_b = 1;
84  }
85  repeated NestedB repeated_a = 2;
86  optional NestedB.NestedC super_nested = 3;
87}
88
89message CamelCaseFields {
90  // To check that any reasonable name converts to camel case correctly.
91  optional bool foo_bar_baz = 1;
92  optional bool barBaz = 2;
93  optional bool MooMoo = 3;
94  optional bool URLEncoder = 4;
95  optional bool XMap = 5;
96  optional bool UrLE_nco__der = 6;
97  optional bool __bigBang = 7;
98  optional bool U2 = 8;
99  optional bool bangBig__ = 9;
100}
101
102message PackedRepeatedFields {
103  repeated int32 field_int32 = 1 [packed = true];
104  repeated fixed32 field_fixed32 = 2 [packed = true];
105  repeated sfixed64 field_sfixed64 = 3 [packed = true];
106}
107
108// The following two messages are for testing that unknown fields being
109// preserved in the decode->reencode path.
110
111message TestVersioning_V1 {
112  enum Enumz_V1 {
113    ONE = 1;
114    TWO = 2;
115  }
116  message Sub1_V1 {
117    optional int32 sub1_int = 1;
118    optional string sub1_string = 2;
119  }
120  optional int32 root_int = 1;
121  repeated Enumz_V1 enumz = 2;
122  optional string root_string = 3;
123  repeated string rep_string = 4;
124  optional Sub1_V1 sub1 = 5;
125  repeated Sub1_V1 sub1_rep = 6;
126  optional Sub1_V1 sub1_lazy = 7 [lazy = true];
127}
128
129message TestVersioning_V2 {
130  enum Enumz_V2 {
131    ONE = 1;
132    TWO = 2;
133    THREE_V2 = 3;
134  }
135  message Sub1_V2 {
136    optional int32 sub1_int = 1;
137    optional string sub1_string = 2;
138    optional int32 sub1_int_v2 = 3;      // New in v2.
139    optional string sub1_string_v2 = 4;  // New in v2.
140  }
141  message Sub2_V2 {  // New in v2.
142    optional int32 sub2_int = 1;
143    optional string sub2_string = 2;
144  }
145
146  optional int32 root_int = 1;
147  repeated Enumz_V2 enumz = 2;
148  optional string root_string = 3;
149  repeated string rep_string = 4;
150  optional Sub1_V2 sub1 = 5;
151  repeated Sub1_V2 sub1_rep = 6;
152  optional Sub1_V2 sub1_lazy = 7 [lazy = true];
153
154  // New fields introduced in V2.
155  optional int32 root_int_v2 = 10;
156  optional Sub2_V2 sub2 = 11;
157  repeated Sub2_V2 sub2_rep = 12;
158  optional Sub2_V2 sub2_lazy = 13 [lazy = true];
159}
160