blob: 22bf095f333bff6f148301e879c11dbc572b8881 [file] [log] [blame]
David Reissea2cba82009-03-30 21:35:00 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
Roger Meier213a6642010-10-27 12:30:11 +000020namespace c_glib TTest
David Reiss2a4bfd62008-04-07 23:45:00 +000021namespace cpp thrift.test.debug
David Reiss3b15ebc2008-03-02 06:29:19 +000022namespace java thrift.test
Jens Geyer123258b2015-10-02 00:38:17 +020023namespace rb thrift.test
David Reiss00dcccf2007-07-21 01:18:10 +000024
David Reissdb0ea152008-02-18 01:49:37 +000025struct Doubles {
26 1: double nan,
27 2: double inf,
28 3: double neginf,
29 4: double repeating,
30 5: double big,
Roger Meier22888ce2014-02-09 11:31:02 +010031 6: double tiny,
David Reissdb0ea152008-02-18 01:49:37 +000032 7: double zero,
33 8: double negzero,
34}
35
David Reiss00dcccf2007-07-21 01:18:10 +000036struct OneOfEach {
37 1: bool im_true,
38 2: bool im_false,
Nobuaki Sukegawaeb344a82016-03-25 09:37:18 +090039 3: i8 a_bite = 0x7f,
Christian Lavoiecbf87cb2010-11-28 14:34:26 +000040 4: i16 integer16 = 0x7fff,
David Reiss00dcccf2007-07-21 01:18:10 +000041 5: i32 integer32,
David Reissa8efac82008-12-16 20:28:13 +000042 6: i64 integer64 = 10000000000,
David Reiss00dcccf2007-07-21 01:18:10 +000043 7: double double_precision,
44 8: string some_characters,
45 9: string zomg_unicode,
46 10: bool what_who,
David Reissdb0ea152008-02-18 01:49:37 +000047 11: binary base64,
Nobuaki Sukegawaeb344a82016-03-25 09:37:18 +090048 12: list<i8> byte_list = [1, 2, 3],
David Reissa8efac82008-12-16 20:28:13 +000049 13: list<i16> i16_list = [1,2,3],
Carel Combrink4035ecc2025-05-14 08:39:55 +020050 14: list<i64> i64_list = [1,2,3],
51 15: uuid rfc4122_uuid,
52 16: list<uuid> rfc4122_uuid_list,
David Reiss00dcccf2007-07-21 01:18:10 +000053}
54
55struct Bonk {
56 1: i32 type,
57 2: string message,
58}
59
60struct Nesting {
61 1: Bonk my_bonk,
62 2: OneOfEach my_ooe,
63}
64
65struct HolyMoley {
66 1: list<OneOfEach> big,
Nobuaki Sukegawa7b894692015-12-23 21:45:06 +090067 2: set<list<string> (python.immutable = "")> contain,
David Reiss00dcccf2007-07-21 01:18:10 +000068 3: map<string,list<Bonk>> bonks,
69}
David Reiss382fc302007-08-25 18:01:30 +000070
71struct Backwards {
72 2: i32 first_tag2,
73 1: i32 second_tag1,
74}
75
76struct Empty {
Nobuaki Sukegawae841b3d2015-11-17 11:01:17 +090077} (
78 python.immutable = "",
79)
David Reiss382fc302007-08-25 18:01:30 +000080
81struct Wrapper {
82 1: Empty foo
Nobuaki Sukegawae841b3d2015-11-17 11:01:17 +090083} (
84 python.immutable = "",
85)
David Reiss382fc302007-08-25 18:01:30 +000086
87struct RandomStuff {
88 1: i32 a,
89 2: i32 b,
90 3: i32 c,
91 4: i32 d,
92 5: list<i32> myintlist,
93 6: map<i32,Wrapper> maps,
94 7: i64 bigint,
95 8: double triple,
96}
97
David Reiss4a8f46c2008-03-07 20:12:07 +000098struct Base64 {
99 1: i32 a,
100 2: binary b1,
101 3: binary b2,
102 4: binary b3,
103 5: binary b4,
104 6: binary b5,
105 7: binary b6,
106}
107
Bryan Duxbury538e3442009-02-10 04:49:39 +0000108struct CompactProtoTestStruct {
109 // primitive fields
Nobuaki Sukegawaeb344a82016-03-25 09:37:18 +0900110 1: i8 a_byte;
David Reissfe5b77d2009-04-07 20:51:48 +0000111 2: i16 a_i16;
112 3: i32 a_i32;
113 4: i64 a_i64;
114 5: double a_double;
115 6: string a_string;
Bryan Duxbury538e3442009-02-10 04:49:39 +0000116 7: binary a_binary;
David Reissfe5b77d2009-04-07 20:51:48 +0000117 8: bool true_field;
118 9: bool false_field;
119 10: Empty empty_struct_field;
Jens Geyeraaa89472014-10-03 20:22:28 +0200120
Bryan Duxbury538e3442009-02-10 04:49:39 +0000121 // primitives in lists
Nobuaki Sukegawaeb344a82016-03-25 09:37:18 +0900122 11: list<i8> byte_list;
David Reissfe5b77d2009-04-07 20:51:48 +0000123 12: list<i16> i16_list;
124 13: list<i32> i32_list;
125 14: list<i64> i64_list;
126 15: list<double> double_list;
127 16: list<string> string_list;
Bryan Duxbury538e3442009-02-10 04:49:39 +0000128 17: list<binary> binary_list;
David Reissfe5b77d2009-04-07 20:51:48 +0000129 18: list<bool> boolean_list;
130 19: list<Empty> struct_list;
Jens Geyeraaa89472014-10-03 20:22:28 +0200131
Bryan Duxbury538e3442009-02-10 04:49:39 +0000132 // primitives in sets
Nobuaki Sukegawaeb344a82016-03-25 09:37:18 +0900133 20: set<i8> byte_set;
David Reissfe5b77d2009-04-07 20:51:48 +0000134 21: set<i16> i16_set;
135 22: set<i32> i32_set;
136 23: set<i64> i64_set;
137 24: set<double> double_set;
138 25: set<string> string_set;
Bryan Duxbury538e3442009-02-10 04:49:39 +0000139 26: set<binary> binary_set;
David Reissfe5b77d2009-04-07 20:51:48 +0000140 27: set<bool> boolean_set;
141 28: set<Empty> struct_set;
Jens Geyeraaa89472014-10-03 20:22:28 +0200142
Bryan Duxbury538e3442009-02-10 04:49:39 +0000143 // maps
144 // primitives as keys
Nobuaki Sukegawaeb344a82016-03-25 09:37:18 +0900145 29: map<i8, i8> byte_byte_map;
146 30: map<i16, i8> i16_byte_map;
147 31: map<i32, i8> i32_byte_map;
148 32: map<i64, i8> i64_byte_map;
149 33: map<double, i8> double_byte_map;
150 34: map<string, i8> string_byte_map;
151 35: map<binary, i8> binary_byte_map;
152 36: map<bool, i8> boolean_byte_map;
Bryan Duxbury538e3442009-02-10 04:49:39 +0000153 // primitives as values
Nobuaki Sukegawaeb344a82016-03-25 09:37:18 +0900154 37: map<i8, i16> byte_i16_map;
155 38: map<i8, i32> byte_i32_map;
156 39: map<i8, i64> byte_i64_map;
157 40: map<i8, double> byte_double_map;
158 41: map<i8, string> byte_string_map;
159 42: map<i8, binary> byte_binary_map;
160 43: map<i8, bool> byte_boolean_map;
Bryan Duxbury538e3442009-02-10 04:49:39 +0000161 // collections as keys
Nobuaki Sukegawaeb344a82016-03-25 09:37:18 +0900162 44: map<list<i8> (python.immutable = ""), i8> list_byte_map;
163 45: map<set<i8> (python.immutable = ""), i8> set_byte_map;
164 46: map<map<i8,i8> (python.immutable = ""), i8> map_byte_map;
Bryan Duxbury538e3442009-02-10 04:49:39 +0000165 // collections as values
Nobuaki Sukegawaeb344a82016-03-25 09:37:18 +0900166 47: map<i8, map<i8,i8>> byte_map_map;
167 48: map<i8, set<i8>> byte_set_map;
168 49: map<i8, list<i8>> byte_list_map;
Jens Geyera715f702019-08-28 22:56:13 +0200169
170 // large field IDs
171 500 : i64 field500;
172 5000 : i64 field5000;
173 20000 : i64 field20000;
David Reissfe5b77d2009-04-07 20:51:48 +0000174}
175
Bryan Duxburye80a1942011-09-20 18:45:56 +0000176// To be used to test the serialization of an empty map
177struct SingleMapTestStruct {
178 1: required map<i32, i32> i32_map;
179}
David Reissfe5b77d2009-04-07 20:51:48 +0000180
181const CompactProtoTestStruct COMPACT_TEST = {
182 'a_byte' : 127,
183 'a_i16' : 32000,
184 'a_i32' : 1000000000,
185 'a_i64' : 0xffffffffff,
186 'a_double' : 5.6789,
187 'a_string' : "my string",
188//'a_binary,'
189 'true_field' : 1,
190 'false_field' : 0,
191 'empty_struct_field' : {},
192 'byte_list' : [-127, -1, 0, 1, 127],
193 'i16_list' : [-1, 0, 1, 0x7fff],
194 'i32_list' : [-1, 0, 0xff, 0xffff, 0xffffff, 0x7fffffff],
195 'i64_list' : [-1, 0, 0xff, 0xffff, 0xffffff, 0xffffffff, 0xffffffffff, 0xffffffffffff, 0xffffffffffffff, 0x7fffffffffffffff],
196 'double_list' : [0.1, 0.2, 0.3],
197 'string_list' : ["first", "second", "third"],
198//'binary_list,'
199 'boolean_list' : [1, 1, 1, 0, 0, 0],
200 'struct_list' : [{}, {}],
201 'byte_set' : [-127, -1, 0, 1, 127],
202 'i16_set' : [-1, 0, 1, 0x7fff],
203 'i32_set' : [1, 2, 3],
204 'i64_set' : [-1, 0, 0xff, 0xffff, 0xffffff, 0xffffffff, 0xffffffffff, 0xffffffffffff, 0xffffffffffffff, 0x7fffffffffffffff],
205 'double_set' : [0.1, 0.2, 0.3],
206 'string_set' : ["first", "second", "third"],
207//'binary_set,'
208 'boolean_set' : [1, 0],
209 'struct_set' : [{}],
210 'byte_byte_map' : {1 : 2},
211 'i16_byte_map' : {1 : 1, -1 : 1, 0x7fff : 1},
212 'i32_byte_map' : {1 : 1, -1 : 1, 0x7fffffff : 1},
213 'i64_byte_map' : {0 : 1, 1 : 1, -1 : 1, 0x7fffffffffffffff : 1},
214 'double_byte_map' : {-1.1 : 1, 1.1 : 1},
215 'string_byte_map' : {"first" : 1, "second" : 2, "third" : 3, "" : 0},
216//'binary_byte_map,'
217 'boolean_byte_map' : {1 : 1, 0 : 0},
218 'byte_i16_map' : {1 : 1, 2 : -1, 3 : 0x7fff},
219 'byte_i32_map' : {1 : 1, 2 : -1, 3 : 0x7fffffff},
220 'byte_i64_map' : {1 : 1, 2 : -1, 3 : 0x7fffffffffffffff},
221 'byte_double_map' : {1 : 0.1, 2 : -0.1, 3 : 1000000.1},
222 'byte_string_map' : {1 : "", 2 : "blah", 3 : "loooooooooooooong string"},
223//'byte_binary_map,'
224 'byte_boolean_map' : {1 : 1, 2 : 0},
225 'list_byte_map' : {[1, 2, 3] : 1, [0, 1] : 2, [] : 0},
226 'set_byte_map' : {[1, 2, 3] : 1, [0, 1] : 2, [] : 0},
227 'map_byte_map' : {{1 : 1} : 1, {2 : 2} : 2, {} : 0},
228 'byte_map_map' : {0 : {}, 1 : {1 : 1}, 2 : {1 : 1, 2 : 2}},
229 'byte_set_map' : {0 : [], 1 : [1], 2 : [1, 2]},
230 'byte_list_map' : {0 : [], 1 : [1], 2 : [1, 2]},
Jens Geyer8ff8abd2019-09-10 00:30:05 +0200231
232 'field500' : 500,
233 'field5000' : 5000,
234 'field20000' : 20000,
Bryan Duxbury538e3442009-02-10 04:49:39 +0000235}
Bryan Duxbury5b8b4842009-04-01 20:10:15 +0000236
237
Bryan Duxbury2d804702009-12-18 19:41:11 +0000238const i32 MYCONST = 2
Bryan Duxbury5b8b4842009-04-01 20:10:15 +0000239
Bryan Duxbury986d50f2009-12-31 18:18:00 +0000240
241exception ExceptionWithAMap {
242 1: string blah;
243 2: map<string, string> map_field;
244}
245
Elvis Pranskevichus9c439622019-12-11 16:47:52 -0500246exception MutableException {
247 1: string msg;
248} (python.immutable = "false")
249
Neil Williams055fe672021-02-16 15:12:15 -0800250exception ExceptionWithoutFields {}
251
Bryan Duxbury986d50f2009-12-31 18:18:00 +0000252service ServiceForExceptionWithAMap {
253 void methodThatThrowsAnException() throws (1: ExceptionWithAMap xwamap);
254}
255
Bryan Duxbury5b8b4842009-04-01 20:10:15 +0000256service Srv {
David Reiss689c9ad2009-04-02 19:24:02 +0000257 i32 Janky(1: i32 arg);
Bryan Duxburyd58ccec2010-05-26 16:34:48 +0000258
Bryan Duxbury5b8b4842009-04-01 20:10:15 +0000259 // return type only methods
Bryan Duxburyd58ccec2010-05-26 16:34:48 +0000260
Bryan Duxbury5b8b4842009-04-01 20:10:15 +0000261 void voidMethod();
262 i32 primitiveMethod();
263 CompactProtoTestStruct structMethod();
Bryan Duxburyd58ccec2010-05-26 16:34:48 +0000264
Bryan Duxbury2d804702009-12-18 19:41:11 +0000265 void methodWithDefaultArgs(1: i32 something = MYCONST);
Bryan Duxburyd58ccec2010-05-26 16:34:48 +0000266
267 oneway void onewayMethod();
John Siroisbd964c72016-02-08 13:04:36 -0700268
269 bool declaredExceptionMethod(1: bool shouldThrow) throws (1: ExceptionWithAMap xwamap);
Bryan Duxbury5b8b4842009-04-01 20:10:15 +0000270}
271
272service Inherited extends Srv {
David Reiss689c9ad2009-04-02 19:24:02 +0000273 i32 identity(1: i32 arg)
Bryan Duxbury5b8b4842009-04-01 20:10:15 +0000274}
275
276service EmptyService {}
277
278// The only purpose of this thing is to increase the size of the generated code
279// so that ZlibTest has more highly compressible data to play with.
280struct BlowUp {
Nobuaki Sukegawa7b894692015-12-23 21:45:06 +0900281 1: map<list<i32>(python.immutable = ""),set<map<i32,string> (python.immutable = "")>> b1;
282 2: map<list<i32>(python.immutable = ""),set<map<i32,string> (python.immutable = "")>> b2;
283 3: map<list<i32>(python.immutable = ""),set<map<i32,string> (python.immutable = "")>> b3;
284 4: map<list<i32>(python.immutable = ""),set<map<i32,string> (python.immutable = "")>> b4;
Bryan Duxbury5b8b4842009-04-01 20:10:15 +0000285}
286
Bryan Duxburyff219ac2009-04-10 21:51:00 +0000287
288struct ReverseOrderStruct {
289 4: string first;
290 3: i16 second;
291 2: i32 third;
292 1: i64 fourth;
293}
294
295service ReverseOrderService {
296 void myMethod(4: string first, 3: i16 second, 2: i32 third, 1: i64 fourth);
Bryan Duxburyab3666e2009-09-01 23:03:47 +0000297}
298
Bryan Duxbury9af23d92009-11-19 17:26:38 +0000299enum SomeEnum {
Bryan Duxbury2d804702009-12-18 19:41:11 +0000300 ONE = 1
301 TWO = 2
302}
303
Bryan Duxburyd4235e02010-09-13 16:28:53 +0000304/** This is a docstring on a constant! */
Bryan Duxbury6e05e252010-09-12 15:22:49 +0000305const SomeEnum MY_SOME_ENUM = SomeEnum.ONE
Bryan Duxbury2d804702009-12-18 19:41:11 +0000306
307const SomeEnum MY_SOME_ENUM_1 = 1
308/*const SomeEnum MY_SOME_ENUM_2 = 7*/
309
310const map<SomeEnum,SomeEnum> MY_ENUM_MAP = {
Bryan Duxbury6e05e252010-09-12 15:22:49 +0000311 SomeEnum.ONE : SomeEnum.TWO
Bryan Duxbury2d804702009-12-18 19:41:11 +0000312}
313
314struct StructWithSomeEnum {
315 1: SomeEnum blah;
316}
317
318const map<SomeEnum,StructWithSomeEnum> EXTRA_CRAZY_MAP = {
Bryan Duxbury6e05e252010-09-12 15:22:49 +0000319 SomeEnum.ONE : {"blah" : SomeEnum.TWO}
Bryan Duxbury9af23d92009-11-19 17:26:38 +0000320}
321
Bryan Duxburyab3666e2009-09-01 23:03:47 +0000322union TestUnion {
323 /**
324 * A doc string
325 */
326 1: string string_field;
327 2: i32 i32_field;
328 3: OneOfEach struct_field;
329 4: list<RandomStuff> struct_list;
330 5: i32 other_i32_field;
Bryan Duxbury9af23d92009-11-19 17:26:38 +0000331 6: SomeEnum enum_field;
Bryan Duxbury162b3ac2010-06-23 21:17:48 +0000332 7: set<i32> i32_set;
333 8: map<i32, i32> i32_map;
Bryan Duxburyab3666e2009-09-01 23:03:47 +0000334}
335
Bryan Duxburyc2ec7ca2009-12-31 18:59:15 +0000336union TestUnionMinusStringField {
337 2: i32 i32_field;
338 3: OneOfEach struct_field;
339 4: list<RandomStuff> struct_list;
340 5: i32 other_i32_field;
341 6: SomeEnum enum_field;
Bryan Duxbury162b3ac2010-06-23 21:17:48 +0000342 7: set<i32> i32_set;
343 8: map<i32, i32> i32_map;
Bryan Duxburyc2ec7ca2009-12-31 18:59:15 +0000344}
345
Bryan Duxburye2e4ea12009-11-11 21:01:35 +0000346union ComparableUnion {
347 1: string string_field;
348 2: binary binary_field;
349}
350
Bryan Duxburyab3666e2009-09-01 23:03:47 +0000351struct StructWithAUnion {
352 1: TestUnion test_union;
Bryan Duxbury51f28802009-10-01 20:53:45 +0000353}
354
355struct PrimitiveThenStruct {
356 1: i32 blah;
357 2: i32 blah2;
358 3: Backwards bw;
Bryan Duxbury2845b162009-11-09 15:55:22 +0000359}
360
361typedef map<i32,i32> SomeMap
362
363struct StructWithASomemap {
364 1: required SomeMap somemap_field;
Bryan Duxbury986d50f2009-12-31 18:18:00 +0000365}
Bryan Duxbury35565a42010-01-06 23:12:09 +0000366
367struct BigFieldIdStruct {
368 1: string field1;
369 45: string field2;
370}
371
372struct BreaksRubyCompactProtocol {
373 1: string field1;
374 2: BigFieldIdStruct field2;
375 3: i32 field3;
Bryan Duxbury162b3ac2010-06-23 21:17:48 +0000376}
377
Bryan Duxbury40d51a22011-09-26 21:29:15 +0000378struct TupleProtocolTestStruct {
379 optional i32 field1;
380 optional i32 field2;
381 optional i32 field3;
382 optional i32 field4;
383 optional i32 field5;
384 optional i32 field6;
385 optional i32 field7;
386 optional i32 field8;
387 optional i32 field9;
388 optional i32 field10;
389 optional i32 field11;
390 optional i32 field12;
Ben Craig384f9762015-07-08 20:33:03 -0500391}
392
393struct ListDoublePerf {
394 1: list<double> field;
395}