blob: ae20f31992bf44f222f4e8f0f7f9891be1a035eb [file] [log] [blame]
Jens Geyer6d15c302014-10-02 10:03:09 +02001%%
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% don't rename this thrift_test, it clobbers generated files
21-module(thrift_test_test).
22-compile(export_all).
23
24-include_lib("eunit/include/eunit.hrl").
25
Nobuaki Sukegawa826ea992015-10-28 22:19:45 +090026-include("gen-erl/thrift_test_constants.hrl").
Jens Geyer6d15c302014-10-02 10:03:09 +020027
28constant_test_() ->
29 [
30 {"myNumberz equals 1", ?_assertEqual(1, ?THRIFT_TEST_MYNUMBERZ)}
31 ].
32
33record_generation_test_() ->
34 [
35 {"Bonk record", ?_assertMatch(
Steve Cohen7ea4a872016-06-14 00:32:48 +020036 {'thrift.test.Bonk', _, _},
37 #'thrift.test.Bonk'{message=null,type=null}
Jens Geyer6d15c302014-10-02 10:03:09 +020038 )},
39 {"Bools record", ?_assertMatch(
Steve Cohen7ea4a872016-06-14 00:32:48 +020040 {'thrift.test.Bools', _, _},
41 #'thrift.test.Bools'{im_true=null,im_false=null}
Jens Geyer6d15c302014-10-02 10:03:09 +020042 )},
43 {"Xtruct record", ?_assertMatch(
Steve Cohen7ea4a872016-06-14 00:32:48 +020044 {'thrift.test.Xtruct', _, _, _, _},
45 #'thrift.test.Xtruct'{string_thing=null,byte_thing=null,i32_thing=null,i64_thing=null}
Jens Geyer6d15c302014-10-02 10:03:09 +020046 )},
47 {"Xtruct2 record", ?_assertMatch(
Steve Cohen7ea4a872016-06-14 00:32:48 +020048 {'thrift.test.Xtruct2', _, _, _},
49 #'thrift.test.Xtruct2'{byte_thing=null,struct_thing=null,i32_thing=null}
Jens Geyer6d15c302014-10-02 10:03:09 +020050 )},
51 {"Xtruct3 record", ?_assertMatch(
Steve Cohen7ea4a872016-06-14 00:32:48 +020052 {'thrift.test.Xtruct3', _, _, _, _},
53 #'thrift.test.Xtruct3'{string_thing=null,changed=null,i32_thing=null,i64_thing=null}
Jens Geyer6d15c302014-10-02 10:03:09 +020054 )},
55 {"Insanity record", ?_assertMatch(
Steve Cohen7ea4a872016-06-14 00:32:48 +020056 {'thrift.test.Insanity', _, _},
57 #'thrift.test.Insanity'{userMap=null,xtructs=null}
Jens Geyer6d15c302014-10-02 10:03:09 +020058 )},
59 {"CrazyNesting record", ?_assertMatch(
Steve Cohen7ea4a872016-06-14 00:32:48 +020060 {'thrift.test.CrazyNesting', _, _, _, _},
61 #'thrift.test.CrazyNesting'{
Jens Geyer6d15c302014-10-02 10:03:09 +020062 string_field=null,
63 set_field=null,
64 list_field=null,
65 binary_field=null
66 }
67 )},
68 {"Xception record", ?_assertMatch(
Steve Cohen7ea4a872016-06-14 00:32:48 +020069 {'thrift.test.Xception', _, _},
70 #'thrift.test.Xception'{errorCode=null,message=null}
Jens Geyer6d15c302014-10-02 10:03:09 +020071 )},
72 {"Xception2 record", ?_assertMatch(
Steve Cohen7ea4a872016-06-14 00:32:48 +020073 {'thrift.test.Xception2', _, _},
74 #'thrift.test.Xception2'{errorCode=null,struct_thing=null}
Jens Geyer6d15c302014-10-02 10:03:09 +020075 )},
Steve Cohen7ea4a872016-06-14 00:32:48 +020076 {"EmptyStruct record", ?_assertMatch({'thrift.test.EmptyStruct'}, #'thrift.test.EmptyStruct'{})},
77 {"OneField record", ?_assertMatch({'thrift.test.OneField', _}, #'thrift.test.OneField'{field=null})},
Jens Geyer6d15c302014-10-02 10:03:09 +020078 {"VersioningTestV1 record", ?_assertMatch(
Steve Cohen7ea4a872016-06-14 00:32:48 +020079 {'thrift.test.VersioningTestV1', _, _, _},
80 #'thrift.test.VersioningTestV1'{begin_in_both=null,old_string=null,end_in_both=null}
Jens Geyer6d15c302014-10-02 10:03:09 +020081 )},
82 {"VersioningTestV2 record", ?_assertMatch(
Steve Cohen7ea4a872016-06-14 00:32:48 +020083 {'thrift.test.VersioningTestV2', _, _, _, _, _, _, _, _, _, _, _, _},
84 #'thrift.test.VersioningTestV2'{
Jens Geyer6d15c302014-10-02 10:03:09 +020085 begin_in_both=null,
86 newint=null,
87 newbyte=null,
88 newshort=null,
89 newlong=null,
90 newdouble=null,
91 newstruct=null,
92 newlist=null,
93 newset=null,
94 newmap=null,
95 newstring=null,
96 end_in_both=null
97 }
98 )},
99 {"ListTypeVersioningV1 record", ?_assertMatch(
Steve Cohen7ea4a872016-06-14 00:32:48 +0200100 {'thrift.test.ListTypeVersioningV1', _, _},
101 #'thrift.test.ListTypeVersioningV1'{myints=null,hello=null}
Jens Geyer6d15c302014-10-02 10:03:09 +0200102 )},
103 {"ListTypeVersioningV2 record", ?_assertMatch(
Steve Cohen7ea4a872016-06-14 00:32:48 +0200104 {'thrift.test.ListTypeVersioningV2', _, _},
105 #'thrift.test.ListTypeVersioningV2'{strings=null,hello=null}
Jens Geyer6d15c302014-10-02 10:03:09 +0200106 )},
107 {"GuessProtocolStruct record", ?_assertMatch(
Steve Cohen7ea4a872016-06-14 00:32:48 +0200108 {'thrift.test.GuessProtocolStruct', _},
109 #'thrift.test.GuessProtocolStruct'{map_field=null}
Jens Geyer6d15c302014-10-02 10:03:09 +0200110 )},
111 {"LargeDeltas record", ?_assertMatch(
Steve Cohen7ea4a872016-06-14 00:32:48 +0200112 {'thrift.test.LargeDeltas', _, _, _, _, _, _, _, _, _, _},
113 #'thrift.test.LargeDeltas'{
Jens Geyer6d15c302014-10-02 10:03:09 +0200114 b1=null,
115 b10=null,
116 b100=null,
117 check_true=null,
118 b1000=null,
119 check_false=null,
120 vertwo2000=null,
121 a_set2500=null,
122 vertwo3000=null,
123 big_numbers=null
124 }
125 )},
126 {"NestedListsI32x2 record", ?_assertMatch(
Steve Cohen7ea4a872016-06-14 00:32:48 +0200127 {'thrift.test.NestedListsI32x2', _},
128 #'thrift.test.NestedListsI32x2'{integerlist=null}
Jens Geyer6d15c302014-10-02 10:03:09 +0200129 )},
130 {"NestedListsI32x3 record", ?_assertMatch(
Steve Cohen7ea4a872016-06-14 00:32:48 +0200131 {'thrift.test.NestedListsI32x3', _},
132 #'thrift.test.NestedListsI32x3'{integerlist=null}
Jens Geyer6d15c302014-10-02 10:03:09 +0200133 )},
134 {"NestedMixedx2 record", ?_assertMatch(
Steve Cohen7ea4a872016-06-14 00:32:48 +0200135 {'thrift.test.NestedMixedx2', _, _, _},
136 #'thrift.test.NestedMixedx2'{
Jens Geyer6d15c302014-10-02 10:03:09 +0200137 int_set_list=null,
138 map_int_strset=null,
139 map_int_strset_list=null
140 }
141 )},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200142 {"ListBonks record", ?_assertMatch({'thrift.test.ListBonks', _}, #'thrift.test.ListBonks'{bonk=null})},
Jens Geyer6d15c302014-10-02 10:03:09 +0200143 {"NestedListsBonk record", ?_assertMatch(
Steve Cohen7ea4a872016-06-14 00:32:48 +0200144 {'thrift.test.NestedListsBonk', _},
145 #'thrift.test.NestedListsBonk'{bonk=null}
Jens Geyer6d15c302014-10-02 10:03:09 +0200146 )},
147 {"BoolTest record", ?_assertMatch(
Steve Cohen7ea4a872016-06-14 00:32:48 +0200148 {'thrift.test.BoolTest', _, _},
149 #'thrift.test.BoolTest'{b=null,s=null}
Jens Geyer6d15c302014-10-02 10:03:09 +0200150 )},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200151 {"StructA record", ?_assertMatch({'thrift.test.StructA', _}, #'thrift.test.StructA'{s=null})},
Jens Geyer6d15c302014-10-02 10:03:09 +0200152 {"StructB record", ?_assertMatch(
Steve Cohen7ea4a872016-06-14 00:32:48 +0200153 {'thrift.test.StructB', _, _},
154 #'thrift.test.StructB'{aa=null,ab=null}
Jens Geyer6d15c302014-10-02 10:03:09 +0200155 )}
156 ].
157
158struct_info_test_() ->
159 [
160 {"Bonk definition (short version)", ?_assertEqual(
161 {struct, [{1, string}, {2, i32}]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200162 thrift_test_types:struct_info('thrift.test.Bonk')
Jens Geyer6d15c302014-10-02 10:03:09 +0200163 )},
164 {"Bonk definition", ?_assertEqual(
165 {struct, [
166 {1, undefined, string, message, undefined},
167 {2, undefined, i32, type, undefined}
168 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200169 thrift_test_types:struct_info_ext('thrift.test.Bonk')
Jens Geyer6d15c302014-10-02 10:03:09 +0200170 )},
171 {"Bools definition", ?_assertEqual(
172 {struct, [
173 {1, undefined, bool, im_true, undefined},
174 {2, undefined, bool, im_false, undefined}
175 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200176 thrift_test_types:struct_info_ext('thrift.test.Bools')
Jens Geyer6d15c302014-10-02 10:03:09 +0200177 )},
178 {"Xtruct definition", ?_assertEqual(
179 {struct, [
180 {1, undefined, string, string_thing, undefined},
181 {4, undefined, byte, byte_thing, undefined},
182 {9, undefined, i32, i32_thing, undefined},
183 {11, undefined, i64, i64_thing, undefined}
184 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200185 thrift_test_types:struct_info_ext('thrift.test.Xtruct')
Jens Geyer6d15c302014-10-02 10:03:09 +0200186 )},
187 {"Xtruct2 definition", ?_assertEqual(
188 {struct, [
189 {1, undefined, byte, byte_thing, undefined},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200190 {2, undefined, {struct, {'thrift_test_types', 'thrift.test.Xtruct'}}, struct_thing, #'thrift.test.Xtruct'{}},
Jens Geyer6d15c302014-10-02 10:03:09 +0200191 {3, undefined, i32, i32_thing, undefined}
192 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200193 thrift_test_types:struct_info_ext('thrift.test.Xtruct2')
Jens Geyer6d15c302014-10-02 10:03:09 +0200194 )},
195 {"Xtruct3 definition", ?_assertEqual(
196 {struct, [
197 {1, undefined, string, string_thing, undefined},
198 {4, undefined, i32, changed, undefined},
199 {9, undefined, i32, i32_thing, undefined},
200 {11, undefined, i64, i64_thing, undefined}
201 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200202 thrift_test_types:struct_info_ext('thrift.test.Xtruct3')
Jens Geyer6d15c302014-10-02 10:03:09 +0200203 )},
204 {"Insanity definition", ?_assertEqual(
205 {struct, [
206 {1, undefined, {map, i32, i64}, userMap, dict:new()},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200207 {2, undefined, {list, {struct, {'thrift_test_types', 'thrift.test.Xtruct'}}}, xtructs, []}
Jens Geyer6d15c302014-10-02 10:03:09 +0200208 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200209 thrift_test_types:struct_info_ext('thrift.test.Insanity')
Jens Geyer6d15c302014-10-02 10:03:09 +0200210 )},
211 {"CrazyNesting definition", ?_assertEqual(
212 {struct, [
213 {1, undefined, string, string_field, undefined},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200214 {2, optional, {set, {struct, {'thrift_test_types', 'thrift.test.Insanity'}}}, set_field, sets:new()},
215 {3, required, {list, {map,
Jens Geyer6d15c302014-10-02 10:03:09 +0200216 {set, i32},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200217 {map, i32, {set, {list, {map, {struct, {'thrift_test_types', 'thrift.test.Insanity'}}, string}}}}
Jens Geyer6d15c302014-10-02 10:03:09 +0200218 }}, list_field, []},
219 {4, undefined, string, binary_field, undefined}
220 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200221 thrift_test_types:struct_info_ext('thrift.test.CrazyNesting')
Jens Geyer6d15c302014-10-02 10:03:09 +0200222 )},
223 {"Xception definition", ?_assertEqual(
224 {struct, [
225 {1, undefined, i32, errorCode, undefined},
226 {2, undefined, string, message, undefined}
227 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200228 thrift_test_types:struct_info_ext('thrift.test.Xception')
Jens Geyer6d15c302014-10-02 10:03:09 +0200229 )},
230 {"Xception2 definition", ?_assertEqual(
231 {struct, [
232 {1, undefined, i32, errorCode, undefined},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200233 {2, undefined, {struct, {'thrift_test_types', 'thrift.test.Xtruct'}}, struct_thing, #'thrift.test.Xtruct'{}}
Jens Geyer6d15c302014-10-02 10:03:09 +0200234 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200235 thrift_test_types:struct_info_ext('thrift.test.Xception2')
Jens Geyer6d15c302014-10-02 10:03:09 +0200236 )},
237 {"EmptyStruct definition", ?_assertEqual(
238 {struct, []},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200239 thrift_test_types:struct_info_ext('thrift.test.EmptyStruct')
Jens Geyer6d15c302014-10-02 10:03:09 +0200240 )},
241 {"OneField definition", ?_assertEqual(
242 {struct, [
Steve Cohen7ea4a872016-06-14 00:32:48 +0200243 {1, undefined, {struct, {'thrift_test_types', 'thrift.test.EmptyStruct'}}, field, #'thrift.test.EmptyStruct'{}}
Jens Geyer6d15c302014-10-02 10:03:09 +0200244 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200245 thrift_test_types:struct_info_ext('thrift.test.OneField')
Jens Geyer6d15c302014-10-02 10:03:09 +0200246 )},
247 {"VersioningTestV1 definition", ?_assertEqual(
248 {struct, [
249 {1, undefined, i32, begin_in_both, undefined},
250 {3, undefined, string, old_string, undefined},
251 {12, undefined, i32, end_in_both, undefined}
252 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200253 thrift_test_types:struct_info_ext('thrift.test.VersioningTestV1')
Jens Geyer6d15c302014-10-02 10:03:09 +0200254 )},
255 {"VersioningTestV2 definition", ?_assertEqual(
256 {struct, [
257 {1, undefined, i32, begin_in_both, undefined},
258 {2, undefined, i32, newint, undefined},
259 {3, undefined, byte, newbyte, undefined},
260 {4, undefined, i16, newshort, undefined},
261 {5, undefined, i64, newlong, undefined},
262 {6, undefined, double, newdouble, undefined},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200263 {7, undefined, {struct, {thrift_test_types, 'thrift.test.Bonk'}}, newstruct, #'thrift.test.Bonk'{}},
Jens Geyer6d15c302014-10-02 10:03:09 +0200264 {8, undefined, {list, i32}, newlist, []},
265 {9, undefined, {set, i32}, newset, sets:new()},
266 {10, undefined, {map, i32, i32}, newmap, dict:new()},
267 {11, undefined, string, newstring, undefined},
268 {12, undefined, i32, end_in_both, undefined}
269 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200270 thrift_test_types:struct_info_ext('thrift.test.VersioningTestV2')
Jens Geyer6d15c302014-10-02 10:03:09 +0200271 )},
272 {"ListTypeVersioningV1 definition", ?_assertEqual(
273 {struct, [
274 {1, undefined, {list, i32}, myints, []},
275 {2, undefined, string, hello, undefined}
276 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200277 thrift_test_types:struct_info_ext('thrift.test.ListTypeVersioningV1')
Jens Geyer6d15c302014-10-02 10:03:09 +0200278 )},
279 {"ListTypeVersioningV2 definition", ?_assertEqual(
280 {struct, [
281 {1, undefined, {list, string}, strings, []},
282 {2, undefined, string, hello, undefined}
283 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200284 thrift_test_types:struct_info_ext('thrift.test.ListTypeVersioningV2')
Jens Geyer6d15c302014-10-02 10:03:09 +0200285 )},
286 {"GuessProtocolStruct definition", ?_assertEqual(
287 {struct, [
288 {7, undefined, {map, string, string}, map_field, dict:new()}
289 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200290 thrift_test_types:struct_info_ext('thrift.test.GuessProtocolStruct')
Jens Geyer6d15c302014-10-02 10:03:09 +0200291 )},
292 {"LargeDeltas definition", ?_assertEqual(
293 {struct, [
Steve Cohen7ea4a872016-06-14 00:32:48 +0200294 {1, undefined, {struct, {thrift_test_types, 'thrift.test.Bools'}}, b1, #'thrift.test.Bools'{}},
295 {10, undefined, {struct, {thrift_test_types, 'thrift.test.Bools'}}, b10, #'thrift.test.Bools'{}},
296 {100, undefined, {struct, {thrift_test_types, 'thrift.test.Bools'}}, b100, #'thrift.test.Bools'{}},
Jens Geyer6d15c302014-10-02 10:03:09 +0200297 {500, undefined, bool, check_true, undefined},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200298 {1000, undefined, {struct, {thrift_test_types, 'thrift.test.Bools'}}, b1000, #'thrift.test.Bools'{}},
Jens Geyer6d15c302014-10-02 10:03:09 +0200299 {1500, undefined, bool, check_false, undefined},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200300 {2000, undefined, {struct, {thrift_test_types, 'thrift.test.VersioningTestV2'}}, vertwo2000, #'thrift.test.VersioningTestV2'{}},
Jens Geyer6d15c302014-10-02 10:03:09 +0200301 {2500, undefined, {set, string}, a_set2500, sets:new()},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200302 {3000, undefined, {struct, {thrift_test_types, 'thrift.test.VersioningTestV2'}}, vertwo3000, #'thrift.test.VersioningTestV2'{}},
Jens Geyer6d15c302014-10-02 10:03:09 +0200303 {4000, undefined, {list, i32}, big_numbers, []}
304 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200305 thrift_test_types:struct_info_ext('thrift.test.LargeDeltas')
Jens Geyer6d15c302014-10-02 10:03:09 +0200306 )},
307 {"NestedListsI32x2 definition", ?_assertEqual(
308 {struct, [
309 {1, undefined, {list, {list, i32}}, integerlist, []}
310 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200311 thrift_test_types:struct_info_ext('thrift.test.NestedListsI32x2')
Jens Geyer6d15c302014-10-02 10:03:09 +0200312 )},
313 {"NestedListsI32x3 definition", ?_assertEqual(
314 {struct, [
315 {1, undefined, {list, {list, {list, i32}}}, integerlist, []}
316 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200317 thrift_test_types:struct_info_ext('thrift.test.NestedListsI32x3')
Jens Geyer6d15c302014-10-02 10:03:09 +0200318 )},
319 {"NestedMixedx2 definition", ?_assertEqual(
320 {struct, [
321 {1, undefined, {list, {set, i32}}, int_set_list, []},
322 {2, undefined, {map, i32, {set, string}}, map_int_strset, dict:new()},
323 {3, undefined, {list, {map, i32, {set, string}}}, map_int_strset_list, []}
324 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200325 thrift_test_types:struct_info_ext('thrift.test.NestedMixedx2')
Jens Geyer6d15c302014-10-02 10:03:09 +0200326 )},
327 {"ListBonks definition", ?_assertEqual(
328 {struct, [
Steve Cohen7ea4a872016-06-14 00:32:48 +0200329 {1, undefined, {list, {struct, {thrift_test_types, 'thrift.test.Bonk'}}}, bonk, []}
Jens Geyer6d15c302014-10-02 10:03:09 +0200330 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200331 thrift_test_types:struct_info_ext('thrift.test.ListBonks')
Jens Geyer6d15c302014-10-02 10:03:09 +0200332 )},
333 {"NestedListsBonk definition", ?_assertEqual(
334 {struct, [
Steve Cohen7ea4a872016-06-14 00:32:48 +0200335 {1, undefined, {list, {list, {list, {struct, {thrift_test_types, 'thrift.test.Bonk'}}}}}, bonk, []}
Jens Geyer6d15c302014-10-02 10:03:09 +0200336 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200337 thrift_test_types:struct_info_ext('thrift.test.NestedListsBonk')
Jens Geyer6d15c302014-10-02 10:03:09 +0200338 )},
339 {"BoolTest definition", ?_assertEqual(
340 {struct, [
341 {1, optional, bool, b, true},
342 {2, optional, string, s, "true"}
343 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200344 thrift_test_types:struct_info_ext('thrift.test.BoolTest')
Jens Geyer6d15c302014-10-02 10:03:09 +0200345 )},
346 {"StructA definition", ?_assertEqual(
347 {struct, [{1, required, string, s, undefined}]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200348 thrift_test_types:struct_info_ext('thrift.test.StructA')
Jens Geyer6d15c302014-10-02 10:03:09 +0200349 )},
350 {"StructB definition", ?_assertEqual(
351 {struct, [
Steve Cohen7ea4a872016-06-14 00:32:48 +0200352 {1, optional, {struct, {thrift_test_types, 'thrift.test.StructA'}}, aa, #'thrift.test.StructA'{}},
353 {2, required, {struct, {thrift_test_types, 'thrift.test.StructA'}}, ab, #'thrift.test.StructA'{}}
Jens Geyer6d15c302014-10-02 10:03:09 +0200354 ]},
Steve Cohen7ea4a872016-06-14 00:32:48 +0200355 thrift_test_types:struct_info_ext('thrift.test.StructB')
Jens Geyer6d15c302014-10-02 10:03:09 +0200356 )}
357 ].
358
359service_info_test_() ->
360 [
361 {"testVoid params", ?_assertEqual(
362 {struct, []},
363 thrift_test_thrift:function_info(testVoid, params_type)
364 )},
365 {"testVoid reply", ?_assertEqual(
366 {struct, []},
367 thrift_test_thrift:function_info(testVoid, reply_type)
368 )},
369 {"testVoid exceptions", ?_assertEqual(
370 {struct, []},
371 thrift_test_thrift:function_info(testVoid, exceptions)
372 )},
373 {"testString params", ?_assertEqual(
374 {struct, [{1, string}]},
375 thrift_test_thrift:function_info(testString, params_type)
376 )},
377 {"testString reply", ?_assertEqual(
378 string,
379 thrift_test_thrift:function_info(testString, reply_type)
380 )},
381 {"testString exceptions", ?_assertEqual(
382 {struct, []},
383 thrift_test_thrift:function_info(testString, exceptions)
384 )},
385 {"testByte params", ?_assertEqual(
386 {struct, [{1, byte}]},
387 thrift_test_thrift:function_info(testByte, params_type)
388 )},
389 {"testByte reply", ?_assertEqual(
390 byte,
391 thrift_test_thrift:function_info(testByte, reply_type)
392 )},
393 {"testByte exceptions", ?_assertEqual(
394 {struct, []},
395 thrift_test_thrift:function_info(testByte, exceptions)
396 )},
397 {"testI32 params", ?_assertEqual(
398 {struct, [{1, i32}]},
399 thrift_test_thrift:function_info(testI32, params_type)
400 )},
401 {"testI32 reply", ?_assertEqual(
402 i32,
403 thrift_test_thrift:function_info(testI32, reply_type)
404 )},
405 {"testI32 exceptions", ?_assertEqual(
406 {struct, []},
407 thrift_test_thrift:function_info(testI32, exceptions)
408 )},
409 {"testI64 params", ?_assertEqual(
410 {struct, [{1, i64}]},
411 thrift_test_thrift:function_info(testI64, params_type)
412 )},
413 {"testI64 reply", ?_assertEqual(
414 i64,
415 thrift_test_thrift:function_info(testI64, reply_type)
416 )},
417 {"testI64 exceptions", ?_assertEqual(
418 {struct, []},
419 thrift_test_thrift:function_info(testI64, exceptions)
420 )},
421 {"testDouble params", ?_assertEqual(
422 {struct, [{1, double}]},
423 thrift_test_thrift:function_info(testDouble, params_type)
424 )},
425 {"testDouble reply", ?_assertEqual(
426 double,
427 thrift_test_thrift:function_info(testDouble, reply_type)
428 )},
429 {"testDouble exceptions", ?_assertEqual(
430 {struct, []},
431 thrift_test_thrift:function_info(testDouble, exceptions)
432 )},
433 {"testStruct params", ?_assertEqual(
434 {struct, [
Steve Cohen7ea4a872016-06-14 00:32:48 +0200435 {1, {struct, {thrift_test_types, 'thrift.test.Xtruct'}}}
Jens Geyer6d15c302014-10-02 10:03:09 +0200436 ]},
437 thrift_test_thrift:function_info(testStruct, params_type)
438 )},
439 {"testStruct reply", ?_assertEqual(
Steve Cohen7ea4a872016-06-14 00:32:48 +0200440 {struct, {thrift_test_types, 'thrift.test.Xtruct'}},
Jens Geyer6d15c302014-10-02 10:03:09 +0200441 thrift_test_thrift:function_info(testStruct, reply_type)
442 )},
443 {"testStruct exceptions", ?_assertEqual(
444 {struct, []},
445 thrift_test_thrift:function_info(testStruct, exceptions)
446 )},
447 {"testNest params", ?_assertEqual(
448 {struct, [
Steve Cohen7ea4a872016-06-14 00:32:48 +0200449 {1, {struct, {thrift_test_types, 'thrift.test.Xtruct2'}}}
Jens Geyer6d15c302014-10-02 10:03:09 +0200450 ]},
451 thrift_test_thrift:function_info(testNest, params_type)
452 )},
453 {"testNest reply", ?_assertEqual(
Steve Cohen7ea4a872016-06-14 00:32:48 +0200454 {struct, {thrift_test_types, 'thrift.test.Xtruct2'}},
Jens Geyer6d15c302014-10-02 10:03:09 +0200455 thrift_test_thrift:function_info(testNest, reply_type)
456 )},
457 {"testNest exceptions", ?_assertEqual(
458 {struct, []},
459 thrift_test_thrift:function_info(testNest, exceptions)
460 )},
461 {"testMap params", ?_assertEqual(
462 {struct, [
463 {1, {map, i32, i32}}
464 ]},
465 thrift_test_thrift:function_info(testMap, params_type)
466 )},
467 {"testMap reply", ?_assertEqual(
468 {map, i32, i32},
469 thrift_test_thrift:function_info(testMap, reply_type)
470 )},
471 {"testMap exceptions", ?_assertEqual(
472 {struct, []},
473 thrift_test_thrift:function_info(testMap, exceptions)
474 )},
475 {"testStringMap params", ?_assertEqual(
476 {struct, [
477 {1, {map, string, string}}
478 ]},
479 thrift_test_thrift:function_info(testStringMap, params_type)
480 )},
481 {"testStringMap reply", ?_assertEqual(
482 {map, string, string},
483 thrift_test_thrift:function_info(testStringMap, reply_type)
484 )},
485 {"testStringMap exceptions", ?_assertEqual(
486 {struct, []},
487 thrift_test_thrift:function_info(testStringMap, exceptions)
488 )},
489 {"testSet params", ?_assertEqual(
490 {struct, [
491 {1, {set, i32}}
492 ]},
493 thrift_test_thrift:function_info(testSet, params_type)
494 )},
495 {"testSet reply", ?_assertEqual(
496 {set, i32},
497 thrift_test_thrift:function_info(testSet, reply_type)
498 )},
499 {"testSet exceptions", ?_assertEqual(
500 {struct, []},
501 thrift_test_thrift:function_info(testSet, exceptions)
502 )},
503 {"testList params", ?_assertEqual(
504 {struct, [
505 {1, {list, i32}}
506 ]},
507 thrift_test_thrift:function_info(testList, params_type)
508 )},
509 {"testList reply", ?_assertEqual(
510 {list, i32},
511 thrift_test_thrift:function_info(testList, reply_type)
512 )},
513 {"testList exceptions", ?_assertEqual(
514 {struct, []},
515 thrift_test_thrift:function_info(testList, exceptions)
516 )},
517 {"testEnum params", ?_assertEqual(
518 {struct, [
519 {1, i32}
520 ]},
521 thrift_test_thrift:function_info(testEnum, params_type)
522 )},
523 {"testEnum reply", ?_assertEqual(
524 i32,
525 thrift_test_thrift:function_info(testEnum, reply_type)
526 )},
527 {"testEnum exceptions", ?_assertEqual(
528 {struct, []},
529 thrift_test_thrift:function_info(testEnum, exceptions)
530 )},
531 {"testTypedef params", ?_assertEqual(
532 {struct, [{1, i64}]},
533 thrift_test_thrift:function_info(testTypedef, params_type)
534 )},
535 {"testTypedef reply", ?_assertEqual(
536 i64,
537 thrift_test_thrift:function_info(testTypedef, reply_type)
538 )},
539 {"testTypedef exceptions", ?_assertEqual(
540 {struct, []},
541 thrift_test_thrift:function_info(testTypedef, exceptions)
542 )},
543 {"testMapMap params", ?_assertEqual(
544 {struct, [
545 {1, i32}
546 ]},
547 thrift_test_thrift:function_info(testMapMap, params_type)
548 )},
549 {"testMapMap reply", ?_assertEqual(
550 {map, i32, {map, i32,i32}},
551 thrift_test_thrift:function_info(testMapMap, reply_type)
552 )},
553 {"testMapMap exceptions", ?_assertEqual(
554 {struct, []},
555 thrift_test_thrift:function_info(testMapMap, exceptions)
556 )},
557 {"testInsanity params", ?_assertEqual(
558 {struct, [
Steve Cohen7ea4a872016-06-14 00:32:48 +0200559 {1, {struct, {thrift_test_types, 'thrift.test.Insanity'}}}
Jens Geyer6d15c302014-10-02 10:03:09 +0200560 ]},
561 thrift_test_thrift:function_info(testInsanity, params_type)
562 )},
563 {"testInsanity reply", ?_assertEqual(
Steve Cohen7ea4a872016-06-14 00:32:48 +0200564 {map, i64, {map, i32, {struct, {'thrift_test_types', 'thrift.test.Insanity'}}}},
Jens Geyer6d15c302014-10-02 10:03:09 +0200565 thrift_test_thrift:function_info(testInsanity, reply_type)
566 )},
567 {"testInsanity exceptions", ?_assertEqual(
568 {struct, []},
569 thrift_test_thrift:function_info(testInsanity, exceptions)
570 )},
571 {"testMulti params", ?_assertEqual(
572 {struct, [
573 {1, byte},
574 {2, i32},
575 {3, i64},
576 {4, {map, i16, string}},
577 {5, i32},
578 {6, i64}
579 ]},
580 thrift_test_thrift:function_info(testMulti, params_type)
581 )},
582 {"testMulti reply", ?_assertEqual(
Steve Cohen7ea4a872016-06-14 00:32:48 +0200583 {struct, {thrift_test_types, 'thrift.test.Xtruct'}},
Jens Geyer6d15c302014-10-02 10:03:09 +0200584 thrift_test_thrift:function_info(testMulti, reply_type)
585 )},
586 {"testMulti exceptions", ?_assertEqual(
587 {struct, []},
588 thrift_test_thrift:function_info(testMulti, exceptions)
589 )},
590 {"testException params", ?_assertEqual(
591 {struct, [{1, string}]},
592 thrift_test_thrift:function_info(testException, params_type)
593 )},
594 {"testException reply", ?_assertEqual(
595 {struct, []},
596 thrift_test_thrift:function_info(testException, reply_type)
597 )},
598 {"testException exceptions", ?_assertEqual(
599 {struct, [
Steve Cohen7ea4a872016-06-14 00:32:48 +0200600 {1, {struct, {thrift_test_types, 'thrift.test.Xception'}}}
Jens Geyer6d15c302014-10-02 10:03:09 +0200601 ]},
602 thrift_test_thrift:function_info(testException, exceptions)
603 )},
604 {"testMultiException params", ?_assertEqual(
605 {struct, [{1, string}, {2, string}]},
606 thrift_test_thrift:function_info(testMultiException, params_type)
607 )},
608 {"testMultiException reply", ?_assertEqual(
Steve Cohen7ea4a872016-06-14 00:32:48 +0200609 {struct, {thrift_test_types, 'thrift.test.Xtruct'}},
Jens Geyer6d15c302014-10-02 10:03:09 +0200610 thrift_test_thrift:function_info(testMultiException, reply_type)
611 )},
612 {"testMultiException exceptions", ?_assertEqual(
613 {struct, [
Steve Cohen7ea4a872016-06-14 00:32:48 +0200614 {1, {struct, {thrift_test_types, 'thrift.test.Xception'}}},
615 {2, {struct, {thrift_test_types, 'thrift.test.Xception2'}}}
Jens Geyer6d15c302014-10-02 10:03:09 +0200616 ]},
617 thrift_test_thrift:function_info(testMultiException, exceptions)
618 )},
619 {"testOneway params", ?_assertEqual(
620 {struct, [{1, i32}]},
621 thrift_test_thrift:function_info(testOneway, params_type)
622 )},
623 {"testOneway reply", ?_assertEqual(
624 oneway_void,
625 thrift_test_thrift:function_info(testOneway, reply_type)
626 )},
627 {"testOneway exceptions", ?_assertEqual(
628 {struct, []},
629 thrift_test_thrift:function_info(testOneway, exceptions)
630 )},
631 {"blahBlah params", ?_assertEqual(
632 {struct, []},
633 second_service_thrift:function_info(blahBlah, params_type)
634 )},
635 {"blahBlah reply", ?_assertEqual(
636 {struct, []},
637 second_service_thrift:function_info(blahBlah, reply_type)
638 )},
639 {"blahBlah exceptions", ?_assertEqual(
640 {struct, []},
641 second_service_thrift:function_info(blahBlah, exceptions)
642 )},
643 {"secondtestString params", ?_assertEqual(
644 {struct, [{1, string}]},
645 second_service_thrift:function_info(secondtestString, params_type)
646 )},
647 {"secondtestString reply", ?_assertEqual(
648 string,
649 second_service_thrift:function_info(secondtestString, reply_type)
650 )},
651 {"secondtestString exceptions", ?_assertEqual(
652 {struct, []},
653 second_service_thrift:function_info(secondtestString, exceptions)
654 )}
Nobuaki Sukegawa826ea992015-10-28 22:19:45 +0900655 ].