aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/test/asn1_test_lib.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/asn1/test/asn1_test_lib.erl')
-rw-r--r--lib/asn1/test/asn1_test_lib.erl23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/asn1/test/asn1_test_lib.erl b/lib/asn1/test/asn1_test_lib.erl
index 530d2a38a1..417380159e 100644
--- a/lib/asn1/test/asn1_test_lib.erl
+++ b/lib/asn1/test/asn1_test_lib.erl
@@ -19,10 +19,9 @@
%%
-module(asn1_test_lib).
--export([compile/3]).
--export([compile_all/3]).
--export([compile_erlang/3]).
--export([hex_to_bin/1]).
+-export([compile/3,compile_all/3,compile_erlang/3,
+ hex_to_bin/1,
+ roundtrip/3,roundtrip/4,roundtrip_enc/3,roundtrip_enc/4]).
-include_lib("test_server/include/test_server.hrl").
@@ -54,6 +53,22 @@ compile_erlang(Mod, Config, Options) ->
hex_to_bin(S) ->
<< <<(hex2num(C)):4>> || C <- S, C =/= $\s >>.
+roundtrip(Mod, Type, Value) ->
+ roundtrip(Mod, Type, Value, Value).
+
+roundtrip(Mod, Type, Value, ExpectedValue) ->
+ {ok,Encoded} = Mod:encode(Type, Value),
+ {ok,ExpectedValue} = Mod:decode(Type, Encoded),
+ ok.
+
+roundtrip_enc(Mod, Type, Value) ->
+ roundtrip_enc(Mod, Type, Value, Value).
+
+roundtrip_enc(Mod, Type, Value, ExpectedValue) ->
+ {ok,Encoded} = Mod:encode(Type, Value),
+ {ok,ExpectedValue} = Mod:decode(Type, Encoded),
+ Encoded.
+
%%%
%%% Internal functions.
%%%