diff options
author | Hans Nilsson <[email protected]> | 2017-11-23 10:35:12 +0100 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2017-11-23 10:35:12 +0100 |
commit | 3bf3ba8c31b13df4fdbd9a83ca3f8b31248a220c (patch) | |
tree | a0a905c9e041fa7735f538aae376263f15d973c6 /lib/asn1/src | |
parent | a256f44fc846933e16a302b9d6b25bb643e9397b (diff) | |
parent | 3af1b1a34a577f890029c09eb755c98f48a1af80 (diff) | |
download | otp-3bf3ba8c31b13df4fdbd9a83ca3f8b31248a220c.tar.gz otp-3bf3ba8c31b13df4fdbd9a83ca3f8b31248a220c.tar.bz2 otp-3bf3ba8c31b13df4fdbd9a83ca3f8b31248a220c.zip |
Merge branch 'hans/asn1/asn1ct_test_fix/ERL-518/OTP-14787' into maint
* hans/asn1/asn1ct_test_fix/ERL-518/OTP-14787:
asn1: asn1:test now handles no_ok_wrapper and undec_rest
Diffstat (limited to 'lib/asn1/src')
-rw-r--r-- | lib/asn1/src/asn1ct.erl | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/lib/asn1/src/asn1ct.erl b/lib/asn1/src/asn1ct.erl index f36d71a601..81a2735a0d 100644 --- a/lib/asn1/src/asn1ct.erl +++ b/lib/asn1/src/asn1ct.erl @@ -1335,25 +1335,39 @@ test_value(Module, Type, Value) -> in_process(fun() -> case catch Module:encode(Type, Value) of {ok, Bytes} -> - NewBytes = prepare_bytes(Bytes), - case Module:decode(Type, NewBytes) of - {ok, Value} -> - {ok, {Module, Type, Value}}; - {ok, Res} -> - {error, {asn1, - {encode_decode_mismatch, - {{Module, Type, Value}, Res}}}}; - Error -> - {error, {asn1, - {{decode, - {Module, Type, Value}, Error}}}} - end; + test_value_decode(Module, Type, Value, Bytes); + Bytes when is_binary(Bytes) -> + test_value_decode(Module, Type, Value, Bytes); Error -> {error, {asn1, {encode, {{Module, Type, Value}, Error}}}} end end). + +test_value_decode(Module, Type, Value, Bytes) -> + NewBytes = prepare_bytes(Bytes), + case Module:decode(Type, NewBytes) of + {ok,Value} -> {ok, {Module,Type,Value}}; + {ok,Value,<<>>} -> {ok, {Module,Type,Value}}; + Value -> {ok, {Module,Type,Value}}; + {Value,<<>>} -> {ok, {Module,Type,Value}}; + + %% Errors: + {ok, Res} -> + {error, {asn1, + {encode_decode_mismatch, + {{Module, Type, Value}, Res}}}}; + {ok, Res, Rest} -> + {error, {asn1, + {encode_decode_mismatch, + {{Module, Type, Value}, {Res,Rest}}}}}; + Error -> + {error, {asn1, + {{decode, + {Module, Type, Value}, Error}}}} + end. + value(Module, Type) -> value(Module, Type, []). value(Module, Type, Includes) -> |