test case for 'switch'
Some checks failed
Gajumaru Serialization Tests / tests (push) Failing after 49m55s
Some checks failed
Gajumaru Serialization Tests / tests (push) Failing after 49m55s
This commit is contained in:
parent
b358dfe914
commit
5df23c05c1
@ -797,6 +797,7 @@ dynamic_types_test_() ->
|
||||
[ ?_test(revert_to_default_types())
|
||||
, ?_test(t_typed_map())
|
||||
, ?_test(t_alts())
|
||||
, ?_test(t_switch())
|
||||
, ?_test(t_anyints())
|
||||
, ?_test(t_missing_labels())
|
||||
].
|
||||
@ -920,6 +921,14 @@ t_alts() ->
|
||||
t_round_trip_typed(#{alt => [negint, int]}, 4),
|
||||
ok.
|
||||
|
||||
t_switch() ->
|
||||
T = #{switch => #{a => int, b => binary}},
|
||||
t_round_trip_typed(T, #{a => 17}),
|
||||
t_round_trip_typed(T, #{b => <<"foo">>}),
|
||||
?assertError({illegal,int,<<"foo">>}, encode_typed(T, #{a => <<"foo">>})),
|
||||
MMap = #{a => 17, b => <<"foo">>},
|
||||
?assertError({illegal, singleton_map, MMap}, encode_typed(T, MMap)).
|
||||
|
||||
t_anyints() ->
|
||||
t_round_trip_typed(anyint, -5),
|
||||
t_round_trip_typed(anyint, 5),
|
||||
@ -947,7 +956,7 @@ t_new_version() ->
|
||||
Types2 = types_from_list([{vsn, V2},
|
||||
{modify, {msg1, {int, int, int}}}], Types1),
|
||||
Enc21 = encode_typed(msg1, T2, Types1),
|
||||
try encode_typed(msg1, T2, Types2) catch error:_ -> ok end,
|
||||
?assertError({illegal,{int,int,int},T2}, encode_typed(msg1, T2, Types2)),
|
||||
T3 = {3,5,7},
|
||||
Enc32 = encode_typed(msg1, T3, Types2),
|
||||
T3 = decode(Enc32, Types2).
|
||||
|
Loading…
x
Reference in New Issue
Block a user