诸暨麻将添加redis
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1118 lines
38 KiB

  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. // Author: kenton@google.com (Kenton Varda)
  31. // Based on original Protocol Buffers design by
  32. // Sanjay Ghemawat, Jeff Dean, and others.
  33. //
  34. // A proto file we will use for unit testing.
  35. //
  36. // LINT: ALLOW_GROUPS, LEGACY_NAMES
  37. syntax = "proto2";
  38. // Some generic_services option(s) added automatically.
  39. // See: http://go/proto2-generic-services-default
  40. option cc_generic_services = true; // auto-added
  41. option java_generic_services = true; // auto-added
  42. option py_generic_services = true; // auto-added
  43. option cc_enable_arenas = true;
  44. import "google/protobuf/unittest_import.proto";
  45. // We don't put this in a package within proto2 because we need to make sure
  46. // that the generated code doesn't depend on being in the proto2 namespace.
  47. // In test_util.h we do "using namespace unittest = protobuf_unittest".
  48. package protobuf_unittest;
  49. // Protos optimized for SPEED use a strict superset of the generated code
  50. // of equivalent ones optimized for CODE_SIZE, so we should optimize all our
  51. // tests for speed unless explicitly testing code size optimization.
  52. option optimize_for = SPEED;
  53. option java_outer_classname = "UnittestProto";
  54. // This proto includes every type of field in both singular and repeated
  55. // forms.
  56. message TestAllTypes {
  57. message NestedMessage {
  58. // The field name "b" fails to compile in proto1 because it conflicts with
  59. // a local variable named "b" in one of the generated methods. Doh.
  60. // This file needs to compile in proto1 to test backwards-compatibility.
  61. optional int32 bb = 1;
  62. }
  63. enum NestedEnum {
  64. FOO = 1;
  65. BAR = 2;
  66. BAZ = 3;
  67. NEG = -1; // Intentionally negative.
  68. }
  69. // Singular
  70. optional int32 optional_int32 = 1;
  71. optional int64 optional_int64 = 2;
  72. optional uint32 optional_uint32 = 3;
  73. optional uint64 optional_uint64 = 4;
  74. optional sint32 optional_sint32 = 5;
  75. optional sint64 optional_sint64 = 6;
  76. optional fixed32 optional_fixed32 = 7;
  77. optional fixed64 optional_fixed64 = 8;
  78. optional sfixed32 optional_sfixed32 = 9;
  79. optional sfixed64 optional_sfixed64 = 10;
  80. optional float optional_float = 11;
  81. optional double optional_double = 12;
  82. optional bool optional_bool = 13;
  83. optional string optional_string = 14;
  84. optional bytes optional_bytes = 15;
  85. optional group OptionalGroup = 16 {
  86. optional int32 a = 17;
  87. }
  88. optional NestedMessage optional_nested_message = 18;
  89. optional ForeignMessage optional_foreign_message = 19;
  90. optional protobuf_unittest_import.ImportMessage optional_import_message = 20;
  91. optional NestedEnum optional_nested_enum = 21;
  92. optional ForeignEnum optional_foreign_enum = 22;
  93. optional protobuf_unittest_import.ImportEnum optional_import_enum = 23;
  94. optional string optional_string_piece = 24 [ctype=STRING_PIECE];
  95. optional string optional_cord = 25 [ctype=CORD];
  96. // Defined in unittest_import_public.proto
  97. optional protobuf_unittest_import.PublicImportMessage
  98. optional_public_import_message = 26;
  99. optional NestedMessage optional_lazy_message = 27 [lazy=true];
  100. // Repeated
  101. repeated int32 repeated_int32 = 31;
  102. repeated int64 repeated_int64 = 32;
  103. repeated uint32 repeated_uint32 = 33;
  104. repeated uint64 repeated_uint64 = 34;
  105. repeated sint32 repeated_sint32 = 35;
  106. repeated sint64 repeated_sint64 = 36;
  107. repeated fixed32 repeated_fixed32 = 37;
  108. repeated fixed64 repeated_fixed64 = 38;
  109. repeated sfixed32 repeated_sfixed32 = 39;
  110. repeated sfixed64 repeated_sfixed64 = 40;
  111. repeated float repeated_float = 41;
  112. repeated double repeated_double = 42;
  113. repeated bool repeated_bool = 43;
  114. repeated string repeated_string = 44;
  115. repeated bytes repeated_bytes = 45;
  116. repeated group RepeatedGroup = 46 {
  117. optional int32 a = 47;
  118. }
  119. repeated NestedMessage repeated_nested_message = 48;
  120. repeated ForeignMessage repeated_foreign_message = 49;
  121. repeated protobuf_unittest_import.ImportMessage repeated_import_message = 50;
  122. repeated NestedEnum repeated_nested_enum = 51;
  123. repeated ForeignEnum repeated_foreign_enum = 52;
  124. repeated protobuf_unittest_import.ImportEnum repeated_import_enum = 53;
  125. repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
  126. repeated string repeated_cord = 55 [ctype=CORD];
  127. repeated NestedMessage repeated_lazy_message = 57 [lazy=true];
  128. // Singular with defaults
  129. optional int32 default_int32 = 61 [default = 41 ];
  130. optional int64 default_int64 = 62 [default = 42 ];
  131. optional uint32 default_uint32 = 63 [default = 43 ];
  132. optional uint64 default_uint64 = 64 [default = 44 ];
  133. optional sint32 default_sint32 = 65 [default = -45 ];
  134. optional sint64 default_sint64 = 66 [default = 46 ];
  135. optional fixed32 default_fixed32 = 67 [default = 47 ];
  136. optional fixed64 default_fixed64 = 68 [default = 48 ];
  137. optional sfixed32 default_sfixed32 = 69 [default = 49 ];
  138. optional sfixed64 default_sfixed64 = 70 [default = -50 ];
  139. optional float default_float = 71 [default = 51.5 ];
  140. optional double default_double = 72 [default = 52e3 ];
  141. optional bool default_bool = 73 [default = true ];
  142. optional string default_string = 74 [default = "hello"];
  143. optional bytes default_bytes = 75 [default = "world"];
  144. optional NestedEnum default_nested_enum = 81 [default = BAR ];
  145. optional ForeignEnum default_foreign_enum = 82 [default = FOREIGN_BAR];
  146. optional protobuf_unittest_import.ImportEnum
  147. default_import_enum = 83 [default = IMPORT_BAR];
  148. optional string default_string_piece = 84 [ctype=STRING_PIECE,default="abc"];
  149. optional string default_cord = 85 [ctype=CORD,default="123"];
  150. // For oneof test
  151. oneof oneof_field {
  152. uint32 oneof_uint32 = 111;
  153. NestedMessage oneof_nested_message = 112;
  154. string oneof_string = 113;
  155. bytes oneof_bytes = 114;
  156. }
  157. }
  158. // This proto includes a recusively nested message.
  159. message NestedTestAllTypes {
  160. optional NestedTestAllTypes child = 1;
  161. optional TestAllTypes payload = 2;
  162. repeated NestedTestAllTypes repeated_child = 3;
  163. }
  164. message TestDeprecatedFields {
  165. optional int32 deprecated_int32 = 1 [deprecated=true];
  166. oneof oneof_fields {
  167. int32 deprecated_int32_in_oneof = 2 [deprecated=true];
  168. }
  169. }
  170. message TestDeprecatedMessage {
  171. option deprecated = true;
  172. }
  173. // Define these after TestAllTypes to make sure the compiler can handle
  174. // that.
  175. message ForeignMessage {
  176. optional int32 c = 1;
  177. optional int32 d = 2;
  178. }
  179. enum ForeignEnum {
  180. FOREIGN_FOO = 4;
  181. FOREIGN_BAR = 5;
  182. FOREIGN_BAZ = 6;
  183. }
  184. message TestReservedFields {
  185. reserved 2, 15, 9 to 11;
  186. reserved "bar", "baz";
  187. }
  188. message TestAllExtensions {
  189. extensions 1 to max;
  190. }
  191. extend TestAllExtensions {
  192. // Singular
  193. optional int32 optional_int32_extension = 1;
  194. optional int64 optional_int64_extension = 2;
  195. optional uint32 optional_uint32_extension = 3;
  196. optional uint64 optional_uint64_extension = 4;
  197. optional sint32 optional_sint32_extension = 5;
  198. optional sint64 optional_sint64_extension = 6;
  199. optional fixed32 optional_fixed32_extension = 7;
  200. optional fixed64 optional_fixed64_extension = 8;
  201. optional sfixed32 optional_sfixed32_extension = 9;
  202. optional sfixed64 optional_sfixed64_extension = 10;
  203. optional float optional_float_extension = 11;
  204. optional double optional_double_extension = 12;
  205. optional bool optional_bool_extension = 13;
  206. optional string optional_string_extension = 14;
  207. optional bytes optional_bytes_extension = 15;
  208. optional group OptionalGroup_extension = 16 {
  209. optional int32 a = 17;
  210. }
  211. optional TestAllTypes.NestedMessage optional_nested_message_extension = 18;
  212. optional ForeignMessage optional_foreign_message_extension = 19;
  213. optional protobuf_unittest_import.ImportMessage
  214. optional_import_message_extension = 20;
  215. optional TestAllTypes.NestedEnum optional_nested_enum_extension = 21;
  216. optional ForeignEnum optional_foreign_enum_extension = 22;
  217. optional protobuf_unittest_import.ImportEnum
  218. optional_import_enum_extension = 23;
  219. optional string optional_string_piece_extension = 24 [ctype=STRING_PIECE];
  220. optional string optional_cord_extension = 25 [ctype=CORD];
  221. optional protobuf_unittest_import.PublicImportMessage
  222. optional_public_import_message_extension = 26;
  223. optional TestAllTypes.NestedMessage
  224. optional_lazy_message_extension = 27 [lazy=true];
  225. // Repeated
  226. repeated int32 repeated_int32_extension = 31;
  227. repeated int64 repeated_int64_extension = 32;
  228. repeated uint32 repeated_uint32_extension = 33;
  229. repeated uint64 repeated_uint64_extension = 34;
  230. repeated sint32 repeated_sint32_extension = 35;
  231. repeated sint64 repeated_sint64_extension = 36;
  232. repeated fixed32 repeated_fixed32_extension = 37;
  233. repeated fixed64 repeated_fixed64_extension = 38;
  234. repeated sfixed32 repeated_sfixed32_extension = 39;
  235. repeated sfixed64 repeated_sfixed64_extension = 40;
  236. repeated float repeated_float_extension = 41;
  237. repeated double repeated_double_extension = 42;
  238. repeated bool repeated_bool_extension = 43;
  239. repeated string repeated_string_extension = 44;
  240. repeated bytes repeated_bytes_extension = 45;
  241. repeated group RepeatedGroup_extension = 46 {
  242. optional int32 a = 47;
  243. }
  244. repeated TestAllTypes.NestedMessage repeated_nested_message_extension = 48;
  245. repeated ForeignMessage repeated_foreign_message_extension = 49;
  246. repeated protobuf_unittest_import.ImportMessage
  247. repeated_import_message_extension = 50;
  248. repeated TestAllTypes.NestedEnum repeated_nested_enum_extension = 51;
  249. repeated ForeignEnum repeated_foreign_enum_extension = 52;
  250. repeated protobuf_unittest_import.ImportEnum
  251. repeated_import_enum_extension = 53;
  252. repeated string repeated_string_piece_extension = 54 [ctype=STRING_PIECE];
  253. repeated string repeated_cord_extension = 55 [ctype=CORD];
  254. repeated TestAllTypes.NestedMessage
  255. repeated_lazy_message_extension = 57 [lazy=true];
  256. // Singular with defaults
  257. optional int32 default_int32_extension = 61 [default = 41 ];
  258. optional int64 default_int64_extension = 62 [default = 42 ];
  259. optional uint32 default_uint32_extension = 63 [default = 43 ];
  260. optional uint64 default_uint64_extension = 64 [default = 44 ];
  261. optional sint32 default_sint32_extension = 65 [default = -45 ];
  262. optional sint64 default_sint64_extension = 66 [default = 46 ];
  263. optional fixed32 default_fixed32_extension = 67 [default = 47 ];
  264. optional fixed64 default_fixed64_extension = 68 [default = 48 ];
  265. optional sfixed32 default_sfixed32_extension = 69 [default = 49 ];
  266. optional sfixed64 default_sfixed64_extension = 70 [default = -50 ];
  267. optional float default_float_extension = 71 [default = 51.5 ];
  268. optional double default_double_extension = 72 [default = 52e3 ];
  269. optional bool default_bool_extension = 73 [default = true ];
  270. optional string default_string_extension = 74 [default = "hello"];
  271. optional bytes default_bytes_extension = 75 [default = "world"];
  272. optional TestAllTypes.NestedEnum
  273. default_nested_enum_extension = 81 [default = BAR];
  274. optional ForeignEnum
  275. default_foreign_enum_extension = 82 [default = FOREIGN_BAR];
  276. optional protobuf_unittest_import.ImportEnum
  277. default_import_enum_extension = 83 [default = IMPORT_BAR];
  278. optional string default_string_piece_extension = 84 [ctype=STRING_PIECE,
  279. default="abc"];
  280. optional string default_cord_extension = 85 [ctype=CORD, default="123"];
  281. // For oneof test
  282. optional uint32 oneof_uint32_extension = 111;
  283. optional TestAllTypes.NestedMessage oneof_nested_message_extension = 112;
  284. optional string oneof_string_extension = 113;
  285. optional bytes oneof_bytes_extension = 114;
  286. }
  287. message TestGroup {
  288. optional group OptionalGroup = 16 {
  289. optional int32 a = 17;
  290. }
  291. optional ForeignEnum optional_foreign_enum = 22;
  292. }
  293. message TestGroupExtension {
  294. extensions 1 to max;
  295. }
  296. message TestNestedExtension {
  297. extend TestAllExtensions {
  298. // Check for bug where string extensions declared in tested scope did not
  299. // compile.
  300. optional string test = 1002 [default="test"];
  301. // Used to test if generated extension name is correct when there are
  302. // underscores.
  303. optional string nested_string_extension = 1003;
  304. }
  305. extend TestGroupExtension {
  306. optional group OptionalGroup_extension = 16 {
  307. optional int32 a = 17;
  308. }
  309. optional ForeignEnum optional_foreign_enum_extension = 22;
  310. }
  311. }
  312. // We have separate messages for testing required fields because it's
  313. // annoying to have to fill in required fields in TestProto in order to
  314. // do anything with it. Note that we don't need to test every type of
  315. // required filed because the code output is basically identical to
  316. // optional fields for all types.
  317. message TestRequired {
  318. required int32 a = 1;
  319. optional int32 dummy2 = 2;
  320. required int32 b = 3;
  321. extend TestAllExtensions {
  322. optional TestRequired single = 1000;
  323. repeated TestRequired multi = 1001;
  324. }
  325. // Pad the field count to 32 so that we can test that IsInitialized()
  326. // properly checks multiple elements of has_bits_.
  327. optional int32 dummy4 = 4;
  328. optional int32 dummy5 = 5;
  329. optional int32 dummy6 = 6;
  330. optional int32 dummy7 = 7;
  331. optional int32 dummy8 = 8;
  332. optional int32 dummy9 = 9;
  333. optional int32 dummy10 = 10;
  334. optional int32 dummy11 = 11;
  335. optional int32 dummy12 = 12;
  336. optional int32 dummy13 = 13;
  337. optional int32 dummy14 = 14;
  338. optional int32 dummy15 = 15;
  339. optional int32 dummy16 = 16;
  340. optional int32 dummy17 = 17;
  341. optional int32 dummy18 = 18;
  342. optional int32 dummy19 = 19;
  343. optional int32 dummy20 = 20;
  344. optional int32 dummy21 = 21;
  345. optional int32 dummy22 = 22;
  346. optional int32 dummy23 = 23;
  347. optional int32 dummy24 = 24;
  348. optional int32 dummy25 = 25;
  349. optional int32 dummy26 = 26;
  350. optional int32 dummy27 = 27;
  351. optional int32 dummy28 = 28;
  352. optional int32 dummy29 = 29;
  353. optional int32 dummy30 = 30;
  354. optional int32 dummy31 = 31;
  355. optional int32 dummy32 = 32;
  356. required int32 c = 33;
  357. }
  358. message TestRequiredForeign {
  359. optional TestRequired optional_message = 1;
  360. repeated TestRequired repeated_message = 2;
  361. optional int32 dummy = 3;
  362. }
  363. message TestRequiredMessage {
  364. optional TestRequired optional_message = 1;
  365. repeated TestRequired repeated_message = 2;
  366. required TestRequired required_message = 3;
  367. }
  368. // Test that we can use NestedMessage from outside TestAllTypes.
  369. message TestForeignNested {
  370. optional TestAllTypes.NestedMessage foreign_nested = 1;
  371. }
  372. // TestEmptyMessage is used to test unknown field support.
  373. message TestEmptyMessage {
  374. }
  375. // Like above, but declare all field numbers as potential extensions. No
  376. // actual extensions should ever be defined for this type.
  377. message TestEmptyMessageWithExtensions {
  378. extensions 1 to max;
  379. }
  380. // Needed for a Python test.
  381. message TestPickleNestedMessage {
  382. message NestedMessage {
  383. optional int32 bb = 1;
  384. message NestedNestedMessage {
  385. optional int32 cc = 1;
  386. }
  387. }
  388. }
  389. message TestMultipleExtensionRanges {
  390. extensions 42;
  391. extensions 4143 to 4243;
  392. extensions 65536 to max;
  393. }
  394. // Test that really large tag numbers don't break anything.
  395. message TestReallyLargeTagNumber {
  396. // The largest possible tag number is 2^28 - 1, since the wire format uses
  397. // three bits to communicate wire type.
  398. optional int32 a = 1;
  399. optional int32 bb = 268435455;
  400. }
  401. message TestRecursiveMessage {
  402. optional TestRecursiveMessage a = 1;
  403. optional int32 i = 2;
  404. }
  405. // Test that mutual recursion works.
  406. message TestMutualRecursionA {
  407. message SubMessage {
  408. optional TestMutualRecursionB b = 1;
  409. }
  410. optional TestMutualRecursionB bb = 1;
  411. optional group SubGroup = 2 {
  412. optional SubMessage sub_message = 3; // Needed because of bug in javatest
  413. optional TestAllTypes not_in_this_scc = 4;
  414. }
  415. }
  416. message TestMutualRecursionB {
  417. optional TestMutualRecursionA a = 1;
  418. optional int32 optional_int32 = 2;
  419. }
  420. message TestIsInitialized {
  421. message SubMessage {
  422. optional group SubGroup = 1 {
  423. required int32 i = 2;
  424. }
  425. }
  426. optional SubMessage sub_message = 1;
  427. }
  428. // Test that groups have disjoint field numbers from their siblings and
  429. // parents. This is NOT possible in proto1; only google.protobuf. When attempting
  430. // to compile with proto1, this will emit an error; so we only include it
  431. // in protobuf_unittest_proto.
  432. message TestDupFieldNumber { // NO_PROTO1
  433. optional int32 a = 1; // NO_PROTO1
  434. optional group Foo = 2 { optional int32 a = 1; } // NO_PROTO1
  435. optional group Bar = 3 { optional int32 a = 1; } // NO_PROTO1
  436. } // NO_PROTO1
  437. // Additional messages for testing lazy fields.
  438. message TestEagerMessage {
  439. optional TestAllTypes sub_message = 1 [lazy=false];
  440. }
  441. message TestLazyMessage {
  442. optional TestAllTypes sub_message = 1 [lazy=true];
  443. }
  444. // Needed for a Python test.
  445. message TestNestedMessageHasBits {
  446. message NestedMessage {
  447. repeated int32 nestedmessage_repeated_int32 = 1;
  448. repeated ForeignMessage nestedmessage_repeated_foreignmessage = 2;
  449. }
  450. optional NestedMessage optional_nested_message = 1;
  451. }
  452. // Test an enum that has multiple values with the same number.
  453. enum TestEnumWithDupValue {
  454. option allow_alias = true;
  455. FOO1 = 1;
  456. BAR1 = 2;
  457. BAZ = 3;
  458. FOO2 = 1;
  459. BAR2 = 2;
  460. }
  461. // Test an enum with large, unordered values.
  462. enum TestSparseEnum {
  463. SPARSE_A = 123;
  464. SPARSE_B = 62374;
  465. SPARSE_C = 12589234;
  466. SPARSE_D = -15;
  467. SPARSE_E = -53452;
  468. SPARSE_F = 0;
  469. SPARSE_G = 2;
  470. }
  471. // Test message with CamelCase field names. This violates Protocol Buffer
  472. // standard style.
  473. message TestCamelCaseFieldNames {
  474. optional int32 PrimitiveField = 1;
  475. optional string StringField = 2;
  476. optional ForeignEnum EnumField = 3;
  477. optional ForeignMessage MessageField = 4;
  478. optional string StringPieceField = 5 [ctype=STRING_PIECE];
  479. optional string CordField = 6 [ctype=CORD];
  480. repeated int32 RepeatedPrimitiveField = 7;
  481. repeated string RepeatedStringField = 8;
  482. repeated ForeignEnum RepeatedEnumField = 9;
  483. repeated ForeignMessage RepeatedMessageField = 10;
  484. repeated string RepeatedStringPieceField = 11 [ctype=STRING_PIECE];
  485. repeated string RepeatedCordField = 12 [ctype=CORD];
  486. }
  487. // We list fields out of order, to ensure that we're using field number and not
  488. // field index to determine serialization order.
  489. message TestFieldOrderings {
  490. optional string my_string = 11;
  491. extensions 2 to 10;
  492. optional int64 my_int = 1;
  493. extensions 12 to 100;
  494. optional float my_float = 101;
  495. message NestedMessage {
  496. optional int64 oo = 2;
  497. // The field name "b" fails to compile in proto1 because it conflicts with
  498. // a local variable named "b" in one of the generated methods. Doh.
  499. // This file needs to compile in proto1 to test backwards-compatibility.
  500. optional int32 bb = 1;
  501. }
  502. optional NestedMessage optional_nested_message = 200;
  503. }
  504. extend TestFieldOrderings {
  505. optional string my_extension_string = 50;
  506. optional int32 my_extension_int = 5;
  507. }
  508. message TestExtensionOrderings1 {
  509. extend TestFieldOrderings {
  510. optional TestExtensionOrderings1 test_ext_orderings1 = 13;
  511. }
  512. optional string my_string = 1;
  513. }
  514. message TestExtensionOrderings2 {
  515. extend TestFieldOrderings {
  516. optional TestExtensionOrderings2 test_ext_orderings2 = 12;
  517. }
  518. message TestExtensionOrderings3 {
  519. extend TestFieldOrderings {
  520. optional TestExtensionOrderings3 test_ext_orderings3 = 14;
  521. }
  522. optional string my_string = 1;
  523. }
  524. optional string my_string = 1;
  525. }
  526. message TestExtremeDefaultValues {
  527. optional bytes escaped_bytes = 1 [default = "\0\001\a\b\f\n\r\t\v\\\'\"\xfe"];
  528. optional uint32 large_uint32 = 2 [default = 0xFFFFFFFF];
  529. optional uint64 large_uint64 = 3 [default = 0xFFFFFFFFFFFFFFFF];
  530. optional int32 small_int32 = 4 [default = -0x7FFFFFFF];
  531. optional int64 small_int64 = 5 [default = -0x7FFFFFFFFFFFFFFF];
  532. optional int32 really_small_int32 = 21 [default = -0x80000000];
  533. optional int64 really_small_int64 = 22 [default = -0x8000000000000000];
  534. // The default value here is UTF-8 for "\u1234". (We could also just type
  535. // the UTF-8 text directly into this text file rather than escape it, but
  536. // lots of people use editors that would be confused by this.)
  537. optional string utf8_string = 6 [default = "\341\210\264"];
  538. // Tests for single-precision floating-point values.
  539. optional float zero_float = 7 [default = 0];
  540. optional float one_float = 8 [default = 1];
  541. optional float small_float = 9 [default = 1.5];
  542. optional float negative_one_float = 10 [default = -1];
  543. optional float negative_float = 11 [default = -1.5];
  544. // Using exponents
  545. optional float large_float = 12 [default = 2E8];
  546. optional float small_negative_float = 13 [default = -8e-28];
  547. // Text for nonfinite floating-point values.
  548. optional double inf_double = 14 [default = inf];
  549. optional double neg_inf_double = 15 [default = -inf];
  550. optional double nan_double = 16 [default = nan];
  551. optional float inf_float = 17 [default = inf];
  552. optional float neg_inf_float = 18 [default = -inf];
  553. optional float nan_float = 19 [default = nan];
  554. // Tests for C++ trigraphs.
  555. // Trigraphs should be escaped in C++ generated files, but they should not be
  556. // escaped for other languages.
  557. // Note that in .proto file, "\?" is a valid way to escape ? in string
  558. // literals.
  559. optional string cpp_trigraph = 20 [default = "? \? ?? \?? \??? ??/ ?\?-"];
  560. // String defaults containing the character '\000'
  561. optional string string_with_zero = 23 [default = "hel\000lo"];
  562. optional bytes bytes_with_zero = 24 [default = "wor\000ld"];
  563. optional string string_piece_with_zero = 25 [ctype=STRING_PIECE,
  564. default="ab\000c"];
  565. optional string cord_with_zero = 26 [ctype=CORD,
  566. default="12\0003"];
  567. optional string replacement_string = 27 [default="${unknown}"];
  568. }
  569. message SparseEnumMessage {
  570. optional TestSparseEnum sparse_enum = 1;
  571. }
  572. // Test String and Bytes: string is for valid UTF-8 strings
  573. message OneString {
  574. optional string data = 1;
  575. }
  576. message MoreString {
  577. repeated string data = 1;
  578. }
  579. message OneBytes {
  580. optional bytes data = 1;
  581. }
  582. message MoreBytes {
  583. repeated bytes data = 1;
  584. }
  585. // Test int32, uint32, int64, uint64, and bool are all compatible
  586. message Int32Message {
  587. optional int32 data = 1;
  588. }
  589. message Uint32Message {
  590. optional uint32 data = 1;
  591. }
  592. message Int64Message {
  593. optional int64 data = 1;
  594. }
  595. message Uint64Message {
  596. optional uint64 data = 1;
  597. }
  598. message BoolMessage {
  599. optional bool data = 1;
  600. }
  601. // Test oneofs.
  602. message TestOneof {
  603. oneof foo {
  604. int32 foo_int = 1;
  605. string foo_string = 2;
  606. TestAllTypes foo_message = 3;
  607. group FooGroup = 4 {
  608. optional int32 a = 5;
  609. optional string b = 6;
  610. }
  611. }
  612. }
  613. message TestOneofBackwardsCompatible {
  614. optional int32 foo_int = 1;
  615. optional string foo_string = 2;
  616. optional TestAllTypes foo_message = 3;
  617. optional group FooGroup = 4 {
  618. optional int32 a = 5;
  619. optional string b = 6;
  620. }
  621. }
  622. message TestOneof2 {
  623. oneof foo {
  624. int32 foo_int = 1;
  625. string foo_string = 2;
  626. string foo_cord = 3 [ctype=CORD];
  627. string foo_string_piece = 4 [ctype=STRING_PIECE];
  628. bytes foo_bytes = 5;
  629. NestedEnum foo_enum = 6;
  630. NestedMessage foo_message = 7;
  631. group FooGroup = 8 {
  632. optional int32 a = 9;
  633. optional string b = 10;
  634. }
  635. NestedMessage foo_lazy_message = 11 [lazy=true];
  636. }
  637. oneof bar {
  638. int32 bar_int = 12 [default = 5];
  639. string bar_string = 13 [default = "STRING"];
  640. string bar_cord = 14 [ctype=CORD, default = "CORD"];
  641. string bar_string_piece = 15 [ctype=STRING_PIECE, default = "SPIECE"];
  642. bytes bar_bytes = 16 [default = "BYTES"];
  643. NestedEnum bar_enum = 17 [default = BAR];
  644. }
  645. optional int32 baz_int = 18;
  646. optional string baz_string = 19 [default = "BAZ"];
  647. message NestedMessage {
  648. optional int64 qux_int = 1;
  649. repeated int32 corge_int = 2;
  650. }
  651. enum NestedEnum {
  652. FOO = 1;
  653. BAR = 2;
  654. BAZ = 3;
  655. }
  656. }
  657. message TestRequiredOneof {
  658. oneof foo {
  659. int32 foo_int = 1;
  660. string foo_string = 2;
  661. NestedMessage foo_message = 3;
  662. }
  663. message NestedMessage {
  664. required double required_double = 1;
  665. }
  666. }
  667. // Test messages for packed fields
  668. message TestPackedTypes {
  669. repeated int32 packed_int32 = 90 [packed = true];
  670. repeated int64 packed_int64 = 91 [packed = true];
  671. repeated uint32 packed_uint32 = 92 [packed = true];
  672. repeated uint64 packed_uint64 = 93 [packed = true];
  673. repeated sint32 packed_sint32 = 94 [packed = true];
  674. repeated sint64 packed_sint64 = 95 [packed = true];
  675. repeated fixed32 packed_fixed32 = 96 [packed = true];
  676. repeated fixed64 packed_fixed64 = 97 [packed = true];
  677. repeated sfixed32 packed_sfixed32 = 98 [packed = true];
  678. repeated sfixed64 packed_sfixed64 = 99 [packed = true];
  679. repeated float packed_float = 100 [packed = true];
  680. repeated double packed_double = 101 [packed = true];
  681. repeated bool packed_bool = 102 [packed = true];
  682. repeated ForeignEnum packed_enum = 103 [packed = true];
  683. }
  684. // A message with the same fields as TestPackedTypes, but without packing. Used
  685. // to test packed <-> unpacked wire compatibility.
  686. message TestUnpackedTypes {
  687. repeated int32 unpacked_int32 = 90 [packed = false];
  688. repeated int64 unpacked_int64 = 91 [packed = false];
  689. repeated uint32 unpacked_uint32 = 92 [packed = false];
  690. repeated uint64 unpacked_uint64 = 93 [packed = false];
  691. repeated sint32 unpacked_sint32 = 94 [packed = false];
  692. repeated sint64 unpacked_sint64 = 95 [packed = false];
  693. repeated fixed32 unpacked_fixed32 = 96 [packed = false];
  694. repeated fixed64 unpacked_fixed64 = 97 [packed = false];
  695. repeated sfixed32 unpacked_sfixed32 = 98 [packed = false];
  696. repeated sfixed64 unpacked_sfixed64 = 99 [packed = false];
  697. repeated float unpacked_float = 100 [packed = false];
  698. repeated double unpacked_double = 101 [packed = false];
  699. repeated bool unpacked_bool = 102 [packed = false];
  700. repeated ForeignEnum unpacked_enum = 103 [packed = false];
  701. }
  702. message TestPackedExtensions {
  703. extensions 1 to max;
  704. }
  705. extend TestPackedExtensions {
  706. repeated int32 packed_int32_extension = 90 [packed = true];
  707. repeated int64 packed_int64_extension = 91 [packed = true];
  708. repeated uint32 packed_uint32_extension = 92 [packed = true];
  709. repeated uint64 packed_uint64_extension = 93 [packed = true];
  710. repeated sint32 packed_sint32_extension = 94 [packed = true];
  711. repeated sint64 packed_sint64_extension = 95 [packed = true];
  712. repeated fixed32 packed_fixed32_extension = 96 [packed = true];
  713. repeated fixed64 packed_fixed64_extension = 97 [packed = true];
  714. repeated sfixed32 packed_sfixed32_extension = 98 [packed = true];
  715. repeated sfixed64 packed_sfixed64_extension = 99 [packed = true];
  716. repeated float packed_float_extension = 100 [packed = true];
  717. repeated double packed_double_extension = 101 [packed = true];
  718. repeated bool packed_bool_extension = 102 [packed = true];
  719. repeated ForeignEnum packed_enum_extension = 103 [packed = true];
  720. }
  721. message TestUnpackedExtensions {
  722. extensions 1 to max;
  723. }
  724. extend TestUnpackedExtensions {
  725. repeated int32 unpacked_int32_extension = 90 [packed = false];
  726. repeated int64 unpacked_int64_extension = 91 [packed = false];
  727. repeated uint32 unpacked_uint32_extension = 92 [packed = false];
  728. repeated uint64 unpacked_uint64_extension = 93 [packed = false];
  729. repeated sint32 unpacked_sint32_extension = 94 [packed = false];
  730. repeated sint64 unpacked_sint64_extension = 95 [packed = false];
  731. repeated fixed32 unpacked_fixed32_extension = 96 [packed = false];
  732. repeated fixed64 unpacked_fixed64_extension = 97 [packed = false];
  733. repeated sfixed32 unpacked_sfixed32_extension = 98 [packed = false];
  734. repeated sfixed64 unpacked_sfixed64_extension = 99 [packed = false];
  735. repeated float unpacked_float_extension = 100 [packed = false];
  736. repeated double unpacked_double_extension = 101 [packed = false];
  737. repeated bool unpacked_bool_extension = 102 [packed = false];
  738. repeated ForeignEnum unpacked_enum_extension = 103 [packed = false];
  739. }
  740. // Used by ExtensionSetTest/DynamicExtensions. The test actually builds
  741. // a set of extensions to TestAllExtensions dynamically, based on the fields
  742. // of this message type.
  743. message TestDynamicExtensions {
  744. enum DynamicEnumType {
  745. DYNAMIC_FOO = 2200;
  746. DYNAMIC_BAR = 2201;
  747. DYNAMIC_BAZ = 2202;
  748. }
  749. message DynamicMessageType {
  750. optional int32 dynamic_field = 2100;
  751. }
  752. optional fixed32 scalar_extension = 2000;
  753. optional ForeignEnum enum_extension = 2001;
  754. optional DynamicEnumType dynamic_enum_extension = 2002;
  755. optional ForeignMessage message_extension = 2003;
  756. optional DynamicMessageType dynamic_message_extension = 2004;
  757. repeated string repeated_extension = 2005;
  758. repeated sint32 packed_extension = 2006 [packed = true];
  759. }
  760. message TestRepeatedScalarDifferentTagSizes {
  761. // Parsing repeated fixed size values used to fail. This message needs to be
  762. // used in order to get a tag of the right size; all of the repeated fields
  763. // in TestAllTypes didn't trigger the check.
  764. repeated fixed32 repeated_fixed32 = 12;
  765. // Check for a varint type, just for good measure.
  766. repeated int32 repeated_int32 = 13;
  767. // These have two-byte tags.
  768. repeated fixed64 repeated_fixed64 = 2046;
  769. repeated int64 repeated_int64 = 2047;
  770. // Three byte tags.
  771. repeated float repeated_float = 262142;
  772. repeated uint64 repeated_uint64 = 262143;
  773. }
  774. // Test that if an optional or required message/group field appears multiple
  775. // times in the input, they need to be merged.
  776. message TestParsingMerge {
  777. // RepeatedFieldsGenerator defines matching field types as TestParsingMerge,
  778. // except that all fields are repeated. In the tests, we will serialize the
  779. // RepeatedFieldsGenerator to bytes, and parse the bytes to TestParsingMerge.
  780. // Repeated fields in RepeatedFieldsGenerator are expected to be merged into
  781. // the corresponding required/optional fields in TestParsingMerge.
  782. message RepeatedFieldsGenerator {
  783. repeated TestAllTypes field1 = 1;
  784. repeated TestAllTypes field2 = 2;
  785. repeated TestAllTypes field3 = 3;
  786. repeated group Group1 = 10 {
  787. optional TestAllTypes field1 = 11;
  788. }
  789. repeated group Group2 = 20 {
  790. optional TestAllTypes field1 = 21;
  791. }
  792. repeated TestAllTypes ext1 = 1000;
  793. repeated TestAllTypes ext2 = 1001;
  794. }
  795. required TestAllTypes required_all_types = 1;
  796. optional TestAllTypes optional_all_types = 2;
  797. repeated TestAllTypes repeated_all_types = 3;
  798. optional group OptionalGroup = 10 {
  799. optional TestAllTypes optional_group_all_types = 11;
  800. }
  801. repeated group RepeatedGroup = 20 {
  802. optional TestAllTypes repeated_group_all_types = 21;
  803. }
  804. extensions 1000 to max;
  805. extend TestParsingMerge {
  806. optional TestAllTypes optional_ext = 1000;
  807. repeated TestAllTypes repeated_ext = 1001;
  808. }
  809. }
  810. message TestCommentInjectionMessage {
  811. // */ <- This should not close the generated doc comment
  812. optional string a = 1 [default="*/ <- Neither should this."];
  813. }
  814. // Test that RPC services work.
  815. message FooRequest {}
  816. message FooResponse {}
  817. message FooClientMessage {}
  818. message FooServerMessage{}
  819. service TestService {
  820. rpc Foo(FooRequest) returns (FooResponse);
  821. rpc Bar(BarRequest) returns (BarResponse);
  822. }
  823. message BarRequest {}
  824. message BarResponse {}
  825. message TestJsonName {
  826. optional int32 field_name1 = 1;
  827. optional int32 fieldName2 = 2;
  828. optional int32 FieldName3 = 3;
  829. optional int32 _field_name4 = 4;
  830. optional int32 FIELD_NAME5 = 5;
  831. optional int32 field_name6 = 6 [json_name = "@type"];
  832. }
  833. message TestHugeFieldNumbers {
  834. optional int32 optional_int32 = 536870000;
  835. optional int32 fixed_32 = 536870001;
  836. repeated int32 repeated_int32 = 536870002 [packed = false];
  837. repeated int32 packed_int32 = 536870003 [packed = true];
  838. optional ForeignEnum optional_enum = 536870004;
  839. optional string optional_string = 536870005;
  840. optional bytes optional_bytes = 536870006;
  841. optional ForeignMessage optional_message = 536870007;
  842. optional group OptionalGroup = 536870008 {
  843. optional int32 group_a = 536870009;
  844. }
  845. map<string, string> string_string_map = 536870010;
  846. oneof oneof_field {
  847. uint32 oneof_uint32 = 536870011;
  848. TestAllTypes oneof_test_all_types = 536870012;
  849. string oneof_string = 536870013;
  850. bytes oneof_bytes = 536870014;
  851. }
  852. extensions 536860000 to 536869999;
  853. }
  854. extend TestHugeFieldNumbers {
  855. optional TestAllTypes test_all_types = 536860000;
  856. }
  857. message TestExtensionInsideTable {
  858. optional int32 field1 = 1;
  859. optional int32 field2 = 2;
  860. optional int32 field3 = 3;
  861. optional int32 field4 = 4;
  862. extensions 5 to 5;
  863. optional int32 field6 = 6;
  864. optional int32 field7 = 7;
  865. optional int32 field8 = 8;
  866. optional int32 field9 = 9;
  867. optional int32 field10 = 10;
  868. }
  869. extend TestExtensionInsideTable {
  870. optional int32 test_extension_inside_table_extension = 5;
  871. }
  872. enum VeryLargeEnum {
  873. ENUM_LABEL_DEFAULT = 0;
  874. ENUM_LABEL_1 = 1;
  875. ENUM_LABEL_2 = 2;
  876. ENUM_LABEL_3 = 3;
  877. ENUM_LABEL_4 = 4;
  878. ENUM_LABEL_5 = 5;
  879. ENUM_LABEL_6 = 6;
  880. ENUM_LABEL_7 = 7;
  881. ENUM_LABEL_8 = 8;
  882. ENUM_LABEL_9 = 9;
  883. ENUM_LABEL_10 = 10;
  884. ENUM_LABEL_11 = 11;
  885. ENUM_LABEL_12 = 12;
  886. ENUM_LABEL_13 = 13;
  887. ENUM_LABEL_14 = 14;
  888. ENUM_LABEL_15 = 15;
  889. ENUM_LABEL_16 = 16;
  890. ENUM_LABEL_17 = 17;
  891. ENUM_LABEL_18 = 18;
  892. ENUM_LABEL_19 = 19;
  893. ENUM_LABEL_20 = 20;
  894. ENUM_LABEL_21 = 21;
  895. ENUM_LABEL_22 = 22;
  896. ENUM_LABEL_23 = 23;
  897. ENUM_LABEL_24 = 24;
  898. ENUM_LABEL_25 = 25;
  899. ENUM_LABEL_26 = 26;
  900. ENUM_LABEL_27 = 27;
  901. ENUM_LABEL_28 = 28;
  902. ENUM_LABEL_29 = 29;
  903. ENUM_LABEL_30 = 30;
  904. ENUM_LABEL_31 = 31;
  905. ENUM_LABEL_32 = 32;
  906. ENUM_LABEL_33 = 33;
  907. ENUM_LABEL_34 = 34;
  908. ENUM_LABEL_35 = 35;
  909. ENUM_LABEL_36 = 36;
  910. ENUM_LABEL_37 = 37;
  911. ENUM_LABEL_38 = 38;
  912. ENUM_LABEL_39 = 39;
  913. ENUM_LABEL_40 = 40;
  914. ENUM_LABEL_41 = 41;
  915. ENUM_LABEL_42 = 42;
  916. ENUM_LABEL_43 = 43;
  917. ENUM_LABEL_44 = 44;
  918. ENUM_LABEL_45 = 45;
  919. ENUM_LABEL_46 = 46;
  920. ENUM_LABEL_47 = 47;
  921. ENUM_LABEL_48 = 48;
  922. ENUM_LABEL_49 = 49;
  923. ENUM_LABEL_50 = 50;
  924. ENUM_LABEL_51 = 51;
  925. ENUM_LABEL_52 = 52;
  926. ENUM_LABEL_53 = 53;
  927. ENUM_LABEL_54 = 54;
  928. ENUM_LABEL_55 = 55;
  929. ENUM_LABEL_56 = 56;
  930. ENUM_LABEL_57 = 57;
  931. ENUM_LABEL_58 = 58;
  932. ENUM_LABEL_59 = 59;
  933. ENUM_LABEL_60 = 60;
  934. ENUM_LABEL_61 = 61;
  935. ENUM_LABEL_62 = 62;
  936. ENUM_LABEL_63 = 63;
  937. ENUM_LABEL_64 = 64;
  938. ENUM_LABEL_65 = 65;
  939. ENUM_LABEL_66 = 66;
  940. ENUM_LABEL_67 = 67;
  941. ENUM_LABEL_68 = 68;
  942. ENUM_LABEL_69 = 69;
  943. ENUM_LABEL_70 = 70;
  944. ENUM_LABEL_71 = 71;
  945. ENUM_LABEL_72 = 72;
  946. ENUM_LABEL_73 = 73;
  947. ENUM_LABEL_74 = 74;
  948. ENUM_LABEL_75 = 75;
  949. ENUM_LABEL_76 = 76;
  950. ENUM_LABEL_77 = 77;
  951. ENUM_LABEL_78 = 78;
  952. ENUM_LABEL_79 = 79;
  953. ENUM_LABEL_80 = 80;
  954. ENUM_LABEL_81 = 81;
  955. ENUM_LABEL_82 = 82;
  956. ENUM_LABEL_83 = 83;
  957. ENUM_LABEL_84 = 84;
  958. ENUM_LABEL_85 = 85;
  959. ENUM_LABEL_86 = 86;
  960. ENUM_LABEL_87 = 87;
  961. ENUM_LABEL_88 = 88;
  962. ENUM_LABEL_89 = 89;
  963. ENUM_LABEL_90 = 90;
  964. ENUM_LABEL_91 = 91;
  965. ENUM_LABEL_92 = 92;
  966. ENUM_LABEL_93 = 93;
  967. ENUM_LABEL_94 = 94;
  968. ENUM_LABEL_95 = 95;
  969. ENUM_LABEL_96 = 96;
  970. ENUM_LABEL_97 = 97;
  971. ENUM_LABEL_98 = 98;
  972. ENUM_LABEL_99 = 99;
  973. ENUM_LABEL_100 = 100;
  974. };