Paul Yang | e0e5466 | 2016-09-15 11:09:01 -0700 | [diff] [blame] | 1 | syntax = "proto3"; |
| 2 | |
Paul Yang | 8faa778 | 2018-12-26 10:36:09 -0800 | [diff] [blame] | 3 | import 'google/protobuf/any.proto'; |
Paul Yang | a32c2d0 | 2019-09-30 14:43:03 -0700 | [diff] [blame] | 4 | import 'google/protobuf/wrappers.proto'; |
Paul Yang | 4b145b1 | 2019-03-12 10:56:58 -0700 | [diff] [blame] | 5 | import 'google/protobuf/struct.proto'; |
Paul Yang | 46ae90d | 2016-12-08 11:16:49 -0800 | [diff] [blame] | 6 | import 'proto/test_include.proto'; |
Paul Yang | 7be0882 | 2017-04-19 20:03:34 -0700 | [diff] [blame] | 7 | import 'proto/test_no_namespace.proto'; |
Paul Yang | 6f32580 | 2017-06-05 00:10:18 -0700 | [diff] [blame] | 8 | import 'proto/test_php_namespace.proto'; |
| 9 | import 'proto/test_empty_php_namespace.proto'; |
Paul Yang | 6b27c1f | 2017-03-17 11:08:06 -0700 | [diff] [blame] | 10 | import 'proto/test_prefix.proto'; |
Paul Yang | e0e5466 | 2016-09-15 11:09:01 -0700 | [diff] [blame] | 11 | |
| 12 | package foo; |
| 13 | |
| 14 | message TestMessage { |
| 15 | // Singular |
| 16 | int32 optional_int32 = 1; |
| 17 | int64 optional_int64 = 2; |
| 18 | uint32 optional_uint32 = 3; |
| 19 | uint64 optional_uint64 = 4; |
| 20 | sint32 optional_sint32 = 5; |
| 21 | sint64 optional_sint64 = 6; |
| 22 | fixed32 optional_fixed32 = 7; |
| 23 | fixed64 optional_fixed64 = 8; |
| 24 | sfixed32 optional_sfixed32 = 9; |
| 25 | sfixed64 optional_sfixed64 = 10; |
| 26 | float optional_float = 11; |
| 27 | double optional_double = 12; |
| 28 | bool optional_bool = 13; |
| 29 | string optional_string = 14; |
| 30 | bytes optional_bytes = 15; |
| 31 | |
| 32 | TestEnum optional_enum = 16; |
| 33 | Sub optional_message = 17; |
| 34 | bar.TestInclude optional_included_message = 18; |
| 35 | TestMessage recursive = 19; |
| 36 | |
Joshua Haberman | ad5a215 | 2020-07-17 13:49:23 -0700 | [diff] [blame] | 37 | // True optional |
| 38 | optional int32 true_optional_int32 = 201; |
| 39 | optional int64 true_optional_int64 = 202; |
| 40 | optional uint32 true_optional_uint32 = 203; |
| 41 | optional uint64 true_optional_uint64 = 204; |
| 42 | optional sint32 true_optional_sint32 = 205; |
| 43 | optional sint64 true_optional_sint64 = 206; |
| 44 | optional fixed32 true_optional_fixed32 = 207; |
| 45 | optional fixed64 true_optional_fixed64 = 208; |
| 46 | optional sfixed32 true_optional_sfixed32 = 209; |
| 47 | optional sfixed64 true_optional_sfixed64 = 210; |
| 48 | optional float true_optional_float = 211; |
| 49 | optional double true_optional_double = 212; |
| 50 | optional bool true_optional_bool = 213; |
| 51 | optional string true_optional_string = 214; |
| 52 | optional bytes true_optional_bytes = 215; |
| 53 | |
| 54 | optional TestEnum true_optional_enum = 216; |
| 55 | optional Sub true_optional_message = 217; |
| 56 | optional bar.TestInclude true_optional_included_message = 218; |
| 57 | |
Paul Yang | e0e5466 | 2016-09-15 11:09:01 -0700 | [diff] [blame] | 58 | // Repeated |
| 59 | repeated int32 repeated_int32 = 31; |
| 60 | repeated int64 repeated_int64 = 32; |
| 61 | repeated uint32 repeated_uint32 = 33; |
| 62 | repeated uint64 repeated_uint64 = 34; |
| 63 | repeated sint32 repeated_sint32 = 35; |
| 64 | repeated sint64 repeated_sint64 = 36; |
| 65 | repeated fixed32 repeated_fixed32 = 37; |
| 66 | repeated fixed64 repeated_fixed64 = 38; |
| 67 | repeated sfixed32 repeated_sfixed32 = 39; |
| 68 | repeated sfixed64 repeated_sfixed64 = 40; |
| 69 | repeated float repeated_float = 41; |
| 70 | repeated double repeated_double = 42; |
| 71 | repeated bool repeated_bool = 43; |
| 72 | repeated string repeated_string = 44; |
| 73 | repeated bytes repeated_bytes = 45; |
| 74 | |
| 75 | repeated TestEnum repeated_enum = 46; |
| 76 | repeated Sub repeated_message = 47; |
| 77 | repeated TestMessage repeated_recursive = 48; |
| 78 | |
| 79 | oneof my_oneof { |
| 80 | int32 oneof_int32 = 51; |
| 81 | int64 oneof_int64 = 52; |
| 82 | uint32 oneof_uint32 = 53; |
| 83 | uint64 oneof_uint64 = 54; |
| 84 | uint32 oneof_sint32 = 55; |
| 85 | uint64 oneof_sint64 = 56; |
| 86 | uint32 oneof_fixed32 = 57; |
| 87 | uint64 oneof_fixed64 = 58; |
| 88 | uint32 oneof_sfixed32 = 59; |
| 89 | uint64 oneof_sfixed64 = 60; |
| 90 | double oneof_double = 61; |
| 91 | float oneof_float = 62; |
| 92 | bool oneof_bool = 63; |
| 93 | string oneof_string = 64; |
| 94 | bytes oneof_bytes = 65; |
| 95 | TestEnum oneof_enum = 66; |
| 96 | Sub oneof_message = 67; |
| 97 | } |
| 98 | |
| 99 | map<int32, int32> map_int32_int32 = 71; |
| 100 | map<int64, int64> map_int64_int64 = 72; |
| 101 | map<uint32, uint32> map_uint32_uint32 = 73; |
| 102 | map<uint64, uint64> map_uint64_uint64 = 74; |
| 103 | map<sint32, sint32> map_sint32_sint32 = 75; |
| 104 | map<sint64, sint64> map_sint64_sint64 = 76; |
| 105 | map<fixed32, fixed32> map_fixed32_fixed32 = 77; |
| 106 | map<fixed64, fixed64> map_fixed64_fixed64 = 78; |
| 107 | map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 79; |
| 108 | map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 80; |
| 109 | map<int32, float> map_int32_float = 81; |
| 110 | map<int32, double> map_int32_double = 82; |
| 111 | map<bool, bool> map_bool_bool = 83; |
| 112 | map<string, string> map_string_string = 84; |
| 113 | map<int32, bytes> map_int32_bytes = 85; |
| 114 | map<int32, TestEnum> map_int32_enum = 86; |
| 115 | map<int32, Sub> map_int32_message = 87; |
| 116 | |
| 117 | map<int32, TestMessage> map_recursive = 88; |
| 118 | |
| 119 | message Sub { |
| 120 | int32 a = 1; |
Paul Yang | bcbaabe | 2017-03-01 10:39:48 -0800 | [diff] [blame] | 121 | repeated int32 b = 2; |
Paul Yang | e0e5466 | 2016-09-15 11:09:01 -0700 | [diff] [blame] | 122 | } |
| 123 | |
Paul Yang | 7f3e237 | 2017-01-31 09:17:32 -0800 | [diff] [blame] | 124 | // Reserved for non-existing field test. |
| 125 | // int32 non_exist = 89; |
Paul Yang | 7be0882 | 2017-04-19 20:03:34 -0700 | [diff] [blame] | 126 | |
| 127 | NoNamespaceMessage optional_no_namespace_message = 91; |
| 128 | NoNamespaceEnum optional_no_namespace_enum = 92; |
| 129 | repeated NoNamespaceMessage repeated_no_namespace_message = 93; |
| 130 | repeated NoNamespaceEnum repeated_no_namespace_enum = 94; |
Paul Yang | b97cd57 | 2017-04-19 21:20:55 -0700 | [diff] [blame] | 131 | |
| 132 | enum NestedEnum { |
| 133 | ZERO = 0; |
| 134 | } |
| 135 | |
| 136 | NestedEnum optional_nested_enum = 101; |
Paul Yang | 4c57e84 | 2017-04-20 01:19:03 -0700 | [diff] [blame] | 137 | |
| 138 | // Test prefix for reserved words. |
| 139 | message Empty { |
| 140 | int32 a = 1; |
| 141 | } |
Paul Yang | 6032746 | 2017-10-09 12:39:13 -0700 | [diff] [blame] | 142 | |
| 143 | reserved 111; |
Paul Yang | 2dec82e | 2019-10-10 16:03:52 -0700 | [diff] [blame] | 144 | |
| 145 | // Test map with missing message value |
| 146 | map<string, TestMessage> map_string_message = 121; |
| 147 | map<string, google.protobuf.Any> map_string_any = 122; |
| 148 | map<string, google.protobuf.ListValue> map_string_list = 123; |
| 149 | map<string, google.protobuf.Struct> map_string_struct = 124; |
Christian Alexander Wolf | f4d0f7c | 2021-01-29 20:33:27 +0100 | [diff] [blame] | 150 | |
| 151 | // deprecated field |
| 152 | int32 deprecated_optional_int32 = 125 [deprecated=true]; |
Paul Yang | e0e5466 | 2016-09-15 11:09:01 -0700 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | enum TestEnum { |
| 156 | ZERO = 0; |
| 157 | ONE = 1; |
Paul Yang | dd8d5f5 | 2017-03-08 14:31:34 -0800 | [diff] [blame] | 158 | TWO = 2; |
Paul Yang | a6189ac | 2017-04-26 16:32:21 -0700 | [diff] [blame] | 159 | ECHO = 3; // Test reserved name. |
Paul Yang | e0e5466 | 2016-09-15 11:09:01 -0700 | [diff] [blame] | 160 | } |
| 161 | |
Paul Yang | 4c57e84 | 2017-04-20 01:19:03 -0700 | [diff] [blame] | 162 | // Test prefix for reserved words. |
| 163 | message Empty { |
| 164 | int32 a = 1; |
| 165 | } |
| 166 | |
Paul Yang | 282fb9e | 2017-05-29 15:30:47 -0700 | [diff] [blame] | 167 | message ARRAY { |
| 168 | int32 a = 1; |
| 169 | } |
| 170 | |
Paul Yang | e0e5466 | 2016-09-15 11:09:01 -0700 | [diff] [blame] | 171 | message TestPackedMessage { |
| 172 | repeated int32 repeated_int32 = 90 [packed = true]; |
| 173 | repeated int64 repeated_int64 = 91 [packed = true]; |
| 174 | repeated uint32 repeated_uint32 = 92 [packed = true]; |
| 175 | repeated uint64 repeated_uint64 = 93 [packed = true]; |
| 176 | repeated sint32 repeated_sint32 = 94 [packed = true]; |
| 177 | repeated sint64 repeated_sint64 = 95 [packed = true]; |
| 178 | repeated fixed32 repeated_fixed32 = 96 [packed = true]; |
| 179 | repeated fixed64 repeated_fixed64 = 97 [packed = true]; |
| 180 | repeated sfixed32 repeated_sfixed32 = 98 [packed = true]; |
| 181 | repeated sfixed64 repeated_sfixed64 = 99 [packed = true]; |
| 182 | repeated float repeated_float = 100 [packed = true]; |
| 183 | repeated double repeated_double = 101 [packed = true]; |
| 184 | repeated bool repeated_bool = 102 [packed = true]; |
| 185 | repeated TestEnum repeated_enum = 103 [packed = true]; |
| 186 | } |
| 187 | |
| 188 | // Need to be in sync with TestPackedMessage. |
| 189 | message TestUnpackedMessage { |
| 190 | repeated int32 repeated_int32 = 90 [packed = false]; |
| 191 | repeated int64 repeated_int64 = 91 [packed = false]; |
| 192 | repeated uint32 repeated_uint32 = 92 [packed = false]; |
| 193 | repeated uint64 repeated_uint64 = 93 [packed = false]; |
| 194 | repeated sint32 repeated_sint32 = 94 [packed = false]; |
| 195 | repeated sint64 repeated_sint64 = 95 [packed = false]; |
| 196 | repeated fixed32 repeated_fixed32 = 96 [packed = false]; |
| 197 | repeated fixed64 repeated_fixed64 = 97 [packed = false]; |
| 198 | repeated sfixed32 repeated_sfixed32 = 98 [packed = false]; |
| 199 | repeated sfixed64 repeated_sfixed64 = 99 [packed = false]; |
| 200 | repeated float repeated_float = 100 [packed = false]; |
| 201 | repeated double repeated_double = 101 [packed = false]; |
| 202 | repeated bool repeated_bool = 102 [packed = false]; |
| 203 | repeated TestEnum repeated_enum = 103 [packed = false]; |
| 204 | } |
Paul Yang | f8ca3ac | 2016-12-01 14:50:53 -0800 | [diff] [blame] | 205 | |
| 206 | // /**/@<>&\{ |
| 207 | message TestPhpDoc { |
| 208 | int32 a = 1; |
| 209 | } |
Paul Yang | 6b27c1f | 2017-03-17 11:08:06 -0700 | [diff] [blame] | 210 | |
| 211 | message TestIncludePrefixMessage { |
| 212 | TestPrefix prefix_message = 1; |
| 213 | } |
Paul Yang | 6f32580 | 2017-06-05 00:10:18 -0700 | [diff] [blame] | 214 | |
| 215 | message TestIncludeNamespaceMessage { |
| 216 | TestNamespace namespace_message = 1; |
| 217 | TestEmptyNamespace empty_namespace_message = 2; |
| 218 | } |
Paul Yang | c78dbd7 | 2017-07-14 15:48:48 -0600 | [diff] [blame] | 219 | |
| 220 | // This will cause upb fields not ordered by the order in the generated code. |
| 221 | message TestRandomFieldOrder { |
| 222 | int64 tag13 = 150; |
| 223 | string tag14 = 160; |
| 224 | } |
Paul Yang | 49b44bf | 2017-08-04 16:35:49 -0700 | [diff] [blame] | 225 | |
Joshua Haberman | d5079ed | 2021-01-27 10:12:59 -0800 | [diff] [blame] | 226 | message TestLargeFieldNumber { |
| 227 | int32 large_field_number = 536870911; |
| 228 | } |
| 229 | |
Paul Yang | 49b44bf | 2017-08-04 16:35:49 -0700 | [diff] [blame] | 230 | message TestReverseFieldOrder { |
| 231 | repeated int32 a = 2; |
| 232 | string b = 1; |
| 233 | } |
Bo Yang | dd51909 | 2017-08-21 13:39:15 -0700 | [diff] [blame] | 234 | |
| 235 | message testLowerCaseMessage { |
| 236 | } |
| 237 | |
| 238 | enum testLowerCaseEnum { |
| 239 | VALUE = 0; |
| 240 | } |
Paul Yang | 8faa778 | 2018-12-26 10:36:09 -0800 | [diff] [blame] | 241 | |
| 242 | message TestAny { |
| 243 | google.protobuf.Any any = 1; |
| 244 | } |
Paul Yang | a32c2d0 | 2019-09-30 14:43:03 -0700 | [diff] [blame] | 245 | |
Paul Yang | 601f696 | 2019-11-14 12:17:04 -0800 | [diff] [blame] | 246 | message TestInt32Value { |
| 247 | google.protobuf.Int32Value field = 1; |
| 248 | repeated google.protobuf.Int32Value repeated_field = 2; |
| 249 | oneof oneof_fields { |
| 250 | google.protobuf.Int32Value oneof_field = 3; |
| 251 | int32 int32_field = 4; |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | message TestInt64Value { |
| 256 | google.protobuf.Int64Value field = 1; |
| 257 | repeated google.protobuf.Int64Value repeated_field = 2; |
| 258 | oneof oneof_fields { |
| 259 | google.protobuf.Int64Value oneof_field = 3; |
| 260 | int32 int32_field = 4; |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | message TestUInt32Value { |
| 265 | google.protobuf.UInt32Value field = 1; |
| 266 | repeated google.protobuf.UInt32Value repeated_field = 2; |
| 267 | oneof oneof_fields { |
| 268 | google.protobuf.UInt32Value oneof_field = 3; |
| 269 | int32 int32_field = 4; |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | message TestUInt64Value { |
| 274 | google.protobuf.UInt64Value field = 1; |
| 275 | repeated google.protobuf.UInt64Value repeated_field = 2; |
| 276 | oneof oneof_fields { |
| 277 | google.protobuf.UInt64Value oneof_field = 3; |
| 278 | int32 int32_field = 4; |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | message TestBoolValue { |
| 283 | google.protobuf.BoolValue field = 1; |
| 284 | repeated google.protobuf.BoolValue repeated_field = 2; |
| 285 | oneof oneof_fields { |
| 286 | google.protobuf.BoolValue oneof_field = 3; |
| 287 | int32 int32_field = 4; |
| 288 | } |
| 289 | } |
| 290 | |
Paul Yang | a32c2d0 | 2019-09-30 14:43:03 -0700 | [diff] [blame] | 291 | message TestStringValue { |
| 292 | google.protobuf.StringValue field = 1; |
Paul Yang | 601f696 | 2019-11-14 12:17:04 -0800 | [diff] [blame] | 293 | repeated google.protobuf.StringValue repeated_field = 2; |
| 294 | oneof oneof_fields { |
| 295 | google.protobuf.StringValue oneof_field = 3; |
| 296 | int32 int32_field = 4; |
| 297 | } |
| 298 | map<int32, google.protobuf.StringValue> map_field = 5; |
| 299 | } |
| 300 | |
| 301 | message TestBytesValue { |
| 302 | google.protobuf.BytesValue field = 1; |
| 303 | repeated google.protobuf.BytesValue repeated_field = 2; |
| 304 | oneof oneof_fields { |
| 305 | google.protobuf.BytesValue oneof_field = 3; |
| 306 | int32 int32_field = 4; |
| 307 | } |
Paul Yang | a32c2d0 | 2019-09-30 14:43:03 -0700 | [diff] [blame] | 308 | } |
Joshua Haberman | 67995fb | 2022-01-27 17:06:41 -0800 | [diff] [blame] | 309 | |
| 310 | message Test32Fields { |
| 311 | optional uint32 id = 1; |
| 312 | optional uint32 random_name_a0 = 2; |
| 313 | optional uint32 random_name_a1 = 3; |
| 314 | optional uint32 random_name_a2 = 4; |
| 315 | optional uint32 random_name_a3 = 5; |
| 316 | optional uint32 random_name_a4 = 6; |
| 317 | optional uint32 random_name_a5 = 7; |
| 318 | optional uint32 random_name_a6 = 8; |
| 319 | optional uint32 random_name_a7 = 9; |
| 320 | optional uint32 random_name_a8 = 10; |
| 321 | optional uint32 random_name_a9 = 11; |
| 322 | optional uint32 random_name_b0 = 12; |
| 323 | optional uint32 random_name_b1 = 13; |
| 324 | optional uint32 random_name_b2 = 14; |
| 325 | optional uint32 random_name_b3 = 15; |
| 326 | optional uint32 random_name_b4 = 16; |
| 327 | optional uint32 random_name_b5 = 17; |
| 328 | optional uint32 random_name_b6 = 18; |
| 329 | optional uint32 random_name_b7 = 19; |
| 330 | optional uint32 random_name_b8 = 20; |
| 331 | optional uint32 random_name_b9 = 21; |
| 332 | optional uint32 random_name_c0 = 22; |
| 333 | optional uint32 random_name_c1 = 23; |
| 334 | optional uint32 random_name_c2 = 24; |
| 335 | optional uint32 random_name_c3 = 25; |
| 336 | optional uint32 random_name_c4 = 26; |
| 337 | optional uint32 random_name_c5 = 27; |
| 338 | optional uint32 random_name_c6 = 28; |
| 339 | optional uint32 random_name_c7 = 29; |
| 340 | optional uint32 random_name_c8 = 30; |
| 341 | optional uint32 random_name_c9 = 31; |
| 342 | optional string version = 32; |
| 343 | } |