| 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. | 
| Todd Lipcon | 53ae9f3 | 2009-12-07 00:42:38 +0000 | [diff] [blame] | 18 | * | 
|  | 19 | * Contains some contributions under the Thrift Software License. | 
|  | 20 | * Please see doc/old-thrift-license.txt in the Thrift distribution for | 
|  | 21 | * details. | 
| David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 22 | */ | 
|  | 23 |  | 
| Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 24 | namespace c_glib TTest | 
| David Reiss | 9a08dc6 | 2008-02-27 01:55:17 +0000 | [diff] [blame] | 25 | namespace cpp thrift.test | 
| James E. King III | 234fb47 | 2019-01-13 23:19:18 -0500 | [diff] [blame] | 26 | namespace delphi Thrift.Test | 
|  | 27 | namespace go thrifttest | 
|  | 28 | namespace java thrift.test | 
| T Jake Luciani | 322caa2 | 2010-02-15 03:24:55 +0000 | [diff] [blame] | 29 | namespace js ThriftTest | 
| James E. King III | 234fb47 | 2019-01-13 23:19:18 -0500 | [diff] [blame] | 30 | namespace lua ThriftTest | 
| Jens Geyer | aa0c8b3 | 2019-01-28 23:27:45 +0100 | [diff] [blame] | 31 | namespace netstd ThriftTest | 
| James E. King III | 234fb47 | 2019-01-13 23:19:18 -0500 | [diff] [blame] | 32 | namespace perl ThriftTest | 
|  | 33 | namespace php ThriftTest | 
| Anthony F. Molinaro | 0b4936d | 2010-09-27 04:43:39 +0000 | [diff] [blame] | 34 | namespace py ThriftTest | 
| Roger Meier | 50e4349 | 2010-10-08 17:46:06 +0000 | [diff] [blame] | 35 | namespace py.twisted ThriftTest | 
| James E. King III | 234fb47 | 2019-01-13 23:19:18 -0500 | [diff] [blame] | 36 | namespace rb Thrift.Test | 
|  | 37 | namespace st ThriftTest | 
| BCG | cc193c1 | 2015-11-12 21:02:51 -0500 | [diff] [blame] | 38 | namespace xsd test (uri = 'http://thrift.apache.org/ns/ThriftTest') | 
| Henrique Mendonça | 8ad13a3 | 2013-05-16 21:26:20 +0200 | [diff] [blame] | 39 |  | 
|  | 40 | // Presence of namespaces and sub-namespaces for which there is | 
|  | 41 | // no generator should compile with warnings only | 
|  | 42 | namespace noexist ThriftTest | 
|  | 43 | namespace cpp.noexist ThriftTest | 
|  | 44 |  | 
| David Reiss | fb790d7 | 2010-09-02 16:41:45 +0000 | [diff] [blame] | 45 | namespace * thrift.test | 
| Marc Slemko | 1785985 | 2006-08-15 00:21:31 +0000 | [diff] [blame] | 46 |  | 
| Bryan Duxbury | 9af23d9 | 2009-11-19 17:26:38 +0000 | [diff] [blame] | 47 | /** | 
|  | 48 | * Docstring! | 
|  | 49 | */ | 
| Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 50 | enum Numberz | 
|  | 51 | { | 
|  | 52 | ONE = 1, | 
|  | 53 | TWO, | 
|  | 54 | THREE, | 
|  | 55 | FIVE = 5, | 
|  | 56 | SIX, | 
|  | 57 | EIGHT = 8 | 
|  | 58 | } | 
|  | 59 |  | 
| Bryan Duxbury | 9f0a786 | 2010-09-12 14:38:36 +0000 | [diff] [blame] | 60 | const Numberz myNumberz = Numberz.ONE; | 
|  | 61 | // the following is expected to fail: | 
|  | 62 | // const Numberz urNumberz = ONE; | 
|  | 63 |  | 
| Mark Slee | 6e53644 | 2006-06-30 18:28:50 +0000 | [diff] [blame] | 64 | typedef i64 UserId | 
| Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 65 |  | 
| Mark Slee | e129a2d | 2007-02-21 05:17:48 +0000 | [diff] [blame] | 66 | struct Bonk | 
|  | 67 | { | 
|  | 68 | 1: string message, | 
|  | 69 | 2: i32 type | 
|  | 70 | } | 
|  | 71 |  | 
| Jens Geyer | 11430df | 2013-07-26 00:23:00 +0200 | [diff] [blame] | 72 | typedef map<string,Bonk> MapType | 
|  | 73 |  | 
| Kevin Clark | 9a863ee | 2009-03-24 16:04:36 +0000 | [diff] [blame] | 74 | struct Bools { | 
|  | 75 | 1: bool im_true, | 
|  | 76 | 2: bool im_false, | 
|  | 77 | } | 
|  | 78 |  | 
| Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 79 | struct Xtruct | 
|  | 80 | { | 
| Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 81 | 1:  string string_thing, | 
| Nobuaki Sukegawa | eb344a8 | 2016-03-25 09:37:18 +0900 | [diff] [blame] | 82 | 4:  i8     byte_thing, | 
| Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 83 | 9:  i32    i32_thing, | 
|  | 84 | 11: i64    i64_thing | 
| Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 85 | } | 
|  | 86 |  | 
|  | 87 | struct Xtruct2 | 
|  | 88 | { | 
| Jens Geyer | 40c28d3 | 2015-10-20 23:13:02 +0200 | [diff] [blame] | 89 | 1: i8     byte_thing,  // used to be byte, hence the name | 
| Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 90 | 2: Xtruct struct_thing, | 
|  | 91 | 3: i32    i32_thing | 
| Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 92 | } | 
|  | 93 |  | 
| David Reiss | 233ace5 | 2009-03-30 20:46:47 +0000 | [diff] [blame] | 94 | struct Xtruct3 | 
|  | 95 | { | 
|  | 96 | 1:  string string_thing, | 
|  | 97 | 4:  i32    changed, | 
|  | 98 | 9:  i32    i32_thing, | 
|  | 99 | 11: i64    i64_thing | 
|  | 100 | } | 
|  | 101 |  | 
|  | 102 |  | 
| Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 103 | struct Insanity | 
|  | 104 | { | 
| Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 105 | 1: map<Numberz, UserId> userMap, | 
|  | 106 | 2: list<Xtruct> xtructs | 
| Nobuaki Sukegawa | e841b3d | 2015-11-17 11:01:17 +0900 | [diff] [blame] | 107 | } (python.immutable= "") | 
| Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 108 |  | 
| Bryan Duxbury | 986d705 | 2009-01-29 01:51:08 +0000 | [diff] [blame] | 109 | struct CrazyNesting { | 
|  | 110 | 1: string string_field, | 
|  | 111 | 2: optional set<Insanity> set_field, | 
| Nobuaki Sukegawa | 6dab9bb | 2015-11-28 22:27:16 +0900 | [diff] [blame] | 112 | // Do not insert line break as test/go/Makefile.am is removing this line with pattern match | 
|  | 113 | 3: required list<map<set<i32> (python.immutable = ""), map<i32,set<list<map<Insanity,string>(python.immutable = "")> (python.immutable = "")>>>> list_field, | 
| Bryan Duxbury | b3d0aa0 | 2010-10-06 20:00:03 +0000 | [diff] [blame] | 114 | 4: binary binary_field | 
| Jens Geyer | 62445c1 | 2022-06-29 00:00:00 +0200 | [diff] [blame] | 115 | 5: uuid uuid_field | 
| Bryan Duxbury | 986d705 | 2009-01-29 01:51:08 +0000 | [diff] [blame] | 116 | } | 
|  | 117 |  | 
| Allen George | 6061191 | 2016-12-11 08:33:52 -0500 | [diff] [blame] | 118 | union SomeUnion { | 
|  | 119 | 1: map<Numberz, UserId> map_thing, | 
|  | 120 | 2: string string_thing, | 
|  | 121 | 3: i32 i32_thing, | 
|  | 122 | 4: Xtruct3 xtruct_thing, | 
|  | 123 | 5: Insanity insanity_thing | 
|  | 124 | } | 
|  | 125 |  | 
| Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 126 | exception Xception { | 
| Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 127 | 1: i32 errorCode, | 
|  | 128 | 2: string message | 
| Marc Slemko | d8b1051 | 2006-08-14 23:30:37 +0000 | [diff] [blame] | 129 | } | 
|  | 130 |  | 
| Marc Slemko | bf4fd19 | 2006-08-15 21:29:39 +0000 | [diff] [blame] | 131 | exception Xception2 { | 
| Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 132 | 1: i32 errorCode, | 
|  | 133 | 2: Xtruct struct_thing | 
| Marc Slemko | d8b1051 | 2006-08-14 23:30:37 +0000 | [diff] [blame] | 134 | } | 
| Mark Slee | 27ed6ec | 2007-08-16 01:26:31 +0000 | [diff] [blame] | 135 |  | 
| Mark Slee | d3d733a | 2006-09-01 22:19:06 +0000 | [diff] [blame] | 136 | struct EmptyStruct {} | 
|  | 137 |  | 
| Marc Slemko | d8b1051 | 2006-08-14 23:30:37 +0000 | [diff] [blame] | 138 | struct OneField { | 
| Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 139 | 1: EmptyStruct field | 
| Marc Slemko | d8b1051 | 2006-08-14 23:30:37 +0000 | [diff] [blame] | 140 | } | 
| Marc Slemko | 5b126d6 | 2006-08-11 23:03:42 +0000 | [diff] [blame] | 141 |  | 
| Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 142 | service ThriftTest | 
|  | 143 | { | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 144 | /** | 
|  | 145 | * Prints "testVoid()" and returns nothing. | 
|  | 146 | */ | 
| Marc Slemko | d8b1051 | 2006-08-14 23:30:37 +0000 | [diff] [blame] | 147 | void         testVoid(), | 
| Jens Geyer | aaa8947 | 2014-10-03 20:22:28 +0200 | [diff] [blame] | 148 |  | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 149 | /** | 
|  | 150 | * Prints 'testString("%s")' with thing as '%s' | 
|  | 151 | * @param string thing - the string to print | 
|  | 152 | * @return string - returns the string 'thing' | 
|  | 153 | */ | 
| Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 154 | string       testString(1: string thing), | 
| Jens Geyer | aaa8947 | 2014-10-03 20:22:28 +0200 | [diff] [blame] | 155 |  | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 156 | /** | 
| Nobuaki Sukegawa | a649e74 | 2015-09-21 13:53:25 +0900 | [diff] [blame] | 157 | * Prints 'testBool("%s")' where '%s' with thing as 'true' or 'false' | 
|  | 158 | * @param bool  thing - the bool data to print | 
|  | 159 | * @return bool  - returns the bool 'thing' | 
|  | 160 | */ | 
|  | 161 | bool         testBool(1: bool thing), | 
|  | 162 |  | 
|  | 163 | /** | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 164 | * Prints 'testByte("%d")' with thing as '%d' | 
| Jens Geyer | 40c28d3 | 2015-10-20 23:13:02 +0200 | [diff] [blame] | 165 | * The types i8 and byte are synonyms, use of i8 is encouraged, byte still exists for the sake of compatibility. | 
|  | 166 | * @param byte thing - the i8/byte to print | 
|  | 167 | * @return i8 - returns the i8/byte 'thing' | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 168 | */ | 
| Nobuaki Sukegawa | eb344a8 | 2016-03-25 09:37:18 +0900 | [diff] [blame] | 169 | i8           testByte(1: i8 thing), | 
| Jens Geyer | aaa8947 | 2014-10-03 20:22:28 +0200 | [diff] [blame] | 170 |  | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 171 | /** | 
|  | 172 | * Prints 'testI32("%d")' with thing as '%d' | 
|  | 173 | * @param i32 thing - the i32 to print | 
|  | 174 | * @return i32 - returns the i32 'thing' | 
|  | 175 | */ | 
| Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 176 | i32          testI32(1: i32 thing), | 
| Jens Geyer | aaa8947 | 2014-10-03 20:22:28 +0200 | [diff] [blame] | 177 |  | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 178 | /** | 
|  | 179 | * Prints 'testI64("%d")' with thing as '%d' | 
|  | 180 | * @param i64 thing - the i64 to print | 
|  | 181 | * @return i64 - returns the i64 'thing' | 
|  | 182 | */ | 
| Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 183 | i64          testI64(1: i64 thing), | 
| Jens Geyer | aaa8947 | 2014-10-03 20:22:28 +0200 | [diff] [blame] | 184 |  | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 185 | /** | 
|  | 186 | * Prints 'testDouble("%f")' with thing as '%f' | 
|  | 187 | * @param double thing - the double to print | 
|  | 188 | * @return double - returns the double 'thing' | 
|  | 189 | */ | 
| Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 190 | double       testDouble(1: double thing), | 
| Jens Geyer | aaa8947 | 2014-10-03 20:22:28 +0200 | [diff] [blame] | 191 |  | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 192 | /** | 
| Jens Geyer | a2d5dfd | 2014-12-13 23:39:45 +0100 | [diff] [blame] | 193 | * Prints 'testBinary("%s")' where '%s' is a hex-formatted string of thing's data | 
|  | 194 | * @param binary  thing - the binary data to print | 
|  | 195 | * @return binary  - returns the binary 'thing' | 
|  | 196 | */ | 
|  | 197 | binary       testBinary(1: binary thing), | 
| wilfrem | 2c69b5a | 2015-04-20 19:24:50 +0900 | [diff] [blame] | 198 |  | 
| Jens Geyer | a2d5dfd | 2014-12-13 23:39:45 +0100 | [diff] [blame] | 199 | /** | 
| Jens Geyer | 62445c1 | 2022-06-29 00:00:00 +0200 | [diff] [blame] | 200 | * Prints 'testUuid("%s")' where '%s' is the uuid given. Note that the uuid byte order should be correct. | 
|  | 201 | * @param uuid  thing - the uuid to print | 
|  | 202 | * @return uuid  - returns the uuid 'thing' | 
|  | 203 | */ | 
|  | 204 | uuid       testUuid(1: uuid thing), | 
|  | 205 |  | 
|  | 206 | /** | 
| Konrad Grochowski | 3b5dacb | 2014-11-24 10:55:31 +0100 | [diff] [blame] | 207 | * Prints 'testStruct("{%s}")' where thing has been formatted into a string of comma separated values | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 208 | * @param Xtruct thing - the Xtruct to print | 
|  | 209 | * @return Xtruct - returns the Xtruct 'thing' | 
|  | 210 | */ | 
| Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 211 | Xtruct       testStruct(1: Xtruct thing), | 
| Jens Geyer | aaa8947 | 2014-10-03 20:22:28 +0200 | [diff] [blame] | 212 |  | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 213 | /** | 
|  | 214 | * Prints 'testNest("{%s}")' where thing has been formatted into a string of the nested struct | 
|  | 215 | * @param Xtruct2 thing - the Xtruct2 to print | 
|  | 216 | * @return Xtruct2 - returns the Xtruct2 'thing' | 
|  | 217 | */ | 
| Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 218 | Xtruct2      testNest(1: Xtruct2 thing), | 
| Jens Geyer | aaa8947 | 2014-10-03 20:22:28 +0200 | [diff] [blame] | 219 |  | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 220 | /** | 
| Kevin Wojniak | c5068e2 | 2019-06-26 22:11:01 -0700 | [diff] [blame] | 221 | * Prints 'testMap("{%s")' where thing has been formatted into a string of 'key => value' pairs | 
| Konrad Grochowski | 3b5dacb | 2014-11-24 10:55:31 +0100 | [diff] [blame] | 222 | *  separated by commas and new lines | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 223 | * @param map<i32,i32> thing - the map<i32,i32> to print | 
|  | 224 | * @return map<i32,i32> - returns the map<i32,i32> 'thing' | 
|  | 225 | */ | 
| Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 226 | map<i32,i32> testMap(1: map<i32,i32> thing), | 
| Jens Geyer | aaa8947 | 2014-10-03 20:22:28 +0200 | [diff] [blame] | 227 |  | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 228 | /** | 
| Kevin Wojniak | c5068e2 | 2019-06-26 22:11:01 -0700 | [diff] [blame] | 229 | * Prints 'testStringMap("{%s}")' where thing has been formatted into a string of 'key => value' pairs | 
| Konrad Grochowski | 3b5dacb | 2014-11-24 10:55:31 +0100 | [diff] [blame] | 230 | *  separated by commas and new lines | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 231 | * @param map<string,string> thing - the map<string,string> to print | 
|  | 232 | * @return map<string,string> - returns the map<string,string> 'thing' | 
|  | 233 | */ | 
| Roger Meier | 9d8e8f8 | 2011-06-14 19:38:27 +0000 | [diff] [blame] | 234 | map<string,string> testStringMap(1: map<string,string> thing), | 
| Jens Geyer | aaa8947 | 2014-10-03 20:22:28 +0200 | [diff] [blame] | 235 |  | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 236 | /** | 
| Kevin Wojniak | c5068e2 | 2019-06-26 22:11:01 -0700 | [diff] [blame] | 237 | * Prints 'testSet("{%s}")' where thing has been formatted into a string of values | 
| Konrad Grochowski | 3b5dacb | 2014-11-24 10:55:31 +0100 | [diff] [blame] | 238 | *  separated by commas and new lines | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 239 | * @param set<i32> thing - the set<i32> to print | 
|  | 240 | * @return set<i32> - returns the set<i32> 'thing' | 
|  | 241 | */ | 
| Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 242 | set<i32>     testSet(1: set<i32> thing), | 
| Jens Geyer | aaa8947 | 2014-10-03 20:22:28 +0200 | [diff] [blame] | 243 |  | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 244 | /** | 
| Kevin Wojniak | c5068e2 | 2019-06-26 22:11:01 -0700 | [diff] [blame] | 245 | * Prints 'testList("{%s}")' where thing has been formatted into a string of values | 
| Konrad Grochowski | 3b5dacb | 2014-11-24 10:55:31 +0100 | [diff] [blame] | 246 | *  separated by commas and new lines | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 247 | * @param list<i32> thing - the list<i32> to print | 
|  | 248 | * @return list<i32> - returns the list<i32> 'thing' | 
|  | 249 | */ | 
| Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 250 | list<i32>    testList(1: list<i32> thing), | 
| Jens Geyer | aaa8947 | 2014-10-03 20:22:28 +0200 | [diff] [blame] | 251 |  | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 252 | /** | 
| Kevin Wojniak | c5068e2 | 2019-06-26 22:11:01 -0700 | [diff] [blame] | 253 | * Prints 'testEnum("%d")' where thing has been formatted into its numeric value | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 254 | * @param Numberz thing - the Numberz to print | 
|  | 255 | * @return Numberz - returns the Numberz 'thing' | 
|  | 256 | */ | 
| Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 257 | Numberz      testEnum(1: Numberz thing), | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 258 |  | 
|  | 259 | /** | 
|  | 260 | * Prints 'testTypedef("%d")' with thing as '%d' | 
|  | 261 | * @param UserId thing - the UserId to print | 
|  | 262 | * @return UserId - returns the UserId 'thing' | 
|  | 263 | */ | 
| Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 264 | UserId       testTypedef(1: UserId thing), | 
| Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 265 |  | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 266 | /** | 
|  | 267 | * Prints 'testMapMap("%d")' with hello as '%d' | 
|  | 268 | * @param i32 hello - the i32 to print | 
|  | 269 | * @return map<i32,map<i32,i32>> - returns a dictionary with these values: | 
|  | 270 | *   {-4 => {-4 => -4, -3 => -3, -2 => -2, -1 => -1, }, 4 => {1 => 1, 2 => 2, 3 => 3, 4 => 4, }, } | 
|  | 271 | */ | 
| Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 272 | map<i32,map<i32,i32>> testMapMap(1: i32 hello), | 
| Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 273 |  | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 274 | /** | 
| Kevin Wojniak | c5068e2 | 2019-06-26 22:11:01 -0700 | [diff] [blame] | 275 | * So you think you've got this all worked out, eh? | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 276 | * | 
| Kevin Wojniak | c5068e2 | 2019-06-26 22:11:01 -0700 | [diff] [blame] | 277 | * Creates a map with these values and prints it out: | 
| Jens Geyer | aaa8947 | 2014-10-03 20:22:28 +0200 | [diff] [blame] | 278 | *   { 1 => { 2 => argument, | 
|  | 279 | *            3 => argument, | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 280 | *          }, | 
|  | 281 | *     2 => { 6 => <empty Insanity struct>, }, | 
|  | 282 | *   } | 
| Jens Geyer | aaa8947 | 2014-10-03 20:22:28 +0200 | [diff] [blame] | 283 | * @return map<UserId, map<Numberz,Insanity>> - a map with the above values | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 284 | */ | 
| Mark Slee | a330265 | 2006-10-25 19:03:32 +0000 | [diff] [blame] | 285 | map<UserId, map<Numberz,Insanity>> testInsanity(1: Insanity argument), | 
| Marc Slemko | d8b1051 | 2006-08-14 23:30:37 +0000 | [diff] [blame] | 286 |  | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 287 | /** | 
|  | 288 | * Prints 'testMulti()' | 
| Nobuaki Sukegawa | eb344a8 | 2016-03-25 09:37:18 +0900 | [diff] [blame] | 289 | * @param i8 arg0 - | 
| Jens Geyer | aaa8947 | 2014-10-03 20:22:28 +0200 | [diff] [blame] | 290 | * @param i32 arg1 - | 
|  | 291 | * @param i64 arg2 - | 
|  | 292 | * @param map<i16, string> arg3 - | 
|  | 293 | * @param Numberz arg4 - | 
|  | 294 | * @param UserId arg5 - | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 295 | * @return Xtruct - returns an Xtruct with string_thing = "Hello2, byte_thing = arg0, i32_thing = arg1 | 
|  | 296 | *    and i64_thing = arg2 | 
|  | 297 | */ | 
| Nobuaki Sukegawa | eb344a8 | 2016-03-25 09:37:18 +0900 | [diff] [blame] | 298 | Xtruct testMulti(1: i8 arg0, 2: i32 arg1, 3: i64 arg2, 4: map<i16, string> arg3, 5: Numberz arg4, 6: UserId arg5), | 
| Marc Slemko | d8b1051 | 2006-08-14 23:30:37 +0000 | [diff] [blame] | 299 |  | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 300 | /** | 
|  | 301 | * Print 'testException(%s)' with arg as '%s' | 
|  | 302 | * @param string arg - a string indication what type of exception to throw | 
|  | 303 | * if arg == "Xception" throw Xception with errorCode = 1001 and message = arg | 
| Kevin Wojniak | c5068e2 | 2019-06-26 22:11:01 -0700 | [diff] [blame] | 304 | * else if arg == "TException" throw TException | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 305 | * else do not throw anything | 
|  | 306 | */ | 
| David Reiss | 689c9ad | 2009-04-02 19:24:02 +0000 | [diff] [blame] | 307 | void testException(1: string arg) throws(1: Xception err1), | 
| Marc Slemko | d8b1051 | 2006-08-14 23:30:37 +0000 | [diff] [blame] | 308 |  | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 309 | /** | 
|  | 310 | * Print 'testMultiException(%s, %s)' with arg0 as '%s' and arg1 as '%s' | 
| Kevin Wojniak | c5068e2 | 2019-06-26 22:11:01 -0700 | [diff] [blame] | 311 | * @param string arg - a string indicating what type of exception to throw | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 312 | * if arg0 == "Xception" throw Xception with errorCode = 1001 and message = "This is an Xception" | 
| Kevin Wojniak | c5068e2 | 2019-06-26 22:11:01 -0700 | [diff] [blame] | 313 | * else if arg0 == "Xception2" throw Xception2 with errorCode = 2002 and struct_thing.string_thing = "This is an Xception2" | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 314 | * else do not throw anything | 
|  | 315 | * @return Xtruct - an Xtruct with string_thing = arg1 | 
|  | 316 | */ | 
| David Reiss | 689c9ad | 2009-04-02 19:24:02 +0000 | [diff] [blame] | 317 | Xtruct testMultiException(1: string arg0, 2: string arg1) throws(1: Xception err1, 2: Xception2 err2) | 
| David Reiss | 2ab6fe8 | 2008-02-18 02:11:44 +0000 | [diff] [blame] | 318 |  | 
| Roger Meier | 1f8b48f | 2012-05-02 22:56:47 +0000 | [diff] [blame] | 319 | /** | 
|  | 320 | * Print 'testOneway(%d): Sleeping...' with secondsToSleep as '%d' | 
|  | 321 | * sleep 'secondsToSleep' | 
|  | 322 | * Print 'testOneway(%d): done sleeping!' with secondsToSleep as '%d' | 
|  | 323 | * @param i32 secondsToSleep - the number of seconds to sleep | 
|  | 324 | */ | 
| David Reiss | cecbed8 | 2009-03-24 20:02:22 +0000 | [diff] [blame] | 325 | oneway void testOneway(1:i32 secondsToSleep) | 
| Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 326 | } | 
| Mark Slee | dafa3cf | 2006-09-02 23:56:49 +0000 | [diff] [blame] | 327 |  | 
|  | 328 | service SecondService | 
|  | 329 | { | 
| henrique | 2fdd916 | 2013-08-28 14:03:34 +0200 | [diff] [blame] | 330 | /** | 
|  | 331 | * Prints 'testString("%s")' with thing as '%s' | 
|  | 332 | * @param string thing - the string to print | 
|  | 333 | * @return string - returns the string 'thing' | 
|  | 334 | */ | 
| James E. King, III | 58402ff | 2017-11-17 14:41:46 -0500 | [diff] [blame] | 335 | string secondtestString(1: string thing) | 
| Mark Slee | dafa3cf | 2006-09-02 23:56:49 +0000 | [diff] [blame] | 336 | } | 
| David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 337 |  | 
|  | 338 | struct VersioningTestV1 { | 
|  | 339 | 1: i32 begin_in_both, | 
| David Reiss | a528f54 | 2009-03-24 22:48:40 +0000 | [diff] [blame] | 340 | 3: string old_string, | 
| David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 341 | 12: i32 end_in_both | 
|  | 342 | } | 
|  | 343 |  | 
|  | 344 | struct VersioningTestV2 { | 
|  | 345 | 1: i32 begin_in_both, | 
|  | 346 |  | 
|  | 347 | 2: i32 newint, | 
| Nobuaki Sukegawa | eb344a8 | 2016-03-25 09:37:18 +0900 | [diff] [blame] | 348 | 3: i8 newbyte, | 
| David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 349 | 4: i16 newshort, | 
|  | 350 | 5: i64 newlong, | 
|  | 351 | 6: double newdouble | 
|  | 352 | 7: Bonk newstruct, | 
|  | 353 | 8: list<i32> newlist, | 
|  | 354 | 9: set<i32> newset, | 
|  | 355 | 10: map<i32, i32> newmap, | 
|  | 356 | 11: string newstring, | 
|  | 357 | 12: i32 end_in_both | 
| David Reiss | 9a08dc6 | 2008-02-27 01:55:17 +0000 | [diff] [blame] | 358 | } | 
| David Reiss | 2a4bfd6 | 2008-04-07 23:45:00 +0000 | [diff] [blame] | 359 |  | 
|  | 360 | struct ListTypeVersioningV1 { | 
|  | 361 | 1: list<i32> myints; | 
|  | 362 | 2: string hello; | 
|  | 363 | } | 
|  | 364 |  | 
|  | 365 | struct ListTypeVersioningV2 { | 
|  | 366 | 1: list<string> strings; | 
|  | 367 | 2: string hello; | 
| Bryan Duxbury | 986d705 | 2009-01-29 01:51:08 +0000 | [diff] [blame] | 368 | } | 
| Bryan Duxbury | 206c0dc | 2010-10-19 23:00:27 +0000 | [diff] [blame] | 369 |  | 
|  | 370 | struct GuessProtocolStruct { | 
|  | 371 | 7: map<string,string> map_field, | 
|  | 372 | } | 
| Bryan Duxbury | df4cffd | 2011-03-15 17:16:09 +0000 | [diff] [blame] | 373 |  | 
|  | 374 | struct LargeDeltas { | 
|  | 375 | 1: Bools b1, | 
|  | 376 | 10: Bools b10, | 
|  | 377 | 100: Bools b100, | 
|  | 378 | 500: bool check_true, | 
|  | 379 | 1000: Bools b1000, | 
|  | 380 | 1500: bool check_false, | 
|  | 381 | 2000: VersioningTestV2 vertwo2000, | 
|  | 382 | 2500: set<string> a_set2500, | 
|  | 383 | 3000: VersioningTestV2 vertwo3000, | 
|  | 384 | 4000: list<i32> big_numbers | 
|  | 385 | } | 
| Roger Meier | f4eec7a | 2011-09-11 18:16:21 +0000 | [diff] [blame] | 386 |  | 
|  | 387 | struct NestedListsI32x2 { | 
|  | 388 | 1: list<list<i32>> integerlist | 
|  | 389 | } | 
|  | 390 | struct NestedListsI32x3 { | 
|  | 391 | 1: list<list<list<i32>>> integerlist | 
|  | 392 | } | 
|  | 393 | struct NestedMixedx2 { | 
|  | 394 | 1: list<set<i32>> int_set_list | 
|  | 395 | 2: map<i32,set<string>> map_int_strset | 
|  | 396 | 3: list<map<i32,set<string>>> map_int_strset_list | 
|  | 397 | } | 
|  | 398 | struct ListBonks { | 
|  | 399 | 1: list<Bonk> bonk | 
|  | 400 | } | 
|  | 401 | struct NestedListsBonk { | 
|  | 402 | 1: list<list<list<Bonk>>> bonk | 
|  | 403 | } | 
| Bryan Duxbury | 6c928f3 | 2011-10-13 21:32:52 +0000 | [diff] [blame] | 404 |  | 
|  | 405 | struct BoolTest { | 
|  | 406 | 1: optional bool b = true; | 
|  | 407 | 2: optional string s = "true"; | 
|  | 408 | } | 
| Bryan Duxbury | a3df547 | 2011-12-27 22:26:59 +0000 | [diff] [blame] | 409 |  | 
|  | 410 | struct StructA { | 
|  | 411 | 1: required string s; | 
|  | 412 | } | 
|  | 413 |  | 
|  | 414 | struct StructB { | 
|  | 415 | 1: optional StructA aa; | 
|  | 416 | 2: required StructA ab; | 
| Henrique Mendonça | 8ad13a3 | 2013-05-16 21:26:20 +0200 | [diff] [blame] | 417 | } | 
| John Boiles | 5eef01f | 2019-06-13 10:49:45 -0700 | [diff] [blame] | 418 |  | 
|  | 419 | struct OptionalSetDefaultTest { | 
|  | 420 | 1: optional set<string> with_default = [ "test" ] | 
|  | 421 | } | 
| Yuri Melnikov | 38bd636 | 2021-09-08 18:46:12 -0400 | [diff] [blame] | 422 |  | 
|  | 423 | struct OptionalBinary { | 
|  | 424 | 1: optional set<binary> bin_set = {} | 
|  | 425 | 2: optional map<binary,i32> bin_map = {} | 
|  | 426 | } |