aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2017-11-23 10:35:12 +0100
committerHans Nilsson <[email protected]>2017-11-23 10:35:12 +0100
commit3bf3ba8c31b13df4fdbd9a83ca3f8b31248a220c (patch)
treea0a905c9e041fa7735f538aae376263f15d973c6 /lib/asn1
parenta256f44fc846933e16a302b9d6b25bb643e9397b (diff)
parent3af1b1a34a577f890029c09eb755c98f48a1af80 (diff)
downloadotp-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')
-rw-r--r--lib/asn1/src/asn1ct.erl40
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) ->