map_unittest.proto 4.0 KB

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