Anthony F. Molinaro | 917d898 | 2011-06-21 06:20:18 +0000 | [diff] [blame] | 1 | -module(test_thrift_1151). |
| 2 | |
Roger Meier | 25c68f4 | 2014-09-29 22:12:50 +0200 | [diff] [blame] | 3 | -include("gen-erl/thrift1151_types.hrl"). |
Anthony F. Molinaro | 917d898 | 2011-06-21 06:20:18 +0000 | [diff] [blame] | 4 | |
| 5 | -ifdef(TEST). |
| 6 | -include_lib("eunit/include/eunit.hrl"). |
| 7 | |
| 8 | unmatched_struct_test() -> |
Jens Geyer | 6d15c30 | 2014-10-02 10:03:09 +0200 | [diff] [blame] | 9 | S1 = #'StructC'{x=#'StructB'{x=1}}, |
Anthony F. Molinaro | 917d898 | 2011-06-21 06:20:18 +0000 | [diff] [blame] | 10 | {ok, Transport} = thrift_memory_buffer:new(), |
| 11 | {ok, Protocol} = thrift_binary_protocol:new(Transport), |
Jens Geyer | 6d15c30 | 2014-10-02 10:03:09 +0200 | [diff] [blame] | 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 | ). |
Anthony F. Molinaro | 917d898 | 2011-06-21 06:20:18 +0000 | [diff] [blame] | 20 | |
| 21 | badarg_test() -> |
Jens Geyer | 6d15c30 | 2014-10-02 10:03:09 +0200 | [diff] [blame] | 22 | S2 = #'StructC'{x=#'StructA'{x="1"}}, |
Anthony F. Molinaro | 917d898 | 2011-06-21 06:20:18 +0000 | [diff] [blame] | 23 | {ok, Transport} = thrift_memory_buffer:new(), |
| 24 | {ok, Protocol} = thrift_binary_protocol:new(Transport), |
Jens Geyer | 6d15c30 | 2014-10-02 10:03:09 +0200 | [diff] [blame] | 25 | ?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. Molinaro | 917d898 | 2011-06-21 06:20:18 +0000 | [diff] [blame] | 33 | |
| 34 | -endif. |