1// Protocol Buffers - Google's data interchange format 2// Copyright 2008 Google Inc. 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// 8// Test schema for proto3 messages. This test schema is used by: 9// 10// - benchmarks 11// - fuzz tests 12// - conformance tests 13// 14 15syntax = "proto3"; 16 17package protobuf_test_messages.proto3; 18 19option java_package = "com.google.protobuf_test_messages.proto3"; 20option objc_class_prefix = "Proto3"; 21 22// This is the default, but we specify it here explicitly. 23option optimize_for = SPEED; 24 25import "google/protobuf/any.proto"; 26import "google/protobuf/duration.proto"; 27import "google/protobuf/field_mask.proto"; 28import "google/protobuf/struct.proto"; 29import "google/protobuf/timestamp.proto"; 30import "google/protobuf/wrappers.proto"; 31 32option cc_enable_arenas = true; 33 34// This proto includes every type of field in both singular and repeated 35// forms. 36// 37// Also, crucially, all messages and enums in this file are eventually 38// submessages of this message. So for example, a fuzz test of TestAllTypes 39// could trigger bugs that occur in any message type in this file. We verify 40// this stays true in a unit test. 41message TestAllTypesProto3 { 42 message NestedMessage { 43 int32 a = 1; 44 TestAllTypesProto3 corecursive = 2; 45 } 46 47 enum NestedEnum { 48 FOO = 0; 49 BAR = 1; 50 BAZ = 2; 51 NEG = -1; // Intentionally negative. 52 } 53 54 enum AliasedEnum { 55 option allow_alias = true; 56 57 ALIAS_FOO = 0; 58 ALIAS_BAR = 1; 59 ALIAS_BAZ = 2; 60 MOO = 2; 61 moo = 2; 62 bAz = 2; 63 } 64 65 // Singular 66 int32 optional_int32 = 1; 67 int64 optional_int64 = 2; 68 uint32 optional_uint32 = 3; 69 uint64 optional_uint64 = 4; 70 sint32 optional_sint32 = 5; 71 sint64 optional_sint64 = 6; 72 fixed32 optional_fixed32 = 7; 73 fixed64 optional_fixed64 = 8; 74 sfixed32 optional_sfixed32 = 9; 75 sfixed64 optional_sfixed64 = 10; 76 float optional_float = 11; 77 double optional_double = 12; 78 bool optional_bool = 13; 79 string optional_string = 14; 80 bytes optional_bytes = 15; 81 82 NestedMessage optional_nested_message = 18; 83 ForeignMessage optional_foreign_message = 19; 84 85 NestedEnum optional_nested_enum = 21; 86 ForeignEnum optional_foreign_enum = 22; 87 AliasedEnum optional_aliased_enum = 23; 88 89 string optional_string_piece = 24 [ctype = STRING_PIECE]; 90 string optional_cord = 25 [ctype = CORD]; 91 92 TestAllTypesProto3 recursive_message = 27; 93 94 // Repeated 95 repeated int32 repeated_int32 = 31; 96 repeated int64 repeated_int64 = 32; 97 repeated uint32 repeated_uint32 = 33; 98 repeated uint64 repeated_uint64 = 34; 99 repeated sint32 repeated_sint32 = 35; 100 repeated sint64 repeated_sint64 = 36; 101 repeated fixed32 repeated_fixed32 = 37; 102 repeated fixed64 repeated_fixed64 = 38; 103 repeated sfixed32 repeated_sfixed32 = 39; 104 repeated sfixed64 repeated_sfixed64 = 40; 105 repeated float repeated_float = 41; 106 repeated double repeated_double = 42; 107 repeated bool repeated_bool = 43; 108 repeated string repeated_string = 44; 109 repeated bytes repeated_bytes = 45; 110 111 repeated NestedMessage repeated_nested_message = 48; 112 repeated ForeignMessage repeated_foreign_message = 49; 113 114 repeated NestedEnum repeated_nested_enum = 51; 115 repeated ForeignEnum repeated_foreign_enum = 52; 116 117 repeated string repeated_string_piece = 54 [ctype = STRING_PIECE]; 118 repeated string repeated_cord = 55 [ctype = CORD]; 119 120 // Packed 121 repeated int32 packed_int32 = 75 [packed = true]; 122 repeated int64 packed_int64 = 76 [packed = true]; 123 repeated uint32 packed_uint32 = 77 [packed = true]; 124 repeated uint64 packed_uint64 = 78 [packed = true]; 125 repeated sint32 packed_sint32 = 79 [packed = true]; 126 repeated sint64 packed_sint64 = 80 [packed = true]; 127 repeated fixed32 packed_fixed32 = 81 [packed = true]; 128 repeated fixed64 packed_fixed64 = 82 [packed = true]; 129 repeated sfixed32 packed_sfixed32 = 83 [packed = true]; 130 repeated sfixed64 packed_sfixed64 = 84 [packed = true]; 131 repeated float packed_float = 85 [packed = true]; 132 repeated double packed_double = 86 [packed = true]; 133 repeated bool packed_bool = 87 [packed = true]; 134 repeated NestedEnum packed_nested_enum = 88 [packed = true]; 135 136 // Unpacked 137 repeated int32 unpacked_int32 = 89 [packed = false]; 138 repeated int64 unpacked_int64 = 90 [packed = false]; 139 repeated uint32 unpacked_uint32 = 91 [packed = false]; 140 repeated uint64 unpacked_uint64 = 92 [packed = false]; 141 repeated sint32 unpacked_sint32 = 93 [packed = false]; 142 repeated sint64 unpacked_sint64 = 94 [packed = false]; 143 repeated fixed32 unpacked_fixed32 = 95 [packed = false]; 144 repeated fixed64 unpacked_fixed64 = 96 [packed = false]; 145 repeated sfixed32 unpacked_sfixed32 = 97 [packed = false]; 146 repeated sfixed64 unpacked_sfixed64 = 98 [packed = false]; 147 repeated float unpacked_float = 99 [packed = false]; 148 repeated double unpacked_double = 100 [packed = false]; 149 repeated bool unpacked_bool = 101 [packed = false]; 150 repeated NestedEnum unpacked_nested_enum = 102 [packed = false]; 151 152 // Map 153 map<int32, int32> map_int32_int32 = 56; 154 map<int64, int64> map_int64_int64 = 57; 155 map<uint32, uint32> map_uint32_uint32 = 58; 156 map<uint64, uint64> map_uint64_uint64 = 59; 157 map<sint32, sint32> map_sint32_sint32 = 60; 158 map<sint64, sint64> map_sint64_sint64 = 61; 159 map<fixed32, fixed32> map_fixed32_fixed32 = 62; 160 map<fixed64, fixed64> map_fixed64_fixed64 = 63; 161 map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 64; 162 map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 65; 163 map<int32, float> map_int32_float = 66; 164 map<int32, double> map_int32_double = 67; 165 map<bool, bool> map_bool_bool = 68; 166 map<string, string> map_string_string = 69; 167 map<string, bytes> map_string_bytes = 70; 168 map<string, NestedMessage> map_string_nested_message = 71; 169 map<string, ForeignMessage> map_string_foreign_message = 72; 170 map<string, NestedEnum> map_string_nested_enum = 73; 171 map<string, ForeignEnum> map_string_foreign_enum = 74; 172 173 oneof oneof_field { 174 uint32 oneof_uint32 = 111; 175 NestedMessage oneof_nested_message = 112; 176 string oneof_string = 113; 177 bytes oneof_bytes = 114; 178 bool oneof_bool = 115; 179 uint64 oneof_uint64 = 116; 180 float oneof_float = 117; 181 double oneof_double = 118; 182 NestedEnum oneof_enum = 119; 183 google.protobuf.NullValue oneof_null_value = 120; 184 } 185 186 // Well-known types 187 google.protobuf.BoolValue optional_bool_wrapper = 201; 188 google.protobuf.Int32Value optional_int32_wrapper = 202; 189 google.protobuf.Int64Value optional_int64_wrapper = 203; 190 google.protobuf.UInt32Value optional_uint32_wrapper = 204; 191 google.protobuf.UInt64Value optional_uint64_wrapper = 205; 192 google.protobuf.FloatValue optional_float_wrapper = 206; 193 google.protobuf.DoubleValue optional_double_wrapper = 207; 194 google.protobuf.StringValue optional_string_wrapper = 208; 195 google.protobuf.BytesValue optional_bytes_wrapper = 209; 196 197 repeated google.protobuf.BoolValue repeated_bool_wrapper = 211; 198 repeated google.protobuf.Int32Value repeated_int32_wrapper = 212; 199 repeated google.protobuf.Int64Value repeated_int64_wrapper = 213; 200 repeated google.protobuf.UInt32Value repeated_uint32_wrapper = 214; 201 repeated google.protobuf.UInt64Value repeated_uint64_wrapper = 215; 202 repeated google.protobuf.FloatValue repeated_float_wrapper = 216; 203 repeated google.protobuf.DoubleValue repeated_double_wrapper = 217; 204 repeated google.protobuf.StringValue repeated_string_wrapper = 218; 205 repeated google.protobuf.BytesValue repeated_bytes_wrapper = 219; 206 207 google.protobuf.Duration optional_duration = 301; 208 google.protobuf.Timestamp optional_timestamp = 302; 209 google.protobuf.FieldMask optional_field_mask = 303; 210 google.protobuf.Struct optional_struct = 304; 211 google.protobuf.Any optional_any = 305; 212 google.protobuf.Value optional_value = 306; 213 google.protobuf.NullValue optional_null_value = 307; 214 215 repeated google.protobuf.Duration repeated_duration = 311; 216 repeated google.protobuf.Timestamp repeated_timestamp = 312; 217 repeated google.protobuf.FieldMask repeated_fieldmask = 313; 218 repeated google.protobuf.Struct repeated_struct = 324; 219 repeated google.protobuf.Any repeated_any = 315; 220 repeated google.protobuf.Value repeated_value = 316; 221 repeated google.protobuf.ListValue repeated_list_value = 317; 222 223 // Test field-name-to-JSON-name convention. 224 // (protobuf says names can be any valid C/C++ identifier.) 225 int32 fieldname1 = 401; 226 int32 field_name2 = 402; 227 int32 _field_name3 = 403; 228 int32 field__name4_ = 404; 229 int32 field0name5 = 405; 230 int32 field_0_name6 = 406; 231 int32 fieldName7 = 407; 232 int32 FieldName8 = 408; 233 int32 field_Name9 = 409; 234 int32 Field_Name10 = 410; 235 int32 FIELD_NAME11 = 411; 236 int32 FIELD_name12 = 412; 237 int32 __field_name13 = 413; 238 int32 __Field_name14 = 414; 239 int32 field__name15 = 415; 240 int32 field__Name16 = 416; 241 int32 field_name17__ = 417; 242 int32 Field_name18__ = 418; 243 244 // Reserved for testing unknown fields 245 reserved 501 to 510; 246} 247 248message ForeignMessage { 249 int32 c = 1; 250} 251 252enum ForeignEnum { 253 FOREIGN_FOO = 0; 254 FOREIGN_BAR = 1; 255 FOREIGN_BAZ = 2; 256} 257 258message NullHypothesisProto3 {} 259 260message EnumOnlyProto3 { 261 enum Bool { 262 kFalse = 0; 263 kTrue = 1; 264 } 265} 266