aboutsummaryrefslogtreecommitdiff
path: root/src/protozero/test/example_proto/test_messages.proto
blob: ba3e5d39c1e6dc41309d07752110165d987e09d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

syntax = "proto2";

package protozero.test.protos;

import "src/protozero/test/example_proto/library.proto";

// This file contains comprehensive set of supported message structures and
// data types. Unit tests depends on the plugin-processed version of this file.

// Tests importing message definition from another proto file.
message TransgalacticParcel {
  optional TransgalacticMessage message = 1;
  optional string tracking_code = 2;
}

enum SmallEnum {
  TO_BE = 1;
  NOT_TO_BE = 0;
}

enum SignedEnum {
  POSITIVE = 1;
  NEUTRAL = 0;
  NEGATIVE = -1;
}

enum BigEnum {
  BEGIN = 10;
  END = 100500;
}

message EveryField {
  optional int32 field_int32 = 1;
  optional int64 field_int64 = 2;
  optional uint32 field_uint32 = 3;
  optional uint64 field_uint64 = 4;
  optional sint32 field_sint32 = 5;
  optional sint64 field_sint64 = 6;
  optional fixed32 field_fixed32 = 7;
  optional fixed64 field_fixed64 = 8;
  optional sfixed32 field_sfixed32 = 9;
  optional sfixed64 field_sfixed64 = 10;
  optional float field_float = 11;
  optional double field_double = 12;
  optional bool field_bool = 13;
  repeated EveryField field_nested = 14;

  optional SmallEnum small_enum = 51;
  optional SignedEnum signed_enum = 52;
  optional BigEnum big_enum = 53;

  optional string field_string = 500;
  optional bytes field_bytes = 505;

  enum NestedEnum {
    PING = 1;
    PONG = 2;
  }
  optional NestedEnum nested_enum = 600;

  repeated int32 repeated_int32 = 999;
}

message NestedA {
  message NestedB {
    message NestedC { optional int32 value_c = 1; }
    optional NestedC value_b = 1;
  }
  repeated NestedB repeated_a = 2;
  optional NestedB.NestedC super_nested = 3;
}

message CamelCaseFields {
  // To check that any reasonable name converts to camel case correctly.
  optional bool foo_bar_baz = 1;
  optional bool barBaz = 2;
  optional bool MooMoo = 3;
  optional bool URLEncoder = 4;
  optional bool XMap = 5;
  optional bool UrLE_nco__der = 6;
  optional bool __bigBang = 7;
  optional bool U2 = 8;
  optional bool bangBig__ = 9;
}

message PackedRepeatedFields {
  repeated int32 field_int32 = 1 [packed = true];
  repeated int64 field_int64 = 4 [packed = true];
  repeated uint32 field_uint32 = 5 [packed = true];
  repeated uint64 field_uint64 = 6 [packed = true];
  // Repeated packed Zig-zag fields are currently unsupported by our protoc
  // plugin.
  // repeated sint32 field_sint32 = 7 [packed = true];
  // repeated sint64 field_sint64 = 8 [packed = true];
  repeated fixed32 field_fixed32 = 2 [packed = true];
  repeated fixed64 field_fixed64 = 9 [packed = true];
  repeated sfixed32 field_sfixed32 = 10 [packed = true];
  repeated sfixed64 field_sfixed64 = 3 [packed = true];
  repeated float field_float = 11 [packed = true];
  repeated double field_double = 12 [packed = true];
  // Repeated (even non-packed) bool fields are currently unsupported by our
  // protoc plugin.
  // repeated bool field_bool = 13 [packed = true];
  // Repeated packed enum fields are currently unsupported by our protoc plugin.
  // repeated SmallEnum small_enum = 51 [packed = true];
  // repeated SignedEnum signed_enum = 52 [packed = true];
  // repeated BigEnum big_enum = 53 [packed = true];
}

// The following two messages are for testing that unknown fields being
// preserved in the decode->reencode path.

message TestVersioning_V1 {
  enum Enumz_V1 {
    ONE = 1;
    TWO = 2;
  }
  message Sub1_V1 {
    optional int32 sub1_int = 1;
    optional string sub1_string = 2;
  }
  optional int32 root_int = 1;
  repeated Enumz_V1 enumz = 2;
  optional string root_string = 3;
  repeated string rep_string = 4;
  optional Sub1_V1 sub1 = 5;
  repeated Sub1_V1 sub1_rep = 6;
  optional Sub1_V1 sub1_lazy = 7 [lazy = true];
}

message TestVersioning_V2 {
  enum Enumz_V2 {
    ONE = 1;
    TWO = 2;
    THREE_V2 = 3;
  }
  message Sub1_V2 {
    optional int32 sub1_int = 1;
    optional string sub1_string = 2;
    optional int32 sub1_int_v2 = 3;      // New in v2.
    optional string sub1_string_v2 = 4;  // New in v2.
  }
  message Sub2_V2 {  // New in v2.
    optional int32 sub2_int = 1;
    optional string sub2_string = 2;
  }

  optional int32 root_int = 1;
  repeated Enumz_V2 enumz = 2;
  optional string root_string = 3;
  repeated string rep_string = 4;
  optional Sub1_V2 sub1 = 5;
  repeated Sub1_V2 sub1_rep = 6;
  optional Sub1_V2 sub1_lazy = 7 [lazy = true];

  // New fields introduced in V2.
  optional int32 root_int_v2 = 10;
  optional Sub2_V2 sub2 = 11;
  repeated Sub2_V2 sub2_rep = 12;
  optional Sub2_V2 sub2_lazy = 13 [lazy = true];
}