1// Protocol Buffers - Google's data interchange format 2// Copyright 2008 Google Inc. All rights reserved. 3// https://developers.google.com/protocol-buffers/ 4// 5// Redistribution and use in source and binary forms, with or without 6// modification, are permitted provided that the following conditions are 7// met: 8// 9// * Redistributions of source code must retain the above copyright 10// notice, this list of conditions and the following disclaimer. 11// * Redistributions in binary form must reproduce the above 12// copyright notice, this list of conditions and the following disclaimer 13// in the documentation and/or other materials provided with the 14// distribution. 15// * Neither the name of Google Inc. nor the names of its 16// contributors may be used to endorse or promote products derived from 17// this software without specific prior written permission. 18// 19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30// 31// Test schema for proto2 messages. This test schema is used by: 32// 33// - conformance tests 34// 35 36// LINT: ALLOW_GROUPS 37 38syntax = "proto2"; 39 40package protobuf_test_messages.proto2; 41option java_package = "com.google.protobuf_test_messages.proto2"; 42 43// This is the default, but we specify it here explicitly. 44option optimize_for = SPEED; 45 46option cc_enable_arenas = true; 47 48// This proto includes every type of field in both singular and repeated 49// forms. 50// 51// Also, crucially, all messages and enums in this file are eventually 52// submessages of this message. So for example, a fuzz test of TestAllTypes 53// could trigger bugs that occur in any message type in this file. We verify 54// this stays true in a unit test. 55message TestAllTypesProto2 { 56 message NestedMessage { 57 optional int32 a = 1; 58 optional TestAllTypesProto2 corecursive = 2; 59 } 60 61 enum NestedEnum { 62 FOO = 0; 63 BAR = 1; 64 BAZ = 2; 65 NEG = -1; // Intentionally negative. 66 } 67 68 // Singular 69 optional int32 optional_int32 = 1; 70 optional int64 optional_int64 = 2; 71 optional uint32 optional_uint32 = 3; 72 optional uint64 optional_uint64 = 4; 73 optional sint32 optional_sint32 = 5; 74 optional sint64 optional_sint64 = 6; 75 optional fixed32 optional_fixed32 = 7; 76 optional fixed64 optional_fixed64 = 8; 77 optional sfixed32 optional_sfixed32 = 9; 78 optional sfixed64 optional_sfixed64 = 10; 79 optional float optional_float = 11; 80 optional double optional_double = 12; 81 optional bool optional_bool = 13; 82 optional string optional_string = 14; 83 optional bytes optional_bytes = 15; 84 85 optional NestedMessage optional_nested_message = 18; 86 optional ForeignMessageProto2 optional_foreign_message = 19; 87 88 optional NestedEnum optional_nested_enum = 21; 89 optional ForeignEnumProto2 optional_foreign_enum = 22; 90 91 optional string optional_string_piece = 24 [ctype=STRING_PIECE]; 92 optional string optional_cord = 25 [ctype=CORD]; 93 94 optional TestAllTypesProto2 recursive_message = 27; 95 96 // Repeated 97 repeated int32 repeated_int32 = 31; 98 repeated int64 repeated_int64 = 32; 99 repeated uint32 repeated_uint32 = 33; 100 repeated uint64 repeated_uint64 = 34; 101 repeated sint32 repeated_sint32 = 35; 102 repeated sint64 repeated_sint64 = 36; 103 repeated fixed32 repeated_fixed32 = 37; 104 repeated fixed64 repeated_fixed64 = 38; 105 repeated sfixed32 repeated_sfixed32 = 39; 106 repeated sfixed64 repeated_sfixed64 = 40; 107 repeated float repeated_float = 41; 108 repeated double repeated_double = 42; 109 repeated bool repeated_bool = 43; 110 repeated string repeated_string = 44; 111 repeated bytes repeated_bytes = 45; 112 113 repeated NestedMessage repeated_nested_message = 48; 114 repeated ForeignMessageProto2 repeated_foreign_message = 49; 115 116 repeated NestedEnum repeated_nested_enum = 51; 117 repeated ForeignEnumProto2 repeated_foreign_enum = 52; 118 119 repeated string repeated_string_piece = 54 [ctype=STRING_PIECE]; 120 repeated string repeated_cord = 55 [ctype=CORD]; 121 122 // Map 123 map < int32, int32> map_int32_int32 = 56; 124 map < int64, int64> map_int64_int64 = 57; 125 map < uint32, uint32> map_uint32_uint32 = 58; 126 map < uint64, uint64> map_uint64_uint64 = 59; 127 map < sint32, sint32> map_sint32_sint32 = 60; 128 map < sint64, sint64> map_sint64_sint64 = 61; 129 map < fixed32, fixed32> map_fixed32_fixed32 = 62; 130 map < fixed64, fixed64> map_fixed64_fixed64 = 63; 131 map <sfixed32, sfixed32> map_sfixed32_sfixed32 = 64; 132 map <sfixed64, sfixed64> map_sfixed64_sfixed64 = 65; 133 map < int32, float> map_int32_float = 66; 134 map < int32, double> map_int32_double = 67; 135 map < bool, bool> map_bool_bool = 68; 136 map < string, string> map_string_string = 69; 137 map < string, bytes> map_string_bytes = 70; 138 map < string, NestedMessage> map_string_nested_message = 71; 139 map < string, ForeignMessageProto2> map_string_foreign_message = 72; 140 map < string, NestedEnum> map_string_nested_enum = 73; 141 map < string, ForeignEnumProto2> map_string_foreign_enum = 74; 142 143 oneof oneof_field { 144 uint32 oneof_uint32 = 111; 145 NestedMessage oneof_nested_message = 112; 146 string oneof_string = 113; 147 bytes oneof_bytes = 114; 148 bool oneof_bool = 115; 149 uint64 oneof_uint64 = 116; 150 float oneof_float = 117; 151 double oneof_double = 118; 152 NestedEnum oneof_enum = 119; 153 } 154 155 // extensions 156 extensions 120 to 200; 157 158 // groups 159 optional group Data = 201 { 160 optional int32 group_int32 = 202; 161 optional uint32 group_uint32 = 203; 162 }; 163 164 // Test field-name-to-JSON-name convention. 165 // (protobuf says names can be any valid C/C++ identifier.) 166 optional int32 fieldname1 = 401; 167 optional int32 field_name2 = 402; 168 optional int32 _field_name3 = 403; 169 optional int32 field__name4_ = 404; 170 optional int32 field0name5 = 405; 171 optional int32 field_0_name6 = 406; 172 optional int32 fieldName7 = 407; 173 optional int32 FieldName8 = 408; 174 optional int32 field_Name9 = 409; 175 optional int32 Field_Name10 = 410; 176 optional int32 FIELD_NAME11 = 411; 177 optional int32 FIELD_name12 = 412; 178 optional int32 __field_name13 = 413; 179 optional int32 __Field_name14 = 414; 180 optional int32 field__name15 = 415; 181 optional int32 field__Name16 = 416; 182 optional int32 field_name17__ = 417; 183 optional int32 Field_name18__ = 418; 184 185 // Reserved for unknown fields test. 186 reserved 1000 to 9999; 187 188 // message_set test case. 189 message MessageSetCorrect { 190 option message_set_wire_format = true; 191 extensions 4 to max; 192 } 193 194 message MessageSetCorrectExtension1 { 195 extend MessageSetCorrect { 196 optional MessageSetCorrectExtension1 message_set_extension = 1547769; 197 } 198 optional string str = 25; 199 } 200 201 message MessageSetCorrectExtension2 { 202 extend MessageSetCorrect { 203 optional MessageSetCorrectExtension2 message_set_extension = 4135312; 204 } 205 optional int32 i = 9; 206 } 207} 208 209message ForeignMessageProto2 { 210 optional int32 c = 1; 211} 212 213enum ForeignEnumProto2 { 214 FOREIGN_FOO = 0; 215 FOREIGN_BAR = 1; 216 FOREIGN_BAZ = 2; 217} 218 219extend TestAllTypesProto2 { 220 optional int32 extension_int32 = 120; 221} 222 223message UnknownToTestAllTypes { 224 optional int32 optional_int32 = 1001; 225 optional string optional_string = 1002; 226 optional ForeignMessageProto2 nested_message = 1003; 227 optional group OptionalGroup = 1004 { 228 optional int32 a = 1; 229 } 230 optional bool optional_bool = 1006; 231 repeated int32 repeated_int32 = 1011; 232} 233 234