• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Protocol Buffers - Google's data interchange format
2// Copyright 2008 Google Inc.  All rights reserved.
3//
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file or at
6// https://developers.google.com/open-source/licenses/bsd
7
8syntax = "proto3";
9
10option cc_enable_arenas = true;
11
12import "google/protobuf/unittest.proto";
13
14// We don't put this in a package within proto2 because we need to make sure
15// that the generated code doesn't depend on being in the proto2 namespace.
16// In map_test_util.h we do "using namespace unittest = protobuf_unittest".
17package protobuf_unittest;
18
19// Tests maps.
20message TestMap {
21  map<int32, int32> map_int32_int32 = 1;
22  map<int64, int64> map_int64_int64 = 2;
23  map<uint32, uint32> map_uint32_uint32 = 3;
24  map<uint64, uint64> map_uint64_uint64 = 4;
25  map<sint32, sint32> map_sint32_sint32 = 5;
26  map<sint64, sint64> map_sint64_sint64 = 6;
27  map<fixed32, fixed32> map_fixed32_fixed32 = 7;
28  map<fixed64, fixed64> map_fixed64_fixed64 = 8;
29  map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;
30  map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;
31  map<int32, float> map_int32_float = 11;
32  map<int32, double> map_int32_double = 12;
33  map<bool, bool> map_bool_bool = 13;
34  map<string, string> map_string_string = 14;
35  map<int32, bytes> map_int32_bytes = 15;
36  map<int32, MapEnum> map_int32_enum = 16;
37  map<int32, ForeignMessage> map_int32_foreign_message = 17;
38  map<string, ForeignMessage> map_string_foreign_message = 18;
39  map<int32, TestAllTypes> map_int32_all_types = 19;
40}
41
42message TestMapWithMessages {
43  map<int32, TestAllTypes> map_int32_all_types = 1;
44  map<int64, TestAllTypes> map_int64_all_types = 2;
45  map<uint32, TestAllTypes> map_uint32_all_types = 3;
46  map<uint64, TestAllTypes> map_uint64_all_types = 4;
47  map<sint32, TestAllTypes> map_sint32_all_types = 5;
48  map<sint64, TestAllTypes> map_sint64_all_types = 6;
49  map<fixed32, TestAllTypes> map_fixed32_all_types = 7;
50  map<fixed64, TestAllTypes> map_fixed64_all_types = 8;
51  map<sfixed32, TestAllTypes> map_sfixed32_all_types = 9;
52  map<sfixed64, TestAllTypes> map_sfixed64_all_types = 10;
53  map<bool, TestAllTypes> map_bool_all_types = 11;
54  map<string, TestAllTypes> map_string_all_types = 12;
55}
56
57message TestMapSubmessage {
58  TestMap test_map = 1;
59}
60
61message TestMessageMap {
62  map<int32, TestAllTypes> map_int32_message = 1;
63}
64
65// Two map fields share the same entry default instance.
66message TestSameTypeMap {
67  map<int32, int32> map1 = 1;
68  map<int32, int32> map2 = 2;
69}
70
71enum MapEnum {
72  MAP_ENUM_FOO = 0;
73  MAP_ENUM_BAR = 1;
74  MAP_ENUM_BAZ = 2;
75}
76
77// Test embedded message with required fields
78message TestRequiredMessageMap {
79  map<int32, TestRequired> map_field = 1;
80}
81
82message TestArenaMap {
83  map<int32, int32> map_int32_int32 = 1;
84  map<int64, int64> map_int64_int64 = 2;
85  map<uint32, uint32> map_uint32_uint32 = 3;
86  map<uint64, uint64> map_uint64_uint64 = 4;
87  map<sint32, sint32> map_sint32_sint32 = 5;
88  map<sint64, sint64> map_sint64_sint64 = 6;
89  map<fixed32, fixed32> map_fixed32_fixed32 = 7;
90  map<fixed64, fixed64> map_fixed64_fixed64 = 8;
91  map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;
92  map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;
93  map<int32, float> map_int32_float = 11;
94  map<int32, double> map_int32_double = 12;
95  map<bool, bool> map_bool_bool = 13;
96  map<string, string> map_string_string = 14;
97  map<int32, bytes> map_int32_bytes = 15;
98  map<int32, MapEnum> map_int32_enum = 16;
99  map<int32, ForeignMessage> map_int32_foreign_message = 17;
100}
101
102// Previously, message containing enum called Type cannot be used as value of
103// map field.
104message MessageContainingEnumCalledType {
105  enum Type {
106    TYPE_FOO = 0;
107  }
108  map<string, MessageContainingEnumCalledType> type = 1;
109}
110
111// Previously, message cannot contain map field called "entry".
112message MessageContainingMapCalledEntry {
113  map<int32, int32> entry = 1;
114}
115
116message TestRecursiveMapMessage {
117  map<string, TestRecursiveMapMessage> a = 1;
118}
119
120message TestI32StrMap {
121  map<int32, string> m_32_str = 1;
122}
123