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: wink@google.com (Wink Saville)
32
33package protobuf_unittest;
34
35import "google/protobuf/unittest_import_micro.proto";
36
37option java_package = "com.google.protobuf.micro";
38option java_outer_classname = "MicroOuterClass";
39
40// Same as TestAllTypes but with the micro runtime.
41message TestAllTypesMicro {
42
43  message NestedMessage {
44    optional int32 bb = 1;
45  }
46
47  enum NestedEnum {
48    FOO = 1;
49    BAR = 2;
50    BAZ = 3;
51  }
52
53  // Singular
54  optional    int32 optional_int32    =  1;
55  optional    int64 optional_int64    =  2;
56  optional   uint32 optional_uint32   =  3;
57  optional   uint64 optional_uint64   =  4;
58  optional   sint32 optional_sint32   =  5;
59  optional   sint64 optional_sint64   =  6;
60  optional  fixed32 optional_fixed32  =  7;
61  optional  fixed64 optional_fixed64  =  8;
62  optional sfixed32 optional_sfixed32 =  9;
63  optional sfixed64 optional_sfixed64 = 10;
64  optional    float optional_float    = 11;
65  optional   double optional_double   = 12;
66  optional     bool optional_bool     = 13;
67  optional   string optional_string   = 14;
68  optional    bytes optional_bytes    = 15;
69
70  optional group OptionalGroup = 16 {
71    optional int32 a = 17;
72  }
73
74  optional NestedMessage      optional_nested_message  = 18;
75  optional ForeignMessageMicro optional_foreign_message = 19;
76  optional protobuf_unittest_import.ImportMessageMicro
77    optional_import_message = 20;
78
79  optional NestedEnum      optional_nested_enum     = 21;
80  optional ForeignEnumMicro optional_foreign_enum    = 22;
81  optional protobuf_unittest_import.ImportEnumMicro optional_import_enum = 23;
82
83  optional string optional_string_piece = 24 [ctype=STRING_PIECE];
84  optional string optional_cord = 25 [ctype=CORD];
85
86  // Repeated
87  repeated    int32 repeated_int32    = 31;
88  repeated    int64 repeated_int64    = 32;
89  repeated   uint32 repeated_uint32   = 33;
90  repeated   uint64 repeated_uint64   = 34;
91  repeated   sint32 repeated_sint32   = 35;
92  repeated   sint64 repeated_sint64   = 36;
93  repeated  fixed32 repeated_fixed32  = 37;
94  repeated  fixed64 repeated_fixed64  = 38;
95  repeated sfixed32 repeated_sfixed32 = 39;
96  repeated sfixed64 repeated_sfixed64 = 40;
97  repeated    float repeated_float    = 41;
98  repeated   double repeated_double   = 42;
99  repeated     bool repeated_bool     = 43;
100  repeated   string repeated_string   = 44;
101  repeated    bytes repeated_bytes    = 45;
102
103  repeated group RepeatedGroup = 46 {
104    optional int32 a = 47;
105  }
106
107  repeated NestedMessage      repeated_nested_message  = 48;
108  repeated ForeignMessageMicro repeated_foreign_message = 49;
109  repeated protobuf_unittest_import.ImportMessageMicro
110    repeated_import_message = 50;
111
112  repeated NestedEnum      repeated_nested_enum  = 51;
113  repeated ForeignEnumMicro repeated_foreign_enum = 52;
114  repeated protobuf_unittest_import.ImportEnumMicro repeated_import_enum = 53;
115
116  repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
117  repeated string repeated_cord = 55 [ctype=CORD];
118
119  // Singular with defaults
120  optional    int32 default_int32    = 61 [default =  41    ];
121  optional    int64 default_int64    = 62 [default =  42    ];
122  optional   uint32 default_uint32   = 63 [default =  43    ];
123  optional   uint64 default_uint64   = 64 [default =  44    ];
124  optional   sint32 default_sint32   = 65 [default = -45    ];
125  optional   sint64 default_sint64   = 66 [default =  46    ];
126  optional  fixed32 default_fixed32  = 67 [default =  47    ];
127  optional  fixed64 default_fixed64  = 68 [default =  48    ];
128  optional sfixed32 default_sfixed32 = 69 [default =  49    ];
129  optional sfixed64 default_sfixed64 = 70 [default = -50    ];
130  optional    float default_float    = 71 [default =  51.5  ];
131  optional   double default_double   = 72 [default =  52e3  ];
132  optional     bool default_bool     = 73 [default = true   ];
133  optional   string default_string   = 74 [default = "hello"];
134  optional    bytes default_bytes    = 75 [default = "world"];
135
136  optional NestedEnum default_nested_enum = 81 [default = BAR];
137  optional ForeignEnumMicro default_foreign_enum = 82
138      [default = FOREIGN_MICRO_BAR];
139  optional protobuf_unittest_import.ImportEnumMicro
140      default_import_enum = 83 [default = IMPORT_MICRO_BAR];
141
142  optional string default_string_piece = 84 [ctype=STRING_PIECE,default="abc"];
143  optional string default_cord = 85 [ctype=CORD,default="123"];
144
145  required int32 id = 86;
146}
147
148message ForeignMessageMicro {
149  optional int32 c = 1;
150}
151
152enum ForeignEnumMicro {
153  FOREIGN_MICRO_FOO = 4;
154  FOREIGN_MICRO_BAR = 5;
155  FOREIGN_MICRO_BAZ = 6;
156}
157
158// Test that deprecated fields work.  We only verify that they compile (at one
159// point this failed).
160message TestDeprecatedMicro {
161  optional int32 deprecated_field = 1 [deprecated = true];
162}
163