• 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
31syntax = "proto3";
32
33option cc_enable_arenas = true;
34
35import "google/protobuf/unittest.proto";
36import "google/protobuf/unittest_no_arena.proto";
37
38// We don't put this in a package within proto2 because we need to make sure
39// that the generated code doesn't depend on being in the proto2 namespace.
40// In map_test_util.h we do "using namespace unittest = protobuf_unittest".
41package protobuf_unittest;
42
43// Tests maps.
44message TestMap {
45  map<int32   , int32   > map_int32_int32       = 1;
46  map<int64   , int64   > map_int64_int64       = 2;
47  map<uint32  , uint32  > map_uint32_uint32     = 3;
48  map<uint64  , uint64  > map_uint64_uint64     = 4;
49  map<sint32  , sint32  > map_sint32_sint32     = 5;
50  map<sint64  , sint64  > map_sint64_sint64     = 6;
51  map<fixed32 , fixed32 > map_fixed32_fixed32   = 7;
52  map<fixed64 , fixed64 > map_fixed64_fixed64   = 8;
53  map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;
54  map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;
55  map<int32   , float   > map_int32_float       = 11;
56  map<int32   , double  > map_int32_double      = 12;
57  map<bool    , bool    > map_bool_bool         = 13;
58  map<string  , string  > map_string_string     = 14;
59  map<int32   , bytes   > map_int32_bytes       = 15;
60  map<int32   , MapEnum > map_int32_enum        = 16;
61  map<int32   , ForeignMessage> map_int32_foreign_message = 17;
62  map<string  , ForeignMessage> map_string_foreign_message = 18;
63}
64
65message TestMapSubmessage {
66  TestMap test_map = 1;
67}
68
69message TestMessageMap {
70  map<int32, TestAllTypes> map_int32_message = 1;
71}
72
73// Two map fields share the same entry default instance.
74message TestSameTypeMap {
75  map<int32, int32> map1 = 1;
76  map<int32, int32> map2 = 2;
77}
78
79
80enum MapEnum {
81  MAP_ENUM_FOO = 0;
82  MAP_ENUM_BAR = 1;
83  MAP_ENUM_BAZ = 2;
84}
85
86// Test embeded message with required fields
87message TestRequiredMessageMap {
88  map<int32, TestRequired> map_field = 1;
89}
90
91message TestArenaMap {
92  map<int32   , int32   > map_int32_int32       = 1;
93  map<int64   , int64   > map_int64_int64       = 2;
94  map<uint32  , uint32  > map_uint32_uint32     = 3;
95  map<uint64  , uint64  > map_uint64_uint64     = 4;
96  map<sint32  , sint32  > map_sint32_sint32     = 5;
97  map<sint64  , sint64  > map_sint64_sint64     = 6;
98  map<fixed32 , fixed32 > map_fixed32_fixed32   = 7;
99  map<fixed64 , fixed64 > map_fixed64_fixed64   = 8;
100  map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;
101  map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;
102  map<int32   , float   > map_int32_float       = 11;
103  map<int32   , double  > map_int32_double      = 12;
104  map<bool    , bool    > map_bool_bool         = 13;
105  map<string  , string  > map_string_string     = 14;
106  map<int32   , bytes   > map_int32_bytes       = 15;
107  map<int32   , MapEnum > map_int32_enum        = 16;
108  map<int32   , ForeignMessage> map_int32_foreign_message = 17;
109  map<int32, .protobuf_unittest_no_arena.ForeignMessage>
110      map_int32_foreign_message_no_arena = 18;
111}
112
113// Previously, message containing enum called Type cannot be used as value of
114// map field.
115message MessageContainingEnumCalledType {
116  enum Type {
117    TYPE_FOO = 0;
118  }
119  map<string, MessageContainingEnumCalledType> type = 1;
120}
121
122// Previously, message cannot contain map field called "entry".
123message MessageContainingMapCalledEntry {
124  map<int32, int32> entry = 1;
125}
126
127message TestRecursiveMapMessage {
128  map<string, TestRecursiveMapMessage> a = 1;
129}
130