1-module(test_thrift_1151).
2
3-include("gen-erl/thrift1151_types.hrl").
4
5-ifdef(TEST).
6-include_lib("eunit/include/eunit.hrl").
7
8unmatched_struct_test() ->
9  S1 = #'StructC'{x=#'StructB'{x=1}},
10  {ok, Transport} = thrift_memory_buffer:new(),
11  {ok, Protocol} = thrift_binary_protocol:new(Transport),
12  ?assertException(
13    error,
14    struct_unmatched,
15    thrift_protocol:write(
16      Protocol,
17      {{struct, element(2, thrift1151_types:struct_info('StructC'))}, S1}
18    )
19  ).
20
21badarg_test() ->
22  S2 = #'StructC'{x=#'StructA'{x="1"}},
23  {ok, Transport} = thrift_memory_buffer:new(),
24  {ok, Protocol} = thrift_binary_protocol:new(Transport),
25  ?assertException(
26    error,
27    badarg,
28    thrift_protocol:write(
29      Protocol,
30      {{struct, element(2, thrift1151_types:struct_info('StructC'))}, S2}
31    )
32  ).
33
34-endif.
35