David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
David Reiss | 2a4bfd6 | 2008-04-07 23:45:00 +0000 | [diff] [blame] | 20 | namespace cpp thrift.test.debug |
David Reiss | 3b15ebc | 2008-03-02 06:29:19 +0000 | [diff] [blame] | 21 | namespace java thrift.test |
David Reiss | 00dcccf | 2007-07-21 01:18:10 +0000 | [diff] [blame] | 22 | |
David Reiss | db0ea15 | 2008-02-18 01:49:37 +0000 | [diff] [blame] | 23 | struct Doubles { |
| 24 | 1: double nan, |
| 25 | 2: double inf, |
| 26 | 3: double neginf, |
| 27 | 4: double repeating, |
| 28 | 5: double big, |
| 29 | 6: double small, |
| 30 | 7: double zero, |
| 31 | 8: double negzero, |
| 32 | } |
| 33 | |
David Reiss | 00dcccf | 2007-07-21 01:18:10 +0000 | [diff] [blame] | 34 | struct OneOfEach { |
| 35 | 1: bool im_true, |
| 36 | 2: bool im_false, |
David Reiss | a8efac8 | 2008-12-16 20:28:13 +0000 | [diff] [blame] | 37 | 3: byte a_bite = 200, |
| 38 | 4: i16 integer16 = 33000, |
David Reiss | 00dcccf | 2007-07-21 01:18:10 +0000 | [diff] [blame] | 39 | 5: i32 integer32, |
David Reiss | a8efac8 | 2008-12-16 20:28:13 +0000 | [diff] [blame] | 40 | 6: i64 integer64 = 10000000000, |
David Reiss | 00dcccf | 2007-07-21 01:18:10 +0000 | [diff] [blame] | 41 | 7: double double_precision, |
| 42 | 8: string some_characters, |
| 43 | 9: string zomg_unicode, |
| 44 | 10: bool what_who, |
David Reiss | db0ea15 | 2008-02-18 01:49:37 +0000 | [diff] [blame] | 45 | 11: binary base64, |
David Reiss | a8efac8 | 2008-12-16 20:28:13 +0000 | [diff] [blame] | 46 | 12: list<byte> byte_list = [1, 2, 3], |
| 47 | 13: list<i16> i16_list = [1,2,3], |
| 48 | 14: list<i64> i64_list = [1,2,3] |
David Reiss | 00dcccf | 2007-07-21 01:18:10 +0000 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | struct Bonk { |
| 52 | 1: i32 type, |
| 53 | 2: string message, |
| 54 | } |
| 55 | |
| 56 | struct Nesting { |
| 57 | 1: Bonk my_bonk, |
| 58 | 2: OneOfEach my_ooe, |
| 59 | } |
| 60 | |
| 61 | struct HolyMoley { |
| 62 | 1: list<OneOfEach> big, |
| 63 | 2: set<list<string>> contain, |
| 64 | 3: map<string,list<Bonk>> bonks, |
| 65 | } |
David Reiss | 382fc30 | 2007-08-25 18:01:30 +0000 | [diff] [blame] | 66 | |
| 67 | struct Backwards { |
| 68 | 2: i32 first_tag2, |
| 69 | 1: i32 second_tag1, |
| 70 | } |
| 71 | |
| 72 | struct Empty { |
| 73 | } |
| 74 | |
| 75 | struct Wrapper { |
| 76 | 1: Empty foo |
| 77 | } |
| 78 | |
| 79 | struct RandomStuff { |
| 80 | 1: i32 a, |
| 81 | 2: i32 b, |
| 82 | 3: i32 c, |
| 83 | 4: i32 d, |
| 84 | 5: list<i32> myintlist, |
| 85 | 6: map<i32,Wrapper> maps, |
| 86 | 7: i64 bigint, |
| 87 | 8: double triple, |
| 88 | } |
| 89 | |
David Reiss | 4a8f46c | 2008-03-07 20:12:07 +0000 | [diff] [blame] | 90 | struct Base64 { |
| 91 | 1: i32 a, |
| 92 | 2: binary b1, |
| 93 | 3: binary b2, |
| 94 | 4: binary b3, |
| 95 | 5: binary b4, |
| 96 | 6: binary b5, |
| 97 | 7: binary b6, |
| 98 | } |
| 99 | |
Bryan Duxbury | 538e344 | 2009-02-10 04:49:39 +0000 | [diff] [blame] | 100 | struct CompactProtoTestStruct { |
| 101 | // primitive fields |
David Reiss | fe5b77d | 2009-04-07 20:51:48 +0000 | [diff] [blame] | 102 | 1: byte a_byte; |
| 103 | 2: i16 a_i16; |
| 104 | 3: i32 a_i32; |
| 105 | 4: i64 a_i64; |
| 106 | 5: double a_double; |
| 107 | 6: string a_string; |
Bryan Duxbury | 538e344 | 2009-02-10 04:49:39 +0000 | [diff] [blame] | 108 | 7: binary a_binary; |
David Reiss | fe5b77d | 2009-04-07 20:51:48 +0000 | [diff] [blame] | 109 | 8: bool true_field; |
| 110 | 9: bool false_field; |
| 111 | 10: Empty empty_struct_field; |
Bryan Duxbury | 538e344 | 2009-02-10 04:49:39 +0000 | [diff] [blame] | 112 | |
| 113 | // primitives in lists |
David Reiss | fe5b77d | 2009-04-07 20:51:48 +0000 | [diff] [blame] | 114 | 11: list<byte> byte_list; |
| 115 | 12: list<i16> i16_list; |
| 116 | 13: list<i32> i32_list; |
| 117 | 14: list<i64> i64_list; |
| 118 | 15: list<double> double_list; |
| 119 | 16: list<string> string_list; |
Bryan Duxbury | 538e344 | 2009-02-10 04:49:39 +0000 | [diff] [blame] | 120 | 17: list<binary> binary_list; |
David Reiss | fe5b77d | 2009-04-07 20:51:48 +0000 | [diff] [blame] | 121 | 18: list<bool> boolean_list; |
| 122 | 19: list<Empty> struct_list; |
Bryan Duxbury | 538e344 | 2009-02-10 04:49:39 +0000 | [diff] [blame] | 123 | |
| 124 | // primitives in sets |
David Reiss | fe5b77d | 2009-04-07 20:51:48 +0000 | [diff] [blame] | 125 | 20: set<byte> byte_set; |
| 126 | 21: set<i16> i16_set; |
| 127 | 22: set<i32> i32_set; |
| 128 | 23: set<i64> i64_set; |
| 129 | 24: set<double> double_set; |
| 130 | 25: set<string> string_set; |
Bryan Duxbury | 538e344 | 2009-02-10 04:49:39 +0000 | [diff] [blame] | 131 | 26: set<binary> binary_set; |
David Reiss | fe5b77d | 2009-04-07 20:51:48 +0000 | [diff] [blame] | 132 | 27: set<bool> boolean_set; |
| 133 | 28: set<Empty> struct_set; |
Bryan Duxbury | 538e344 | 2009-02-10 04:49:39 +0000 | [diff] [blame] | 134 | |
| 135 | // maps |
| 136 | // primitives as keys |
David Reiss | fe5b77d | 2009-04-07 20:51:48 +0000 | [diff] [blame] | 137 | 29: map<byte, byte> byte_byte_map; |
| 138 | 30: map<i16, byte> i16_byte_map; |
| 139 | 31: map<i32, byte> i32_byte_map; |
| 140 | 32: map<i64, byte> i64_byte_map; |
| 141 | 33: map<double, byte> double_byte_map; |
| 142 | 34: map<string, byte> string_byte_map; |
Bryan Duxbury | 538e344 | 2009-02-10 04:49:39 +0000 | [diff] [blame] | 143 | 35: map<binary, byte> binary_byte_map; |
David Reiss | fe5b77d | 2009-04-07 20:51:48 +0000 | [diff] [blame] | 144 | 36: map<bool, byte> boolean_byte_map; |
Bryan Duxbury | 538e344 | 2009-02-10 04:49:39 +0000 | [diff] [blame] | 145 | // primitives as values |
David Reiss | fe5b77d | 2009-04-07 20:51:48 +0000 | [diff] [blame] | 146 | 37: map<byte, i16> byte_i16_map; |
| 147 | 38: map<byte, i32> byte_i32_map; |
| 148 | 39: map<byte, i64> byte_i64_map; |
| 149 | 40: map<byte, double> byte_double_map; |
| 150 | 41: map<byte, string> byte_string_map; |
Bryan Duxbury | 538e344 | 2009-02-10 04:49:39 +0000 | [diff] [blame] | 151 | 42: map<byte, binary> byte_binary_map; |
David Reiss | fe5b77d | 2009-04-07 20:51:48 +0000 | [diff] [blame] | 152 | 43: map<byte, bool> byte_boolean_map; |
Bryan Duxbury | 538e344 | 2009-02-10 04:49:39 +0000 | [diff] [blame] | 153 | // collections as keys |
David Reiss | fe5b77d | 2009-04-07 20:51:48 +0000 | [diff] [blame] | 154 | 44: map<list<byte>, byte> list_byte_map; |
| 155 | 45: map<set<byte>, byte> set_byte_map; |
| 156 | 46: map<map<byte,byte>, byte> map_byte_map; |
Bryan Duxbury | 538e344 | 2009-02-10 04:49:39 +0000 | [diff] [blame] | 157 | // collections as values |
David Reiss | fe5b77d | 2009-04-07 20:51:48 +0000 | [diff] [blame] | 158 | 47: map<byte, map<byte,byte>> byte_map_map; |
| 159 | 48: map<byte, set<byte>> byte_set_map; |
| 160 | 49: map<byte, list<byte>> byte_list_map; |
| 161 | } |
| 162 | |
| 163 | |
| 164 | const CompactProtoTestStruct COMPACT_TEST = { |
| 165 | 'a_byte' : 127, |
| 166 | 'a_i16' : 32000, |
| 167 | 'a_i32' : 1000000000, |
| 168 | 'a_i64' : 0xffffffffff, |
| 169 | 'a_double' : 5.6789, |
| 170 | 'a_string' : "my string", |
| 171 | //'a_binary,' |
| 172 | 'true_field' : 1, |
| 173 | 'false_field' : 0, |
| 174 | 'empty_struct_field' : {}, |
| 175 | 'byte_list' : [-127, -1, 0, 1, 127], |
| 176 | 'i16_list' : [-1, 0, 1, 0x7fff], |
| 177 | 'i32_list' : [-1, 0, 0xff, 0xffff, 0xffffff, 0x7fffffff], |
| 178 | 'i64_list' : [-1, 0, 0xff, 0xffff, 0xffffff, 0xffffffff, 0xffffffffff, 0xffffffffffff, 0xffffffffffffff, 0x7fffffffffffffff], |
| 179 | 'double_list' : [0.1, 0.2, 0.3], |
| 180 | 'string_list' : ["first", "second", "third"], |
| 181 | //'binary_list,' |
| 182 | 'boolean_list' : [1, 1, 1, 0, 0, 0], |
| 183 | 'struct_list' : [{}, {}], |
| 184 | 'byte_set' : [-127, -1, 0, 1, 127], |
| 185 | 'i16_set' : [-1, 0, 1, 0x7fff], |
| 186 | 'i32_set' : [1, 2, 3], |
| 187 | 'i64_set' : [-1, 0, 0xff, 0xffff, 0xffffff, 0xffffffff, 0xffffffffff, 0xffffffffffff, 0xffffffffffffff, 0x7fffffffffffffff], |
| 188 | 'double_set' : [0.1, 0.2, 0.3], |
| 189 | 'string_set' : ["first", "second", "third"], |
| 190 | //'binary_set,' |
| 191 | 'boolean_set' : [1, 0], |
| 192 | 'struct_set' : [{}], |
| 193 | 'byte_byte_map' : {1 : 2}, |
| 194 | 'i16_byte_map' : {1 : 1, -1 : 1, 0x7fff : 1}, |
| 195 | 'i32_byte_map' : {1 : 1, -1 : 1, 0x7fffffff : 1}, |
| 196 | 'i64_byte_map' : {0 : 1, 1 : 1, -1 : 1, 0x7fffffffffffffff : 1}, |
| 197 | 'double_byte_map' : {-1.1 : 1, 1.1 : 1}, |
| 198 | 'string_byte_map' : {"first" : 1, "second" : 2, "third" : 3, "" : 0}, |
| 199 | //'binary_byte_map,' |
| 200 | 'boolean_byte_map' : {1 : 1, 0 : 0}, |
| 201 | 'byte_i16_map' : {1 : 1, 2 : -1, 3 : 0x7fff}, |
| 202 | 'byte_i32_map' : {1 : 1, 2 : -1, 3 : 0x7fffffff}, |
| 203 | 'byte_i64_map' : {1 : 1, 2 : -1, 3 : 0x7fffffffffffffff}, |
| 204 | 'byte_double_map' : {1 : 0.1, 2 : -0.1, 3 : 1000000.1}, |
| 205 | 'byte_string_map' : {1 : "", 2 : "blah", 3 : "loooooooooooooong string"}, |
| 206 | //'byte_binary_map,' |
| 207 | 'byte_boolean_map' : {1 : 1, 2 : 0}, |
| 208 | 'list_byte_map' : {[1, 2, 3] : 1, [0, 1] : 2, [] : 0}, |
| 209 | 'set_byte_map' : {[1, 2, 3] : 1, [0, 1] : 2, [] : 0}, |
| 210 | 'map_byte_map' : {{1 : 1} : 1, {2 : 2} : 2, {} : 0}, |
| 211 | 'byte_map_map' : {0 : {}, 1 : {1 : 1}, 2 : {1 : 1, 2 : 2}}, |
| 212 | 'byte_set_map' : {0 : [], 1 : [1], 2 : [1, 2]}, |
| 213 | 'byte_list_map' : {0 : [], 1 : [1], 2 : [1, 2]}, |
Bryan Duxbury | 538e344 | 2009-02-10 04:49:39 +0000 | [diff] [blame] | 214 | } |
Bryan Duxbury | 5b8b484 | 2009-04-01 20:10:15 +0000 | [diff] [blame] | 215 | |
| 216 | |
| 217 | |
| 218 | service Srv { |
David Reiss | 689c9ad | 2009-04-02 19:24:02 +0000 | [diff] [blame] | 219 | i32 Janky(1: i32 arg); |
Bryan Duxbury | 5b8b484 | 2009-04-01 20:10:15 +0000 | [diff] [blame] | 220 | |
| 221 | // return type only methods |
| 222 | |
| 223 | void voidMethod(); |
| 224 | i32 primitiveMethod(); |
| 225 | CompactProtoTestStruct structMethod(); |
| 226 | } |
| 227 | |
| 228 | service Inherited extends Srv { |
David Reiss | 689c9ad | 2009-04-02 19:24:02 +0000 | [diff] [blame] | 229 | i32 identity(1: i32 arg) |
Bryan Duxbury | 5b8b484 | 2009-04-01 20:10:15 +0000 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | service EmptyService {} |
| 233 | |
| 234 | // The only purpose of this thing is to increase the size of the generated code |
| 235 | // so that ZlibTest has more highly compressible data to play with. |
| 236 | struct BlowUp { |
| 237 | 1: map<list<i32>,set<map<i32,string>>> b1; |
| 238 | 2: map<list<i32>,set<map<i32,string>>> b2; |
| 239 | 3: map<list<i32>,set<map<i32,string>>> b3; |
| 240 | 4: map<list<i32>,set<map<i32,string>>> b4; |
| 241 | } |
| 242 | |
Bryan Duxbury | ff219ac | 2009-04-10 21:51:00 +0000 | [diff] [blame] | 243 | |
| 244 | struct ReverseOrderStruct { |
| 245 | 4: string first; |
| 246 | 3: i16 second; |
| 247 | 2: i32 third; |
| 248 | 1: i64 fourth; |
| 249 | } |
| 250 | |
| 251 | service ReverseOrderService { |
| 252 | void myMethod(4: string first, 3: i16 second, 2: i32 third, 1: i64 fourth); |
Bryan Duxbury | ab3666e | 2009-09-01 23:03:47 +0000 | [diff] [blame] | 253 | } |
| 254 | |
Bryan Duxbury | 9af23d9 | 2009-11-19 17:26:38 +0000 | [diff] [blame] | 255 | enum SomeEnum { |
| 256 | ONE |
| 257 | TWO |
| 258 | } |
| 259 | |
Bryan Duxbury | ab3666e | 2009-09-01 23:03:47 +0000 | [diff] [blame] | 260 | union TestUnion { |
| 261 | /** |
| 262 | * A doc string |
| 263 | */ |
| 264 | 1: string string_field; |
| 265 | 2: i32 i32_field; |
| 266 | 3: OneOfEach struct_field; |
| 267 | 4: list<RandomStuff> struct_list; |
| 268 | 5: i32 other_i32_field; |
Bryan Duxbury | 9af23d9 | 2009-11-19 17:26:38 +0000 | [diff] [blame] | 269 | 6: SomeEnum enum_field; |
Bryan Duxbury | ab3666e | 2009-09-01 23:03:47 +0000 | [diff] [blame] | 270 | } |
| 271 | |
Bryan Duxbury | e2e4ea1 | 2009-11-11 21:01:35 +0000 | [diff] [blame] | 272 | union ComparableUnion { |
| 273 | 1: string string_field; |
| 274 | 2: binary binary_field; |
| 275 | } |
| 276 | |
Bryan Duxbury | ab3666e | 2009-09-01 23:03:47 +0000 | [diff] [blame] | 277 | struct StructWithAUnion { |
| 278 | 1: TestUnion test_union; |
Bryan Duxbury | 51f2880 | 2009-10-01 20:53:45 +0000 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | struct PrimitiveThenStruct { |
| 282 | 1: i32 blah; |
| 283 | 2: i32 blah2; |
| 284 | 3: Backwards bw; |
Bryan Duxbury | 2845b16 | 2009-11-09 15:55:22 +0000 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | typedef map<i32,i32> SomeMap |
| 288 | |
| 289 | struct StructWithASomemap { |
| 290 | 1: required SomeMap somemap_field; |
Bryan Duxbury | ff219ac | 2009-04-10 21:51:00 +0000 | [diff] [blame] | 291 | } |