maps.proto 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. syntax = "proto3";
  31. package google.protobuf.testing;
  32. // Top-level test cases proto used by MarshallingTest. See description
  33. // at the top of the class MarshallingTest for details on how to write
  34. // test cases.
  35. message MapsTestCases {
  36. EmptyMap empty_map = 1;
  37. StringtoInt string_to_int = 2;
  38. IntToString int_to_string = 3;
  39. Mixed1 mixed1 = 4;
  40. Mixed2 mixed2 = 5;
  41. MapOfObjects map_of_objects = 6;
  42. // Empty key tests
  43. StringtoInt empty_key_string_to_int1 = 7;
  44. StringtoInt empty_key_string_to_int2 = 8;
  45. StringtoInt empty_key_string_to_int3 = 9;
  46. BoolToString empty_key_bool_to_string = 10;
  47. IntToString empty_key_int_to_string = 11;
  48. Mixed1 empty_key_mixed = 12;
  49. MapOfObjects empty_key_map_objects = 13;
  50. }
  51. message EmptyMap {
  52. map<int32, int32> map = 1;
  53. }
  54. message StringtoInt {
  55. map<string, int32> map = 1;
  56. }
  57. message IntToString {
  58. map<int32, string> map = 1;
  59. }
  60. message BoolToString {
  61. map<bool, string> map = 1;
  62. }
  63. message Mixed1 {
  64. string msg = 1;
  65. map<string, float> map = 2;
  66. }
  67. message Mixed2 {
  68. enum E {
  69. E0 = 0;
  70. E1 = 1;
  71. E2 = 2;
  72. E3 = 3;
  73. }
  74. map<int32, bool> map = 1;
  75. E ee = 2;
  76. }
  77. message MapOfObjects {
  78. message M {
  79. string inner_text = 1;
  80. }
  81. map<string, M> map = 1;
  82. }
  83. message DummyRequest {
  84. }
  85. service MapsTestService {
  86. rpc Call(DummyRequest) returns (MapsTestCases);
  87. }
  88. message MapIn {
  89. string other = 1;
  90. repeated string things = 2;
  91. map<string, string> map_input = 3;
  92. }
  93. message MapOut {
  94. map<string, MapM> map1 = 1;
  95. map<string, MapOut> map2 = 2;
  96. map<int32, string> map3 = 3;
  97. map<bool, string> map4 = 5;
  98. string bar = 4;
  99. }
  100. // A message with exactly the same wire representation as MapOut, but using
  101. // repeated message fields instead of map fields. We use this message to test
  102. // the wire-format compatibility of the JSON transcoder (e.g., whether it
  103. // handles missing keys correctly).
  104. message MapOutWireFormat {
  105. message Map1Entry {
  106. string key = 1;
  107. MapM value = 2;
  108. }
  109. repeated Map1Entry map1 = 1;
  110. message Map2Entry {
  111. string key = 1;
  112. MapOut value = 2;
  113. }
  114. repeated Map2Entry map2 = 2;
  115. message Map3Entry {
  116. int32 key = 1;
  117. string value = 2;
  118. }
  119. repeated Map3Entry map3 = 3;
  120. message Map4Entry {
  121. bool key = 1;
  122. string value = 2;
  123. }
  124. repeated Map4Entry map4 = 5;
  125. string bar = 4;
  126. }
  127. message MapM {
  128. string foo = 1;
  129. }