• 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
8// This file is mostly equivalent to map_unittest.proto, but imports
9// unittest_proto3.proto instead of unittest.proto, so that it only
10// uses proto3 messages. This makes it suitable for testing
11// implementations which only support proto3.
12// The TestRequiredMessageMap message has been removed as there are no
13// required fields in proto3.
14syntax = "proto3";
15
16option cc_enable_arenas = true;
17option csharp_namespace = "Google.Protobuf.TestProtos";
18
19import "google/protobuf/unittest_proto3.proto";
20
21// We don't put this in a package within proto2 because we need to make sure
22// that the generated code doesn't depend on being in the proto2 namespace.
23// In map_test_util.h we do "using namespace unittest = protobuf_unittest".
24package protobuf_unittest;
25
26// Tests maps.
27message TestMap {
28  map<int32   , int32   > map_int32_int32       = 1;
29  map<int64   , int64   > map_int64_int64       = 2;
30  map<uint32  , uint32  > map_uint32_uint32     = 3;
31  map<uint64  , uint64  > map_uint64_uint64     = 4;
32  map<sint32  , sint32  > map_sint32_sint32     = 5;
33  map<sint64  , sint64  > map_sint64_sint64     = 6;
34  map<fixed32 , fixed32 > map_fixed32_fixed32   = 7;
35  map<fixed64 , fixed64 > map_fixed64_fixed64   = 8;
36  map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;
37  map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;
38  map<int32   , float   > map_int32_float       = 11;
39  map<int32   , double  > map_int32_double      = 12;
40  map<bool    , bool    > map_bool_bool         = 13;
41  map<string  , string  > map_string_string     = 14;
42  map<int32   , bytes   > map_int32_bytes       = 15;
43  map<int32   , MapEnum > map_int32_enum        = 16;
44  map<int32   , ForeignMessage> map_int32_foreign_message = 17;
45}
46
47message TestMapSubmessage {
48  TestMap test_map = 1;
49}
50
51message TestMessageMap {
52  map<int32, TestAllTypes> map_int32_message = 1;
53}
54
55// Two map fields share the same entry default instance.
56message TestSameTypeMap {
57  map<int32, int32> map1 = 1;
58  map<int32, int32> map2 = 2;
59}
60
61enum MapEnum {
62  MAP_ENUM_FOO = 0;
63  MAP_ENUM_BAR = 1;
64  MAP_ENUM_BAZ = 2;
65}
66
67message TestArenaMap {
68  map<int32   , int32   > map_int32_int32       = 1;
69  map<int64   , int64   > map_int64_int64       = 2;
70  map<uint32  , uint32  > map_uint32_uint32     = 3;
71  map<uint64  , uint64  > map_uint64_uint64     = 4;
72  map<sint32  , sint32  > map_sint32_sint32     = 5;
73  map<sint64  , sint64  > map_sint64_sint64     = 6;
74  map<fixed32 , fixed32 > map_fixed32_fixed32   = 7;
75  map<fixed64 , fixed64 > map_fixed64_fixed64   = 8;
76  map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;
77  map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;
78  map<int32   , float   > map_int32_float       = 11;
79  map<int32   , double  > map_int32_double      = 12;
80  map<bool    , bool    > map_bool_bool         = 13;
81  map<int32   , MapEnum > map_int32_enum        = 14;
82  map<int32   , ForeignMessage> map_int32_foreign_message = 15;
83}
84
85// Previously, message containing enum called Type cannot be used as value of
86// map field.
87message MessageContainingEnumCalledType {
88  enum Type {
89    TYPE_FOO = 0;
90  }
91  map<int32, MessageContainingEnumCalledType> type = 1;
92}
93
94// Previously, message cannot contain map field called "entry".
95message MessageContainingMapCalledEntry {
96  map<int32, int32> entry = 1;
97}
98