diff options
author | Björn Gustavsson <[email protected]> | 2014-01-29 10:50:21 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2014-01-29 10:50:21 +0100 |
commit | 228ef1c22ee2f6f39183091aa70f17417c3d9aa6 (patch) | |
tree | 7d2203d6df886ce1d7f2344dbfd3e6ec7c8a5c3d /lib/asn1/test/testParameterizedInfObj.erl | |
parent | ae2c2f1d838b523939b586014ceb66c2970b8cf2 (diff) | |
parent | d16a480a43a858d604d1ac8d644589be3f49dda1 (diff) | |
download | otp-228ef1c22ee2f6f39183091aa70f17417c3d9aa6.tar.gz otp-228ef1c22ee2f6f39183091aa70f17417c3d9aa6.tar.bz2 otp-228ef1c22ee2f6f39183091aa70f17417c3d9aa6.zip |
Merge branch 'bjorn/asn1/erlang-types/OTP-11594'
* bjorn/asn1/erlang-types/OTP-11594:
Update documentation
Fix open types
Fix OCTET STRING
Fix BIT STRING
Add legacy_erlang_types
asn1 test suite: Modernize testTimer_* and testTimer.erl
testPrimStrings: Run test of fragmented strings for PER too
Diffstat (limited to 'lib/asn1/test/testParameterizedInfObj.erl')
-rw-r--r-- | lib/asn1/test/testParameterizedInfObj.erl | 78 |
1 files changed, 44 insertions, 34 deletions
diff --git a/lib/asn1/test/testParameterizedInfObj.erl b/lib/asn1/test/testParameterizedInfObj.erl index f3b4f9b170..2fe900792d 100644 --- a/lib/asn1/test/testParameterizedInfObj.erl +++ b/lib/asn1/test/testParameterizedInfObj.erl @@ -20,7 +20,7 @@ -module(testParameterizedInfObj). --export([main/2,ranap/1]). +-export([main/2,param/1,ranap/1]). -include_lib("test_server/include/test_server.hrl"). @@ -36,31 +36,29 @@ main(Config, Erule) -> param2(Config, Erule). param(Erule) -> - PERVal = #'AllocationOrRetentionPriority' - {priorityLevel = true, - iE_Extensions = - [#'ProtocolExtensionField'{id=14, - criticality=reject, - extensionValue= <<0>>}, - #'ProtocolExtensionField'{id=2, - criticality=ignore, - extensionValue= <<1>>}]}, - BERVal = #'AllocationOrRetentionPriority' - {priorityLevel = true, - iE_Extensions = - [#'ProtocolExtensionField'{id=14, - criticality=reject, - extensionValue= <<2,1,0>>}, - #'ProtocolExtensionField'{id=2, - criticality=ignore, - extensionValue= <<2,1,1>>}]}, - case Erule of - ber -> - roundtrip('AllocationOrRetentionPriority', BERVal); - per -> - roundtrip('AllocationOrRetentionPriority', PERVal); - uper -> - roundtrip('AllocationOrRetentionPriority', PERVal) + Exts0 = case Erule of + ber -> + %% As implemented, the open type must contain + %% valid BER-encoded data. + [{14,<<2,1,0>>},{2,<<2,1,0>>}]; + _ -> + %% The PER decoder will not look inside the open type. + [{14,<<0>>},{2,<<"anything goes">>}] + end, + case 'Param':legacy_erlang_types() of + false -> + Exts = [#'ProtocolExtensionField'{id=Id, + criticality=reject, + extensionValue={asn1_OPENTYPE, + Eval}} || + {Id,Eval} <- Exts0], + aor_roundtrip(Exts); + true -> + Exts = [#'ProtocolExtensionField'{id=Id, + criticality=reject, + extensionValue=Eval} || + {Id,Eval} <- Exts0], + aor_roundtrip(Exts) end, %% test code for OTP-4242, ValueFromObject @@ -72,8 +70,13 @@ param(Erule) -> {error,_Reason2} = 'Param':decode('OS2',[4,4,1,2,3,4]), {ok,_Val4} = 'Param':decode('OS1',[4,2,1,2]); _ -> %per/uper - roundtrip('OS1', [1,2]), - {error,_Reason3} = 'Param':encode('OS1', [1,2,3,4]) + case 'Param':legacy_erlang_types() of + false -> + roundtrip('OS1', <<1,2>>), + {error,_Reason3} = 'Param':encode('OS1', <<1,2,3,4>>); + true -> + ok + end end, roundtrip('Scl', {'Scl',42,{a,9738654}}), @@ -82,6 +85,11 @@ param(Erule) -> ok. +aor_roundtrip(Exts) -> + Val = #'AllocationOrRetentionPriority'{priorityLevel = true, + iE_Extensions = Exts}, + roundtrip('AllocationOrRetentionPriority', Val). + roundtrip(T, V) -> asn1_test_lib:roundtrip('Param', T, V). @@ -102,11 +110,11 @@ ranap(_Erule) -> param2(Config, Erule) -> roundtrip2('HandoverRequired', {'HandoverRequired', - [{'ProtocolIE-Field',1,"ABC"}, + [{'ProtocolIE-Field',1,<<"ABC">>}, {'ProtocolIE-Field',2,577799}]}), Enc = roundtrip2('HandoverRequired', {'HandoverRequired', - [{'ProtocolIE-Field',1,"ABC"}, + [{'ProtocolIE-Field',1,<<"ABC">>}, {'ProtocolIE-Field',2,-42}, {'ProtocolIE-Field',100,533}, {'ProtocolIE-Field',101,true}]}), @@ -127,17 +135,19 @@ param2(Config, Erule) -> [{i,DataDir},{outdir,CaseDir},Erule]), %% Decompile extended data. - {ok,{'HandoverRequired',[{'ProtocolIE-Field',1,"ABC"}, + {ok,{'HandoverRequired',[{'ProtocolIE-Field',1,<<"ABC">>}, {'ProtocolIE-Field',2,-42}, - {'ProtocolIE-Field',100,Open100}, - {'ProtocolIE-Field',101,Open101}]}} = + {'ProtocolIE-Field',100, + {asn1_OPENTYPE,Open100}}, + {'ProtocolIE-Field',101, + {asn1_OPENTYPE,Open101}}]}} = 'Param2':decode('HandoverRequired', Enc), true = is_binary(Open100), true = is_binary(Open101), %% Test single root. roundtrip2('SingleRoot', - {'SingleRoot',[{'ProtocolIE-Field',1,"ABC"}, + {'SingleRoot',[{'ProtocolIE-Field',1,<<"ABC">>}, {'ProtocolIE-Field',2,9999}]}), ok. |