• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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// A proto file used to test a message type with no explicit field presence.
32
33syntax = "proto3";
34
35// We want to test embedded proto2 messages, so include some proto2 types.
36import "google/protobuf/unittest.proto";
37
38package proto2_nofieldpresence_unittest;
39
40// This proto includes every type of field in both singular and repeated
41// forms.
42message TestAllTypes {
43  message NestedMessage {
44    int32 bb = 1;
45  }
46
47  enum NestedEnum {
48    FOO = 0;
49    BAR = 1;
50    BAZ = 2;
51  }
52
53  // Singular
54  // TODO: remove 'optional' labels as soon as CL 69188077 is LGTM'd to make
55  // 'optional' optional.
56     int32 optional_int32    =  1;
57     int64 optional_int64    =  2;
58    uint32 optional_uint32   =  3;
59    uint64 optional_uint64   =  4;
60    sint32 optional_sint32   =  5;
61    sint64 optional_sint64   =  6;
62   fixed32 optional_fixed32  =  7;
63   fixed64 optional_fixed64  =  8;
64  sfixed32 optional_sfixed32 =  9;
65  sfixed64 optional_sfixed64 = 10;
66     float optional_float    = 11;
67    double optional_double   = 12;
68      bool optional_bool     = 13;
69    string optional_string   = 14;
70     bytes optional_bytes    = 15;
71
72  NestedMessage                        optional_nested_message  = 18;
73  ForeignMessage                       optional_foreign_message = 19;
74  protobuf_unittest.TestAllTypes         optional_proto2_message = 20;
75
76  NestedEnum                           optional_nested_enum     = 21;
77  ForeignEnum                          optional_foreign_enum    = 22;
78  // N.B.: proto2-enum-type fields not allowed, because their default values
79  // might not be zero.
80  //optional protobuf_unittest.ForeignEnum          optional_proto2_enum     = 23;
81
82  string optional_string_piece = 24 [ctype=STRING_PIECE];
83  string optional_cord = 25 [ctype=CORD];
84
85  NestedMessage optional_lazy_message = 30 [lazy=true];
86
87  // Repeated
88  repeated    int32 repeated_int32    = 31;
89  repeated    int64 repeated_int64    = 32;
90  repeated   uint32 repeated_uint32   = 33;
91  repeated   uint64 repeated_uint64   = 34;
92  repeated   sint32 repeated_sint32   = 35;
93  repeated   sint64 repeated_sint64   = 36;
94  repeated  fixed32 repeated_fixed32  = 37;
95  repeated  fixed64 repeated_fixed64  = 38;
96  repeated sfixed32 repeated_sfixed32 = 39;
97  repeated sfixed64 repeated_sfixed64 = 40;
98  repeated    float repeated_float    = 41;
99  repeated   double repeated_double   = 42;
100  repeated     bool repeated_bool     = 43;
101  repeated   string repeated_string   = 44;
102  repeated    bytes repeated_bytes    = 45;
103
104  repeated NestedMessage                        repeated_nested_message  = 48;
105  repeated ForeignMessage                       repeated_foreign_message = 49;
106  repeated protobuf_unittest.TestAllTypes         repeated_proto2_message  = 50;
107
108  repeated NestedEnum                           repeated_nested_enum     = 51;
109  repeated ForeignEnum                          repeated_foreign_enum    = 52;
110
111  repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
112  repeated string repeated_cord = 55 [ctype=CORD];
113
114  repeated NestedMessage repeated_lazy_message = 57 [lazy=true];
115
116  oneof oneof_field {
117    uint32 oneof_uint32 = 111;
118    NestedMessage oneof_nested_message = 112;
119    string oneof_string = 113;
120    NestedEnum oneof_enum = 114;
121  }
122}
123
124message TestProto2Required {
125  protobuf_unittest.TestRequired proto2 = 1;
126}
127
128// Define these after TestAllTypes to make sure the compiler can handle
129// that.
130message ForeignMessage {
131  int32 c = 1;
132}
133
134enum ForeignEnum {
135  FOREIGN_FOO = 0;
136  FOREIGN_BAR = 1;
137  FOREIGN_BAZ = 2;
138}
139