| Jens Geyer | f066d84 | 2022-06-13 23:37:25 +0200 | [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 |  | 
|  | 20 | namespace c_glib TTest | 
|  | 21 | namespace cpp thrift.test.debug | 
|  | 22 | namespace java thrift.test | 
|  | 23 | namespace rb thrift.test | 
|  | 24 |  | 
|  | 25 | struct Doubles { | 
|  | 26 | 1: double nan, | 
|  | 27 | 2: double inf, | 
|  | 28 | 3: double neginf, | 
|  | 29 | 4: double repeating, | 
|  | 30 | 5: double big, | 
|  | 31 | 6: double tiny, | 
|  | 32 | 7: double zero, | 
|  | 33 | 8: double negzero, | 
|  | 34 | } | 
|  | 35 |  | 
|  | 36 | struct OneOfEach { | 
|  | 37 | 1: bool im_true, | 
|  | 38 | 2: bool im_false, | 
|  | 39 | 3: i8 a_bite = 0x7f, | 
|  | 40 | 4: i16 integer16 = 0x7fff, | 
|  | 41 | 5: i32 integer32, | 
|  | 42 | 6: i64 integer64 = 10000000000, | 
|  | 43 | 7: double double_precision, | 
|  | 44 | 8: string some_characters, | 
|  | 45 | 9: string zomg_unicode, | 
|  | 46 | 10: bool what_who, | 
|  | 47 | 11: binary base64, | 
|  | 48 | 12: list<i8> byte_list = [1, 2, 3], | 
|  | 49 | 13: list<i16> i16_list = [1,2,3], | 
|  | 50 | 14: list<i64> i64_list = [1,2,3] | 
|  | 51 | } | 
|  | 52 |  | 
|  | 53 | struct Bonk { | 
|  | 54 | 1: i32 type, | 
|  | 55 | 2: string message, | 
|  | 56 | } | 
|  | 57 |  | 
|  | 58 | struct Nesting { | 
|  | 59 | 1: Bonk my_bonk, | 
|  | 60 | 2: OneOfEach my_ooe, | 
|  | 61 | } | 
|  | 62 |  | 
|  | 63 | struct HolyMoley { | 
|  | 64 | 1: list<OneOfEach> big, | 
|  | 65 | 2: set<list<string> (python.immutable = "")> contain, | 
|  | 66 | 3: map<string,list<Bonk>> bonks, | 
|  | 67 | } | 
|  | 68 |  | 
|  | 69 | struct Backwards { | 
|  | 70 | 2: i32 first_tag2, | 
|  | 71 | 1: i32 second_tag1, | 
|  | 72 | } | 
|  | 73 |  | 
|  | 74 | struct Empty { | 
|  | 75 | } ( | 
|  | 76 | python.immutable = "", | 
|  | 77 | ) | 
|  | 78 |  | 
|  | 79 | struct Wrapper { | 
|  | 80 | 1: Empty foo | 
|  | 81 | } ( | 
|  | 82 | python.immutable = "", | 
|  | 83 | ) | 
|  | 84 |  | 
|  | 85 | struct RandomStuff { | 
|  | 86 | 1: i32 a, | 
|  | 87 | 2: i32 b, | 
|  | 88 | 3: i32 c, | 
|  | 89 | 4: i32 d, | 
|  | 90 | 5: list<i32> myintlist, | 
|  | 91 | 6: map<i32,Wrapper> maps, | 
|  | 92 | 7: i64 bigint, | 
|  | 93 | 8: double triple, | 
|  | 94 | } | 
|  | 95 |  | 
|  | 96 | struct Base64 { | 
|  | 97 | 1: i32 a, | 
|  | 98 | 2: binary b1, | 
|  | 99 | 3: binary b2, | 
|  | 100 | 4: binary b3, | 
|  | 101 | 5: binary b4, | 
|  | 102 | 6: binary b5, | 
|  | 103 | 7: binary b6, | 
|  | 104 | } | 
|  | 105 |  | 
|  | 106 | struct CompactProtoTestStruct { | 
|  | 107 | // primitive fields | 
|  | 108 | 1: i8     a_byte; | 
|  | 109 | 2: i16    a_i16; | 
|  | 110 | 3: i32    a_i32; | 
|  | 111 | 4: i64    a_i64; | 
|  | 112 | 5: double a_double; | 
|  | 113 | 6: string a_string; | 
|  | 114 | 7: binary a_binary; | 
|  | 115 | 8: bool   true_field; | 
|  | 116 | 9: bool   false_field; | 
|  | 117 | 10: Empty empty_struct_field; | 
|  | 118 |  | 
|  | 119 | // primitives in lists | 
|  | 120 | 11: list<i8>      byte_list; | 
|  | 121 | 12: list<i16>     i16_list; | 
|  | 122 | 13: list<i32>     i32_list; | 
|  | 123 | 14: list<i64>     i64_list; | 
|  | 124 | 15: list<double>  double_list; | 
|  | 125 | 16: list<string>  string_list; | 
|  | 126 | 17: list<binary>  binary_list; | 
|  | 127 | 18: list<bool>    boolean_list; | 
|  | 128 | 19: list<Empty>   struct_list; | 
|  | 129 |  | 
|  | 130 | // primitives in sets | 
|  | 131 | 20: set<i8>       byte_set; | 
|  | 132 | 21: set<i16>      i16_set; | 
|  | 133 | 22: set<i32>      i32_set; | 
|  | 134 | 23: set<i64>      i64_set; | 
|  | 135 | 24: set<double>   double_set; | 
|  | 136 | 25: set<string>   string_set; | 
|  | 137 | 26: set<binary>   binary_set; | 
|  | 138 | 27: set<bool>     boolean_set; | 
|  | 139 | 28: set<Empty>    struct_set; | 
|  | 140 |  | 
|  | 141 | // maps | 
|  | 142 | // primitives as keys | 
|  | 143 | 29: map<i8, i8>               byte_byte_map; | 
|  | 144 | 30: map<i16, i8>              i16_byte_map; | 
|  | 145 | 31: map<i32, i8>              i32_byte_map; | 
|  | 146 | 32: map<i64, i8>              i64_byte_map; | 
|  | 147 | 33: map<double, i8>           double_byte_map; | 
|  | 148 | 34: map<string, i8>           string_byte_map; | 
|  | 149 | 35: map<binary, i8>           binary_byte_map; | 
|  | 150 | 36: map<bool, i8>             boolean_byte_map; | 
|  | 151 | // primitives as values | 
|  | 152 | 37: map<i8, i16>              byte_i16_map; | 
|  | 153 | 38: map<i8, i32>              byte_i32_map; | 
|  | 154 | 39: map<i8, i64>              byte_i64_map; | 
|  | 155 | 40: map<i8, double>           byte_double_map; | 
|  | 156 | 41: map<i8, string>           byte_string_map; | 
|  | 157 | 42: map<i8, binary>           byte_binary_map; | 
|  | 158 | 43: map<i8, bool>             byte_boolean_map; | 
|  | 159 | // collections as keys | 
|  | 160 | 44: map<list<i8> (python.immutable = ""), i8>       list_byte_map; | 
|  | 161 | 45: map<set<i8> (python.immutable = ""), i8>        set_byte_map; | 
|  | 162 | 46: map<map<i8,i8> (python.immutable = ""), i8>     map_byte_map; | 
|  | 163 | // collections as values | 
|  | 164 | 47: map<i8, map<i8,i8>>     byte_map_map; | 
|  | 165 | 48: map<i8, set<i8>>        byte_set_map; | 
|  | 166 | 49: map<i8, list<i8>>       byte_list_map; | 
|  | 167 |  | 
|  | 168 | // large field IDs | 
|  | 169 | 500 : i64  field500; | 
|  | 170 | 5000 : i64  field5000; | 
|  | 171 | 20000 : i64  field20000; | 
|  | 172 | } | 
|  | 173 |  | 
|  | 174 | // To be used to test the serialization of an empty map | 
|  | 175 | struct SingleMapTestStruct { | 
|  | 176 | 1: required map<i32, i32>       i32_map; | 
|  | 177 | } | 
|  | 178 |  | 
|  | 179 | const CompactProtoTestStruct COMPACT_TEST = { | 
|  | 180 | 'a_byte'             : 127, | 
|  | 181 | 'a_i16'              : 32000, | 
|  | 182 | 'a_i32'              : 1000000000, | 
|  | 183 | 'a_i64'              : 0xffffffffff, | 
|  | 184 | 'a_double'           : 5.6789, | 
|  | 185 | 'a_string'           : "my string", | 
|  | 186 | //'a_binary,' | 
|  | 187 | 'true_field'         : 1, | 
|  | 188 | 'false_field'        : 0, | 
|  | 189 | 'empty_struct_field' : {}, | 
|  | 190 | 'byte_list'          : [-127, -1, 0, 1, 127], | 
|  | 191 | 'i16_list'           : [-1, 0, 1, 0x7fff], | 
|  | 192 | 'i32_list'           : [-1, 0, 0xff, 0xffff, 0xffffff, 0x7fffffff], | 
|  | 193 | 'i64_list'           : [-1, 0, 0xff, 0xffff, 0xffffff, 0xffffffff, 0xffffffffff, 0xffffffffffff, 0xffffffffffffff, 0x7fffffffffffffff], | 
|  | 194 | 'double_list'        : [0.1, 0.2, 0.3], | 
|  | 195 | 'string_list'        : ["first", "second", "third"], | 
|  | 196 | //'binary_list,' | 
|  | 197 | 'boolean_list'       : [1, 1, 1, 0, 0, 0], | 
|  | 198 | 'struct_list'        : [{}, {}], | 
|  | 199 | 'byte_set'           : [-127, -1, 0, 1, 127], | 
|  | 200 | 'i16_set'            : [-1, 0, 1, 0x7fff], | 
|  | 201 | 'i32_set'            : [1, 2, 3], | 
|  | 202 | 'i64_set'            : [-1, 0, 0xff, 0xffff, 0xffffff, 0xffffffff, 0xffffffffff, 0xffffffffffff, 0xffffffffffffff, 0x7fffffffffffffff], | 
|  | 203 | 'double_set'         : [0.1, 0.2, 0.3], | 
|  | 204 | 'string_set'         : ["first", "second", "third"], | 
|  | 205 | //'binary_set,' | 
|  | 206 | 'boolean_set'        : [1, 0], | 
|  | 207 | 'struct_set'         : [{}], | 
|  | 208 | 'byte_byte_map'      : {1 : 2}, | 
|  | 209 | 'i16_byte_map'       : {1 : 1, -1 : 1, 0x7fff : 1}, | 
|  | 210 | 'i32_byte_map'       : {1 : 1, -1 : 1, 0x7fffffff : 1}, | 
|  | 211 | 'i64_byte_map'       : {0 : 1,  1 : 1, -1 : 1, 0x7fffffffffffffff : 1}, | 
|  | 212 | 'double_byte_map'    : {-1.1 : 1, 1.1 : 1}, | 
|  | 213 | 'string_byte_map'    : {"first" : 1, "second" : 2, "third" : 3, "" : 0}, | 
|  | 214 | //'binary_byte_map,' | 
|  | 215 | 'boolean_byte_map'   : {1 : 1, 0 : 0}, | 
|  | 216 | 'byte_i16_map'       : {1 : 1, 2 : -1, 3 : 0x7fff}, | 
|  | 217 | 'byte_i32_map'       : {1 : 1, 2 : -1, 3 : 0x7fffffff}, | 
|  | 218 | 'byte_i64_map'       : {1 : 1, 2 : -1, 3 : 0x7fffffffffffffff}, | 
|  | 219 | 'byte_double_map'    : {1 : 0.1, 2 : -0.1, 3 : 1000000.1}, | 
|  | 220 | 'byte_string_map'    : {1 : "", 2 : "blah", 3 : "loooooooooooooong string"}, | 
|  | 221 | //'byte_binary_map,' | 
|  | 222 | 'byte_boolean_map'   : {1 : 1, 2 : 0}, | 
|  | 223 | 'list_byte_map'      : {[1, 2, 3] : 1, [0, 1] : 2, [] : 0}, | 
|  | 224 | 'set_byte_map'       : {[1, 2, 3] : 1, [0, 1] : 2, [] : 0}, | 
|  | 225 | 'map_byte_map'       : {{1 : 1} : 1, {2 : 2} : 2, {} : 0}, | 
|  | 226 | 'byte_map_map'       : {0 : {}, 1 : {1 : 1}, 2 : {1 : 1, 2 : 2}}, | 
|  | 227 | 'byte_set_map'       : {0 : [], 1 : [1], 2 : [1, 2]}, | 
|  | 228 | 'byte_list_map'      : {0 : [], 1 : [1], 2 : [1, 2]}, | 
|  | 229 |  | 
|  | 230 | 'field500'           : 500, | 
|  | 231 | 'field5000'          : 5000, | 
|  | 232 | 'field20000'         : 20000, | 
|  | 233 | } | 
|  | 234 |  | 
|  | 235 |  | 
|  | 236 | const i32 MYCONST = 2 | 
|  | 237 |  | 
|  | 238 |  | 
|  | 239 | exception ExceptionWithAMap { | 
|  | 240 | 1: string blah; | 
|  | 241 | 2: map<string, string> map_field; | 
|  | 242 | } | 
|  | 243 |  | 
|  | 244 | exception MutableException { | 
|  | 245 | 1: string msg; | 
|  | 246 | } (python.immutable = "false") | 
|  | 247 |  | 
|  | 248 | exception ExceptionWithoutFields {} | 
|  | 249 |  | 
|  | 250 | service ServiceForExceptionWithAMap { | 
|  | 251 | void methodThatThrowsAnException() throws (1: ExceptionWithAMap xwamap); | 
|  | 252 | } | 
|  | 253 |  | 
|  | 254 | service Srv { | 
|  | 255 | i32 Janky(1: i32 arg); | 
|  | 256 |  | 
|  | 257 | // return type only methods | 
|  | 258 |  | 
|  | 259 | void voidMethod(); | 
|  | 260 | i32 primitiveMethod(); | 
|  | 261 | CompactProtoTestStruct structMethod(); | 
|  | 262 |  | 
|  | 263 | void methodWithDefaultArgs(1: i32 something = MYCONST); | 
|  | 264 |  | 
|  | 265 | oneway void onewayMethod(); | 
|  | 266 |  | 
|  | 267 | bool declaredExceptionMethod(1: bool shouldThrow) throws (1: ExceptionWithAMap xwamap); | 
|  | 268 | } | 
|  | 269 |  | 
|  | 270 | service Inherited extends Srv { | 
|  | 271 | i32 identity(1: i32 arg) | 
|  | 272 | } | 
|  | 273 |  | 
|  | 274 | service EmptyService {} | 
|  | 275 |  | 
|  | 276 | // The only purpose of this thing is to increase the size of the generated code | 
|  | 277 | // so that ZlibTest has more highly compressible data to play with. | 
|  | 278 | struct BlowUp { | 
|  | 279 | 1: map<list<i32>(python.immutable = ""),set<map<i32,string> (python.immutable = "")>> b1; | 
|  | 280 | 2: map<list<i32>(python.immutable = ""),set<map<i32,string> (python.immutable = "")>> b2; | 
|  | 281 | 3: map<list<i32>(python.immutable = ""),set<map<i32,string> (python.immutable = "")>> b3; | 
|  | 282 | 4: map<list<i32>(python.immutable = ""),set<map<i32,string> (python.immutable = "")>> b4; | 
|  | 283 | } | 
|  | 284 |  | 
|  | 285 |  | 
|  | 286 | struct ReverseOrderStruct { | 
|  | 287 | 4: string first; | 
|  | 288 | 3: i16 second; | 
|  | 289 | 2: i32 third; | 
|  | 290 | 1: i64 fourth; | 
|  | 291 | } | 
|  | 292 |  | 
|  | 293 | service ReverseOrderService { | 
|  | 294 | void myMethod(4: string first, 3: i16 second, 2: i32 third, 1: i64 fourth); | 
|  | 295 | } | 
|  | 296 |  | 
|  | 297 | enum SomeEnum { | 
|  | 298 | ONE = 1 | 
|  | 299 | TWO = 2 | 
|  | 300 | } | 
|  | 301 |  | 
|  | 302 | /** This is a docstring on a constant! */ | 
|  | 303 | const SomeEnum MY_SOME_ENUM = SomeEnum.ONE | 
|  | 304 |  | 
|  | 305 | const SomeEnum MY_SOME_ENUM_1 = 1 | 
|  | 306 | /*const SomeEnum MY_SOME_ENUM_2 = 7*/ | 
|  | 307 |  | 
|  | 308 | const map<SomeEnum,SomeEnum> MY_ENUM_MAP = { | 
|  | 309 | SomeEnum.ONE : SomeEnum.TWO | 
|  | 310 | } | 
|  | 311 |  | 
|  | 312 | struct StructWithSomeEnum { | 
|  | 313 | 1: SomeEnum blah; | 
|  | 314 | } | 
|  | 315 |  | 
|  | 316 | const map<SomeEnum,StructWithSomeEnum> EXTRA_CRAZY_MAP = { | 
|  | 317 | SomeEnum.ONE : {"blah" : SomeEnum.TWO} | 
|  | 318 | } | 
|  | 319 |  | 
|  | 320 | union TestUnion { | 
|  | 321 | /** | 
|  | 322 | * A doc string | 
|  | 323 | */ | 
|  | 324 | 1: string string_field; | 
|  | 325 | 2: i32 i32_field; | 
|  | 326 | 3: OneOfEach struct_field; | 
|  | 327 | 4: list<RandomStuff> struct_list; | 
|  | 328 | 5: i32 other_i32_field; | 
|  | 329 | 6: SomeEnum enum_field; | 
|  | 330 | 7: set<i32> i32_set; | 
|  | 331 | 8: map<i32, i32> i32_map; | 
|  | 332 | } | 
|  | 333 |  | 
|  | 334 | union TestUnionMinusStringField { | 
|  | 335 | 2: i32 i32_field; | 
|  | 336 | 3: OneOfEach struct_field; | 
|  | 337 | 4: list<RandomStuff> struct_list; | 
|  | 338 | 5: i32 other_i32_field; | 
|  | 339 | 6: SomeEnum enum_field; | 
|  | 340 | 7: set<i32> i32_set; | 
|  | 341 | 8: map<i32, i32> i32_map; | 
|  | 342 | } | 
|  | 343 |  | 
|  | 344 | union ComparableUnion { | 
|  | 345 | 1: string string_field; | 
|  | 346 | 2: binary binary_field; | 
|  | 347 | } | 
|  | 348 |  | 
|  | 349 | struct StructWithAUnion { | 
|  | 350 | 1: TestUnion test_union; | 
|  | 351 | } | 
|  | 352 |  | 
|  | 353 | struct PrimitiveThenStruct { | 
|  | 354 | 1: i32 blah; | 
|  | 355 | 2: i32 blah2; | 
|  | 356 | 3: Backwards bw; | 
|  | 357 | } | 
|  | 358 |  | 
|  | 359 | typedef map<i32,i32> SomeMap | 
|  | 360 |  | 
|  | 361 | struct StructWithASomemap { | 
|  | 362 | 1: required SomeMap somemap_field; | 
|  | 363 | } | 
|  | 364 |  | 
|  | 365 | struct BigFieldIdStruct { | 
|  | 366 | 1: string field1; | 
|  | 367 | 45: string field2; | 
|  | 368 | } | 
|  | 369 |  | 
|  | 370 | struct BreaksRubyCompactProtocol { | 
|  | 371 | 1: string field1; | 
|  | 372 | 2: BigFieldIdStruct field2; | 
|  | 373 | 3: i32 field3; | 
|  | 374 | } | 
|  | 375 |  | 
|  | 376 | struct TupleProtocolTestStruct { | 
|  | 377 | optional i32 field1; | 
|  | 378 | optional i32 field2; | 
|  | 379 | optional i32 field3; | 
|  | 380 | optional i32 field4; | 
|  | 381 | optional i32 field5; | 
|  | 382 | optional i32 field6; | 
|  | 383 | optional i32 field7; | 
|  | 384 | optional i32 field8; | 
|  | 385 | optional i32 field9; | 
|  | 386 | optional i32 field10; | 
|  | 387 | optional i32 field11; | 
|  | 388 | optional i32 field12; | 
|  | 389 | } | 
|  | 390 |  | 
|  | 391 | struct ListDoublePerf { | 
|  | 392 | 1: list<double> field; | 
|  | 393 | } |