aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/test
diff options
context:
space:
mode:
Diffstat (limited to 'lib/asn1/test')
-rw-r--r--lib/asn1/test/asn1_test_lib.erl23
-rw-r--r--lib/asn1/test/testChoExtension.erl4
-rw-r--r--lib/asn1/test/testChoExternal.erl4
-rw-r--r--lib/asn1/test/testChoRecursive.erl4
-rw-r--r--lib/asn1/test/testConstraints.erl8
-rw-r--r--lib/asn1/test/testDeepTConstr.erl4
-rw-r--r--lib/asn1/test/testEnumExt.erl4
-rw-r--r--lib/asn1/test/testFragmented.erl4
-rw-r--r--lib/asn1/test/testInfObj.erl4
-rw-r--r--lib/asn1/test/testParameterizedInfObj.erl8
-rw-r--r--lib/asn1/test/testPrim.erl4
-rw-r--r--lib/asn1/test/testPrimStrings.erl8
-rw-r--r--lib/asn1/test/testSeqExtension.erl8
-rw-r--r--lib/asn1/test/testSeqOf.erl12
-rw-r--r--lib/asn1/test/testSetOptional.erl4
-rw-r--r--lib/asn1/test/testWSParamClass.erl5
16 files changed, 40 insertions, 68 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.
%%%
diff --git a/lib/asn1/test/testChoExtension.erl b/lib/asn1/test/testChoExtension.erl
index c6a07646c2..083b4cf016 100644
--- a/lib/asn1/test/testChoExtension.erl
+++ b/lib/asn1/test/testChoExtension.erl
@@ -51,6 +51,4 @@ extension(_Rules) ->
roundtrip(Type, Value) ->
- {ok,Encoded} = 'ChoExtension':encode(Type, Value),
- {ok,Value} = 'ChoExtension':decode(Type, Encoded),
- ok.
+ asn1_test_lib:roundtrip('ChoExtension', Type, Value).
diff --git a/lib/asn1/test/testChoExternal.erl b/lib/asn1/test/testChoExternal.erl
index f6b7345026..12abdbb2bc 100644
--- a/lib/asn1/test/testChoExternal.erl
+++ b/lib/asn1/test/testChoExternal.erl
@@ -45,6 +45,4 @@ external(_Rules) ->
ok.
roundtrip(Type, Value) ->
- {ok,Encoded} = 'ChoExternal':encode(Type, Value),
- {ok,Value} = 'ChoExternal':decode(Type, Encoded),
- ok.
+ asn1_test_lib:roundtrip('ChoExternal', Type, Value).
diff --git a/lib/asn1/test/testChoRecursive.erl b/lib/asn1/test/testChoRecursive.erl
index ee26d124a9..593b845949 100644
--- a/lib/asn1/test/testChoRecursive.erl
+++ b/lib/asn1/test/testChoRecursive.erl
@@ -43,6 +43,4 @@ recursive(_Rules) ->
ok.
roundtrip(Type, Value) ->
- {ok,Encoded} = 'ChoRecursive':encode(Type, Value),
- {ok,Value} = 'ChoRecursive':decode(Type, Encoded),
- ok.
+ asn1_test_lib:roundtrip('ChoRecursive', Type, Value).
diff --git a/lib/asn1/test/testConstraints.erl b/lib/asn1/test/testConstraints.erl
index 03a09492af..ed0cae0076 100644
--- a/lib/asn1/test/testConstraints.erl
+++ b/lib/asn1/test/testConstraints.erl
@@ -216,14 +216,10 @@ roundtrip(Type, Value) ->
roundtrip('Constraints', Type, Value).
roundtrip(Module, Type, Value) ->
- {ok,Encoded} = Module:encode(Type, Value),
- {ok,Value} = Module:decode(Type, Encoded),
- Encoded.
+ asn1_test_lib:roundtrip_enc(Module, Type, Value).
roundtrip_enc(Type, Value, Enc) ->
- Module = 'Constraints',
- {ok,Encoded} = Module:encode(Type, Value),
- {ok,Value} = Module:decode(Type, Encoded),
+ Encoded = asn1_test_lib:roundtrip_enc('Constraints', Type, Value),
case Enc of
none -> ok;
Encoded -> ok
diff --git a/lib/asn1/test/testDeepTConstr.erl b/lib/asn1/test/testDeepTConstr.erl
index 620b5f3356..880f15e91a 100644
--- a/lib/asn1/test/testDeepTConstr.erl
+++ b/lib/asn1/test/testDeepTConstr.erl
@@ -88,9 +88,7 @@ main(_Erule) ->
roundtrip(M, T, V) ->
- {ok,E} = M:encode(T, V),
- {ok,V} = M:decode(T, E),
- ok.
+ asn1_test_lib:roundtrip(M, T, V).
%% Either encoding or decoding must fail.
must_fail(M, T, V) ->
diff --git a/lib/asn1/test/testEnumExt.erl b/lib/asn1/test/testEnumExt.erl
index cbc13ee6da..b1e55d95ad 100644
--- a/lib/asn1/test/testEnumExt.erl
+++ b/lib/asn1/test/testEnumExt.erl
@@ -77,9 +77,7 @@ common(Erule) ->
ok.
roundtrip(Type, Value) ->
- {ok,Encoded} = 'EnumExt':encode(Type, Value),
- {ok,Value} = 'EnumExt':decode(Type, Encoded),
- Encoded.
+ asn1_test_lib:roundtrip_enc('EnumExt', Type, Value).
v_roundtrip(Erule, Type, Value) ->
Encoded = roundtrip(Type, Value),
diff --git a/lib/asn1/test/testFragmented.erl b/lib/asn1/test/testFragmented.erl
index c391ba8305..8d5fa07a5b 100644
--- a/lib/asn1/test/testFragmented.erl
+++ b/lib/asn1/test/testFragmented.erl
@@ -37,6 +37,4 @@ main(_Erule) ->
ok.
roundtrip(T, V) ->
- {ok,E} = 'Fragmented':encode(T, V),
- {ok,V} = 'Fragmented':decode(T, E),
- ok.
+ asn1_test_lib:roundtrip('Fragmented', T, V).
diff --git a/lib/asn1/test/testInfObj.erl b/lib/asn1/test/testInfObj.erl
index 76f216fdad..cd335e1023 100644
--- a/lib/asn1/test/testInfObj.erl
+++ b/lib/asn1/test/testInfObj.erl
@@ -121,9 +121,7 @@ main(_Erule) ->
{'Multiple-Optionals',1,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE}).
roundtrip(M, T, V) ->
- {ok,Enc} = M:encode(T, V),
- {ok,V} = M:decode(T, Enc),
- ok.
+ asn1_test_lib:roundtrip(M, T, V).
enc_dec(M, T, V0) ->
{ok,Enc} = M:encode(T, V0),
diff --git a/lib/asn1/test/testParameterizedInfObj.erl b/lib/asn1/test/testParameterizedInfObj.erl
index 02847e502b..47e5a02868 100644
--- a/lib/asn1/test/testParameterizedInfObj.erl
+++ b/lib/asn1/test/testParameterizedInfObj.erl
@@ -93,9 +93,7 @@ param(Erule) ->
ok.
roundtrip(T, V) ->
- {ok,Enc} = 'Param':encode(T, V),
- {ok,V} = 'Param':decode(T, Enc),
- ok.
+ asn1_test_lib:roundtrip('Param', T, V).
ranap(_Erule) ->
@@ -160,6 +158,4 @@ param2(Config, Erule) ->
roundtrip2(T, V) ->
- {ok,Enc} = asn1_wrapper:encode('Param2', T, V),
- {ok,V} = asn1_wrapper:decode('Param2', T, Enc),
- Enc.
+ asn1_test_lib:roundtrip_enc('Param2', T, V).
diff --git a/lib/asn1/test/testPrim.erl b/lib/asn1/test/testPrim.erl
index a6e68a9fe0..0be4f31f56 100644
--- a/lib/asn1/test/testPrim.erl
+++ b/lib/asn1/test/testPrim.erl
@@ -134,9 +134,7 @@ null(_Rules) ->
ok.
roundtrip(T, V) ->
- {ok,E} = 'Prim':encode(T, V),
- {ok,V} = 'Prim':decode(T, E),
- E.
+ asn1_test_lib:roundtrip_enc('Prim', T, V).
real(_Rules) ->
%%==========================================================
diff --git a/lib/asn1/test/testPrimStrings.erl b/lib/asn1/test/testPrimStrings.erl
index 1762e34599..be5409aa92 100644
--- a/lib/asn1/test/testPrimStrings.erl
+++ b/lib/asn1/test/testPrimStrings.erl
@@ -722,14 +722,10 @@ p_roundtrip(Type, Value0) ->
roundtrip(Type, Value).
roundtrip(Type, Value) ->
- {ok,Encoded} = 'PrimStrings':encode(Type, Value),
- {ok,Value} = 'PrimStrings':decode(Type, Encoded),
- ok.
+ roundtrip(Type, Value, Value).
roundtrip(Type, Value, Expected) ->
- {ok,Encoded} = 'PrimStrings':encode(Type, Value),
- {ok,Expected} = 'PrimStrings':decode(Type, Encoded),
- ok.
+ asn1_test_lib:roundtrip('PrimStrings', Type, Value, Expected).
bs_roundtrip(Type, Value) ->
bs_roundtrip(Type, Value, Value).
diff --git a/lib/asn1/test/testSeqExtension.erl b/lib/asn1/test/testSeqExtension.erl
index b996634996..8473459c36 100644
--- a/lib/asn1/test/testSeqExtension.erl
+++ b/lib/asn1/test/testSeqExtension.erl
@@ -108,18 +108,14 @@ main(Erule, DataDir, Opts) ->
ok.
roundtrip(Type, Value) ->
- {ok,Encoded} = 'SeqExtension':encode(Type, Value),
- {ok,Value} = 'SeqExtension':decode(Type, Encoded),
- ok.
+ asn1_test_lib:roundtrip('SeqExtension', Type, Value).
v_roundtrip2(Erule, Type, Value) ->
Encoded = asn1_test_lib:hex_to_bin(v(Erule, Type)),
Encoded = roundtrip2(Type, Value).
roundtrip2(Type, Value) ->
- {ok,Encoded} = 'SeqExtension2':encode(Type, Value),
- {ok,Value} = 'SeqExtension2':decode(Type, Encoded),
- Encoded.
+ asn1_test_lib:roundtrip_enc('SeqExtension2', Type, Value).
v(ber, 'SeqExt66') -> "30049F41 017D";
v(per, 'SeqExt66') -> "C0420000 00000000 00004001 FA";
diff --git a/lib/asn1/test/testSeqOf.erl b/lib/asn1/test/testSeqOf.erl
index c50cc27f6f..7f8f4079b4 100644
--- a/lib/asn1/test/testSeqOf.erl
+++ b/lib/asn1/test/testSeqOf.erl
@@ -149,15 +149,9 @@ roundtrip(T, V) ->
roundtrip(T, V, V).
roundtrip(Type, Val, Expected) ->
- M = 'SeqOf',
- {ok,Enc} = M:encode(Type, Val),
- {ok,Expected} = M:decode(Type, Enc),
- ok.
+ asn1_test_lib:roundtrip('SeqOf', Type, Val, Expected).
xroundtrip(T1, T2, Val) ->
- M = 'XSeqOf',
- {ok,Enc} = M:encode(T1, Val),
- {ok,Enc} = M:encode(T2, Val),
- {ok,Val} = M:decode(T1, Enc),
- {ok,Val} = M:decode(T2, Enc),
+ Enc = asn1_test_lib:roundtrip_enc('XSeqOf', T1, Val),
+ Enc = asn1_test_lib:roundtrip_enc('XSeqOf', T2, Val),
ok.
diff --git a/lib/asn1/test/testSetOptional.erl b/lib/asn1/test/testSetOptional.erl
index bb43ff0a96..eb095fd480 100644
--- a/lib/asn1/test/testSetOptional.erl
+++ b/lib/asn1/test/testSetOptional.erl
@@ -93,6 +93,4 @@ ticket_7533(_) ->
ok.
roundtrip(Type, Value) ->
- {ok,Encoded} = 'SetOptional':encode(Type, Value),
- {ok,Value} = 'SetOptional':decode(Type, Encoded),
- ok.
+ asn1_test_lib:roundtrip('SetOptional', Type, Value).
diff --git a/lib/asn1/test/testWSParamClass.erl b/lib/asn1/test/testWSParamClass.erl
index ae67ca8b81..66ba56a6d8 100644
--- a/lib/asn1/test/testWSParamClass.erl
+++ b/lib/asn1/test/testWSParamClass.erl
@@ -11,7 +11,4 @@ main(_) ->
ok.
roundtrip(Data) ->
- IF = 'InformationFramework',
- {ok,Enc} = asn1_wrapper:encode(IF, 'Attribute', Data),
- {ok,Data} = IF:decode('Attribute', Enc),
- ok.
+ asn1_test_lib:roundtrip('InformationFramework', 'Attribute', Data).