blob: f4a910e7dbbb721a7561ce23b1a9cd35c9156e1b [file] [log] [blame]
Anthony F. Molinaro917d8982011-06-21 06:20:18 +00001-module(test_thrift_1151).
2
Roger Meier25c68f42014-09-29 22:12:50 +02003-include("gen-erl/thrift1151_types.hrl").
Anthony F. Molinaro917d8982011-06-21 06:20:18 +00004
5-ifdef(TEST).
6-include_lib("eunit/include/eunit.hrl").
7
8unmatched_struct_test() ->
Jens Geyer6d15c302014-10-02 10:03:09 +02009 S1 = #'StructC'{x=#'StructB'{x=1}},
Anthony F. Molinaro917d8982011-06-21 06:20:18 +000010 {ok, Transport} = thrift_memory_buffer:new(),
11 {ok, Protocol} = thrift_binary_protocol:new(Transport),
Jens Geyer6d15c302014-10-02 10:03:09 +020012 ?assertException(
13 error,
14 struct_unmatched,
15 thrift_protocol:write(
16 Protocol,
17 {{struct, element(2, thrift1151_types:struct_info('StructC'))}, S1}
18 )
19 ).
Anthony F. Molinaro917d8982011-06-21 06:20:18 +000020
21badarg_test() ->
Jens Geyer6d15c302014-10-02 10:03:09 +020022 S2 = #'StructC'{x=#'StructA'{x="1"}},
Anthony F. Molinaro917d8982011-06-21 06:20:18 +000023 {ok, Transport} = thrift_memory_buffer:new(),
24 {ok, Protocol} = thrift_binary_protocol:new(Transport),
Jens Geyer6d15c302014-10-02 10:03:09 +020025 ?assertException(
26 error,
27 badarg,
28 thrift_protocol:write(
29 Protocol,
30 {{struct, element(2, thrift1151_types:struct_info('StructC'))}, S2}
31 )
32 ).
Anthony F. Molinaro917d8982011-06-21 06:20:18 +000033
34-endif.