edition_unittest.proto 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910
  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. // Author: kenton@google.com (Kenton Varda)
  8. // Based on original Protocol Buffers design by
  9. // Sanjay Ghemawat, Jeff Dean, and others.
  10. //
  11. // A proto file we will use for unit testing. See comments in
  12. // edition_message_unittest.cc before adding new features.
  13. //
  14. // LINT: ALLOW_GROUPS, LEGACY_NAMES
  15. edition = "2023";
  16. import "google/protobuf/cpp_features.proto";
  17. option features.field_presence = EXPLICIT;
  18. option features.enum_type = CLOSED;
  19. option features.(pb.cpp).string_type = VIEW;
  20. // Some generic_services option(s) added automatically.
  21. // See: http://go/proto2-generic-services-default
  22. option cc_generic_services = true; // auto-added
  23. option java_generic_services = true; // auto-added
  24. option py_generic_services = true; // auto-added
  25. option cc_enable_arenas = true;
  26. import "google/protobuf/unittest_import.proto";
  27. // We don't put this in a package within proto2 because we need to make sure
  28. // that the generated code doesn't depend on being in the proto2 namespace.
  29. // In test_util.h we do "using namespace unittest = edition_unittest".
  30. package edition_unittest;
  31. // Protos optimized for SPEED use a strict superset of the generated code
  32. // of equivalent ones optimized for CODE_SIZE, so we should optimize all our
  33. // tests for speed unless explicitly testing code size optimization.
  34. option optimize_for = SPEED;
  35. // This proto includes every type of field in both singular and repeated
  36. // forms.
  37. message TestAllTypes {
  38. message NestedMessage {
  39. // The field name "b" fails to compile in proto1 because it conflicts with
  40. // a local variable named "b" in one of the generated methods. Doh.
  41. // This file needs to compile in proto1 to test backwards-compatibility.
  42. int32 bb = 1;
  43. }
  44. enum NestedEnum {
  45. FOO = 1;
  46. BAR = 2;
  47. BAZ = 3;
  48. NEG = -1; // Intentionally negative.
  49. }
  50. // Singular
  51. int32 optional_int32 = 1;
  52. int64 optional_int64 = 2;
  53. uint32 optional_uint32 = 3;
  54. uint64 optional_uint64 = 4;
  55. sint32 optional_sint32 = 5;
  56. sint64 optional_sint64 = 6;
  57. fixed32 optional_fixed32 = 7;
  58. fixed64 optional_fixed64 = 8;
  59. sfixed32 optional_sfixed32 = 9;
  60. sfixed64 optional_sfixed64 = 10;
  61. float optional_float = 11;
  62. double optional_double = 12;
  63. bool optional_bool = 13;
  64. string optional_string = 14;
  65. bytes optional_bytes = 15;
  66. message OptionalGroup {
  67. int32 a = 17;
  68. }
  69. OptionalGroup optionalgroup = 16
  70. [features.message_encoding = DELIMITED];
  71. NestedMessage optional_nested_message = 18;
  72. ForeignMessage optional_foreign_message = 19;
  73. protobuf_unittest_import.ImportMessage optional_import_message = 20;
  74. NestedEnum optional_nested_enum = 21;
  75. ForeignEnum optional_foreign_enum = 22;
  76. protobuf_unittest_import.ImportEnum optional_import_enum = 23;
  77. string optional_string_piece = 24 [ctype=STRING_PIECE];
  78. string optional_cord = 25 [ctype=CORD];
  79. bytes optional_bytes_cord = 86 [ctype=CORD];
  80. // Defined in unittest_import_public.proto
  81. protobuf_unittest_import.PublicImportMessage
  82. optional_public_import_message = 26;
  83. NestedMessage optional_lazy_message = 27 [lazy=true];
  84. NestedMessage optional_unverified_lazy_message = 28 [unverified_lazy=true];
  85. // Repeated
  86. repeated int32 repeated_int32 = 31;
  87. repeated int64 repeated_int64 = 32;
  88. repeated uint32 repeated_uint32 = 33;
  89. repeated uint64 repeated_uint64 = 34;
  90. repeated sint32 repeated_sint32 = 35;
  91. repeated sint64 repeated_sint64 = 36;
  92. repeated fixed32 repeated_fixed32 = 37;
  93. repeated fixed64 repeated_fixed64 = 38;
  94. repeated sfixed32 repeated_sfixed32 = 39;
  95. repeated sfixed64 repeated_sfixed64 = 40;
  96. repeated float repeated_float = 41;
  97. repeated double repeated_double = 42;
  98. repeated bool repeated_bool = 43;
  99. repeated string repeated_string = 44;
  100. repeated bytes repeated_bytes = 45;
  101. message RepeatedGroup {
  102. int32 a = 47;
  103. }
  104. repeated RepeatedGroup repeatedgroup = 46
  105. [features.message_encoding = DELIMITED];
  106. repeated NestedMessage repeated_nested_message = 48;
  107. repeated ForeignMessage repeated_foreign_message = 49;
  108. repeated protobuf_unittest_import.ImportMessage repeated_import_message = 50;
  109. repeated NestedEnum repeated_nested_enum = 51;
  110. repeated ForeignEnum repeated_foreign_enum = 52;
  111. repeated protobuf_unittest_import.ImportEnum repeated_import_enum = 53;
  112. repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
  113. repeated string repeated_cord = 55 [ctype=CORD];
  114. repeated NestedMessage repeated_lazy_message = 57 ;
  115. // Singular with defaults
  116. int32 default_int32 = 61 [default = 41 ];
  117. int64 default_int64 = 62 [default = 42 ];
  118. uint32 default_uint32 = 63 [default = 43 ];
  119. uint64 default_uint64 = 64 [default = 44 ];
  120. sint32 default_sint32 = 65 [default = -45 ];
  121. sint64 default_sint64 = 66 [default = 46 ];
  122. fixed32 default_fixed32 = 67 [default = 47 ];
  123. fixed64 default_fixed64 = 68 [default = 48 ];
  124. sfixed32 default_sfixed32 = 69 [default = 49 ];
  125. sfixed64 default_sfixed64 = 70 [default = -50 ];
  126. float default_float = 71 [default = 51.5 ];
  127. double default_double = 72 [default = 52e3 ];
  128. bool default_bool = 73 [default = true ];
  129. string default_string = 74 [default = "hello"];
  130. bytes default_bytes = 75 [default = "world"];
  131. NestedEnum default_nested_enum = 81 [default = BAR ];
  132. ForeignEnum default_foreign_enum = 82 [default = FOREIGN_BAR];
  133. protobuf_unittest_import.ImportEnum
  134. default_import_enum = 83 [default = IMPORT_BAR];
  135. string default_string_piece = 84 [ctype=STRING_PIECE,default="abc"];
  136. string default_cord = 85 [ctype=CORD,default="123"];
  137. // For oneof test
  138. oneof oneof_field {
  139. uint32 oneof_uint32 = 111;
  140. NestedMessage oneof_nested_message = 112;
  141. string oneof_string = 113;
  142. bytes oneof_bytes = 114;
  143. string oneof_cord = 115 [ctype=CORD];
  144. string oneof_string_piece = 116 [ctype=STRING_PIECE];
  145. NestedMessage oneof_lazy_nested_message = 117 [lazy=true];
  146. }
  147. }
  148. // This proto includes a recursively nested message.
  149. message NestedTestAllTypes {
  150. NestedTestAllTypes child = 1;
  151. TestAllTypes payload = 2;
  152. repeated NestedTestAllTypes repeated_child = 3;
  153. NestedTestAllTypes lazy_child = 4 [lazy=true];
  154. TestAllTypes eager_child = 5 [lazy=false];
  155. }
  156. message TestDeprecatedFields {
  157. int32 deprecated_int32 = 1 [deprecated=true];
  158. repeated string deprecated_repeated_string = 4 [deprecated=true];
  159. TestAllTypes.NestedMessage deprecated_message = 3 [deprecated=true];
  160. oneof oneof_fields {
  161. int32 deprecated_int32_in_oneof = 2 [deprecated=true];
  162. }
  163. TestDeprecatedFields nested = 5;
  164. }
  165. message TestDeprecatedMessage {
  166. option deprecated = true;
  167. }
  168. // Define these after TestAllTypes to make sure the compiler can handle that.
  169. message ForeignMessage {
  170. int32 c = 1;
  171. int32 d = 2;
  172. }
  173. enum ForeignEnum {
  174. FOREIGN_FOO = 4;
  175. FOREIGN_BAR = 5;
  176. FOREIGN_BAZ = 6;
  177. FOREIGN_BAX = 32; // (1 << 32) to generate a 64b bitmask would be incorrect.
  178. }
  179. message TestReservedFields {
  180. reserved 2, 15, 9 to 11;
  181. reserved bar, baz;
  182. }
  183. enum TestReservedEnumFields {
  184. UNKNOWN = 0;
  185. reserved 2, 15, 9 to 11;
  186. reserved bar, baz;
  187. }
  188. message TestAllExtensions {
  189. extensions 1 to max;
  190. }
  191. message OptionalGroup_extension {
  192. int32 a = 17;
  193. }
  194. message RepeatedGroup_extension {
  195. int32 a = 47;
  196. }
  197. extend TestAllExtensions {
  198. // Singular
  199. int32 optional_int32_extension = 1;
  200. int64 optional_int64_extension = 2;
  201. uint32 optional_uint32_extension = 3;
  202. uint64 optional_uint64_extension = 4;
  203. sint32 optional_sint32_extension = 5;
  204. sint64 optional_sint64_extension = 6;
  205. fixed32 optional_fixed32_extension = 7;
  206. fixed64 optional_fixed64_extension = 8;
  207. sfixed32 optional_sfixed32_extension = 9;
  208. sfixed64 optional_sfixed64_extension = 10;
  209. float optional_float_extension = 11;
  210. double optional_double_extension = 12;
  211. bool optional_bool_extension = 13;
  212. string optional_string_extension = 14;
  213. bytes optional_bytes_extension = 15;
  214. OptionalGroup_extension optionalgroup_extension = 16
  215. [features.message_encoding = DELIMITED];
  216. TestAllTypes.NestedMessage optional_nested_message_extension = 18;
  217. ForeignMessage optional_foreign_message_extension = 19;
  218. protobuf_unittest_import.ImportMessage
  219. optional_import_message_extension = 20;
  220. TestAllTypes.NestedEnum optional_nested_enum_extension = 21;
  221. ForeignEnum optional_foreign_enum_extension = 22;
  222. protobuf_unittest_import.ImportEnum
  223. optional_import_enum_extension = 23;
  224. string optional_string_piece_extension = 24 [ctype=STRING_PIECE];
  225. // TODO: ctype=CORD is not supported for extension. Add
  226. // ctype=CORD option back after it is supported.
  227. string optional_cord_extension = 25;
  228. bytes optional_bytes_cord_extension = 86;
  229. protobuf_unittest_import.PublicImportMessage
  230. optional_public_import_message_extension = 26;
  231. TestAllTypes.NestedMessage
  232. optional_lazy_message_extension = 27 [lazy=true];
  233. TestAllTypes.NestedMessage
  234. optional_unverified_lazy_message_extension = 28 [unverified_lazy=true];
  235. // Repeated
  236. repeated int32 repeated_int32_extension = 31;
  237. repeated int64 repeated_int64_extension = 32;
  238. repeated uint32 repeated_uint32_extension = 33;
  239. repeated uint64 repeated_uint64_extension = 34;
  240. repeated sint32 repeated_sint32_extension = 35;
  241. repeated sint64 repeated_sint64_extension = 36;
  242. repeated fixed32 repeated_fixed32_extension = 37;
  243. repeated fixed64 repeated_fixed64_extension = 38;
  244. repeated sfixed32 repeated_sfixed32_extension = 39;
  245. repeated sfixed64 repeated_sfixed64_extension = 40;
  246. repeated float repeated_float_extension = 41;
  247. repeated double repeated_double_extension = 42;
  248. repeated bool repeated_bool_extension = 43;
  249. repeated string repeated_string_extension = 44;
  250. repeated bytes repeated_bytes_extension = 45;
  251. repeated RepeatedGroup_extension repeatedgroup_extension = 46
  252. [features.message_encoding = DELIMITED];
  253. repeated TestAllTypes.NestedMessage repeated_nested_message_extension = 48;
  254. repeated ForeignMessage repeated_foreign_message_extension = 49;
  255. repeated protobuf_unittest_import.ImportMessage
  256. repeated_import_message_extension = 50;
  257. repeated TestAllTypes.NestedEnum repeated_nested_enum_extension = 51;
  258. repeated ForeignEnum repeated_foreign_enum_extension = 52;
  259. repeated protobuf_unittest_import.ImportEnum
  260. repeated_import_enum_extension = 53;
  261. repeated string repeated_string_piece_extension = 54 [ctype=STRING_PIECE];
  262. // TODO: ctype=CORD is not supported for extension. Add
  263. // ctype=CORD option back after it is supported.
  264. repeated string repeated_cord_extension = 55;
  265. repeated TestAllTypes.NestedMessage
  266. repeated_lazy_message_extension = 57 [lazy=true];
  267. // Singular with defaults
  268. int32 default_int32_extension = 61 [default = 41 ];
  269. int64 default_int64_extension = 62 [default = 42 ];
  270. uint32 default_uint32_extension = 63 [default = 43 ];
  271. uint64 default_uint64_extension = 64 [default = 44 ];
  272. sint32 default_sint32_extension = 65 [default = -45 ];
  273. sint64 default_sint64_extension = 66 [default = 46 ];
  274. fixed32 default_fixed32_extension = 67 [default = 47 ];
  275. fixed64 default_fixed64_extension = 68 [default = 48 ];
  276. sfixed32 default_sfixed32_extension = 69 [default = 49 ];
  277. sfixed64 default_sfixed64_extension = 70 [default = -50 ];
  278. float default_float_extension = 71 [default = 51.5 ];
  279. double default_double_extension = 72 [default = 52e3 ];
  280. bool default_bool_extension = 73 [default = true ];
  281. string default_string_extension = 74 [default = "hello"];
  282. bytes default_bytes_extension = 75 [default = "world"];
  283. TestAllTypes.NestedEnum
  284. default_nested_enum_extension = 81 [default = BAR];
  285. ForeignEnum
  286. default_foreign_enum_extension = 82 [default = FOREIGN_BAR];
  287. protobuf_unittest_import.ImportEnum
  288. default_import_enum_extension = 83 [default = IMPORT_BAR];
  289. string default_string_piece_extension = 84
  290. [ctype=STRING_PIECE, default="abc"];
  291. // TODO: ctype=CORD is not supported for extension. Add
  292. // ctype=CORD option back after it is supported.
  293. string default_cord_extension = 85 [default="123"];
  294. // For oneof test
  295. uint32 oneof_uint32_extension = 111;
  296. TestAllTypes.NestedMessage oneof_nested_message_extension = 112;
  297. string oneof_string_extension = 113;
  298. bytes oneof_bytes_extension = 114;
  299. }
  300. message TestMixedFieldsAndExtensions {
  301. int32 a = 1;
  302. repeated fixed32 b = 3;
  303. extensions 2, 4;
  304. extend TestMixedFieldsAndExtensions {
  305. int32 c = 2;
  306. repeated fixed32 d = 4;
  307. }
  308. }
  309. message TestGroup {
  310. message OptionalGroup {
  311. int32 a = 17;
  312. int32 zz = 89; // fast table size must be at least 16, for this
  313. // field to be parsed by the fast parser, since
  314. // 89 - 17 = 72 is a multiple of 8.
  315. }
  316. OptionalGroup optionalgroup = 16 [features.message_encoding = DELIMITED];
  317. ForeignEnum optional_foreign_enum = 22;
  318. }
  319. message TestGroupExtension {
  320. extensions 1 to max;
  321. }
  322. message TestNestedExtension {
  323. extend TestAllExtensions {
  324. // Check for bug where string extensions declared in tested scope did not
  325. // compile.
  326. string test = 1002 [default="test"];
  327. // Used to test if generated extension name is correct when there are
  328. // underscores.
  329. string nested_string_extension = 1003;
  330. }
  331. message OptionalGroup_extension {
  332. int32 a = 17;
  333. }
  334. extend TestGroupExtension {
  335. OptionalGroup_extension optionalgroup_extension = 16
  336. [features.message_encoding = DELIMITED];
  337. ForeignEnum optional_foreign_enum_extension = 22;
  338. }
  339. }
  340. message TestChildExtension {
  341. string a = 1;
  342. string b = 2;
  343. TestAllExtensions optional_extension = 3;
  344. }
  345. // Emulates wireformat data of TestChildExtension with dynamic extension
  346. // (DynamicExtension).
  347. message TestChildExtensionData {
  348. message NestedTestAllExtensionsData {
  349. message NestedDynamicExtensions {
  350. int32 a = 1;
  351. int32 b = 2;
  352. }
  353. NestedDynamicExtensions dynamic = 409707008;
  354. }
  355. string a = 1;
  356. string b = 2;
  357. NestedTestAllExtensionsData optional_extension = 3;
  358. }
  359. message TestNestedChildExtension {
  360. int32 a = 1;
  361. TestChildExtension child = 2;
  362. }
  363. // Emulates wireformat data of TestNestedChildExtension with dynamic extension
  364. // (DynamicExtension).
  365. message TestNestedChildExtensionData {
  366. int32 a = 1;
  367. TestChildExtensionData child = 2;
  368. }
  369. // Required and closed enum fields are considered unknown fields if the value is
  370. // not valid. We need to make sure it functions as expected.
  371. message TestRequiredEnum {
  372. ForeignEnum required_enum = 1 [features.field_presence = LEGACY_REQUIRED];
  373. // A dummy optional field.
  374. int32 a = 2;
  375. }
  376. // TestRequiredEnum + using enum values that won't fit to 64 bitmask.
  377. message TestRequiredEnumNoMask {
  378. enum NestedEnum {
  379. UNSPECIFIED = 0;
  380. FOO = 2;
  381. BAR = 100;
  382. BAZ = -1; // Intentionally negative.
  383. }
  384. NestedEnum required_enum = 1 [features.field_presence = LEGACY_REQUIRED];
  385. // A dummy optional field.
  386. int32 a = 2;
  387. }
  388. message TestRequiredEnumMulti {
  389. enum NestedEnum {
  390. UNSPECIFIED = 0;
  391. FOO = 1;
  392. BAR = 2;
  393. BAZ = 100;
  394. }
  395. // Intentionally placed in descending field number to force sorting in closed
  396. // enum verification.
  397. NestedEnum required_enum_4 = 4 [features.field_presence = LEGACY_REQUIRED];
  398. int32 a_3 = 3;
  399. NestedEnum required_enum_2 = 2 [features.field_presence = LEGACY_REQUIRED];
  400. ForeignEnum required_enum_1 = 1 [features.field_presence = LEGACY_REQUIRED];
  401. }
  402. message TestRequiredNoMaskMulti {
  403. enum NestedEnum {
  404. UNSPECIFIED = 0;
  405. FOO = 1;
  406. BAR = 2;
  407. BAZ = 100;
  408. }
  409. // Intentionally placed in descending field number to force sorting in closed
  410. // enum verification. Also, using large field numbers to use tag only
  411. // matching for fields.
  412. fixed32 required_fixed32_80 = 80 [features.field_presence = LEGACY_REQUIRED];
  413. fixed32 required_fixed32_70 = 70 [features.field_presence = LEGACY_REQUIRED];
  414. NestedEnum required_enum_64 = 64 [features.field_presence = LEGACY_REQUIRED];
  415. NestedEnum required_enum_4 = 4 [features.field_presence = LEGACY_REQUIRED];
  416. int32 a_3 = 3;
  417. NestedEnum required_enum_2 = 2 [features.field_presence = LEGACY_REQUIRED];
  418. ForeignEnum required_enum_1 = 1 [features.field_presence = LEGACY_REQUIRED];
  419. }
  420. // We have separate messages for testing fields because it's
  421. // annoying to have to fill in fields in TestProto in order to
  422. // do anything with it. Note that we don't need to test every type of
  423. // filed because the code output is basically identical to
  424. // optional fields for all types.
  425. message TestRequired {
  426. int32 a = 1 [features.field_presence = LEGACY_REQUIRED];
  427. int32 dummy2 = 2;
  428. int32 b = 3 [features.field_presence = LEGACY_REQUIRED];
  429. extend TestAllExtensions {
  430. TestRequired single = 1000;
  431. repeated TestRequired multi = 1001;
  432. }
  433. // Pad the field count to 32 so that we can test that IsInitialized()
  434. // properly checks multiple elements of has_bits_.
  435. int32 dummy4 = 4;
  436. int32 dummy5 = 5;
  437. int32 dummy6 = 6;
  438. int32 dummy7 = 7;
  439. int32 dummy8 = 8;
  440. int32 dummy9 = 9;
  441. int32 dummy10 = 10;
  442. int32 dummy11 = 11;
  443. int32 dummy12 = 12;
  444. int32 dummy13 = 13;
  445. int32 dummy14 = 14;
  446. int32 dummy15 = 15;
  447. int32 dummy16 = 16;
  448. int32 dummy17 = 17;
  449. int32 dummy18 = 18;
  450. int32 dummy19 = 19;
  451. int32 dummy20 = 20;
  452. int32 dummy21 = 21;
  453. int32 dummy22 = 22;
  454. int32 dummy23 = 23;
  455. int32 dummy24 = 24;
  456. int32 dummy25 = 25;
  457. int32 dummy26 = 26;
  458. int32 dummy27 = 27;
  459. int32 dummy28 = 28;
  460. int32 dummy29 = 29;
  461. int32 dummy30 = 30;
  462. int32 dummy31 = 31;
  463. int32 dummy32 = 32;
  464. int32 c = 33 [features.field_presence = LEGACY_REQUIRED];
  465. // Add an optional child message to make this non-trivial for go/pdlazy.
  466. ForeignMessage optional_foreign = 34;
  467. }
  468. message TestRequiredForeign {
  469. TestRequired optional_message = 1;
  470. repeated TestRequired repeated_message = 2;
  471. int32 dummy = 3;
  472. // Missing fields must not affect verification of child messages.
  473. NestedTestAllTypes optional_lazy_message = 4 [lazy = true];
  474. }
  475. message TestRequiredMessage {
  476. TestRequired optional_message = 1;
  477. repeated TestRequired repeated_message = 2;
  478. TestRequired required_message = 3 [features.field_presence = LEGACY_REQUIRED];
  479. }
  480. message TestNestedRequiredForeign {
  481. TestNestedRequiredForeign child = 1;
  482. TestRequiredForeign payload = 2;
  483. int32 dummy = 3;
  484. // optional message to test closed enum.
  485. TestRequiredEnum required_enum = 5;
  486. TestRequiredEnumNoMask required_enum_no_mask = 6;
  487. TestRequiredEnumMulti required_enum_multi = 7;
  488. TestRequiredNoMaskMulti required_no_mask = 9;
  489. }
  490. // Test that we can use NestedMessage from outside TestAllTypes.
  491. message TestForeignNested {
  492. TestAllTypes.NestedMessage foreign_nested = 1;
  493. }
  494. // TestEmptyMessage is used to test unknown field support.
  495. message TestEmptyMessage {
  496. }
  497. // Like above, but declare all field numbers as potential extensions. No
  498. // actual extensions should ever be defined for this type.
  499. message TestEmptyMessageWithExtensions {
  500. extensions 1 to max;
  501. }
  502. // Needed for a Python test.
  503. message TestPickleNestedMessage {
  504. message NestedMessage {
  505. int32 bb = 1;
  506. message NestedNestedMessage {
  507. int32 cc = 1;
  508. }
  509. }
  510. }
  511. message TestMultipleExtensionRanges {
  512. extensions 42;
  513. extensions 4143 to 4243;
  514. extensions 65536 to max;
  515. }
  516. // Test that really large tag numbers don't break anything.
  517. message TestReallyLargeTagNumber {
  518. // The largest possible tag number is 2^28 - 1, since the wire format uses
  519. // three bits to communicate wire type.
  520. int32 a = 1;
  521. int32 bb = 268435455;
  522. }
  523. message TestRecursiveMessage {
  524. TestRecursiveMessage a = 1;
  525. int32 i = 2;
  526. }
  527. // Test that mutual recursion works.
  528. message TestMutualRecursionA {
  529. message SubMessage {
  530. TestMutualRecursionB b = 1;
  531. }
  532. TestMutualRecursionB bb = 1;
  533. message SubGroup {
  534. SubMessage sub_message = 3; // Needed because of bug in javatest
  535. TestAllTypes not_in_this_scc = 4;
  536. }
  537. SubGroup subgroup = 2 [features.message_encoding = DELIMITED];
  538. message SubGroupR {
  539. TestAllTypes payload = 6;
  540. }
  541. repeated SubGroupR subgroupr = 5 [features.message_encoding = DELIMITED];
  542. }
  543. message TestMutualRecursionB {
  544. TestMutualRecursionA a = 1;
  545. int32 optional_int32 = 2;
  546. }
  547. message TestIsInitialized {
  548. message SubMessage {
  549. message SubGroup {
  550. int32 i = 2 [features.field_presence = LEGACY_REQUIRED];
  551. }
  552. SubGroup subgroup = 1 [features.message_encoding = DELIMITED];
  553. }
  554. SubMessage sub_message = 1;
  555. }
  556. // Test that groups have disjoint field numbers from their siblings and
  557. // parents. This is NOT possible in proto1; only google.protobuf. When attempting
  558. // to compile with proto1, this will emit an error; so we only include it
  559. // in protobuf_unittest_proto.
  560. message TestDupFieldNumber { // NO_PROTO1
  561. int32 a = 1; // NO_PROTO1
  562. message Foo { int32 a = 1; } // NO_PROTO1
  563. message Bar { int32 a = 1; } // NO_PROTO1
  564. Foo foo = 2 [features.message_encoding = DELIMITED];
  565. Bar bar = 3 [features.message_encoding = DELIMITED];
  566. } // NO_PROTO1
  567. // Additional messages for testing lazy fields.
  568. message TestEagerMessage {
  569. TestAllTypes sub_message = 1 [lazy=false];
  570. }
  571. message TestLazyMessage {
  572. TestAllTypes sub_message = 1 [lazy=true];
  573. }
  574. message TestLazyMessageRepeated {
  575. repeated TestLazyMessage repeated_message = 1;
  576. }
  577. message TestEagerMaybeLazy {
  578. message NestedMessage {
  579. TestPackedTypes packed = 1;
  580. }
  581. TestAllTypes message_foo = 1;
  582. TestAllTypes message_bar = 2;
  583. NestedMessage message_baz = 3;
  584. }
  585. // Needed for a Python test.
  586. message TestNestedMessageHasBits {
  587. message NestedMessage {
  588. repeated int32 nestedmessage_repeated_int32 = 1;
  589. repeated ForeignMessage nestedmessage_repeated_foreignmessage = 2;
  590. }
  591. NestedMessage optional_nested_message = 1;
  592. }
  593. // Test an enum that has multiple values with the same number.
  594. enum TestEnumWithDupValue {
  595. option allow_alias = true;
  596. DUP_UNKNOWN1 = 0;
  597. DUP_FOO1 = 1;
  598. DUP_BAR1 = 2;
  599. DUP_BAZ = 3;
  600. DUP_UNKNOWN2 = 0;
  601. DUP_FOO2 = 1;
  602. DUP_BAR2 = 2;
  603. }
  604. // Test an enum with large, unordered values.
  605. enum TestSparseEnum {
  606. SPARSE_A = 123;
  607. SPARSE_B = 62374;
  608. SPARSE_C = 12589234;
  609. SPARSE_D = -15;
  610. SPARSE_E = -53452;
  611. SPARSE_F = 0;
  612. SPARSE_G = 2;
  613. }
  614. // Test message with CamelCase field names. This violates Protocol Buffer
  615. // standard style.
  616. message TestCamelCaseFieldNames {
  617. int32 PrimitiveField = 1;
  618. string StringField = 2;
  619. ForeignEnum EnumField = 3;
  620. ForeignMessage MessageField = 4;
  621. string StringPieceField = 5 [ctype=STRING_PIECE];
  622. string CordField = 6 [ctype=CORD];
  623. repeated int32 RepeatedPrimitiveField = 7;
  624. repeated string RepeatedStringField = 8;
  625. repeated ForeignEnum RepeatedEnumField = 9;
  626. repeated ForeignMessage RepeatedMessageField = 10;
  627. repeated string RepeatedStringPieceField = 11 [ctype=STRING_PIECE];
  628. repeated string RepeatedCordField = 12 [ctype=CORD];
  629. }
  630. // We list fields out of order, to ensure that we're using field number and not
  631. // field index to determine serialization order.
  632. message TestFieldOrderings {
  633. string my_string = 11;
  634. extensions 2 to 10;
  635. int64 my_int = 1;
  636. extensions 12 to 100;
  637. float my_float = 101;
  638. message NestedMessage {
  639. int64 oo = 2;
  640. // The field name "b" fails to compile in proto1 because it conflicts with
  641. // a local variable named "b" in one of the generated methods. Doh.
  642. // This file needs to compile in proto1 to test backwards-compatibility.
  643. int32 bb = 1;
  644. }
  645. NestedMessage optional_nested_message = 200;
  646. }
  647. extend TestFieldOrderings {
  648. string my_extension_string = 50;
  649. int32 my_extension_int = 5;
  650. }
  651. message TestExtensionOrderings1 {
  652. extend TestFieldOrderings {
  653. TestExtensionOrderings1 test_ext_orderings1 = 13;
  654. }
  655. string my_string = 1;
  656. }
  657. message TestExtensionOrderings2 {
  658. extend TestFieldOrderings {
  659. TestExtensionOrderings2 test_ext_orderings2 = 12;
  660. }
  661. message TestExtensionOrderings3 {
  662. extend TestFieldOrderings {
  663. TestExtensionOrderings3 test_ext_orderings3 = 14;
  664. }
  665. string my_string = 1;
  666. }
  667. string my_string = 1;
  668. }
  669. message TestExtremeDefaultValues {
  670. bytes escaped_bytes = 1 [default = "\0\001\a\b\f\n\r\t\v\\\'\"\xfe"];
  671. uint32 large_uint32 = 2 [default = 0xFFFFFFFF];
  672. uint64 large_uint64 = 3 [default = 0xFFFFFFFFFFFFFFFF];
  673. int32 small_int32 = 4 [default = -0x7FFFFFFF];
  674. int64 small_int64 = 5 [default = -0x7FFFFFFFFFFFFFFF];
  675. int32 really_small_int32 = 21 [default = -0x80000000];
  676. int64 really_small_int64 = 22 [default = -0x8000000000000000];
  677. // The default value here is UTF-8 for "\u1234". (We could also just type
  678. // the UTF-8 text directly into this text file rather than escape it, but
  679. // lots of people use editors that would be confused by this.)
  680. string utf8_string = 6 [default = "\341\210\264"];
  681. // Tests for single-precision floating-point values.
  682. float zero_float = 7 [default = 0];
  683. float one_float = 8 [default = 1];
  684. float small_float = 9 [default = 1.5];
  685. float negative_one_float = 10 [default = -1];
  686. float negative_float = 11 [default = -1.5];
  687. // Using exponents
  688. float large_float = 12 [default = 2E8];
  689. float small_negative_float = 13 [default = -8e-28];
  690. // Text for nonfinite floating-point values.
  691. double inf_double = 14 [default = inf];
  692. double neg_inf_double = 15 [default = -inf];
  693. double nan_double = 16 [default = nan];
  694. float inf_float = 17 [default = inf];
  695. float neg_inf_float = 18 [default = -inf];
  696. float nan_float = 19 [default = nan];
  697. // Tests for C++ trigraphs.
  698. // Trigraphs should be escaped in C++ generated files, but they should not be
  699. // escaped for other languages.
  700. // Note that in .proto file, "\?" is a valid way to escape ? in string
  701. // literals.
  702. string cpp_trigraph = 20 [default = "? \? ?? \?? \??? ??/ ?\?-"];
  703. // String defaults containing the character '\000'
  704. string string_with_zero = 23 [default = "hel\000lo"];
  705. bytes bytes_with_zero = 24 [default = "wor\000ld"];
  706. string string_piece_with_zero = 25 [ctype=STRING_PIECE,
  707. default="ab\000c"];
  708. string cord_with_zero = 26 [ctype=CORD,
  709. default="12\0003"];
  710. string replacement_string = 27 [default="${unknown}"];
  711. }
  712. message SparseEnumMessage {
  713. TestSparseEnum sparse_enum = 1;
  714. }
  715. // Test String and Bytes: string is for valid UTF-8 strings
  716. message OneString {
  717. string data = 1;
  718. }
  719. message MoreString {
  720. repeated string data = 1;
  721. }
  722. message OneBytes {
  723. bytes data = 1;
  724. }
  725. message MoreBytes {
  726. repeated bytes data = 1;
  727. }
  728. message ManyOptionalString {
  729. string str1 = 1;
  730. string str2 = 2;
  731. string str3 = 3;
  732. string str4 = 4;
  733. string str5 = 5;
  734. string str6 = 6;
  735. string str7 = 7;
  736. string str8 = 8;
  737. string str9 = 9;
  738. string str10 = 10;
  739. string str11 = 11;
  740. string str12 = 12;
  741. string str13 = 13;
  742. string str14 = 14;
  743. string str15 = 15;
  744. string str16 = 16;
  745. string str17 = 17;
  746. string str18 = 18;
  747. string str19 = 19;
  748. string str20 = 20;
  749. string str21 = 21;
  750. string str22 = 22;
  751. string str23 = 23;
  752. string str24 = 24;
  753. string str25 = 25;
  754. string str26 = 26;
  755. string str27 = 27;
  756. string str28 = 28;
  757. string str29 = 29;
  758. string str30 = 30;
  759. string str31 = 31;
  760. string str32 = 32;
  761. }
  762. // Test int32, uint32, int64, uint64, and bool are all compatible
  763. message Int32Message {
  764. int32 data = 1;
  765. }
  766. message Uint32Message {
  767. uint32 data = 1;
  768. }
  769. message Int64Message {
  770. int64 data = 1;
  771. }
  772. message Uint64Message {
  773. uint64 data = 1;
  774. }
  775. message BoolMessage {
  776. bool data = 1;
  777. }
  778. // Test oneofs.
  779. message TestOneof {
  780. message FooGroup {
  781. int32 a = 5;
  782. string b = 6;
  783. }
  784. oneof foo {
  785. int32 foo_int = 1;
  786. string foo_string = 2;
  787. TestAllTypes foo_message = 3;
  788. FooGroup foogroup= 4 [features.message_encoding = DELIMITED];
  789. }
  790. }
  791. message TestOneofBackwardsCompatible {
  792. int32 foo_int = 1;
  793. string foo_string = 2;
  794. TestAllTypes foo_message = 3;
  795. message FooGroup {
  796. int32 a = 5;
  797. string b = 6;
  798. }
  799. FooGroup foogroup= 4 [features.message_encoding = DELIMITED];
  800. }
  801. message TestOneof2 {
  802. message FooGroup {
  803. int32 a = 9;
  804. string b = 10;
  805. }
  806. oneof foo {
  807. int32 foo_int = 1;
  808. string foo_string = 2;
  809. string foo_cord = 3 [ctype=CORD];
  810. string foo_string_piece = 4 [ctype=STRING_PIECE];
  811. bytes foo_bytes = 5;
  812. NestedEnum foo_enum = 6;
  813. NestedMessage foo_message = 7;
  814. FooGroup foogroup = 8 [features.message_encoding = DELIMITED];
  815. NestedMessage foo_lazy_message = 11 [lazy=true];
  816. bytes foo_bytes_cord = 30 [ctype=CORD];
  817. }
  818. oneof bar {
  819. int32 bar_int = 12 [default = 5];
  820. string bar_string = 13 [default = "STRING"];
  821. string bar_cord = 14 [ctype=CORD, default = "CORD"];
  822. string bar_string_piece = 15 [ctype=STRING_PIECE, default = "SPIECE"];
  823. bytes bar_bytes = 16 [default = "BYTES"];
  824. NestedEnum bar_enum = 17 [default = BAR];
  825. string bar_string_with_empty_default = 20 [default = ""];
  826. string bar_cord_with_empty_default = 21 [ctype=CORD, default = ""];
  827. string bar_string_piece_with_empty_default = 22
  828. [ctype=STRING_PIECE, default = ""];
  829. bytes bar_bytes_with_empty_default = 23 [default = ""];
  830. }
  831. int32 baz_int = 18;
  832. string baz_string = 19 [default = "BAZ"];
  833. message NestedMessage {
  834. int64 moo_int = 1;
  835. repeated int32 corge_int = 2;
  836. }
  837. enum NestedEnum {
  838. UNKNOWN = 0;
  839. FOO = 1;
  840. BAR = 2;
  841. BAZ = 3;
  842. }
  843. }
  844. message TestRequiredOneof {
  845. oneof foo {
  846. int32 foo_int = 1;
  847. string foo_string = 2;
  848. NestedMessage foo_message = 3;
  849. NestedMessage foo_lazy_message = 4 [lazy = true];
  850. }
  851. message NestedMessage {
  852. double required_double = 1 [features.field_presence = LEGACY_REQUIRED];
  853. }
  854. }
  855. // Test messages for packed fields
  856. message TestPackedTypes {
  857. repeated int32 packed_int32 = 90 [features.repeated_field_encoding = PACKED];
  858. repeated int64 packed_int64 = 91 [features.repeated_field_encoding = PACKED];
  859. repeated uint32 packed_uint32 = 92 [features.repeated_field_encoding = PACKED];
  860. repeated uint64 packed_uint64 = 93 [features.repeated_field_encoding = PACKED];
  861. repeated sint32 packed_sint32 = 94 [features.repeated_field_encoding = PACKED];
  862. repeated sint64 packed_sint64 = 95 [features.repeated_field_encoding = PACKED];
  863. repeated fixed32 packed_fixed32 = 96 [features.repeated_field_encoding = PACKED];
  864. repeated fixed64 packed_fixed64 = 97 [features.repeated_field_encoding = PACKED];
  865. repeated sfixed32 packed_sfixed32 = 98 [features.repeated_field_encoding = PACKED];
  866. repeated sfixed64 packed_sfixed64 = 99 [features.repeated_field_encoding = PACKED];
  867. repeated float packed_float = 100 [features.repeated_field_encoding = PACKED];
  868. repeated double packed_double = 101 [features.repeated_field_encoding = PACKED];
  869. repeated bool packed_bool = 102 [features.repeated_field_encoding = PACKED];
  870. repeated ForeignEnum packed_enum = 103 [features.repeated_field_encoding = PACKED];
  871. }
  872. // A message with the same fields as TestPackedTypes, but without packing. Used
  873. // to test packed <-> unpacked wire compatibility.
  874. message TestUnpackedTypes {
  875. repeated int32 unpacked_int32 = 90 [features.repeated_field_encoding = EXPANDED];
  876. repeated int64 unpacked_int64 = 91 [features.repeated_field_encoding = EXPANDED];
  877. repeated uint32 unpacked_uint32 = 92 [features.repeated_field_encoding = EXPANDED];
  878. repeated uint64 unpacked_uint64 = 93 [features.repeated_field_encoding = EXPANDED];
  879. repeated sint32 unpacked_sint32 = 94 [features.repeated_field_encoding = EXPANDED];
  880. repeated sint64 unpacked_sint64 = 95 [features.repeated_field_encoding = EXPANDED];
  881. repeated fixed32 unpacked_fixed32 = 96 [features.repeated_field_encoding = EXPANDED];
  882. repeated fixed64 unpacked_fixed64 = 97 [features.repeated_field_encoding = EXPANDED];
  883. repeated sfixed32 unpacked_sfixed32 = 98 [features.repeated_field_encoding = EXPANDED];
  884. repeated sfixed64 unpacked_sfixed64 = 99 [features.repeated_field_encoding = EXPANDED];
  885. repeated float unpacked_float = 100 [features.repeated_field_encoding = EXPANDED];
  886. repeated double unpacked_double = 101 [features.repeated_field_encoding = EXPANDED];
  887. repeated bool unpacked_bool = 102 [features.repeated_field_encoding = EXPANDED];
  888. repeated ForeignEnum unpacked_enum = 103 [features.repeated_field_encoding = EXPANDED];
  889. }
  890. message TestPackedExtensions {
  891. extensions 1 to max;
  892. }
  893. extend TestPackedExtensions {
  894. repeated int32 packed_int32_extension = 90 [features.repeated_field_encoding = PACKED];
  895. repeated int64 packed_int64_extension = 91 [features.repeated_field_encoding = PACKED];
  896. repeated uint32 packed_uint32_extension = 92 [features.repeated_field_encoding = PACKED];
  897. repeated uint64 packed_uint64_extension = 93 [features.repeated_field_encoding = PACKED];
  898. repeated sint32 packed_sint32_extension = 94 [features.repeated_field_encoding = PACKED];
  899. repeated sint64 packed_sint64_extension = 95 [features.repeated_field_encoding = PACKED];
  900. repeated fixed32 packed_fixed32_extension = 96 [features.repeated_field_encoding = PACKED];
  901. repeated fixed64 packed_fixed64_extension = 97 [features.repeated_field_encoding = PACKED];
  902. repeated sfixed32 packed_sfixed32_extension = 98 [features.repeated_field_encoding = PACKED];
  903. repeated sfixed64 packed_sfixed64_extension = 99 [features.repeated_field_encoding = PACKED];
  904. repeated float packed_float_extension = 100 [features.repeated_field_encoding = PACKED];
  905. repeated double packed_double_extension = 101 [features.repeated_field_encoding = PACKED];
  906. repeated bool packed_bool_extension = 102 [features.repeated_field_encoding = PACKED];
  907. repeated ForeignEnum packed_enum_extension = 103 [features.repeated_field_encoding = PACKED];
  908. }
  909. message TestUnpackedExtensions {
  910. extensions 1 to max;
  911. }
  912. extend TestUnpackedExtensions {
  913. repeated int32 unpacked_int32_extension = 90 [features.repeated_field_encoding = EXPANDED];
  914. repeated int64 unpacked_int64_extension = 91 [features.repeated_field_encoding = EXPANDED];
  915. repeated uint32 unpacked_uint32_extension = 92 [features.repeated_field_encoding = EXPANDED];
  916. repeated uint64 unpacked_uint64_extension = 93 [features.repeated_field_encoding = EXPANDED];
  917. repeated sint32 unpacked_sint32_extension = 94 [features.repeated_field_encoding = EXPANDED];
  918. repeated sint64 unpacked_sint64_extension = 95 [features.repeated_field_encoding = EXPANDED];
  919. repeated fixed32 unpacked_fixed32_extension = 96 [features.repeated_field_encoding = EXPANDED];
  920. repeated fixed64 unpacked_fixed64_extension = 97 [features.repeated_field_encoding = EXPANDED];
  921. repeated sfixed32 unpacked_sfixed32_extension = 98 [features.repeated_field_encoding = EXPANDED];
  922. repeated sfixed64 unpacked_sfixed64_extension = 99 [features.repeated_field_encoding = EXPANDED];
  923. repeated float unpacked_float_extension = 100 [features.repeated_field_encoding = EXPANDED];
  924. repeated double unpacked_double_extension = 101 [features.repeated_field_encoding = EXPANDED];
  925. repeated bool unpacked_bool_extension = 102 [features.repeated_field_encoding = EXPANDED];
  926. repeated ForeignEnum unpacked_enum_extension = 103 [features.repeated_field_encoding = EXPANDED];
  927. }
  928. // Used by ExtensionSetTest/DynamicExtensions. The test actually builds
  929. // a set of extensions to TestAllExtensions dynamically, based on the fields
  930. // of this message type.
  931. message TestDynamicExtensions {
  932. enum DynamicEnumType {
  933. DYNAMIC_UNKNOWN = 0;
  934. DYNAMIC_FOO = 2200;
  935. DYNAMIC_BAR = 2201;
  936. DYNAMIC_BAZ = 2202;
  937. }
  938. message DynamicMessageType {
  939. int32 dynamic_field = 2100;
  940. }
  941. fixed32 scalar_extension = 2000;
  942. ForeignEnum enum_extension = 2001;
  943. DynamicEnumType dynamic_enum_extension = 2002;
  944. ForeignMessage message_extension = 2003;
  945. DynamicMessageType dynamic_message_extension = 2004;
  946. repeated string repeated_extension = 2005;
  947. repeated sint32 packed_extension = 2006 [features.repeated_field_encoding = PACKED];
  948. }
  949. message TestRepeatedString {
  950. repeated string repeated_string1 = 1;
  951. repeated string repeated_string2 = 2;
  952. repeated bytes repeated_bytes11 = 11;
  953. repeated bytes repeated_bytes12 = 12;
  954. }
  955. message TestRepeatedScalarDifferentTagSizes {
  956. // Parsing repeated fixed size values used to fail. This message needs to be
  957. // used in order to get a tag of the right size; all of the repeated fields
  958. // in TestAllTypes didn't trigger the check.
  959. repeated fixed32 repeated_fixed32 = 12;
  960. // Check for a varint type, just for good measure.
  961. repeated int32 repeated_int32 = 13;
  962. // These have two-byte tags.
  963. repeated fixed64 repeated_fixed64 = 2046;
  964. repeated int64 repeated_int64 = 2047;
  965. // Three byte tags.
  966. repeated float repeated_float = 262142;
  967. repeated uint64 repeated_uint64 = 262143;
  968. }
  969. // Test that if an optional or message/group field appears multiple
  970. // times in the input, they need to be merged.
  971. message TestParsingMerge {
  972. // RepeatedFieldsGenerator defines matching field types as TestParsingMerge,
  973. // except that all fields are repeated. In the tests, we will serialize the
  974. // RepeatedFieldsGenerator to bytes, and parse the bytes to TestParsingMerge.
  975. // Repeated fields in RepeatedFieldsGenerator are expected to be merged into
  976. // the corresponding required/optional fields in TestParsingMerge.
  977. message RepeatedFieldsGenerator {
  978. repeated TestAllTypes field1 = 1;
  979. repeated TestAllTypes field2 = 2;
  980. repeated TestAllTypes field3 = 3;
  981. message Group1 {
  982. TestAllTypes field1 = 11;
  983. }
  984. repeated Group1 group1= 10 [features.message_encoding = DELIMITED];
  985. message Group2 {
  986. TestAllTypes field1 = 21;
  987. }
  988. repeated Group2 group2= 20 [features.message_encoding = DELIMITED];
  989. repeated TestAllTypes ext1 = 1000;
  990. repeated TestAllTypes ext2 = 1001;
  991. }
  992. TestAllTypes required_all_types = 1 [features.field_presence = LEGACY_REQUIRED];
  993. TestAllTypes optional_all_types = 2;
  994. repeated TestAllTypes repeated_all_types = 3;
  995. message OptionalGroup {
  996. TestAllTypes optional_group_all_types = 11;
  997. }
  998. OptionalGroup optionalgroup= 10 [features.message_encoding = DELIMITED];
  999. message RepeatedGroup {
  1000. TestAllTypes repeated_group_all_types = 21;
  1001. }
  1002. repeated RepeatedGroup repeatedgroup= 20 [features.message_encoding = DELIMITED];
  1003. extensions 1000 to max;
  1004. extend TestParsingMerge {
  1005. TestAllTypes optional_ext = 1000;
  1006. repeated TestAllTypes repeated_ext = 1001;
  1007. }
  1008. }
  1009. // Test that the correct exception is thrown by parseFrom in a corner case
  1010. // involving merging, extensions, and fields.
  1011. message TestMergeException {
  1012. TestAllExtensions all_extensions = 1;
  1013. }
  1014. message TestCommentInjectionMessage {
  1015. // */ <- This should not close the generated doc comment
  1016. string a = 1 [default="*/ <- Neither should this."];
  1017. }
  1018. // Used to check that the c++ code generator re-orders messages to reduce
  1019. // padding.
  1020. message TestMessageSize {
  1021. bool m1 = 1;
  1022. int64 m2 = 2;
  1023. bool m3 = 3;
  1024. string m4 = 4;
  1025. int32 m5 = 5;
  1026. int64 m6 = 6;
  1027. }
  1028. // Test that RPC services work.
  1029. message FooRequest {}
  1030. message FooResponse {}
  1031. message FooClientMessage {}
  1032. message FooServerMessage{}
  1033. message BarRequest {}
  1034. message BarResponse {}
  1035. message TestJsonName {
  1036. int32 field_name1 = 1;
  1037. int32 fieldName2 = 2;
  1038. int32 FieldName3 = 3;
  1039. int32 _field_name4 = 4;
  1040. int32 FIELD_NAME5 = 5;
  1041. int32 field_name6 = 6 [json_name = "@type"];
  1042. int32 fieldname7 = 7;
  1043. }
  1044. message TestHugeFieldNumbers {
  1045. int32 optional_int32 = 536870000;
  1046. int32 fixed_32 = 536870001;
  1047. repeated int32 repeated_int32 = 536870002 [features.repeated_field_encoding = EXPANDED];
  1048. repeated int32 packed_int32 = 536870003 [features.repeated_field_encoding = PACKED];
  1049. ForeignEnum optional_enum = 536870004;
  1050. string optional_string = 536870005;
  1051. bytes optional_bytes = 536870006;
  1052. ForeignMessage optional_message = 536870007;
  1053. message OptionalGroup {
  1054. int32 group_a = 536870009;
  1055. }
  1056. OptionalGroup optionalgroup = 536870008 [features.message_encoding = DELIMITED];
  1057. map<string, string> string_string_map = 536870010;
  1058. oneof oneof_field {
  1059. uint32 oneof_uint32 = 536870011;
  1060. TestAllTypes oneof_test_all_types = 536870012;
  1061. string oneof_string = 536870013;
  1062. bytes oneof_bytes = 536870014;
  1063. }
  1064. extensions 536860000 to 536869999 [declaration = {
  1065. number: 536860000
  1066. full_name: ".edition_unittest.test_all_types"
  1067. type: ".edition_unittest.TestAllTypes"
  1068. }];
  1069. }
  1070. extend TestHugeFieldNumbers {
  1071. TestAllTypes test_all_types = 536860000;
  1072. }
  1073. message TestExtensionInsideTable {
  1074. int32 field1 = 1;
  1075. int32 field2 = 2;
  1076. int32 field3 = 3;
  1077. int32 field4 = 4;
  1078. extensions 5 to 5;
  1079. int32 field6 = 6;
  1080. int32 field7 = 7;
  1081. int32 field8 = 8;
  1082. int32 field9 = 9;
  1083. int32 field10 = 10;
  1084. }
  1085. extend TestExtensionInsideTable {
  1086. int32 test_extension_inside_table_extension = 5;
  1087. }
  1088. // NOTE: Intentionally nested to mirror go/glep.
  1089. message TestNestedGroupExtensionOuter {
  1090. message Layer1OptionalGroup {
  1091. message Layer2RepeatedGroup {
  1092. extensions 3
  1093. // NOTE: extension metadata is not supported due to targets such as
  1094. // `//google/protobuf_legacy_opensource/src:shell_scripts_test`,
  1095. // eee https://screenshot.googleplex.com/Axz2QD8nxjdpyFF
  1096. //[metadata = {
  1097. // NOTE: can't write type there due to some clever build gen code at
  1098. // http://google3/google/protobuf/BUILD;l=1247;rcl=411090862
  1099. // type: "edition_unittest.TestNestedGroupExtensionInnerExtension",
  1100. // name: "inner",
  1101. // }]
  1102. ;
  1103. string another_field = 6;
  1104. }
  1105. message Layer2AnotherOptionalRepeatedGroup {
  1106. string but_why_tho = 5;
  1107. }
  1108. repeated Layer2RepeatedGroup layer2repeatedgroup = 2 [features.message_encoding = DELIMITED];
  1109. repeated Layer2AnotherOptionalRepeatedGroup layer2anotheroptionalrepeatedgroup = 4 [features.message_encoding = DELIMITED];
  1110. }
  1111. Layer1OptionalGroup lay1optionalgroup = 1 [features.message_encoding = DELIMITED];
  1112. }
  1113. message TestNestedGroupExtensionInnerExtension {
  1114. string inner_name= 1;
  1115. }
  1116. extend TestNestedGroupExtensionOuter.Layer1OptionalGroup.Layer2RepeatedGroup {
  1117. TestNestedGroupExtensionInnerExtension inner = 3;
  1118. }
  1119. enum VeryLargeEnum {
  1120. ENUM_LABEL_DEFAULT = 0;
  1121. ENUM_LABEL_1 = 1;
  1122. ENUM_LABEL_2 = 2;
  1123. ENUM_LABEL_3 = 3;
  1124. ENUM_LABEL_4 = 4;
  1125. ENUM_LABEL_5 = 5;
  1126. ENUM_LABEL_6 = 6;
  1127. ENUM_LABEL_7 = 7;
  1128. ENUM_LABEL_8 = 8;
  1129. ENUM_LABEL_9 = 9;
  1130. ENUM_LABEL_10 = 10;
  1131. ENUM_LABEL_11 = 11;
  1132. ENUM_LABEL_12 = 12;
  1133. ENUM_LABEL_13 = 13;
  1134. ENUM_LABEL_14 = 14;
  1135. ENUM_LABEL_15 = 15;
  1136. ENUM_LABEL_16 = 16;
  1137. ENUM_LABEL_17 = 17;
  1138. ENUM_LABEL_18 = 18;
  1139. ENUM_LABEL_19 = 19;
  1140. ENUM_LABEL_20 = 20;
  1141. ENUM_LABEL_21 = 21;
  1142. ENUM_LABEL_22 = 22;
  1143. ENUM_LABEL_23 = 23;
  1144. ENUM_LABEL_24 = 24;
  1145. ENUM_LABEL_25 = 25;
  1146. ENUM_LABEL_26 = 26;
  1147. ENUM_LABEL_27 = 27;
  1148. ENUM_LABEL_28 = 28;
  1149. ENUM_LABEL_29 = 29;
  1150. ENUM_LABEL_30 = 30;
  1151. ENUM_LABEL_31 = 31;
  1152. ENUM_LABEL_32 = 32;
  1153. ENUM_LABEL_33 = 33;
  1154. ENUM_LABEL_34 = 34;
  1155. ENUM_LABEL_35 = 35;
  1156. ENUM_LABEL_36 = 36;
  1157. ENUM_LABEL_37 = 37;
  1158. ENUM_LABEL_38 = 38;
  1159. ENUM_LABEL_39 = 39;
  1160. ENUM_LABEL_40 = 40;
  1161. ENUM_LABEL_41 = 41;
  1162. ENUM_LABEL_42 = 42;
  1163. ENUM_LABEL_43 = 43;
  1164. ENUM_LABEL_44 = 44;
  1165. ENUM_LABEL_45 = 45;
  1166. ENUM_LABEL_46 = 46;
  1167. ENUM_LABEL_47 = 47;
  1168. ENUM_LABEL_48 = 48;
  1169. ENUM_LABEL_49 = 49;
  1170. ENUM_LABEL_50 = 50;
  1171. ENUM_LABEL_51 = 51;
  1172. ENUM_LABEL_52 = 52;
  1173. ENUM_LABEL_53 = 53;
  1174. ENUM_LABEL_54 = 54;
  1175. ENUM_LABEL_55 = 55;
  1176. ENUM_LABEL_56 = 56;
  1177. ENUM_LABEL_57 = 57;
  1178. ENUM_LABEL_58 = 58;
  1179. ENUM_LABEL_59 = 59;
  1180. ENUM_LABEL_60 = 60;
  1181. ENUM_LABEL_61 = 61;
  1182. ENUM_LABEL_62 = 62;
  1183. ENUM_LABEL_63 = 63;
  1184. ENUM_LABEL_64 = 64;
  1185. ENUM_LABEL_65 = 65;
  1186. ENUM_LABEL_66 = 66;
  1187. ENUM_LABEL_67 = 67;
  1188. ENUM_LABEL_68 = 68;
  1189. ENUM_LABEL_69 = 69;
  1190. ENUM_LABEL_70 = 70;
  1191. ENUM_LABEL_71 = 71;
  1192. ENUM_LABEL_72 = 72;
  1193. ENUM_LABEL_73 = 73;
  1194. ENUM_LABEL_74 = 74;
  1195. ENUM_LABEL_75 = 75;
  1196. ENUM_LABEL_76 = 76;
  1197. ENUM_LABEL_77 = 77;
  1198. ENUM_LABEL_78 = 78;
  1199. ENUM_LABEL_79 = 79;
  1200. ENUM_LABEL_80 = 80;
  1201. ENUM_LABEL_81 = 81;
  1202. ENUM_LABEL_82 = 82;
  1203. ENUM_LABEL_83 = 83;
  1204. ENUM_LABEL_84 = 84;
  1205. ENUM_LABEL_85 = 85;
  1206. ENUM_LABEL_86 = 86;
  1207. ENUM_LABEL_87 = 87;
  1208. ENUM_LABEL_88 = 88;
  1209. ENUM_LABEL_89 = 89;
  1210. ENUM_LABEL_90 = 90;
  1211. ENUM_LABEL_91 = 91;
  1212. ENUM_LABEL_92 = 92;
  1213. ENUM_LABEL_93 = 93;
  1214. ENUM_LABEL_94 = 94;
  1215. ENUM_LABEL_95 = 95;
  1216. ENUM_LABEL_96 = 96;
  1217. ENUM_LABEL_97 = 97;
  1218. ENUM_LABEL_98 = 98;
  1219. ENUM_LABEL_99 = 99;
  1220. ENUM_LABEL_100 = 100;
  1221. };
  1222. message TestExtensionRangeSerialize {
  1223. int32 foo_one = 1;
  1224. extensions 2 to 2;
  1225. extensions 3 to 4;
  1226. int32 foo_two = 6;
  1227. int32 foo_three = 7;
  1228. extensions 9 to 10;
  1229. int32 foo_four = 13;
  1230. extensions 15 to 15;
  1231. extensions 17 to 17;
  1232. extensions 19 to 19;
  1233. extend TestExtensionRangeSerialize {
  1234. int32 bar_one = 2;
  1235. int32 bar_two = 4;
  1236. int32 bar_three = 10;
  1237. int32 bar_four = 15;
  1238. int32 bar_five = 19;
  1239. }
  1240. }
  1241. message TestVerifyInt32Simple {
  1242. int32 optional_int32_1 = 1;
  1243. int32 optional_int32_2 = 2;
  1244. int32 optional_int32_63 = 63;
  1245. int32 optional_int32_64 = 64;
  1246. }
  1247. message TestVerifyInt32 {
  1248. int32 optional_int32_1 = 1;
  1249. int32 optional_int32_2 = 2;
  1250. int32 optional_int32_63 = 63;
  1251. int32 optional_int32_64 = 64;
  1252. TestAllTypes optional_all_types = 9;
  1253. repeated TestAllTypes repeated_all_types = 10;
  1254. }
  1255. message TestVerifyMostlyInt32 {
  1256. int64 optional_int64_30 = 30;
  1257. int32 optional_int32_1 = 1;
  1258. int32 optional_int32_2 = 2;
  1259. int32 optional_int32_3 = 3;
  1260. int32 optional_int32_4 = 4;
  1261. int32 optional_int32_63 = 63;
  1262. int32 optional_int32_64 = 64;
  1263. TestAllTypes optional_all_types = 9;
  1264. repeated TestAllTypes repeated_all_types = 10;
  1265. }
  1266. message TestVerifyMostlyInt32BigFieldNumber {
  1267. int64 optional_int64_30 = 30;
  1268. int32 optional_int32_300 = 300;
  1269. int32 optional_int32_1 = 1;
  1270. int32 optional_int32_2 = 2;
  1271. int32 optional_int32_3 = 3;
  1272. int32 optional_int32_4 = 4;
  1273. int32 optional_int32_63 = 63;
  1274. int32 optional_int32_64 = 64;
  1275. TestAllTypes optional_all_types = 9;
  1276. repeated TestAllTypes repeated_all_types = 10;
  1277. }
  1278. message TestVerifyUint32Simple {
  1279. uint32 optional_uint32_1 = 1;
  1280. uint32 optional_uint32_2 = 2;
  1281. uint32 optional_uint32_63 = 63;
  1282. uint32 optional_uint32_64 = 64;
  1283. }
  1284. message TestVerifyUint32 {
  1285. uint32 optional_uint32_1 = 1;
  1286. uint32 optional_uint32_2 = 2;
  1287. uint32 optional_uint32_63 = 63;
  1288. uint32 optional_uint32_64 = 64;
  1289. TestAllTypes optional_all_types = 9;
  1290. repeated TestAllTypes repeated_all_types = 10;
  1291. }
  1292. message TestVerifyOneUint32 {
  1293. uint32 optional_uint32_1 = 1;
  1294. int32 optional_int32_2 = 2;
  1295. int32 optional_int32_63 = 63;
  1296. int32 optional_int32_64 = 64;
  1297. TestAllTypes optional_all_types = 9;
  1298. repeated TestAllTypes repeated_all_types = 10;
  1299. }
  1300. message TestVerifyOneInt32BigFieldNumber {
  1301. int32 optional_int32_65 = 65;
  1302. int64 optional_int64_1 = 1;
  1303. int64 optional_int64_2 = 2;
  1304. int64 optional_int64_63 = 63;
  1305. int64 optional_int64_64 = 64;
  1306. TestAllTypes optional_all_types = 9;
  1307. repeated TestAllTypes repeated_all_types = 10;
  1308. }
  1309. message TestVerifyInt32BigFieldNumber {
  1310. int32 optional_int32_1000 = 1000;
  1311. int32 optional_int32_65 = 65;
  1312. int32 optional_int32_1 = 1;
  1313. int32 optional_int32_2 = 2;
  1314. int32 optional_int32_63 = 63;
  1315. int32 optional_int32_64 = 64;
  1316. TestAllTypes optional_all_types = 9;
  1317. repeated TestAllTypes repeated_all_types = 10;
  1318. }
  1319. message TestVerifyUint32BigFieldNumber {
  1320. uint32 optional_uint32_1000 = 1000;
  1321. uint32 optional_uint32_65 = 65;
  1322. uint32 optional_uint32_1 = 1;
  1323. uint32 optional_uint32_2 = 2;
  1324. uint32 optional_uint32_63 = 63;
  1325. uint32 optional_uint32_64 = 64;
  1326. TestAllTypes optional_all_types = 9;
  1327. repeated TestAllTypes repeated_all_types = 10;
  1328. }
  1329. message TestVerifyBigFieldNumberUint32 {
  1330. message Nested {
  1331. uint32 optional_uint32_5000 = 5000;
  1332. uint32 optional_uint32_1000 = 1000;
  1333. uint32 optional_uint32_66 = 66;
  1334. uint32 optional_uint32_65 = 65;
  1335. uint32 optional_uint32_1 = 1;
  1336. uint32 optional_uint32_2 = 2;
  1337. uint32 optional_uint32_63 = 63;
  1338. uint32 optional_uint32_64 = 64;
  1339. Nested optional_nested = 9;
  1340. repeated Nested repeated_nested = 10;
  1341. }
  1342. Nested optional_nested = 1;
  1343. }
  1344. // This message contains different kind of enums to exercise the different
  1345. // parsers in table-driven.
  1346. message EnumParseTester {
  1347. enum SeqSmall0 {
  1348. SEQ_SMALL_0_DEFAULT = 0;
  1349. SEQ_SMALL_0_1 = 1;
  1350. SEQ_SMALL_0_2 = 2;
  1351. };
  1352. SeqSmall0 optional_seq_small_0_lowfield = 1;
  1353. SeqSmall0 optional_seq_small_0_midfield = 1001;
  1354. SeqSmall0 optional_seq_small_0_hifield = 1000001;
  1355. repeated SeqSmall0 repeated_seq_small_0_lowfield = 2;
  1356. repeated SeqSmall0 repeated_seq_small_0_midfield = 1002;
  1357. repeated SeqSmall0 repeated_seq_small_0_hifield = 1000002;
  1358. repeated SeqSmall0 packed_seq_small_0_lowfield = 3
  1359. [features.repeated_field_encoding = PACKED];
  1360. repeated SeqSmall0 packed_seq_small_0_midfield = 1003
  1361. [features.repeated_field_encoding = PACKED];
  1362. repeated SeqSmall0 packed_seq_small_0_hifield = 1000003
  1363. [features.repeated_field_encoding = PACKED];
  1364. enum SeqSmall1 {
  1365. UNKNOWN = 0;
  1366. SEQ_SMALL_1_DEFAULT = 1;
  1367. SEQ_SMALL_1_2 = 2;
  1368. SEQ_SMALL_1_3 = 3;
  1369. };
  1370. SeqSmall1 optional_seq_small_1_lowfield = 4;
  1371. SeqSmall1 optional_seq_small_1_midfield = 1004;
  1372. SeqSmall1 optional_seq_small_1_hifield = 1000004;
  1373. repeated SeqSmall1 repeated_seq_small_1_lowfield = 5;
  1374. repeated SeqSmall1 repeated_seq_small_1_midfield = 1005;
  1375. repeated SeqSmall1 repeated_seq_small_1_hifield = 1000005;
  1376. repeated SeqSmall1 packed_seq_small_1_lowfield = 6
  1377. [features.repeated_field_encoding = PACKED];
  1378. repeated SeqSmall1 packed_seq_small_1_midfield = 1006
  1379. [features.repeated_field_encoding = PACKED];
  1380. repeated SeqSmall1 packed_seq_small_1_hifield = 1000006
  1381. [features.repeated_field_encoding = PACKED];
  1382. enum SeqLarge {
  1383. SEQ_LARGE_DEFAULT = -1;
  1384. SEQ_LARGE_0 = 0;
  1385. SEQ_LARGE_1 = 1;
  1386. SEQ_LARGE_2 = 2;
  1387. SEQ_LARGE_3 = 3;
  1388. SEQ_LARGE_4 = 4;
  1389. SEQ_LARGE_5 = 5;
  1390. SEQ_LARGE_6 = 6;
  1391. SEQ_LARGE_7 = 7;
  1392. SEQ_LARGE_8 = 8;
  1393. SEQ_LARGE_9 = 9;
  1394. SEQ_LARGE_10 = 10;
  1395. SEQ_LARGE_11 = 11;
  1396. SEQ_LARGE_12 = 12;
  1397. SEQ_LARGE_13 = 13;
  1398. SEQ_LARGE_14 = 14;
  1399. SEQ_LARGE_15 = 15;
  1400. SEQ_LARGE_16 = 16;
  1401. SEQ_LARGE_17 = 17;
  1402. SEQ_LARGE_18 = 18;
  1403. SEQ_LARGE_19 = 19;
  1404. SEQ_LARGE_20 = 20;
  1405. SEQ_LARGE_21 = 21;
  1406. SEQ_LARGE_22 = 22;
  1407. SEQ_LARGE_23 = 23;
  1408. SEQ_LARGE_24 = 24;
  1409. SEQ_LARGE_25 = 25;
  1410. SEQ_LARGE_26 = 26;
  1411. SEQ_LARGE_27 = 27;
  1412. SEQ_LARGE_28 = 28;
  1413. SEQ_LARGE_29 = 29;
  1414. SEQ_LARGE_30 = 30;
  1415. SEQ_LARGE_31 = 31;
  1416. SEQ_LARGE_32 = 32;
  1417. SEQ_LARGE_33 = 33;
  1418. };
  1419. SeqLarge optional_seq_large_lowfield = 7;
  1420. SeqLarge optional_seq_large_midfield = 1007;
  1421. SeqLarge optional_seq_large_hifield = 1000007;
  1422. repeated SeqLarge repeated_seq_large_lowfield = 8;
  1423. repeated SeqLarge repeated_seq_large_midfield = 1008;
  1424. repeated SeqLarge repeated_seq_large_hifield = 1000008;
  1425. repeated SeqLarge packed_seq_large_lowfield = 9
  1426. [features.repeated_field_encoding = PACKED];
  1427. repeated SeqLarge packed_seq_large_midfield = 1009
  1428. [features.repeated_field_encoding = PACKED];
  1429. repeated SeqLarge packed_seq_large_hifield = 1000009
  1430. [features.repeated_field_encoding = PACKED];
  1431. enum Arbitrary {
  1432. ARBITRARY_DEFAULT = -123123;
  1433. ARBITRARY_1 = -123;
  1434. ARBITRARY_2 = 213;
  1435. ARBITRARY_3 = 213213;
  1436. ARBITRARY_MIN = -2147483648;
  1437. ARBITRARY_MAX = 2147483647;
  1438. };
  1439. Arbitrary optional_arbitrary_lowfield = 10;
  1440. Arbitrary optional_arbitrary_midfield = 1010;
  1441. Arbitrary optional_arbitrary_hifield = 1000010;
  1442. repeated Arbitrary repeated_arbitrary_lowfield = 11;
  1443. repeated Arbitrary repeated_arbitrary_midfield = 1011;
  1444. repeated Arbitrary repeated_arbitrary_hifield = 1000011;
  1445. repeated Arbitrary packed_arbitrary_lowfield = 12
  1446. [features.repeated_field_encoding = PACKED];
  1447. repeated Arbitrary packed_arbitrary_midfield = 1012
  1448. [features.repeated_field_encoding = PACKED];
  1449. repeated Arbitrary packed_arbitrary_hifield = 1000012
  1450. [features.repeated_field_encoding = PACKED];
  1451. extensions 2000000 to max;
  1452. extend EnumParseTester {
  1453. Arbitrary optional_arbitrary_ext = 2000000;
  1454. repeated Arbitrary repeated_arbitrary_ext = 2000001;
  1455. repeated Arbitrary packed_arbitrary_ext = 2000002
  1456. [features.repeated_field_encoding = PACKED];
  1457. }
  1458. // An arbitrary field we can append to to break the runs of repeated fields.
  1459. int32 other_field = 99;
  1460. }
  1461. // This message contains different kind of bool fields to exercise the different
  1462. // parsers in table-drived.
  1463. message BoolParseTester {
  1464. bool optional_bool_lowfield = 1;
  1465. bool optional_bool_midfield = 1001;
  1466. bool optional_bool_hifield = 1000001;
  1467. repeated bool repeated_bool_lowfield = 2;
  1468. repeated bool repeated_bool_midfield = 1002;
  1469. repeated bool repeated_bool_hifield = 1000002;
  1470. repeated bool packed_bool_lowfield = 3
  1471. [features.repeated_field_encoding = PACKED];
  1472. repeated bool packed_bool_midfield = 1003
  1473. [features.repeated_field_encoding = PACKED];
  1474. repeated bool packed_bool_hifield = 1000003
  1475. [features.repeated_field_encoding = PACKED];
  1476. extensions 2000000 to max;
  1477. extend BoolParseTester {
  1478. bool optional_bool_ext = 2000000;
  1479. repeated bool repeated_bool_ext = 2000001;
  1480. repeated bool packed_bool_ext = 2000002
  1481. [features.repeated_field_encoding = PACKED];
  1482. }
  1483. // An arbitrary field we can append to to break the runs of repeated fields.
  1484. int32 other_field = 99;
  1485. }
  1486. message Int32ParseTester {
  1487. int32 optional_int32_lowfield = 1;
  1488. int32 optional_int32_midfield = 1001;
  1489. int32 optional_int32_hifield = 1000001;
  1490. repeated int32 repeated_int32_lowfield = 2;
  1491. repeated int32 repeated_int32_midfield = 1002;
  1492. repeated int32 repeated_int32_hifield = 1000002;
  1493. repeated int32 packed_int32_lowfield = 3
  1494. [features.repeated_field_encoding = PACKED];
  1495. repeated int32 packed_int32_midfield = 1003
  1496. [features.repeated_field_encoding = PACKED];
  1497. repeated int32 packed_int32_hifield = 1000003
  1498. [features.repeated_field_encoding = PACKED];
  1499. extensions 2000000 to max;
  1500. extend Int32ParseTester {
  1501. int32 optional_int32_ext = 2000000;
  1502. repeated int32 repeated_int32_ext = 2000001;
  1503. repeated int32 packed_int32_ext = 2000002
  1504. [features.repeated_field_encoding = PACKED];
  1505. }
  1506. // An arbitrary field we can append to to break the runs of repeated fields.
  1507. int32 other_field = 99;
  1508. }
  1509. message Int64ParseTester {
  1510. int64 optional_int64_lowfield = 1;
  1511. int64 optional_int64_midfield = 1001;
  1512. int64 optional_int64_hifield = 1000001;
  1513. repeated int64 repeated_int64_lowfield = 2;
  1514. repeated int64 repeated_int64_midfield = 1002;
  1515. repeated int64 repeated_int64_hifield = 1000002;
  1516. repeated int64 packed_int64_lowfield = 3
  1517. [features.repeated_field_encoding = PACKED];
  1518. repeated int64 packed_int64_midfield = 1003
  1519. [features.repeated_field_encoding = PACKED];
  1520. repeated int64 packed_int64_hifield = 1000003
  1521. [features.repeated_field_encoding = PACKED];
  1522. extensions 2000000 to max;
  1523. extend Int64ParseTester {
  1524. int64 optional_int64_ext = 2000000;
  1525. repeated int64 repeated_int64_ext = 2000001;
  1526. repeated int64 packed_int64_ext = 2000002
  1527. [features.repeated_field_encoding = PACKED];
  1528. }
  1529. // An arbitrary field we can append to to break the runs of repeated fields.
  1530. int32 other_field = 99;
  1531. }
  1532. message InlinedStringIdxRegressionProto {
  1533. // We mix data to make sure aux ids and inlined string idx do not match.
  1534. // aux_idx == inlined_string_idx == 1
  1535. string str1 = 1;
  1536. // aux_idx == 2
  1537. InlinedStringIdxRegressionProto sub = 2;
  1538. // aux_idx == 3, inlined_string_idx == 2
  1539. string str2 = 3;
  1540. // aux_idx == 4, inlined_string_idx == 3
  1541. bytes str3 = 4;
  1542. }
  1543. message StringParseTester {
  1544. string optional_string_lowfield = 1;
  1545. string optional_string_midfield = 1001;
  1546. string optional_string_hifield = 1000001;
  1547. repeated string repeated_string_lowfield = 2;
  1548. repeated string repeated_string_midfield = 1002;
  1549. repeated string repeated_string_hifield = 1000002;
  1550. extensions 2000000 to max;
  1551. extend StringParseTester {
  1552. string optional_string_ext = 2000000;
  1553. repeated string repeated_string_ext = 2000001;
  1554. }
  1555. }
  1556. message BadFieldNames{
  1557. int32 OptionalInt32 = 1;
  1558. int32 for = 2;
  1559. }
  1560. message TestNestedMessageRedaction {
  1561. string optional_unredacted_nested_string = 1;
  1562. string optional_redacted_nested_string = 2 [debug_redact = true];
  1563. }
  1564. message RedactedFields {
  1565. string optional_redacted_string = 1 [debug_redact = true];
  1566. string optional_unredacted_string = 2;
  1567. repeated string repeated_redacted_string = 3 [debug_redact = true];
  1568. repeated string repeated_unredacted_string = 4;
  1569. TestNestedMessageRedaction optional_redacted_message = 5 [debug_redact = true];
  1570. TestNestedMessageRedaction optional_unredacted_message = 6;
  1571. repeated TestNestedMessageRedaction repeated_redacted_message = 7
  1572. [debug_redact = true];
  1573. repeated TestNestedMessageRedaction repeated_unredacted_message = 8;
  1574. map<string, string> map_redacted_string = 9 [debug_redact = true];
  1575. map<string, string> map_unredacted_string = 10;
  1576. }
  1577. message TestCord{
  1578. bytes optional_bytes_cord = 1 [ctype=CORD];
  1579. bytes optional_bytes_cord_default = 2 [ctype=CORD, default = "hello"];
  1580. }
  1581. message TestPackedEnumSmallRange {
  1582. enum NestedEnum {
  1583. UNSPECIFIED = 0;
  1584. FOO = 1;
  1585. BAR = 2;
  1586. BAZ = 3;
  1587. }
  1588. repeated NestedEnum vals = 1
  1589. [features.repeated_field_encoding = PACKED];
  1590. }
  1591. message EnumsForBenchmark {
  1592. enum Flat {
  1593. A0 = 0;
  1594. A1 = 1;
  1595. A2 = 2;
  1596. A3 = 3;
  1597. A4 = 4;
  1598. A5 = 5;
  1599. A6 = 6;
  1600. A7 = 7;
  1601. A8 = 8;
  1602. A9 = 9;
  1603. A10 = 10;
  1604. A11 = 11;
  1605. A12 = 12;
  1606. A13 = 13;
  1607. A14 = 14;
  1608. A15 = 15;
  1609. }
  1610. // Has a few holes, bitmap can be used.
  1611. enum AlmostFlat {
  1612. B0 = 0;
  1613. B1 = 1;
  1614. B2 = 2;
  1615. B3 = 3;
  1616. B5 = 5;
  1617. B6 = 6;
  1618. B7 = 7;
  1619. B8 = 8;
  1620. B9 = 9;
  1621. B11 = 11;
  1622. B12 = 12;
  1623. B13 = 13;
  1624. B14 = 14;
  1625. B15 = 15;
  1626. B17 = 17;
  1627. B19 = 19;
  1628. }
  1629. enum Sparse {
  1630. C0 = 0;
  1631. C536 = 536;
  1632. C8387 = 8387;
  1633. C9673 = 9673;
  1634. C10285 = 10285;
  1635. C13318 = 13318;
  1636. C15963 = 15963;
  1637. C16439 = 16439;
  1638. C18197 = 18197;
  1639. C19430 = 19430;
  1640. C20361 = 20361;
  1641. C20706 = 20706;
  1642. C21050 = 21050;
  1643. C21906 = 21906;
  1644. C27265 = 27265;
  1645. C30109 = 30109;
  1646. C31670 = 31670;
  1647. }
  1648. }
  1649. message TestMessageWithManyRepeatedPtrFields {
  1650. repeated string repeated_string_1 = 1;
  1651. repeated string repeated_string_2 = 2;
  1652. repeated string repeated_string_3 = 3;
  1653. repeated string repeated_string_4 = 4;
  1654. repeated string repeated_string_5 = 5;
  1655. repeated string repeated_string_6 = 6;
  1656. repeated string repeated_string_7 = 7;
  1657. repeated string repeated_string_8 = 8;
  1658. repeated string repeated_string_9 = 9;
  1659. repeated string repeated_string_10 = 10;
  1660. repeated string repeated_string_11 = 11;
  1661. repeated string repeated_string_12 = 12;
  1662. repeated string repeated_string_13 = 13;
  1663. repeated string repeated_string_14 = 14;
  1664. repeated string repeated_string_15 = 15;
  1665. repeated string repeated_string_16 = 16;
  1666. repeated string repeated_string_17 = 17;
  1667. repeated string repeated_string_18 = 18;
  1668. repeated string repeated_string_19 = 19;
  1669. repeated string repeated_string_20 = 20;
  1670. repeated string repeated_string_21 = 21;
  1671. repeated string repeated_string_22 = 22;
  1672. repeated string repeated_string_23 = 23;
  1673. repeated string repeated_string_24 = 24;
  1674. repeated string repeated_string_25 = 25;
  1675. repeated string repeated_string_26 = 26;
  1676. repeated string repeated_string_27 = 27;
  1677. repeated string repeated_string_28 = 28;
  1678. repeated string repeated_string_29 = 29;
  1679. repeated string repeated_string_30 = 30;
  1680. repeated string repeated_string_31 = 31;
  1681. repeated string repeated_string_32 = 32;
  1682. }