Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.ProtobufCS/0.9.1/ProtobufCS/protos/google/protobuf/unittest.proto @ 5404

Last change on this file since 5404 was 3857, checked in by abeham, 15 years ago

#866

  • Added protobuf-csharp-port project source to ExtLibs
File size: 20.0 KB
Line 
1// Additional options required for C# generation. File from copyright
2// line onwards is as per original distribution.
3import "google/protobuf/csharp_options.proto";
4option (google.protobuf.csharp_file_options).namespace = "Google.ProtocolBuffers.TestProtos";
5option (google.protobuf.csharp_file_options).umbrella_classname = "UnitTestProtoFile";
6
7// Protocol Buffers - Google's data interchange format
8// Copyright 2008 Google Inc.  All rights reserved.
9// http://code.google.com/p/protobuf/
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15//     * Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17//     * Redistributions in binary form must reproduce the above
18// copyright notice, this list of conditions and the following disclaimer
19// in the documentation and/or other materials provided with the
20// distribution.
21//     * Neither the name of Google Inc. nor the names of its
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
37// Author: kenton@google.com (Kenton Varda)
38//  Based on original Protocol Buffers design by
39//  Sanjay Ghemawat, Jeff Dean, and others.
40//
41// A proto file we will use for unit testing.
42
43
44import "google/protobuf/unittest_import.proto";
45
46// We don't put this in a package within proto2 because we need to make sure
47// that the generated code doesn't depend on being in the proto2 namespace.
48// In test_util.h we do "using namespace unittest = protobuf_unittest".
49package protobuf_unittest;
50
51// Protos optimized for SPEED use a strict superset of the generated code
52// of equivalent ones optimized for CODE_SIZE, so we should optimize all our
53// tests for speed unless explicitly testing code size optimization.
54option optimize_for = SPEED;
55
56option java_outer_classname = "UnittestProto";
57
58// This proto includes every type of field in both singular and repeated
59// forms.
60message TestAllTypes {
61  message NestedMessage {
62    // The field name "b" fails to compile in proto1 because it conflicts with
63    // a local variable named "b" in one of the generated methods.  Doh.
64    // This file needs to compile in proto1 to test backwards-compatibility.
65    optional int32 bb = 1;
66  }
67
68  enum NestedEnum {
69    FOO = 1;
70    BAR = 2;
71    BAZ = 3;
72  }
73
74  // Singular
75  optional    int32 optional_int32    =  1;
76  optional    int64 optional_int64    =  2;
77  optional   uint32 optional_uint32   =  3;
78  optional   uint64 optional_uint64   =  4;
79  optional   sint32 optional_sint32   =  5;
80  optional   sint64 optional_sint64   =  6;
81  optional  fixed32 optional_fixed32  =  7;
82  optional  fixed64 optional_fixed64  =  8;
83  optional sfixed32 optional_sfixed32 =  9;
84  optional sfixed64 optional_sfixed64 = 10;
85  optional    float optional_float    = 11;
86  optional   double optional_double   = 12;
87  optional     bool optional_bool     = 13;
88  optional   string optional_string   = 14;
89  optional    bytes optional_bytes    = 15;
90
91  optional group OptionalGroup = 16 {
92    optional int32 a = 17;
93  }
94
95  optional NestedMessage                        optional_nested_message  = 18;
96  optional ForeignMessage                       optional_foreign_message = 19;
97  optional protobuf_unittest_import.ImportMessage optional_import_message  = 20;
98
99  optional NestedEnum                           optional_nested_enum     = 21;
100  optional ForeignEnum                          optional_foreign_enum    = 22;
101  optional protobuf_unittest_import.ImportEnum    optional_import_enum     = 23;
102
103  optional string optional_string_piece = 24 [ctype=STRING_PIECE];
104  optional string optional_cord = 25 [ctype=CORD];
105
106  // Repeated
107  repeated    int32 repeated_int32    = 31;
108  repeated    int64 repeated_int64    = 32;
109  repeated   uint32 repeated_uint32   = 33;
110  repeated   uint64 repeated_uint64   = 34;
111  repeated   sint32 repeated_sint32   = 35;
112  repeated   sint64 repeated_sint64   = 36;
113  repeated  fixed32 repeated_fixed32  = 37;
114  repeated  fixed64 repeated_fixed64  = 38;
115  repeated sfixed32 repeated_sfixed32 = 39;
116  repeated sfixed64 repeated_sfixed64 = 40;
117  repeated    float repeated_float    = 41;
118  repeated   double repeated_double   = 42;
119  repeated     bool repeated_bool     = 43;
120  repeated   string repeated_string   = 44;
121  repeated    bytes repeated_bytes    = 45;
122
123  repeated group RepeatedGroup = 46 {
124    optional int32 a = 47;
125  }
126
127  repeated NestedMessage                        repeated_nested_message  = 48;
128  repeated ForeignMessage                       repeated_foreign_message = 49;
129  repeated protobuf_unittest_import.ImportMessage repeated_import_message  = 50;
130
131  repeated NestedEnum                           repeated_nested_enum     = 51;
132  repeated ForeignEnum                          repeated_foreign_enum    = 52;
133  repeated protobuf_unittest_import.ImportEnum    repeated_import_enum     = 53;
134
135  repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
136  repeated string repeated_cord = 55 [ctype=CORD];
137
138  // Singular with defaults
139  optional    int32 default_int32    = 61 [default =  41    ];
140  optional    int64 default_int64    = 62 [default =  42    ];
141  optional   uint32 default_uint32   = 63 [default =  43    ];
142  optional   uint64 default_uint64   = 64 [default =  44    ];
143  optional   sint32 default_sint32   = 65 [default = -45    ];
144  optional   sint64 default_sint64   = 66 [default =  46    ];
145  optional  fixed32 default_fixed32  = 67 [default =  47    ];
146  optional  fixed64 default_fixed64  = 68 [default =  48    ];
147  optional sfixed32 default_sfixed32 = 69 [default =  49    ];
148  optional sfixed64 default_sfixed64 = 70 [default = -50    ];
149  optional    float default_float    = 71 [default =  51.5  ];
150  optional   double default_double   = 72 [default =  52e3  ];
151  optional     bool default_bool     = 73 [default = true   ];
152  optional   string default_string   = 74 [default = "hello"];
153  optional    bytes default_bytes    = 75 [default = "world"];
154
155  optional NestedEnum  default_nested_enum  = 81 [default = BAR        ];
156  optional ForeignEnum default_foreign_enum = 82 [default = FOREIGN_BAR];
157  optional protobuf_unittest_import.ImportEnum
158      default_import_enum = 83 [default = IMPORT_BAR];
159
160  optional string default_string_piece = 84 [ctype=STRING_PIECE,default="abc"];
161  optional string default_cord = 85 [ctype=CORD,default="123"];
162}
163
164// Define these after TestAllTypes to make sure the compiler can handle
165// that.
166message ForeignMessage {
167  optional int32 c = 1;
168}
169
170enum ForeignEnum {
171  FOREIGN_FOO = 4;
172  FOREIGN_BAR = 5;
173  FOREIGN_BAZ = 6;
174}
175
176message TestAllExtensions {
177  extensions 1 to max;
178}
179
180extend TestAllExtensions {
181  // Singular
182  optional    int32 optional_int32_extension    =  1;
183  optional    int64 optional_int64_extension    =  2;
184  optional   uint32 optional_uint32_extension   =  3;
185  optional   uint64 optional_uint64_extension   =  4;
186  optional   sint32 optional_sint32_extension   =  5;
187  optional   sint64 optional_sint64_extension   =  6;
188  optional  fixed32 optional_fixed32_extension  =  7;
189  optional  fixed64 optional_fixed64_extension  =  8;
190  optional sfixed32 optional_sfixed32_extension =  9;
191  optional sfixed64 optional_sfixed64_extension = 10;
192  optional    float optional_float_extension    = 11;
193  optional   double optional_double_extension   = 12;
194  optional     bool optional_bool_extension     = 13;
195  optional   string optional_string_extension   = 14;
196  optional    bytes optional_bytes_extension    = 15;
197
198  optional group OptionalGroup_extension = 16 {
199    optional int32 a = 17;
200  }
201
202  optional TestAllTypes.NestedMessage optional_nested_message_extension = 18;
203  optional ForeignMessage optional_foreign_message_extension = 19;
204  optional protobuf_unittest_import.ImportMessage
205    optional_import_message_extension = 20;
206
207  optional TestAllTypes.NestedEnum optional_nested_enum_extension = 21;
208  optional ForeignEnum optional_foreign_enum_extension = 22;
209  optional protobuf_unittest_import.ImportEnum
210    optional_import_enum_extension = 23;
211
212  optional string optional_string_piece_extension = 24 [ctype=STRING_PIECE];
213  optional string optional_cord_extension = 25 [ctype=CORD];
214
215  // Repeated
216  repeated    int32 repeated_int32_extension    = 31;
217  repeated    int64 repeated_int64_extension    = 32;
218  repeated   uint32 repeated_uint32_extension   = 33;
219  repeated   uint64 repeated_uint64_extension   = 34;
220  repeated   sint32 repeated_sint32_extension   = 35;
221  repeated   sint64 repeated_sint64_extension   = 36;
222  repeated  fixed32 repeated_fixed32_extension  = 37;
223  repeated  fixed64 repeated_fixed64_extension  = 38;
224  repeated sfixed32 repeated_sfixed32_extension = 39;
225  repeated sfixed64 repeated_sfixed64_extension = 40;
226  repeated    float repeated_float_extension    = 41;
227  repeated   double repeated_double_extension   = 42;
228  repeated     bool repeated_bool_extension     = 43;
229  repeated   string repeated_string_extension   = 44;
230  repeated    bytes repeated_bytes_extension    = 45;
231
232  repeated group RepeatedGroup_extension = 46 {
233    optional int32 a = 47;
234  }
235
236  repeated TestAllTypes.NestedMessage repeated_nested_message_extension = 48;
237  repeated ForeignMessage repeated_foreign_message_extension = 49;
238  repeated protobuf_unittest_import.ImportMessage
239    repeated_import_message_extension = 50;
240
241  repeated TestAllTypes.NestedEnum repeated_nested_enum_extension = 51;
242  repeated ForeignEnum repeated_foreign_enum_extension = 52;
243  repeated protobuf_unittest_import.ImportEnum
244    repeated_import_enum_extension = 53;
245
246  repeated string repeated_string_piece_extension = 54 [ctype=STRING_PIECE];
247  repeated string repeated_cord_extension = 55 [ctype=CORD];
248
249  // Singular with defaults
250  optional    int32 default_int32_extension    = 61 [default =  41    ];
251  optional    int64 default_int64_extension    = 62 [default =  42    ];
252  optional   uint32 default_uint32_extension   = 63 [default =  43    ];
253  optional   uint64 default_uint64_extension   = 64 [default =  44    ];
254  optional   sint32 default_sint32_extension   = 65 [default = -45    ];
255  optional   sint64 default_sint64_extension   = 66 [default =  46    ];
256  optional  fixed32 default_fixed32_extension  = 67 [default =  47    ];
257  optional  fixed64 default_fixed64_extension  = 68 [default =  48    ];
258  optional sfixed32 default_sfixed32_extension = 69 [default =  49    ];
259  optional sfixed64 default_sfixed64_extension = 70 [default = -50    ];
260  optional    float default_float_extension    = 71 [default =  51.5  ];
261  optional   double default_double_extension   = 72 [default =  52e3  ];
262  optional     bool default_bool_extension     = 73 [default = true   ];
263  optional   string default_string_extension   = 74 [default = "hello"];
264  optional    bytes default_bytes_extension    = 75 [default = "world"];
265
266  optional TestAllTypes.NestedEnum
267    default_nested_enum_extension = 81 [default = BAR];
268  optional ForeignEnum
269    default_foreign_enum_extension = 82 [default = FOREIGN_BAR];
270  optional protobuf_unittest_import.ImportEnum
271    default_import_enum_extension = 83 [default = IMPORT_BAR];
272
273  optional string default_string_piece_extension = 84 [ctype=STRING_PIECE,
274                                                       default="abc"];
275  optional string default_cord_extension = 85 [ctype=CORD, default="123"];
276}
277
278// We have separate messages for testing required fields because it's
279// annoying to have to fill in required fields in TestProto in order to
280// do anything with it.  Note that we don't need to test every type of
281// required filed because the code output is basically identical to
282// optional fields for all types.
283message TestRequired {
284  required int32 a = 1;
285  optional int32 dummy2 = 2;
286  required int32 b = 3;
287
288  extend TestAllExtensions {
289    optional TestRequired single = 1000;
290    repeated TestRequired multi  = 1001;
291  }
292
293  // Pad the field count to 32 so that we can test that IsInitialized()
294  // properly checks multiple elements of has_bits_.
295  optional int32 dummy4  =  4;
296  optional int32 dummy5  =  5;
297  optional int32 dummy6  =  6;
298  optional int32 dummy7  =  7;
299  optional int32 dummy8  =  8;
300  optional int32 dummy9  =  9;
301  optional int32 dummy10 = 10;
302  optional int32 dummy11 = 11;
303  optional int32 dummy12 = 12;
304  optional int32 dummy13 = 13;
305  optional int32 dummy14 = 14;
306  optional int32 dummy15 = 15;
307  optional int32 dummy16 = 16;
308  optional int32 dummy17 = 17;
309  optional int32 dummy18 = 18;
310  optional int32 dummy19 = 19;
311  optional int32 dummy20 = 20;
312  optional int32 dummy21 = 21;
313  optional int32 dummy22 = 22;
314  optional int32 dummy23 = 23;
315  optional int32 dummy24 = 24;
316  optional int32 dummy25 = 25;
317  optional int32 dummy26 = 26;
318  optional int32 dummy27 = 27;
319  optional int32 dummy28 = 28;
320  optional int32 dummy29 = 29;
321  optional int32 dummy30 = 30;
322  optional int32 dummy31 = 31;
323  optional int32 dummy32 = 32;
324
325  required int32 c = 33;
326}
327
328message TestRequiredForeign {
329  optional TestRequired optional_message = 1;
330  repeated TestRequired repeated_message = 2;
331  optional int32 dummy = 3;
332}
333
334// Test that we can use NestedMessage from outside TestAllTypes.
335message TestForeignNested {
336  optional TestAllTypes.NestedMessage foreign_nested = 1;
337}
338
339// TestEmptyMessage is used to test unknown field support.
340message TestEmptyMessage {
341}
342
343// Like above, but declare all field numbers as potential extensions.  No
344// actual extensions should ever be defined for this type.
345message TestEmptyMessageWithExtensions {
346  extensions 1 to max;
347}
348
349// Test that really large tag numbers don't break anything.
350message TestReallyLargeTagNumber {
351  // The largest possible tag number is 2^28 - 1, since the wire format uses
352  // three bits to communicate wire type.
353  optional int32 a = 1;
354  optional int32 bb = 268435455;
355}
356
357message TestRecursiveMessage {
358  optional TestRecursiveMessage a = 1;
359  optional int32 i = 2;
360}
361
362// Test that mutual recursion works.
363message TestMutualRecursionA {
364  optional TestMutualRecursionB bb = 1;
365}
366
367message TestMutualRecursionB {
368  optional TestMutualRecursionA a = 1;
369  optional int32 optional_int32 = 2;
370}
371
372// Test that groups have disjoint field numbers from their siblings and
373// parents.  This is NOT possible in proto1; only proto2.  When outputting
374// proto1, the dup fields should be dropped.
375message TestDupFieldNumber {
376  optional int32 a = 1;
377  optional group Foo = 2 { optional int32 a = 1; }
378  optional group Bar = 3 { optional int32 a = 1; }
379}
380
381
382// Needed for a Python test.
383message TestNestedMessageHasBits {
384  message NestedMessage {
385    repeated int32 nestedmessage_repeated_int32 = 1;
386    repeated ForeignMessage nestedmessage_repeated_foreignmessage = 2;
387  }
388  optional NestedMessage optional_nested_message = 1;
389}
390
391
392// Test an enum that has multiple values with the same number.
393enum TestEnumWithDupValue {
394  FOO1 = 1;
395  BAR1 = 2;
396  BAZ = 3;
397  FOO2 = 1;
398  BAR2 = 2;
399}
400
401// Test an enum with large, unordered values.
402enum TestSparseEnum {
403  SPARSE_A = 123;
404  SPARSE_B = 62374;
405  SPARSE_C = 12589234;
406  SPARSE_D = -15;
407  SPARSE_E = -53452;
408  SPARSE_F = 0;
409  SPARSE_G = 2;
410}
411
412// Test message with CamelCase field names.  This violates Protocol Buffer
413// standard style.
414message TestCamelCaseFieldNames {
415  optional int32 PrimitiveField = 1;
416  optional string StringField = 2;
417  optional ForeignEnum EnumField = 3;
418  optional ForeignMessage MessageField = 4;
419  optional string StringPieceField = 5 [ctype=STRING_PIECE];
420  optional string CordField = 6 [ctype=CORD];
421
422  repeated int32 RepeatedPrimitiveField = 7;
423  repeated string RepeatedStringField = 8;
424  repeated ForeignEnum RepeatedEnumField = 9;
425  repeated ForeignMessage RepeatedMessageField = 10;
426  repeated string RepeatedStringPieceField = 11 [ctype=STRING_PIECE];
427  repeated string RepeatedCordField = 12 [ctype=CORD];
428}
429
430
431// We list fields out of order, to ensure that we're using field number and not
432// field index to determine serialization order.
433message TestFieldOrderings {
434  optional string my_string = 11;
435  extensions 2 to 10;
436  optional int64 my_int = 1;
437  extensions 12 to 100;
438  optional float my_float = 101;
439}
440
441
442extend TestFieldOrderings {
443  optional string my_extension_string = 50;
444  optional int32 my_extension_int = 5;
445}
446
447
448message TestExtremeDefaultValues {
449  optional bytes escaped_bytes = 1 [default = "\0\001\a\b\f\n\r\t\v\\\'\"\xfe"];
450  optional uint32 large_uint32 = 2 [default = 0xFFFFFFFF];
451  optional uint64 large_uint64 = 3 [default = 0xFFFFFFFFFFFFFFFF];
452  optional  int32 small_int32  = 4 [default = -0x7FFFFFFF];
453  optional  int64 small_int64  = 5 [default = -0x7FFFFFFFFFFFFFFF];
454
455  // The default value here is UTF-8 for "\u1234".  (We could also just type
456  // the UTF-8 text directly into this text file rather than escape it, but
457  // lots of people use editors that would be confused by this.)
458  optional string utf8_string = 6 [default = "\341\210\264"];
459}
460
461message TestPackedTypes {
462  repeated    int32 packed_int32    =  90 [packed = true];
463  repeated    int64 packed_int64    =  91 [packed = true];
464  repeated   uint32 packed_uint32   =  92 [packed = true];
465  repeated   uint64 packed_uint64   =  93 [packed = true];
466  repeated   sint32 packed_sint32   =  94 [packed = true];
467  repeated   sint64 packed_sint64   =  95 [packed = true];
468  repeated  fixed32 packed_fixed32  =  96 [packed = true];
469  repeated  fixed64 packed_fixed64  =  97 [packed = true];
470  repeated sfixed32 packed_sfixed32 =  98 [packed = true];
471  repeated sfixed64 packed_sfixed64 =  99 [packed = true];
472  repeated    float packed_float    = 100 [packed = true];
473  repeated   double packed_double   = 101 [packed = true];
474  repeated     bool packed_bool     = 102 [packed = true];
475  repeated ForeignEnum packed_enum  = 103 [packed = true];
476}
477
478message TestPackedExtensions {
479  extensions 1 to max;
480}
481
482extend TestPackedExtensions {
483  repeated    int32 packed_int32_extension    =  90 [packed = true];
484  repeated    int64 packed_int64_extension    =  91 [packed = true];
485  repeated   uint32 packed_uint32_extension   =  92 [packed = true];
486  repeated   uint64 packed_uint64_extension   =  93 [packed = true];
487  repeated   sint32 packed_sint32_extension   =  94 [packed = true];
488  repeated   sint64 packed_sint64_extension   =  95 [packed = true];
489  repeated  fixed32 packed_fixed32_extension  =  96 [packed = true];
490  repeated  fixed64 packed_fixed64_extension  =  97 [packed = true];
491  repeated sfixed32 packed_sfixed32_extension =  98 [packed = true];
492  repeated sfixed64 packed_sfixed64_extension =  99 [packed = true];
493  repeated    float packed_float_extension    = 100 [packed = true];
494  repeated   double packed_double_extension   = 101 [packed = true];
495  repeated     bool packed_bool_extension     = 102 [packed = true];
496  repeated ForeignEnum packed_enum_extension  = 103 [packed = true];
497}
498
499// Test that RPC services work.
500message FooRequest  {}
501message FooResponse {}
502
503service TestService {
504  rpc Foo(FooRequest) returns (FooResponse);
505  rpc Bar(BarRequest) returns (BarResponse);
506}
507
508
509message BarRequest  {}
510message BarResponse {}
Note: See TracBrowser for help on using the repository browser.