blob: 23d5d97373f52047397cc28e75684a474ebbf2c6 [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
David Reiss00dcccf2007-07-21 01:18:10 +000023
David Reissdb0ea152008-02-18 01:49:37 +000024struct Doubles {
25 1: double nan,
26 2: double inf,
27 3: double neginf,
28 4: double repeating,
29 5: double big,
30 6: double small,
31 7: double zero,
32 8: double negzero,
33}
34
David Reiss00dcccf2007-07-21 01:18:10 +000035struct OneOfEach {
36 1: bool im_true,
37 2: bool im_false,
Christian Lavoiecbf87cb2010-11-28 14:34:26 +000038 3: byte a_bite = 0x7f,
39 4: i16 integer16 = 0x7fff,
David Reiss00dcccf2007-07-21 01:18:10 +000040 5: i32 integer32,
David Reissa8efac82008-12-16 20:28:13 +000041 6: i64 integer64 = 10000000000,
David Reiss00dcccf2007-07-21 01:18:10 +000042 7: double double_precision,
43 8: string some_characters,
44 9: string zomg_unicode,
45 10: bool what_who,
David Reissdb0ea152008-02-18 01:49:37 +000046 11: binary base64,
David Reissa8efac82008-12-16 20:28:13 +000047 12: list<byte> byte_list = [1, 2, 3],
48 13: list<i16> i16_list = [1,2,3],
49 14: list<i64> i64_list = [1,2,3]
David Reiss00dcccf2007-07-21 01:18:10 +000050}
51
52struct Bonk {
53 1: i32 type,
54 2: string message,
55}
56
57struct Nesting {
58 1: Bonk my_bonk,
59 2: OneOfEach my_ooe,
60}
61
62struct HolyMoley {
63 1: list<OneOfEach> big,
64 2: set<list<string>> contain,
65 3: map<string,list<Bonk>> bonks,
66}
David Reiss382fc302007-08-25 18:01:30 +000067
68struct Backwards {
69 2: i32 first_tag2,
70 1: i32 second_tag1,
71}
72
73struct Empty {
74}
75
76struct Wrapper {
77 1: Empty foo
78}
79
80struct RandomStuff {
81 1: i32 a,
82 2: i32 b,
83 3: i32 c,
84 4: i32 d,
85 5: list<i32> myintlist,
86 6: map<i32,Wrapper> maps,
87 7: i64 bigint,
88 8: double triple,
89}
90
David Reiss4a8f46c2008-03-07 20:12:07 +000091struct Base64 {
92 1: i32 a,
93 2: binary b1,
94 3: binary b2,
95 4: binary b3,
96 5: binary b4,
97 6: binary b5,
98 7: binary b6,
99}
100
Bryan Duxbury538e3442009-02-10 04:49:39 +0000101struct CompactProtoTestStruct {
102 // primitive fields
David Reissfe5b77d2009-04-07 20:51:48 +0000103 1: byte a_byte;
104 2: i16 a_i16;
105 3: i32 a_i32;
106 4: i64 a_i64;
107 5: double a_double;
108 6: string a_string;
Bryan Duxbury538e3442009-02-10 04:49:39 +0000109 7: binary a_binary;
David Reissfe5b77d2009-04-07 20:51:48 +0000110 8: bool true_field;
111 9: bool false_field;
112 10: Empty empty_struct_field;
Bryan Duxbury538e3442009-02-10 04:49:39 +0000113
114 // primitives in lists
David Reissfe5b77d2009-04-07 20:51:48 +0000115 11: list<byte> byte_list;
116 12: list<i16> i16_list;
117 13: list<i32> i32_list;
118 14: list<i64> i64_list;
119 15: list<double> double_list;
120 16: list<string> string_list;
Bryan Duxbury538e3442009-02-10 04:49:39 +0000121 17: list<binary> binary_list;
David Reissfe5b77d2009-04-07 20:51:48 +0000122 18: list<bool> boolean_list;
123 19: list<Empty> struct_list;
Bryan Duxbury538e3442009-02-10 04:49:39 +0000124
125 // primitives in sets
David Reissfe5b77d2009-04-07 20:51:48 +0000126 20: set<byte> byte_set;
127 21: set<i16> i16_set;
128 22: set<i32> i32_set;
129 23: set<i64> i64_set;
130 24: set<double> double_set;
131 25: set<string> string_set;
Bryan Duxbury538e3442009-02-10 04:49:39 +0000132 26: set<binary> binary_set;
David Reissfe5b77d2009-04-07 20:51:48 +0000133 27: set<bool> boolean_set;
134 28: set<Empty> struct_set;
Bryan Duxbury538e3442009-02-10 04:49:39 +0000135
136 // maps
137 // primitives as keys
David Reissfe5b77d2009-04-07 20:51:48 +0000138 29: map<byte, byte> byte_byte_map;
139 30: map<i16, byte> i16_byte_map;
140 31: map<i32, byte> i32_byte_map;
141 32: map<i64, byte> i64_byte_map;
142 33: map<double, byte> double_byte_map;
143 34: map<string, byte> string_byte_map;
Bryan Duxbury538e3442009-02-10 04:49:39 +0000144 35: map<binary, byte> binary_byte_map;
David Reissfe5b77d2009-04-07 20:51:48 +0000145 36: map<bool, byte> boolean_byte_map;
Bryan Duxbury538e3442009-02-10 04:49:39 +0000146 // primitives as values
David Reissfe5b77d2009-04-07 20:51:48 +0000147 37: map<byte, i16> byte_i16_map;
148 38: map<byte, i32> byte_i32_map;
149 39: map<byte, i64> byte_i64_map;
150 40: map<byte, double> byte_double_map;
151 41: map<byte, string> byte_string_map;
Bryan Duxbury538e3442009-02-10 04:49:39 +0000152 42: map<byte, binary> byte_binary_map;
David Reissfe5b77d2009-04-07 20:51:48 +0000153 43: map<byte, bool> byte_boolean_map;
Bryan Duxbury538e3442009-02-10 04:49:39 +0000154 // collections as keys
David Reissfe5b77d2009-04-07 20:51:48 +0000155 44: map<list<byte>, byte> list_byte_map;
156 45: map<set<byte>, byte> set_byte_map;
157 46: map<map<byte,byte>, byte> map_byte_map;
Bryan Duxbury538e3442009-02-10 04:49:39 +0000158 // collections as values
David Reissfe5b77d2009-04-07 20:51:48 +0000159 47: map<byte, map<byte,byte>> byte_map_map;
160 48: map<byte, set<byte>> byte_set_map;
161 49: map<byte, list<byte>> byte_list_map;
162}
163
164
165const CompactProtoTestStruct COMPACT_TEST = {
166 'a_byte' : 127,
167 'a_i16' : 32000,
168 'a_i32' : 1000000000,
169 'a_i64' : 0xffffffffff,
170 'a_double' : 5.6789,
171 'a_string' : "my string",
172//'a_binary,'
173 'true_field' : 1,
174 'false_field' : 0,
175 'empty_struct_field' : {},
176 'byte_list' : [-127, -1, 0, 1, 127],
177 'i16_list' : [-1, 0, 1, 0x7fff],
178 'i32_list' : [-1, 0, 0xff, 0xffff, 0xffffff, 0x7fffffff],
179 'i64_list' : [-1, 0, 0xff, 0xffff, 0xffffff, 0xffffffff, 0xffffffffff, 0xffffffffffff, 0xffffffffffffff, 0x7fffffffffffffff],
180 'double_list' : [0.1, 0.2, 0.3],
181 'string_list' : ["first", "second", "third"],
182//'binary_list,'
183 'boolean_list' : [1, 1, 1, 0, 0, 0],
184 'struct_list' : [{}, {}],
185 'byte_set' : [-127, -1, 0, 1, 127],
186 'i16_set' : [-1, 0, 1, 0x7fff],
187 'i32_set' : [1, 2, 3],
188 'i64_set' : [-1, 0, 0xff, 0xffff, 0xffffff, 0xffffffff, 0xffffffffff, 0xffffffffffff, 0xffffffffffffff, 0x7fffffffffffffff],
189 'double_set' : [0.1, 0.2, 0.3],
190 'string_set' : ["first", "second", "third"],
191//'binary_set,'
192 'boolean_set' : [1, 0],
193 'struct_set' : [{}],
194 'byte_byte_map' : {1 : 2},
195 'i16_byte_map' : {1 : 1, -1 : 1, 0x7fff : 1},
196 'i32_byte_map' : {1 : 1, -1 : 1, 0x7fffffff : 1},
197 'i64_byte_map' : {0 : 1, 1 : 1, -1 : 1, 0x7fffffffffffffff : 1},
198 'double_byte_map' : {-1.1 : 1, 1.1 : 1},
199 'string_byte_map' : {"first" : 1, "second" : 2, "third" : 3, "" : 0},
200//'binary_byte_map,'
201 'boolean_byte_map' : {1 : 1, 0 : 0},
202 'byte_i16_map' : {1 : 1, 2 : -1, 3 : 0x7fff},
203 'byte_i32_map' : {1 : 1, 2 : -1, 3 : 0x7fffffff},
204 'byte_i64_map' : {1 : 1, 2 : -1, 3 : 0x7fffffffffffffff},
205 'byte_double_map' : {1 : 0.1, 2 : -0.1, 3 : 1000000.1},
206 'byte_string_map' : {1 : "", 2 : "blah", 3 : "loooooooooooooong string"},
207//'byte_binary_map,'
208 'byte_boolean_map' : {1 : 1, 2 : 0},
209 'list_byte_map' : {[1, 2, 3] : 1, [0, 1] : 2, [] : 0},
210 'set_byte_map' : {[1, 2, 3] : 1, [0, 1] : 2, [] : 0},
211 'map_byte_map' : {{1 : 1} : 1, {2 : 2} : 2, {} : 0},
212 'byte_map_map' : {0 : {}, 1 : {1 : 1}, 2 : {1 : 1, 2 : 2}},
213 'byte_set_map' : {0 : [], 1 : [1], 2 : [1, 2]},
214 'byte_list_map' : {0 : [], 1 : [1], 2 : [1, 2]},
Bryan Duxbury538e3442009-02-10 04:49:39 +0000215}
Bryan Duxbury5b8b4842009-04-01 20:10:15 +0000216
217
Bryan Duxbury2d804702009-12-18 19:41:11 +0000218const i32 MYCONST = 2
Bryan Duxbury5b8b4842009-04-01 20:10:15 +0000219
Bryan Duxbury986d50f2009-12-31 18:18:00 +0000220
221exception ExceptionWithAMap {
222 1: string blah;
223 2: map<string, string> map_field;
224}
225
226service ServiceForExceptionWithAMap {
227 void methodThatThrowsAnException() throws (1: ExceptionWithAMap xwamap);
228}
229
Bryan Duxbury5b8b4842009-04-01 20:10:15 +0000230service Srv {
David Reiss689c9ad2009-04-02 19:24:02 +0000231 i32 Janky(1: i32 arg);
Bryan Duxburyd58ccec2010-05-26 16:34:48 +0000232
Bryan Duxbury5b8b4842009-04-01 20:10:15 +0000233 // return type only methods
Bryan Duxburyd58ccec2010-05-26 16:34:48 +0000234
Bryan Duxbury5b8b4842009-04-01 20:10:15 +0000235 void voidMethod();
236 i32 primitiveMethod();
237 CompactProtoTestStruct structMethod();
Bryan Duxburyd58ccec2010-05-26 16:34:48 +0000238
Bryan Duxbury2d804702009-12-18 19:41:11 +0000239 void methodWithDefaultArgs(1: i32 something = MYCONST);
Bryan Duxburyd58ccec2010-05-26 16:34:48 +0000240
241 oneway void onewayMethod();
Bryan Duxbury5b8b4842009-04-01 20:10:15 +0000242}
243
244service Inherited extends Srv {
David Reiss689c9ad2009-04-02 19:24:02 +0000245 i32 identity(1: i32 arg)
Bryan Duxbury5b8b4842009-04-01 20:10:15 +0000246}
247
248service EmptyService {}
249
250// The only purpose of this thing is to increase the size of the generated code
251// so that ZlibTest has more highly compressible data to play with.
252struct BlowUp {
253 1: map<list<i32>,set<map<i32,string>>> b1;
254 2: map<list<i32>,set<map<i32,string>>> b2;
255 3: map<list<i32>,set<map<i32,string>>> b3;
256 4: map<list<i32>,set<map<i32,string>>> b4;
257}
258
Bryan Duxburyff219ac2009-04-10 21:51:00 +0000259
260struct ReverseOrderStruct {
261 4: string first;
262 3: i16 second;
263 2: i32 third;
264 1: i64 fourth;
265}
266
267service ReverseOrderService {
268 void myMethod(4: string first, 3: i16 second, 2: i32 third, 1: i64 fourth);
Bryan Duxburyab3666e2009-09-01 23:03:47 +0000269}
270
Bryan Duxbury9af23d92009-11-19 17:26:38 +0000271enum SomeEnum {
Bryan Duxbury2d804702009-12-18 19:41:11 +0000272 ONE = 1
273 TWO = 2
274}
275
Bryan Duxburyd4235e02010-09-13 16:28:53 +0000276/** This is a docstring on a constant! */
Bryan Duxbury6e05e252010-09-12 15:22:49 +0000277const SomeEnum MY_SOME_ENUM = SomeEnum.ONE
Bryan Duxbury2d804702009-12-18 19:41:11 +0000278
279const SomeEnum MY_SOME_ENUM_1 = 1
280/*const SomeEnum MY_SOME_ENUM_2 = 7*/
281
282const map<SomeEnum,SomeEnum> MY_ENUM_MAP = {
Bryan Duxbury6e05e252010-09-12 15:22:49 +0000283 SomeEnum.ONE : SomeEnum.TWO
Bryan Duxbury2d804702009-12-18 19:41:11 +0000284}
285
286struct StructWithSomeEnum {
287 1: SomeEnum blah;
288}
289
290const map<SomeEnum,StructWithSomeEnum> EXTRA_CRAZY_MAP = {
Bryan Duxbury6e05e252010-09-12 15:22:49 +0000291 SomeEnum.ONE : {"blah" : SomeEnum.TWO}
Bryan Duxbury9af23d92009-11-19 17:26:38 +0000292}
293
Bryan Duxburyab3666e2009-09-01 23:03:47 +0000294union TestUnion {
295 /**
296 * A doc string
297 */
298 1: string string_field;
299 2: i32 i32_field;
300 3: OneOfEach struct_field;
301 4: list<RandomStuff> struct_list;
302 5: i32 other_i32_field;
Bryan Duxbury9af23d92009-11-19 17:26:38 +0000303 6: SomeEnum enum_field;
Bryan Duxbury162b3ac2010-06-23 21:17:48 +0000304 7: set<i32> i32_set;
305 8: map<i32, i32> i32_map;
Bryan Duxburyab3666e2009-09-01 23:03:47 +0000306}
307
Bryan Duxburyc2ec7ca2009-12-31 18:59:15 +0000308union TestUnionMinusStringField {
309 2: i32 i32_field;
310 3: OneOfEach struct_field;
311 4: list<RandomStuff> struct_list;
312 5: i32 other_i32_field;
313 6: SomeEnum enum_field;
Bryan Duxbury162b3ac2010-06-23 21:17:48 +0000314 7: set<i32> i32_set;
315 8: map<i32, i32> i32_map;
Bryan Duxburyc2ec7ca2009-12-31 18:59:15 +0000316}
317
Bryan Duxburye2e4ea12009-11-11 21:01:35 +0000318union ComparableUnion {
319 1: string string_field;
320 2: binary binary_field;
321}
322
Bryan Duxburyab3666e2009-09-01 23:03:47 +0000323struct StructWithAUnion {
324 1: TestUnion test_union;
Bryan Duxbury51f28802009-10-01 20:53:45 +0000325}
326
327struct PrimitiveThenStruct {
328 1: i32 blah;
329 2: i32 blah2;
330 3: Backwards bw;
Bryan Duxbury2845b162009-11-09 15:55:22 +0000331}
332
333typedef map<i32,i32> SomeMap
334
335struct StructWithASomemap {
336 1: required SomeMap somemap_field;
Bryan Duxbury986d50f2009-12-31 18:18:00 +0000337}
Bryan Duxbury35565a42010-01-06 23:12:09 +0000338
339struct BigFieldIdStruct {
340 1: string field1;
341 45: string field2;
342}
343
344struct BreaksRubyCompactProtocol {
345 1: string field1;
346 2: BigFieldIdStruct field2;
347 3: i32 field3;
Bryan Duxbury162b3ac2010-06-23 21:17:48 +0000348}
349