unittest_objc.proto 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2011 Google Inc. All rights reserved.
  3. //
  4. // Redistribution and use in source and binary forms, with or without
  5. // modification, are permitted provided that the following conditions are
  6. // met:
  7. //
  8. // * Redistributions of source code must retain the above copyright
  9. // notice, this list of conditions and the following disclaimer.
  10. // * Redistributions in binary form must reproduce the above
  11. // copyright notice, this list of conditions and the following disclaimer
  12. // in the documentation and/or other materials provided with the
  13. // distribution.
  14. // * Neither the name of Google Inc. nor the names of its
  15. // contributors may be used to endorse or promote products derived from
  16. // this software without specific prior written permission.
  17. //
  18. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. syntax = "proto2";
  30. import "google/protobuf/unittest.proto";
  31. package protobuf_unittest;
  32. // Using the messages in unittest.proto, setup for recursive cases for testing
  33. // extensions at various depths.
  34. extend TestAllExtensions {
  35. optional TestAllExtensions recursive_extension = 86;
  36. }
  37. // Recursive message to for testing autocreators at different depths.
  38. message TestRecursiveMessageWithRepeatedField {
  39. optional TestRecursiveMessageWithRepeatedField a = 1;
  40. repeated int32 i = 2;
  41. repeated string str = 3;
  42. map<int32, int32> i_to_i = 4;
  43. map<string, string> str_to_str = 5;
  44. }
  45. // Recursive message and extension to for testing autocreators at different
  46. // depths.
  47. message TestRecursiveExtension {
  48. optional TestRecursiveExtension recursive_sub_message = 1;
  49. repeated int32 repeated_value = 2;
  50. extensions 1000 to max;
  51. }
  52. extend TestRecursiveExtension {
  53. optional TestRecursiveExtension recursive_message_extension = 1000;
  54. }
  55. message self {
  56. message super {
  57. optional int32 description = 1;
  58. }
  59. enum autorelease {
  60. retain = 1;
  61. release = 2;
  62. retainCount = 3;
  63. }
  64. // Singular
  65. optional bool id = 1;
  66. optional bool _cmd = 2;
  67. optional bool in = 3;
  68. optional bool out = 4;
  69. optional bool inout = 5;
  70. optional bool bycopy = 6;
  71. optional bool byref = 7;
  72. optional bool oneway = 8;
  73. optional bool dealloc = 9;
  74. optional bool zone = 10;
  75. optional bool isProxy = 11;
  76. optional bool copy = 12;
  77. optional bool readonly = 13;
  78. optional bool default = 14;
  79. optional bool assign = 15;
  80. optional bool getter = 16;
  81. optional bool setter = 17;
  82. optional bool weak = 18;
  83. optional bool public = 19;
  84. optional bool case = 20;
  85. optional autorelease SubEnum = 25;
  86. optional group New = 50 {
  87. optional string copy = 51;
  88. }
  89. optional group MutableCopy = 60 {
  90. optional int32 extensionRegistry = 61;
  91. }
  92. extensions 90 to 94;
  93. }
  94. enum retain {
  95. count = 4;
  96. initialized = 5;
  97. serializedSize = 6;
  98. }
  99. // EnumValueShortName: The short names shouldn't get suffixes/prefixes.
  100. enum Foo {
  101. SERIALIZED_SIZE = 1;
  102. SIZE = 2;
  103. OTHER = 3;
  104. }
  105. // EnumValueShortName: The enum name gets a prefix.
  106. enum Category {
  107. RED = 1;
  108. BLUE = 2;
  109. }
  110. // EnumValueShortName: Twist case, full name gets PB, but the short names
  111. // should still end up correct.
  112. enum Time {
  113. BASE = 1;
  114. RECORD = 2;
  115. SOMETHING_ELSE = 3;
  116. }
  117. extend self {
  118. repeated int32 debugDescription = 90 [packed = true];
  119. repeated int64 finalize = 91 [packed = true];
  120. repeated uint32 hash = 92 [packed = true];
  121. repeated uint64 classForCoder = 93 [packed = true];
  122. repeated sint32 byref = 94 [packed = true];
  123. }
  124. // Test handing of fields that start with init* since Xcode 5's ARC support
  125. // doesn't like messages that look like initializers but aren't.
  126. message ObjCInitFoo {
  127. optional string init_val = 11;
  128. optional int32 init_size = 12;
  129. optional self init_self = 13;
  130. repeated string init_vals = 21;
  131. repeated int32 init_sizes = 22;
  132. repeated self init_selfs = 23;
  133. }
  134. // Test handling of fields that start with retained names.
  135. message ObjCRetainedFoo {
  136. optional string new_val_lower_complex = 11;
  137. optional string new_Val_upper_complex = 12;
  138. optional string newvalue_lower_no_underscore_complex = 13;
  139. optional string newValue_upper_no_underscore_complex = 14;
  140. optional int32 new_val_lower_primitive = 15;
  141. optional int32 new_Val_upper_primitive = 16;
  142. optional int32 newvalue_lower_no_underscore_primitive = 17;
  143. optional int32 newValue_upper_no_underscore_primitive = 18;
  144. optional self new_val_lower_message = 19;
  145. optional self new_Val_upper_message = 20;
  146. optional self newvalue_lower_no_underscore_message = 21;
  147. optional self newValue_upper_no_underscore_message = 22;
  148. optional Foo new_val_lower_enum = 23;
  149. optional Foo new_Val_upper_enum = 24;
  150. optional Foo newvalue_lower_no_underscore_enum = 25;
  151. optional Foo newValue_upper_no_underscore_enum = 26;
  152. repeated string new_val_lower_complex_repeated = 111;
  153. repeated string new_Val_upper_complex_repeated = 112;
  154. repeated string newvalue_lower_no_underscore_complex_repeated = 113;
  155. repeated string newValue_upper_no_underscore_complex_repeated = 114;
  156. repeated int32 new_val_lower_primitive_repeated = 115;
  157. repeated int32 new_Val_upper_primitive_repeated = 116;
  158. repeated int32 newvalue_lower_no_underscore_primitive_repeated = 117;
  159. repeated int32 newValue_upper_no_underscore_primitive_repeated = 118;
  160. repeated self new_val_lower_message_repeated = 119;
  161. repeated self new_Val_upper_message_repeated = 120;
  162. repeated self newvalue_lower_no_underscore_message_repeated = 121;
  163. repeated self newValue_upper_no_underscore_message_repeated = 122;
  164. repeated Foo new_val_lower_enum_repeated = 123;
  165. repeated Foo new_Val_upper_enum_repeated = 124;
  166. repeated Foo newvalue_lower_no_underscore_enum_repeated = 125;
  167. repeated Foo newValue_upper_no_underscore_enum_repeated = 126;
  168. optional string alloc_val_lower_complex = 211;
  169. optional string alloc_Val_upper_complex = 212;
  170. optional string allocvalue_lower_no_underscore_complex = 213;
  171. optional string allocValue_upper_no_underscore_complex = 214;
  172. optional int32 alloc_val_lower_primitive = 215;
  173. optional int32 alloc_Val_upper_primitive = 216;
  174. optional int32 allocvalue_lower_no_underscore_primitive = 217;
  175. optional int32 allocValue_upper_no_underscore_primitive = 218;
  176. optional self alloc_val_lower_message = 219;
  177. optional self alloc_Val_upper_message = 220;
  178. optional self allocvalue_lower_no_underscore_message = 221;
  179. optional self allocValue_upper_no_underscore_message = 222;
  180. optional Foo alloc_val_lower_enum = 223;
  181. optional Foo alloc_Val_upper_enum = 224;
  182. optional Foo allocvalue_lower_no_underscore_enum = 225;
  183. optional Foo allocValue_upper_no_underscore_enum = 226;
  184. repeated string alloc_val_lower_complex_repeated = 311;
  185. repeated string alloc_Val_upper_complex_repeated = 312;
  186. repeated string allocvalue_lower_no_underscore_complex_repeated = 313;
  187. repeated string allocValue_upper_no_underscore_complex_repeated = 314;
  188. repeated int32 alloc_val_lower_primitive_repeated = 315;
  189. repeated int32 alloc_Val_upper_primitive_repeated = 316;
  190. repeated int32 allocvalue_lower_no_underscore_primitive_repeated = 317;
  191. repeated int32 allocValue_upper_no_underscore_primitive_repeated = 318;
  192. repeated self alloc_val_lower_message_repeated = 319;
  193. repeated self alloc_Val_upper_message_repeated = 320;
  194. repeated self allocvalue_lower_no_underscore_message_repeated = 321;
  195. repeated self allocValue_upper_no_underscore_message_repeated = 322;
  196. repeated Foo alloc_val_lower_enum_repeated = 323;
  197. repeated Foo alloc_Val_upper_enum_repeated = 324;
  198. repeated Foo allocvalue_lower_no_underscore_enum_repeated = 325;
  199. repeated Foo allocValue_upper_no_underscore_enum_repeated = 326;
  200. optional string copy_val_lower_complex = 411;
  201. optional string copy_Val_upper_complex = 412;
  202. optional string copyvalue_lower_no_underscore_complex = 413;
  203. optional string copyValue_upper_no_underscore_complex = 414;
  204. optional int32 copy_val_lower_primitive = 415;
  205. optional int32 copy_Val_upper_primitive = 416;
  206. optional int32 copyvalue_lower_no_underscore_primitive = 417;
  207. optional int32 copyValue_upper_no_underscore_primitive = 418;
  208. optional self copy_val_lower_message = 419;
  209. optional self copy_Val_upper_message = 420;
  210. optional self copyvalue_lower_no_underscore_message = 421;
  211. optional self copyValue_upper_no_underscore_message = 422;
  212. optional Foo copy_val_lower_enum = 423;
  213. optional Foo copy_Val_upper_enum = 424;
  214. optional Foo copyvalue_lower_no_underscore_enum = 425;
  215. optional Foo copyValue_upper_no_underscore_enum = 426;
  216. repeated string copy_val_lower_complex_repeated = 511;
  217. repeated string copy_Val_upper_complex_repeated = 512;
  218. repeated string copyvalue_lower_no_underscore_complex_repeated = 513;
  219. repeated string copyValue_upper_no_underscore_complex_repeated = 514;
  220. repeated int32 copy_val_lower_primitive_repeated = 515;
  221. repeated int32 copy_Val_upper_primitive_repeated = 516;
  222. repeated int32 copyvalue_lower_no_underscore_primitive_repeated = 517;
  223. repeated int32 copyValue_upper_no_underscore_primitive_repeated = 518;
  224. repeated self copy_val_lower_message_repeated = 519;
  225. repeated self copy_Val_upper_message_repeated = 520;
  226. repeated self copyvalue_lower_no_underscore_message_repeated = 521;
  227. repeated self copyValue_upper_no_underscore_message_repeated = 522;
  228. repeated Foo copy_val_lower_enum_repeated = 523;
  229. repeated Foo copy_Val_upper_enum_repeated = 524;
  230. repeated Foo copyvalue_lower_no_underscore_enum_repeated = 525;
  231. repeated Foo copyValue_upper_no_underscore_enum_repeated = 526;
  232. optional string mutableCopy_val_lower_complex = 611;
  233. optional string mutableCopy_Val_upper_complex = 612;
  234. optional string mutableCopyvalue_lower_no_underscore_complex = 613;
  235. optional string mutableCopyValue_upper_no_underscore_complex = 614;
  236. optional int32 mutableCopy_val_lower_primitive = 615;
  237. optional int32 mutableCopy_Val_upper_primitive = 616;
  238. optional int32 mutableCopyvalue_lower_no_underscore_primitive = 617;
  239. optional int32 mutableCopyValue_upper_no_underscore_primitive = 618;
  240. optional self mutableCopy_val_lower_message = 619;
  241. optional self mutableCopy_Val_upper_message = 620;
  242. optional self mutableCopyvalue_lower_no_underscore_message = 621;
  243. optional self mutableCopyValue_upper_no_underscore_message = 622;
  244. optional Foo mutableCopy_val_lower_enum = 623;
  245. optional Foo mutableCopy_Val_upper_enum = 624;
  246. optional Foo mutableCopyvalue_lower_no_underscore_enum = 625;
  247. optional Foo mutableCopyValue_upper_no_underscore_enum = 626;
  248. repeated string mutableCopy_val_lower_complex_repeated = 711;
  249. repeated string mutableCopy_Val_upper_complex_repeated = 712;
  250. repeated string mutableCopyvalue_lower_no_underscore_complex_repeated = 713;
  251. repeated string mutableCopyValue_upper_no_underscore_complex_repeated = 714;
  252. repeated int32 mutableCopy_val_lower_primitive_repeated = 715;
  253. repeated int32 mutableCopy_Val_upper_primitive_repeated = 716;
  254. repeated int32 mutableCopyvalue_lower_no_underscore_primitive_repeated = 717;
  255. repeated int32 mutableCopyValue_upper_no_underscore_primitive_repeated = 718;
  256. repeated self mutableCopy_val_lower_message_repeated = 719;
  257. repeated self mutableCopy_Val_upper_message_repeated = 720;
  258. repeated self mutableCopyvalue_lower_no_underscore_message_repeated = 721;
  259. repeated self mutableCopyValue_upper_no_underscore_message_repeated = 722;
  260. repeated Foo mutableCopy_val_lower_enum_repeated = 723;
  261. repeated Foo mutableCopy_Val_upper_enum_repeated = 724;
  262. repeated Foo mutableCopyvalue_lower_no_underscore_enum_repeated = 725;
  263. repeated Foo mutableCopyValue_upper_no_underscore_enum_repeated = 726;
  264. }
  265. // Test handling of fields that are the retained names.
  266. message ObjCRetainedComplex {
  267. optional string new = 1;
  268. optional string alloc = 2;
  269. optional string copy = 3;
  270. optional string mutableCopy = 4;
  271. }
  272. message ObjCRetainedComplexRepeated {
  273. repeated string new = 1;
  274. repeated string alloc = 2;
  275. repeated string copy = 3;
  276. repeated string mutableCopy = 4;
  277. }
  278. message ObjCRetainedPrimitive {
  279. optional int32 new = 1;
  280. optional int32 alloc = 2;
  281. optional int32 copy = 3;
  282. optional int32 mutableCopy = 4;
  283. }
  284. message ObjCRetainedPrimitiveRepeated {
  285. repeated int32 new = 1;
  286. repeated int32 alloc = 2;
  287. repeated int32 copy = 3;
  288. repeated int32 mutableCopy = 4;
  289. }
  290. message ObjCRetainedMessage {
  291. optional self new = 1;
  292. optional self alloc = 2;
  293. optional self copy = 3;
  294. optional self mutableCopy = 4;
  295. }
  296. message ObjCRetainedMessageRepeated {
  297. repeated self new = 1;
  298. repeated self alloc = 2;
  299. repeated self copy = 3;
  300. repeated self mutableCopy = 4;
  301. }
  302. // Test Handling some MacTypes
  303. message Point {
  304. message Rect {
  305. optional int32 TimeValue = 1;
  306. }
  307. }
  308. // Test some weird defaults that we see in protos.
  309. message ObjcWeirdDefaults {
  310. // Set default values that match the protocol buffer defined defaults to
  311. // confirm hasDefault and the default values are set correctly.
  312. optional string foo = 1 [default = ""];
  313. optional bytes bar = 2 [default = ""];
  314. }
  315. // Used to confirm negative enum values work as expected.
  316. message EnumTestMsg {
  317. enum MyEnum {
  318. ZERO = 0;
  319. ONE = 1;
  320. TWO = 2;
  321. NEG_ONE = -1;
  322. NEG_TWO = -2;
  323. }
  324. optional MyEnum foo = 1;
  325. optional MyEnum bar = 2 [default = ONE];
  326. optional MyEnum baz = 3 [default = NEG_ONE];
  327. repeated MyEnum mumble = 4;
  328. }