unittest_proto3_lite.proto 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. package proto3_lite_unittest;
  9. import "google/protobuf/unittest_import.proto";
  10. option optimize_for = LITE_RUNTIME;
  11. // This proto includes every type of field in both singular and repeated
  12. // forms.
  13. message TestAllTypes {
  14. message NestedMessage {
  15. // The field name "b" fails to compile in proto1 because it conflicts with
  16. // a local variable named "b" in one of the generated methods. Doh.
  17. // This file needs to compile in proto1 to test backwards-compatibility.
  18. int32 bb = 1;
  19. }
  20. enum NestedEnum {
  21. ZERO = 0;
  22. FOO = 1;
  23. BAR = 2;
  24. BAZ = 3;
  25. NEG = -1; // Intentionally negative.
  26. }
  27. // Singular
  28. int32 optional_int32 = 1;
  29. int64 optional_int64 = 2;
  30. uint32 optional_uint32 = 3;
  31. uint64 optional_uint64 = 4;
  32. sint32 optional_sint32 = 5;
  33. sint64 optional_sint64 = 6;
  34. fixed32 optional_fixed32 = 7;
  35. fixed64 optional_fixed64 = 8;
  36. sfixed32 optional_sfixed32 = 9;
  37. sfixed64 optional_sfixed64 = 10;
  38. float optional_float = 11;
  39. double optional_double = 12;
  40. bool optional_bool = 13;
  41. string optional_string = 14;
  42. bytes optional_bytes = 15;
  43. // Groups are not allowed in proto3.
  44. // optional group OptionalGroup = 16 {
  45. // optional int32 a = 17;
  46. // }
  47. NestedMessage optional_nested_message = 18;
  48. ForeignMessage optional_foreign_message = 19;
  49. protobuf_unittest_import.ImportMessage optional_import_message = 20;
  50. NestedEnum optional_nested_enum = 21;
  51. ForeignEnum optional_foreign_enum = 22;
  52. // Omitted (compared to unittest.proto) because proto2 enums are not allowed
  53. // inside proto2 messages.
  54. //
  55. // optional protobuf_unittest_import.ImportEnum optional_import_enum = 23;
  56. string optional_string_piece = 24 [ctype = STRING_PIECE];
  57. string optional_cord = 25 [ctype = CORD];
  58. // Defined in unittest_import_public.proto
  59. protobuf_unittest_import.PublicImportMessage optional_public_import_message =
  60. 26;
  61. NestedMessage optional_lazy_message = 27 [lazy = true];
  62. // Repeated
  63. repeated int32 repeated_int32 = 31;
  64. repeated int64 repeated_int64 = 32;
  65. repeated uint32 repeated_uint32 = 33;
  66. repeated uint64 repeated_uint64 = 34;
  67. repeated sint32 repeated_sint32 = 35;
  68. repeated sint64 repeated_sint64 = 36;
  69. repeated fixed32 repeated_fixed32 = 37;
  70. repeated fixed64 repeated_fixed64 = 38;
  71. repeated sfixed32 repeated_sfixed32 = 39;
  72. repeated sfixed64 repeated_sfixed64 = 40;
  73. repeated float repeated_float = 41;
  74. repeated double repeated_double = 42;
  75. repeated bool repeated_bool = 43;
  76. repeated string repeated_string = 44;
  77. repeated bytes repeated_bytes = 45;
  78. // Groups are not allowed in proto3.
  79. // repeated group RepeatedGroup = 46 {
  80. // optional int32 a = 47;
  81. // }
  82. repeated NestedMessage repeated_nested_message = 48;
  83. repeated ForeignMessage repeated_foreign_message = 49;
  84. repeated protobuf_unittest_import.ImportMessage repeated_import_message = 50;
  85. repeated NestedEnum repeated_nested_enum = 51;
  86. repeated ForeignEnum repeated_foreign_enum = 52;
  87. // Omitted (compared to unittest.proto) because proto2 enums are not allowed
  88. // inside proto2 messages.
  89. //
  90. // repeated protobuf_unittest_import.ImportEnum repeated_import_enum = 53;
  91. repeated string repeated_string_piece = 54 [ctype = STRING_PIECE];
  92. repeated string repeated_cord = 55 [ctype = CORD];
  93. repeated NestedMessage repeated_lazy_message = 57 ;
  94. oneof oneof_field {
  95. uint32 oneof_uint32 = 111;
  96. NestedMessage oneof_nested_message = 112;
  97. string oneof_string = 113;
  98. bytes oneof_bytes = 114;
  99. }
  100. }
  101. // Test messages for packed fields
  102. message TestPackedTypes {
  103. repeated int32 packed_int32 = 90 [packed = true];
  104. repeated int64 packed_int64 = 91 [packed = true];
  105. repeated uint32 packed_uint32 = 92 [packed = true];
  106. repeated uint64 packed_uint64 = 93 [packed = true];
  107. repeated sint32 packed_sint32 = 94 [packed = true];
  108. repeated sint64 packed_sint64 = 95 [packed = true];
  109. repeated fixed32 packed_fixed32 = 96 [packed = true];
  110. repeated fixed64 packed_fixed64 = 97 [packed = true];
  111. repeated sfixed32 packed_sfixed32 = 98 [packed = true];
  112. repeated sfixed64 packed_sfixed64 = 99 [packed = true];
  113. repeated float packed_float = 100 [packed = true];
  114. repeated double packed_double = 101 [packed = true];
  115. repeated bool packed_bool = 102 [packed = true];
  116. repeated ForeignEnum packed_enum = 103 [packed = true];
  117. }
  118. // Explicitly set packed to false
  119. message TestUnpackedTypes {
  120. repeated int32 repeated_int32 = 1 [packed = false];
  121. repeated int64 repeated_int64 = 2 [packed = false];
  122. repeated uint32 repeated_uint32 = 3 [packed = false];
  123. repeated uint64 repeated_uint64 = 4 [packed = false];
  124. repeated sint32 repeated_sint32 = 5 [packed = false];
  125. repeated sint64 repeated_sint64 = 6 [packed = false];
  126. repeated fixed32 repeated_fixed32 = 7 [packed = false];
  127. repeated fixed64 repeated_fixed64 = 8 [packed = false];
  128. repeated sfixed32 repeated_sfixed32 = 9 [packed = false];
  129. repeated sfixed64 repeated_sfixed64 = 10 [packed = false];
  130. repeated float repeated_float = 11 [packed = false];
  131. repeated double repeated_double = 12 [packed = false];
  132. repeated bool repeated_bool = 13 [packed = false];
  133. repeated TestAllTypes.NestedEnum repeated_nested_enum = 14 [packed = false];
  134. }
  135. // This proto includes a recursively nested message.
  136. message NestedTestAllTypes {
  137. NestedTestAllTypes child = 1;
  138. TestAllTypes payload = 2;
  139. }
  140. // Define these after TestAllTypes to make sure the compiler can handle
  141. // that.
  142. message ForeignMessage {
  143. int32 c = 1;
  144. }
  145. enum ForeignEnum {
  146. FOREIGN_ZERO = 0;
  147. FOREIGN_FOO = 4;
  148. FOREIGN_BAR = 5;
  149. FOREIGN_BAZ = 6;
  150. }
  151. // TestEmptyMessage is used to test behavior of unknown fields.
  152. message TestEmptyMessage {}