• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 int64 field_int64 = 4 [packed = true];
105  repeated uint32 field_uint32 = 5 [packed = true];
106  repeated uint64 field_uint64 = 6 [packed = true];
107  // Repeated packed Zig-zag fields are currently unsupported by our protoc
108  // plugin.
109  // repeated sint32 field_sint32 = 7 [packed = true];
110  // repeated sint64 field_sint64 = 8 [packed = true];
111  repeated fixed32 field_fixed32 = 2 [packed = true];
112  repeated fixed64 field_fixed64 = 9 [packed = true];
113  repeated sfixed32 field_sfixed32 = 10 [packed = true];
114  repeated sfixed64 field_sfixed64 = 3 [packed = true];
115  repeated float field_float = 11 [packed = true];
116  repeated double field_double = 12 [packed = true];
117  // Repeated (even non-packed) bool fields are currently unsupported by our
118  // protoc plugin.
119  // repeated bool field_bool = 13 [packed = true];
120  // Repeated packed enum fields are currently unsupported by our protoc plugin.
121  // repeated SmallEnum small_enum = 51 [packed = true];
122  // repeated SignedEnum signed_enum = 52 [packed = true];
123  // repeated BigEnum big_enum = 53 [packed = true];
124}
125
126// The following two messages are for testing that unknown fields being
127// preserved in the decode->reencode path.
128
129message TestVersioning_V1 {
130  enum Enumz_V1 {
131    ONE = 1;
132    TWO = 2;
133  }
134  message Sub1_V1 {
135    optional int32 sub1_int = 1;
136    optional string sub1_string = 2;
137  }
138  optional int32 root_int = 1;
139  repeated Enumz_V1 enumz = 2;
140  optional string root_string = 3;
141  repeated string rep_string = 4;
142  optional Sub1_V1 sub1 = 5;
143  repeated Sub1_V1 sub1_rep = 6;
144  optional Sub1_V1 sub1_lazy = 7 [lazy = true];
145}
146
147message TestVersioning_V2 {
148  enum Enumz_V2 {
149    ONE = 1;
150    TWO = 2;
151    THREE_V2 = 3;
152  }
153  message Sub1_V2 {
154    optional int32 sub1_int = 1;
155    optional string sub1_string = 2;
156    optional int32 sub1_int_v2 = 3;      // New in v2.
157    optional string sub1_string_v2 = 4;  // New in v2.
158  }
159  message Sub2_V2 {  // New in v2.
160    optional int32 sub2_int = 1;
161    optional string sub2_string = 2;
162  }
163
164  optional int32 root_int = 1;
165  repeated Enumz_V2 enumz = 2;
166  optional string root_string = 3;
167  repeated string rep_string = 4;
168  optional Sub1_V2 sub1 = 5;
169  repeated Sub1_V2 sub1_rep = 6;
170  optional Sub1_V2 sub1_lazy = 7 [lazy = true];
171
172  // New fields introduced in V2.
173  optional int32 root_int_v2 = 10;
174  optional Sub2_V2 sub2 = 11;
175  repeated Sub2_V2 sub2_rep = 12;
176  optional Sub2_V2 sub2_lazy = 13 [lazy = true];
177}
178