• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Protocol Buffers - Google's data interchange format
2// Copyright 2023 Google LLC.  All rights reserved.
3//
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file or at
6// https://developers.google.com/open-source/licenses/bsd
7
8syntax = "proto2";
9
10package hpb_unittest;
11
12import "google/protobuf/compiler/hpb/tests/child_model.proto";
13
14message TestModelContainer {
15  repeated TestModel models = 1;
16  optional ChildModel3 proto_3_child = 2;
17  extensions 10000 to max
18  [verification = UNVERIFIED];
19}
20
21message TestModel {
22  optional int32 value = 1;
23  repeated int32 value_array = 2;  // _UPB_MODE_ARRAY
24  repeated int32 value_packed_array = 3
25      [packed = true];  // _UPB_MODE_ARRAY | _UPB_MODE_IS_PACKED
26  repeated int32 value_deprec = 4 [deprecated = true];
27  optional string str1 = 115;
28  optional bool b1 = 9;
29  optional bool b2 = 10;
30  optional string str2 = 50;
31  optional string str3 = 11;
32  optional float optional_float = 14;
33  optional double optional_double = 15;
34  optional int64 optional_int64 = 16;
35  optional uint32 optional_uint32 = 17;
36  optional uint64 optional_uint64 = 18;
37  optional sint32 optional_sint32 = 19;
38  optional sint64 optional_sint64 = 20;
39  optional fixed32 optional_fixed32 = 21;
40  optional fixed64 optional_fixed64 = 22;
41  optional sfixed32 optional_sfixed32 = 23;
42  optional sfixed64 optional_sfixed64 = 24;
43  repeated int64 repeated_int64 = 25;
44  repeated uint64 repeated_uint64 = 26;
45  repeated fixed64 repeated_fixed64 = 27;
46  repeated sfixed64 repeated_sfixed64 = 28;
47  repeated bool repeated_bool = 29;
48  repeated string repeated_string = 35;
49  optional bytes optional_bytes = 36;
50  message NestedChild {
51    optional string nested_child_name = 211;
52  }
53  optional NestedChild nested_child_1 = 212;
54  optional ChildModel1 child_model_1 = 222;
55  repeated ChildModel1 child_models = 223;
56  optional ChildModel1 bar = 224;
57  oneof child_oneof1 {
58    string oneof_member1 = 98;
59    bool oneof_member2 = 99;
60  }
61  optional int32 int_value_with_default = 31
62      [default = 65];  // Not supported yet
63  optional string string_value_with_default = 32
64      [default = "hello"];  // Not supported yet
65  optional float float_value_with_default = 33 [default = inf];
66  optional float double_value_with_default = 34 [default = -inf];
67
68  map<int32, ChildModel1> child_map = 225;
69  optional TestModel recursive_child = 226;
70  map<string, ChildModel1> child_str_map = 227;
71  map<string, int32> str_to_int_map = 228;
72  map<string, string> str_to_str_map = 229;
73
74  extend TestAnnotation {
75    optional OtherExtension in_message_ext = 15000;
76  }
77
78  enum Category {
79    IMAGES = 5;
80    NEWS = 6;
81    VIDEO = 7;
82    RADIO = 8 [deprecated = true];
83  }
84  optional Category category = 37;
85
86  // keyword collisions (double, template, ...)
87  oneof type {
88    string string = 230;
89    int64 int64 = 231;
90    double double = 232;
91  }
92  optional string template = 233;
93  optional string msg = 234;
94  optional string arena = 235;
95
96  // Tests publicly imported enum.
97  optional TestEnum imported_enum = 238;
98
99  optional string phase = 239;
100  optional bool clear_phase = 240;
101
102  optional string doc_id = 241;
103  optional bool set_doc_id = 242;
104
105  extensions 10000 to max
106  [verification = UNVERIFIED];
107}
108
109// Old version with fewer fields to test backward/forward compatibility.
110message TestModelContainerV1 {
111  repeated TestModelV1 models = 1;
112}
113
114message TestModelV1 {
115  optional int32 value = 1;
116  repeated int32 value2 = 2;
117  repeated int32 value3 = 3 [packed = true];
118  repeated int32 value4 = 4 [deprecated = true];
119  optional bool b1 = 9;
120  optional bool b2 = 10;
121  optional string str2 = 50;
122}
123
124enum PrimaryColors {
125  RED = 1;
126  GREEN = 2;
127  BLUE = 3;
128}
129
130// TestModel extension.
131message ThemeExtension {
132  extend TestModel {
133    optional ThemeExtension theme_extension = 12003;
134  }
135  optional string ext_name = 1;
136  optional bool ext_bool = 2;
137}
138
139extend TestModel {
140  optional ThemeExtension theme = 12001;
141}
142
143message ContainerExtension {
144  extend TestModelContainer {
145    optional ContainerExtension container_extension = 12004;
146  }
147  optional string ext_container_name = 1;
148}
149
150extend TestModelContainer {
151  optional ContainerExtension container_ext = 12005;
152}
153
154message OtherExtension {
155  optional string ext2_name = 1;
156}
157
158extend TestModel {
159  optional OtherExtension other_ext = 12002;
160}
161
162message TestAnnotation {
163  extensions 10000 to max
164  [verification = UNVERIFIED];
165}
166
167message TestMessageHasEnum {
168  optional EnumDeclaredAfterMessage enum_declared_after_message = 1;
169}
170
171enum EnumDeclaredAfterMessage {
172  ZERO = 0;
173  ONE = 1;
174  TWO = 2;
175  THREE = 3;
176}
177