1// Protocol Buffers - Google's data interchange format 2// Copyright 2008 Google Inc. All rights reserved. 3// http://code.google.com/p/protobuf/ 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// Author: kenton@google.com (Kenton Varda) 32// 33// This is like unittest.proto but with optimize_for = LITE_RUNTIME. 34 35package protobuf_unittest; 36 37import "google/protobuf/unittest_import_lite.proto"; 38 39option optimize_for = LITE_RUNTIME; 40 41option java_package = "com.google.protobuf"; 42 43// Same as TestAllTypes but with the lite runtime. 44message TestAllTypesLite { 45 message NestedMessage { 46 optional int32 bb = 1; 47 } 48 49 enum NestedEnum { 50 FOO = 1; 51 BAR = 2; 52 BAZ = 3; 53 } 54 55 // Singular 56 optional int32 optional_int32 = 1; 57 optional int64 optional_int64 = 2; 58 optional uint32 optional_uint32 = 3; 59 optional uint64 optional_uint64 = 4; 60 optional sint32 optional_sint32 = 5; 61 optional sint64 optional_sint64 = 6; 62 optional fixed32 optional_fixed32 = 7; 63 optional fixed64 optional_fixed64 = 8; 64 optional sfixed32 optional_sfixed32 = 9; 65 optional sfixed64 optional_sfixed64 = 10; 66 optional float optional_float = 11; 67 optional double optional_double = 12; 68 optional bool optional_bool = 13; 69 optional string optional_string = 14; 70 optional bytes optional_bytes = 15; 71 72 optional group OptionalGroup = 16 { 73 optional int32 a = 17; 74 } 75 76 optional NestedMessage optional_nested_message = 18; 77 optional ForeignMessageLite optional_foreign_message = 19; 78 optional protobuf_unittest_import.ImportMessageLite 79 optional_import_message = 20; 80 81 optional NestedEnum optional_nested_enum = 21; 82 optional ForeignEnumLite optional_foreign_enum = 22; 83 optional protobuf_unittest_import.ImportEnumLite optional_import_enum = 23; 84 85 optional string optional_string_piece = 24 [ctype=STRING_PIECE]; 86 optional string optional_cord = 25 [ctype=CORD]; 87 88 // Repeated 89 repeated int32 repeated_int32 = 31; 90 repeated int64 repeated_int64 = 32; 91 repeated uint32 repeated_uint32 = 33; 92 repeated uint64 repeated_uint64 = 34; 93 repeated sint32 repeated_sint32 = 35; 94 repeated sint64 repeated_sint64 = 36; 95 repeated fixed32 repeated_fixed32 = 37; 96 repeated fixed64 repeated_fixed64 = 38; 97 repeated sfixed32 repeated_sfixed32 = 39; 98 repeated sfixed64 repeated_sfixed64 = 40; 99 repeated float repeated_float = 41; 100 repeated double repeated_double = 42; 101 repeated bool repeated_bool = 43; 102 repeated string repeated_string = 44; 103 repeated bytes repeated_bytes = 45; 104 105 repeated group RepeatedGroup = 46 { 106 optional int32 a = 47; 107 } 108 109 repeated NestedMessage repeated_nested_message = 48; 110 repeated ForeignMessageLite repeated_foreign_message = 49; 111 repeated protobuf_unittest_import.ImportMessageLite 112 repeated_import_message = 50; 113 114 repeated NestedEnum repeated_nested_enum = 51; 115 repeated ForeignEnumLite repeated_foreign_enum = 52; 116 repeated protobuf_unittest_import.ImportEnumLite repeated_import_enum = 53; 117 118 repeated string repeated_string_piece = 54 [ctype=STRING_PIECE]; 119 repeated string repeated_cord = 55 [ctype=CORD]; 120 121 // Singular with defaults 122 optional int32 default_int32 = 61 [default = 41 ]; 123 optional int64 default_int64 = 62 [default = 42 ]; 124 optional uint32 default_uint32 = 63 [default = 43 ]; 125 optional uint64 default_uint64 = 64 [default = 44 ]; 126 optional sint32 default_sint32 = 65 [default = -45 ]; 127 optional sint64 default_sint64 = 66 [default = 46 ]; 128 optional fixed32 default_fixed32 = 67 [default = 47 ]; 129 optional fixed64 default_fixed64 = 68 [default = 48 ]; 130 optional sfixed32 default_sfixed32 = 69 [default = 49 ]; 131 optional sfixed64 default_sfixed64 = 70 [default = -50 ]; 132 optional float default_float = 71 [default = 51.5 ]; 133 optional double default_double = 72 [default = 52e3 ]; 134 optional bool default_bool = 73 [default = true ]; 135 optional string default_string = 74 [default = "hello"]; 136 optional bytes default_bytes = 75 [default = "world"]; 137 138 optional NestedEnum default_nested_enum = 81 [default = BAR]; 139 optional ForeignEnumLite default_foreign_enum = 82 140 [default = FOREIGN_LITE_BAR]; 141 optional protobuf_unittest_import.ImportEnumLite 142 default_import_enum = 83 [default = IMPORT_LITE_BAR]; 143 144 optional string default_string_piece = 84 [ctype=STRING_PIECE,default="abc"]; 145 optional string default_cord = 85 [ctype=CORD,default="123"]; 146} 147 148message ForeignMessageLite { 149 optional int32 c = 1; 150} 151 152enum ForeignEnumLite { 153 FOREIGN_LITE_FOO = 4; 154 FOREIGN_LITE_BAR = 5; 155 FOREIGN_LITE_BAZ = 6; 156} 157 158message TestPackedTypesLite { 159 repeated int32 packed_int32 = 90 [packed = true]; 160 repeated int64 packed_int64 = 91 [packed = true]; 161 repeated uint32 packed_uint32 = 92 [packed = true]; 162 repeated uint64 packed_uint64 = 93 [packed = true]; 163 repeated sint32 packed_sint32 = 94 [packed = true]; 164 repeated sint64 packed_sint64 = 95 [packed = true]; 165 repeated fixed32 packed_fixed32 = 96 [packed = true]; 166 repeated fixed64 packed_fixed64 = 97 [packed = true]; 167 repeated sfixed32 packed_sfixed32 = 98 [packed = true]; 168 repeated sfixed64 packed_sfixed64 = 99 [packed = true]; 169 repeated float packed_float = 100 [packed = true]; 170 repeated double packed_double = 101 [packed = true]; 171 repeated bool packed_bool = 102 [packed = true]; 172 repeated ForeignEnumLite packed_enum = 103 [packed = true]; 173} 174 175message TestAllExtensionsLite { 176 extensions 1 to max; 177} 178 179extend TestAllExtensionsLite { 180 // Singular 181 optional int32 optional_int32_extension_lite = 1; 182 optional int64 optional_int64_extension_lite = 2; 183 optional uint32 optional_uint32_extension_lite = 3; 184 optional uint64 optional_uint64_extension_lite = 4; 185 optional sint32 optional_sint32_extension_lite = 5; 186 optional sint64 optional_sint64_extension_lite = 6; 187 optional fixed32 optional_fixed32_extension_lite = 7; 188 optional fixed64 optional_fixed64_extension_lite = 8; 189 optional sfixed32 optional_sfixed32_extension_lite = 9; 190 optional sfixed64 optional_sfixed64_extension_lite = 10; 191 optional float optional_float_extension_lite = 11; 192 optional double optional_double_extension_lite = 12; 193 optional bool optional_bool_extension_lite = 13; 194 optional string optional_string_extension_lite = 14; 195 optional bytes optional_bytes_extension_lite = 15; 196 197 optional group OptionalGroup_extension_lite = 16 { 198 optional int32 a = 17; 199 } 200 201 optional TestAllTypesLite.NestedMessage optional_nested_message_extension_lite 202 = 18; 203 optional ForeignMessageLite optional_foreign_message_extension_lite = 19; 204 optional protobuf_unittest_import.ImportMessageLite 205 optional_import_message_extension_lite = 20; 206 207 optional TestAllTypesLite.NestedEnum optional_nested_enum_extension_lite = 21; 208 optional ForeignEnumLite optional_foreign_enum_extension_lite = 22; 209 optional protobuf_unittest_import.ImportEnumLite 210 optional_import_enum_extension_lite = 23; 211 212 optional string optional_string_piece_extension_lite = 24 213 [ctype=STRING_PIECE]; 214 optional string optional_cord_extension_lite = 25 [ctype=CORD]; 215 216 // Repeated 217 repeated int32 repeated_int32_extension_lite = 31; 218 repeated int64 repeated_int64_extension_lite = 32; 219 repeated uint32 repeated_uint32_extension_lite = 33; 220 repeated uint64 repeated_uint64_extension_lite = 34; 221 repeated sint32 repeated_sint32_extension_lite = 35; 222 repeated sint64 repeated_sint64_extension_lite = 36; 223 repeated fixed32 repeated_fixed32_extension_lite = 37; 224 repeated fixed64 repeated_fixed64_extension_lite = 38; 225 repeated sfixed32 repeated_sfixed32_extension_lite = 39; 226 repeated sfixed64 repeated_sfixed64_extension_lite = 40; 227 repeated float repeated_float_extension_lite = 41; 228 repeated double repeated_double_extension_lite = 42; 229 repeated bool repeated_bool_extension_lite = 43; 230 repeated string repeated_string_extension_lite = 44; 231 repeated bytes repeated_bytes_extension_lite = 45; 232 233 repeated group RepeatedGroup_extension_lite = 46 { 234 optional int32 a = 47; 235 } 236 237 repeated TestAllTypesLite.NestedMessage repeated_nested_message_extension_lite 238 = 48; 239 repeated ForeignMessageLite repeated_foreign_message_extension_lite = 49; 240 repeated protobuf_unittest_import.ImportMessageLite 241 repeated_import_message_extension_lite = 50; 242 243 repeated TestAllTypesLite.NestedEnum repeated_nested_enum_extension_lite = 51; 244 repeated ForeignEnumLite repeated_foreign_enum_extension_lite = 52; 245 repeated protobuf_unittest_import.ImportEnumLite 246 repeated_import_enum_extension_lite = 53; 247 248 repeated string repeated_string_piece_extension_lite = 54 249 [ctype=STRING_PIECE]; 250 repeated string repeated_cord_extension_lite = 55 [ctype=CORD]; 251 252 // Singular with defaults 253 optional int32 default_int32_extension_lite = 61 [default = 41 ]; 254 optional int64 default_int64_extension_lite = 62 [default = 42 ]; 255 optional uint32 default_uint32_extension_lite = 63 [default = 43 ]; 256 optional uint64 default_uint64_extension_lite = 64 [default = 44 ]; 257 optional sint32 default_sint32_extension_lite = 65 [default = -45 ]; 258 optional sint64 default_sint64_extension_lite = 66 [default = 46 ]; 259 optional fixed32 default_fixed32_extension_lite = 67 [default = 47 ]; 260 optional fixed64 default_fixed64_extension_lite = 68 [default = 48 ]; 261 optional sfixed32 default_sfixed32_extension_lite = 69 [default = 49 ]; 262 optional sfixed64 default_sfixed64_extension_lite = 70 [default = -50 ]; 263 optional float default_float_extension_lite = 71 [default = 51.5 ]; 264 optional double default_double_extension_lite = 72 [default = 52e3 ]; 265 optional bool default_bool_extension_lite = 73 [default = true ]; 266 optional string default_string_extension_lite = 74 [default = "hello"]; 267 optional bytes default_bytes_extension_lite = 75 [default = "world"]; 268 269 optional TestAllTypesLite.NestedEnum 270 default_nested_enum_extension_lite = 81 [default = BAR]; 271 optional ForeignEnumLite 272 default_foreign_enum_extension_lite = 82 [default = FOREIGN_LITE_BAR]; 273 optional protobuf_unittest_import.ImportEnumLite 274 default_import_enum_extension_lite = 83 [default = IMPORT_LITE_BAR]; 275 276 optional string default_string_piece_extension_lite = 84 [ctype=STRING_PIECE, 277 default="abc"]; 278 optional string default_cord_extension_lite = 85 [ctype=CORD, default="123"]; 279} 280 281message TestPackedExtensionsLite { 282 extensions 1 to max; 283} 284 285extend TestPackedExtensionsLite { 286 repeated int32 packed_int32_extension_lite = 90 [packed = true]; 287 repeated int64 packed_int64_extension_lite = 91 [packed = true]; 288 repeated uint32 packed_uint32_extension_lite = 92 [packed = true]; 289 repeated uint64 packed_uint64_extension_lite = 93 [packed = true]; 290 repeated sint32 packed_sint32_extension_lite = 94 [packed = true]; 291 repeated sint64 packed_sint64_extension_lite = 95 [packed = true]; 292 repeated fixed32 packed_fixed32_extension_lite = 96 [packed = true]; 293 repeated fixed64 packed_fixed64_extension_lite = 97 [packed = true]; 294 repeated sfixed32 packed_sfixed32_extension_lite = 98 [packed = true]; 295 repeated sfixed64 packed_sfixed64_extension_lite = 99 [packed = true]; 296 repeated float packed_float_extension_lite = 100 [packed = true]; 297 repeated double packed_double_extension_lite = 101 [packed = true]; 298 repeated bool packed_bool_extension_lite = 102 [packed = true]; 299 repeated ForeignEnumLite packed_enum_extension_lite = 103 [packed = true]; 300} 301 302message TestNestedExtensionLite { 303 extend TestAllExtensionsLite { 304 optional int32 nested_extension = 12345; 305 } 306} 307 308// Test that deprecated fields work. We only verify that they compile (at one 309// point this failed). 310message TestDeprecatedLite { 311 optional int32 deprecated_field = 1 [deprecated = true]; 312} 313