From b379d700e1450a3fc7e76bb75369fa6b5eb2d327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Fri, 13 Sep 2013 12:56:06 +0200 Subject: Eliminate the use of asn1_wrapper The asn1_wrapper made some sense when encode functions could either produce a list or a binary, depending on the backend. Now encode functions always produce a binary. To improve readbility of the test suites, eliminate the asn1_wrapper functions by replacing them with calls to one of the roundtrip functions in asn1_test_lib. When it is not possible to use the roundtrip functions, call the module in question directly. While at it, also remove ?line macros that are near to the touched code and use asn1_test_lib:hex_to_bin/1 instead of home-brewn hex conversion routines. --- lib/asn1/test/asn1_SUITE.erl | 47 ++- lib/asn1/test/ber_decode_error.erl | 10 +- lib/asn1/test/h323test.erl | 82 +++-- lib/asn1/test/testChoExtension.erl | 5 +- lib/asn1/test/testChoPrim.erl | 106 ++---- lib/asn1/test/testChoTypeRefCho.erl | 50 +-- lib/asn1/test/testChoTypeRefPrim.erl | 72 +--- lib/asn1/test/testChoTypeRefSeq.erl | 91 +---- lib/asn1/test/testChoTypeRefSet.erl | 92 +---- lib/asn1/test/testChoiceIndefinite.erl | 4 +- lib/asn1/test/testConstraints.erl | 5 +- lib/asn1/test/testContextSwitchingTypes.erl | 42 +-- lib/asn1/test/testDER.erl | 34 +- lib/asn1/test/testDef.erl | 118 +++--- lib/asn1/test/testDoubleEllipses.erl | 84 ++--- lib/asn1/test/testEnumExt.erl | 8 +- lib/asn1/test/testINSTANCE_OF.erl | 43 +-- lib/asn1/test/testInfObjectClass.erl | 24 +- lib/asn1/test/testMegaco.erl | 51 +-- lib/asn1/test/testMergeCompile.erl | 114 +++--- lib/asn1/test/testNBAPsystem.erl | 23 +- lib/asn1/test/testOpenTypeImplicitTag.erl | 19 +- lib/asn1/test/testOpt.erl | 99 ++--- lib/asn1/test/testParamBasic.erl | 59 +-- lib/asn1/test/testParameterizedInfObj.erl | 61 ++- lib/asn1/test/testPrim.erl | 92 ++--- lib/asn1/test/testPrimExternal.erl | 105 ++---- lib/asn1/test/testSelectionTypes.erl | 15 +- lib/asn1/test/testSeq2738.erl | 19 +- lib/asn1/test/testSeqDefault.erl | 198 +++------- lib/asn1/test/testSeqExternal.erl | 119 ++---- lib/asn1/test/testSeqIndefinite.erl | 16 +- lib/asn1/test/testSeqOfCho.erl | 150 ++------ lib/asn1/test/testSeqOfExternal.erl | 174 +++------ lib/asn1/test/testSeqOfIndefinite.erl | 78 ++-- lib/asn1/test/testSeqOfTag.erl | 185 +++------- lib/asn1/test/testSeqOptional.erl | 199 +++------- lib/asn1/test/testSeqPrim.erl | 63 +--- lib/asn1/test/testSeqSetDefaultVal.erl | 448 +++++++++++------------ lib/asn1/test/testSeqTag.erl | 86 ++--- lib/asn1/test/testSeqTypeRefCho.erl | 21 +- lib/asn1/test/testSeqTypeRefPrim.erl | 30 +- lib/asn1/test/testSeqTypeRefSeq.erl | 166 ++------- lib/asn1/test/testSeqTypeRefSet.erl | 45 +-- lib/asn1/test/testSetDefault.erl | 76 ++-- lib/asn1/test/testSetExtension.erl | 73 +--- lib/asn1/test/testSetExternal.erl | 119 ++---- lib/asn1/test/testSetIndefinite.erl | 13 +- lib/asn1/test/testSetOf.erl | 282 +++++--------- lib/asn1/test/testSetOfCho.erl | 150 ++------ lib/asn1/test/testSetOfExternal.erl | 151 ++------ lib/asn1/test/testSetOfTag.erl | 185 ++-------- lib/asn1/test/testSetPrim.erl | 66 +--- lib/asn1/test/testSetTag.erl | 87 ++--- lib/asn1/test/testSetTypeRefCho.erl | 21 +- lib/asn1/test/testSetTypeRefPrim.erl | 30 +- lib/asn1/test/testSetTypeRefSeq.erl | 20 +- lib/asn1/test/testSetTypeRefSet.erl | 163 ++------- lib/asn1/test/testTCAP.erl | 52 +-- lib/asn1/test/testTypeValueNotation.erl | 22 +- lib/asn1/test/testX420.erl | 6 +- lib/asn1/test/test_modified_x420.erl | 5 +- lib/asn1/test/test_partial_incomplete_decode.erl | 116 +++--- lib/asn1/test/test_selective_decode.erl | 45 ++- lib/asn1/test/test_undecoded_rest.erl | 23 +- lib/asn1/test/test_x691.erl | 183 ++------- 66 files changed, 1607 insertions(+), 3833 deletions(-) diff --git a/lib/asn1/test/asn1_SUITE.erl b/lib/asn1/test/asn1_SUITE.erl index 51d22c7a0f..adeede5253 100644 --- a/lib/asn1/test/asn1_SUITE.erl +++ b/lib/asn1/test/asn1_SUITE.erl @@ -653,10 +653,7 @@ ber_optional(Config, Rule, Opts) -> V = {'S', {'A', 10, asn1_NOVALUE, asn1_NOVALUE}, {'B', asn1_NOVALUE, asn1_NOVALUE, asn1_NOVALUE}, {'C', asn1_NOVALUE, 111, asn1_NOVALUE}}, - {ok, B} = asn1_wrapper:encode('SOpttest', 'S', V), - Bytes = lists:flatten(B), - V2 = asn1_wrapper:decode('SOpttest', 'S', Bytes), - V = element(2, V2). + asn1_test_lib:roundtrip('SOpttest', 'S', V). %% records used by test-case default -record('Def1', {bool0, @@ -667,14 +664,16 @@ ber_optional(Config, Rule, Opts) -> default(Config) -> test(Config, fun default/3). default(Config, Rule, Opts) -> asn1_test_lib:compile("Def", Config, [Rule|Opts]), - {ok, Bytes1} = asn1_wrapper:encode('Def', 'Def1', #'Def1'{bool0 = true}), - {ok, {'Def1', true, false, false, false}} = - asn1_wrapper:decode('Def', 'Def1', lists:flatten(Bytes1)), - - {ok, Bytes2} = asn1_wrapper:encode('Def', 'Def1', #'Def1'{bool0 = true, - bool2 = false}), - {ok, {'Def1', true, false, false, false}} = - asn1_wrapper:decode('Def', 'Def1', lists:flatten(Bytes2)). + asn1_test_lib:roundtrip('Def', + 'Def1', + #'Def1'{bool0=true}, + #'Def1'{bool0=true,bool1=false, + bool2=false,bool3=false}), + asn1_test_lib:roundtrip('Def', + 'Def1', + #'Def1'{bool0=true,bool2=false}, + #'Def1'{bool0=true,bool1=false, + bool2=false,bool3=false}). value_test(Config) -> test(Config, fun value_test/3). value_test(Config, Rule, Opts) -> @@ -686,12 +685,13 @@ constructed(Config) -> test(Config, fun constructed/3, [ber]). constructed(Config, Rule, Opts) -> asn1_test_lib:compile("Constructed", Config, [Rule|Opts]), - {ok, B} = asn1_wrapper:encode('Constructed', 'S', {'S', false}), - [40, 3, 1, 1, 0] = lists:flatten(B), - {ok, B1} = asn1_wrapper:encode('Constructed', 'S2', {'S2', false}), - [40, 5, 48, 3, 1, 1, 0] = lists:flatten(B1), - {ok, B2} = asn1_wrapper:encode('Constructed', 'I', 10), - [136, 1, 10] = lists:flatten(B2). + <<40,3,1,1,0>> = + asn1_test_lib:roundtrip_enc('Constructed', 'S', {'S',false}), + <<40,5,48,3,1,1,0>> = + asn1_test_lib:roundtrip_enc('Constructed', 'S2', {'S2',false}), + <<136,1,10>> = + asn1_test_lib:roundtrip_enc('Constructed', 'I', 10), + ok. ber_decode_error(Config) -> test(Config, fun ber_decode_error/3, [ber]). @@ -920,7 +920,7 @@ test_Defed_ObjectIdentifier(Config, Rule, Opts) -> testSelectionType(Config) -> test(Config, fun testSelectionType/3). testSelectionType(Config, Rule, Opts) -> asn1_test_lib:compile("SelectionType", Config, [Rule|Opts]), - {ok, _} = testSelectionTypes:test(). + testSelectionTypes:test(). testSSLspecs(Config) -> test(Config, fun testSSLspecs/3, [ber]). @@ -1017,10 +1017,7 @@ test_x691(Config) -> test_x691(Config, Rule, Opts) -> Files = ["P-RecordA1", "P-RecordA2", "P-RecordA3"], asn1_test_lib:compile_all(Files, Config, [Rule|Opts]), - test_x691:cases(Rule, case Rule of - uper -> unaligned; - _ -> aligned - end), + test_x691:cases(Rule), %% OTP-7708. asn1_test_lib:compile("EUTRA-extract-55", Config, [Rule|Opts]), @@ -1149,9 +1146,7 @@ testTimer_uper(Config) -> testComment(suite) -> []; testComment(Config) -> asn1_test_lib:compile("Comment", Config, []), - {ok,Enc} = asn1_wrapper:encode('Comment','Seq',{'Seq',12,true}), - {ok,{'Seq',12,true}} = asn1_wrapper:decode('Comment','Seq',Enc), - ok. + asn1_test_lib:roundtrip('Comment', 'Seq', {'Seq',12,true}). testName2Number(suite) -> []; testName2Number(Config) -> diff --git a/lib/asn1/test/ber_decode_error.erl b/lib/asn1/test/ber_decode_error.erl index 1c4b4c6894..8be92292ee 100644 --- a/lib/asn1/test/ber_decode_error.erl +++ b/lib/asn1/test/ber_decode_error.erl @@ -22,15 +22,15 @@ -export([run/1]). run([]) -> - {ok,B} = asn1_wrapper:encode('Constructed','S3',{'S3',17}), - [T,L|V] = lists:flatten(B), - Bytes = [T,L+3|V] ++ [2,1,3], - case asn1_wrapper:decode('Constructed','S3',Bytes) of + {ok,B} = 'Constructed':encode('S3', {'S3',17}), + [T,L|V] = binary_to_list(B), + Bytes = list_to_binary([T,L+3|V] ++ [2,1,3]), + case 'Constructed':decode('S3', Bytes) of {error,{asn1,{unexpected,_}}} -> ok end, %% Unexpected bytes must be accepted if there is an extensionmark - {ok,{'S3ext',17}} = asn1_wrapper:decode('Constructed','S3ext',Bytes), + {ok,{'S3ext',17}} = 'Constructed':decode('S3ext', Bytes), %% Truncated tag. {error,{asn1,{invalid_tag,_}}} = diff --git a/lib/asn1/test/h323test.erl b/lib/asn1/test/h323test.erl index dfc1173d68..3baaa994ea 100644 --- a/lib/asn1/test/h323test.erl +++ b/lib/asn1/test/h323test.erl @@ -26,50 +26,62 @@ run(per) -> run(); run(_Rules) -> ok. run() -> - alerting(), - connect(), + roundtrip('H323-UserInformation', alerting_val(), alerting_enc()), + roundtrip('H323-UserInformation', connect_val(), connect_enc()), general_string(), ok. -dec_alerting() -> - Cs = "0380060008914a0002020120110000000000000000000000000000000000", - ByteList = hexstr2bytes(Cs), - asn1_wrapper:decode('H323-MESSAGES','H323-UserInformation',ByteList). +alerting_val() -> + {'H323-UserInformation', + {'H323-UU-PDU', + {alerting, + {'Alerting-UUIE', + {0,0,8,2250,0,2}, + {'EndpointType',asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE, + asn1_NOVALUE,asn1_NOVALUE, + {'TerminalInfo',asn1_NOVALUE}, + false,false}, + asn1_NOVALUE, + {'CallIdentifier',[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}, + asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE}}, + asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE}, + asn1_NOVALUE}. -enc_alerting(V) -> - asn1_wrapper:encode('H323-MESSAGES','H323-UserInformation',V). +alerting_enc() -> + "0380060008914a0002020120110000000000000000000000000000000000". -alerting() -> - {ok,V} = dec_alerting(), - {ok,B} = enc_alerting(V), - ByteList = lists:flatten(B), - {ok,V} = asn1_wrapper:decode('H323-MESSAGES','H323-UserInformation',ByteList). +connect_val() -> + {'H323-UserInformation', + {'H323-UU-PDU', + {connect, + {'Connect-UUIE', + {0,0,8,2250,0,2}, + {ipAddress, + {'TransportAddress_ipAddress',[136,225,41,58],1187}}, + {'EndpointType',asn1_NOVALUE, + {'VendorIdentifier', + {'H221NonStandard',181,0,21324}, + [77,105,99,114,111,115,111,102,116,174,32,78,101,116, + 77,101,100,116,105,110,103,174,0], + [51,46,48,0]}, + asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE, + {'TerminalInfo',asn1_NOVALUE}, + false,false}, + [22,137,237,197,191,35,211,17,140,45,0,192,79,75,28,208], + {'CallIdentifier',[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}, + asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE}}, + asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE}, + asn1_NOVALUE}. - -dec_connect() -> - Cs = "02c0060008914a00020088e1293a04a322c0b500534c164d6963726f736f6674ae204e65744d656474696e67ae0003332e3000001689edc5bf23d3118c2d00c04f4b1cd00900110000000000000000000000000000000000", - ByteList = hexstr2bytes(Cs), - asn1_wrapper:decode('H323-MESSAGES','H323-UserInformation',ByteList). - -enc_connect(V) -> - asn1_wrapper:encode('H323-MESSAGES','H323-UserInformation',V). - -connect() -> - {ok,V} = dec_connect(), - {ok,B} = enc_connect(V), - ByteList = lists:flatten(B), - {ok,V} = asn1_wrapper:decode('H323-MESSAGES','H323-UserInformation',ByteList). +connect_enc() -> + "02c0060008914a00020088e1293a04a322c0b500534c164d6963726f736f6674ae204e65744d656474696e67ae0003332e3000001689edc5bf23d3118c2d00c04f4b1cd00900110000000000000000000000000000000000". general_string() -> Type = 'MultimediaSystemControlMessage', UI = <<109,64,1,57>>, {ok, _V} = 'MULTIMEDIA-SYSTEM-CONTROL':decode(Type, UI). -hexstr2bytes([D1,D2|T]) -> - [dig2num(D1)*16+dig2num(D2)|hexstr2bytes(T)]; -hexstr2bytes([]) -> - []. - -dig2num(D) when D >= $0, D =< $9 -> D - $0; -dig2num(D) when D >= $a, D =< $f -> 10 + D - $a; -dig2num(D) when D >= $A, D =< $F -> 10 + D - $A. +roundtrip(T, V, HexString) -> + Enc = asn1_test_lib:hex_to_bin(HexString), + Enc = asn1_test_lib:roundtrip_enc('H323-MESSAGES', T, V), + ok. diff --git a/lib/asn1/test/testChoExtension.erl b/lib/asn1/test/testChoExtension.erl index 083b4cf016..e54cbe825b 100644 --- a/lib/asn1/test/testChoExtension.erl +++ b/lib/asn1/test/testChoExtension.erl @@ -31,10 +31,7 @@ extension(_Rules) -> %% A trick to encode with another compatible CHOICE type to test reception %% extension alternative - {ok,Bytes2x} = asn1_wrapper:encode('ChoExtension','ChoExt1x',{str,"abc"}), - {ok,Val2x} = - asn1_wrapper:decode('ChoExtension','ChoExt1',lists:flatten(Bytes2x)), - io:format("Choice extension alternative = ~p~n",[Val2x]), + roundtrip('ChoExt1x', {str,"abc"}), roundtrip('ChoExt2', {bool,true}), roundtrip('ChoExt2', {int,33}), diff --git a/lib/asn1/test/testChoPrim.erl b/lib/asn1/test/testChoPrim.erl index 936a38f76c..4665de6989 100644 --- a/lib/asn1/test/testChoPrim.erl +++ b/lib/asn1/test/testChoPrim.erl @@ -25,80 +25,44 @@ -include_lib("test_server/include/test_server.hrl"). bool(Rules) -> - - ?line {ok,Bytes11} = asn1_wrapper:encode('ChoPrim','ChoCon',{bool0,true}), - ?line {ok,{bool0,true}} = asn1_wrapper:decode('ChoPrim','ChoCon',lists:flatten(Bytes11)), - - ?line {ok,Bytes12} = asn1_wrapper:encode('ChoPrim','ChoCon',{bool1,true}), - ?line {ok,{bool1,true}} = asn1_wrapper:decode('ChoPrim','ChoCon',lists:flatten(Bytes12)), - - ?line {ok,Bytes13} = asn1_wrapper:encode('ChoPrim','ChoCon',{int2,233}), - ?line {ok,{int2,233}} = asn1_wrapper:decode('ChoPrim','ChoCon',lists:flatten(Bytes13)), - - ?line case asn1_wrapper:erule(Rules) of - ber -> - ?line {error,{asn1,{invalid_choice_type,wrong}}} = - case catch asn1_wrapper:encode('ChoPrim','ChoCon',{wrong,233}) of - X1 -> X1 end, - ?line {error,{asn1,{invalid_choice_tag,_WrongTag}}} = - case catch asn1_wrapper:decode('ChoPrim','ChoCon',[131,2,0,233]) of - X2 -> X2 end, - ok; - - per -> - ok - end, - + roundtrip('ChoCon', {bool0,true}), + roundtrip('ChoCon', {bool1,true}), + roundtrip('ChoCon', {int2,233}), + case Rules of + ber -> + {error,{asn1,{invalid_choice_type,wrong}}} = + (catch 'ChoPrim':encode('ChoCon', {wrong,233})), + {error,{asn1,{invalid_choice_tag,_WrongTag}}} = + (catch 'ChoPrim':decode('ChoCon', <<131,2,0,233>>)); + per -> + ok; + uper -> + ok + end, ok. - - int(Rules) -> - - ?line {ok,Bytes21} = asn1_wrapper:encode('ChoPrim','ChoExp',{int10,1}), - ?line {ok,{int10,first}} = asn1_wrapper:decode('ChoPrim','ChoExp',lists:flatten(Bytes21)), - - ?line {ok,Bytes22} = asn1_wrapper:encode('ChoPrim','ChoExp',{int10,first}), - ?line {ok,{int10,first}} = asn1_wrapper:decode('ChoPrim','ChoExp',lists:flatten(Bytes22)), - - ?line {ok,Bytes23} = asn1_wrapper:encode('ChoPrim','ChoExp',{int10,last}), - ?line {ok,{int10,last}} = asn1_wrapper:decode('ChoPrim','ChoExp',lists:flatten(Bytes23)), - - ?line {ok,Bytes24} = asn1_wrapper:encode('ChoPrim','ChoExp',{bool11,true}), - ?line {ok,{bool11,true}} = asn1_wrapper:decode('ChoPrim','ChoExp',lists:flatten(Bytes24)), - - - ?line {ok,Bytes26} = asn1_wrapper:encode('ChoPrim','ChoExp',{enum12,one}), - ?line {ok,{enum12,one}} = asn1_wrapper:decode('ChoPrim','ChoExp',lists:flatten(Bytes26)), - - ?line {ok,Bytes25} = asn1_wrapper:encode('ChoPrim','ChoExp',{bool11,true}), - ?line {ok,{bool11,true}} = - asn1_wrapper:decode('ChoPrim','ChoExp',lists:flatten(Bytes25)), - - ?line {error,{asn1,_}} = - case catch asn1_wrapper:encode('ChoPrim','ChoExp',{enum12,four}) of - X3 -> X3 end, - - ?line {error,{asn1,_}} = - case catch asn1_wrapper:encode('ChoPrim','ChoExp',{wrong,233}) of - X4 -> io:format("error reason = ~p~n",[X4]), X4 end, - - ?line case asn1_wrapper:erule(Rules) of - ber -> - ?line {error,{asn1,_}} = - case catch asn1_wrapper:decode('ChoPrim','ChoExp',[107,3,2,1,1]) of - X5 -> X5 end, - ok; - - per -> - ok - end, + roundtrip('ChoExp', {int10,1}, {int10,first}), + roundtrip('ChoExp', {int10,first}), + roundtrip('ChoExp', {int10,last}), + roundtrip('ChoExp', {bool11,true}), + roundtrip('ChoExp', {enum12,one}), + roundtrip('ChoExp', {bool11,true}), + + {error,{asn1,_}} = (catch 'ChoPrim':encode('ChoExp', {enum12,four})), + {error,{asn1,_}} = (catch 'ChoPrim':encode('ChoExp', {wrong,233})), + case Rules of + ber -> + {error,{asn1,_}} = (catch 'ChoPrim':decode('ChoExp', <<107,3,2,1,1>>)); + per -> + ok; + uper -> + ok + end, ok. +roundtrip(Type, Value) -> + roundtrip(Type, Value, Value). - - - - - - +roundtrip(Type, Value, ExpectedValue) -> + asn1_test_lib:roundtrip('ChoPrim', Type, Value, ExpectedValue). diff --git a/lib/asn1/test/testChoTypeRefCho.erl b/lib/asn1/test/testChoTypeRefCho.erl index 9bd732f462..cd2672add0 100644 --- a/lib/asn1/test/testChoTypeRefCho.erl +++ b/lib/asn1/test/testChoTypeRefCho.erl @@ -24,43 +24,15 @@ -include_lib("test_server/include/test_server.hrl"). choice(_Rules) -> - - ?line {ok,Bytes11} = asn1_wrapper:encode('ChoTypeRefCho','ChoTRcho',{choCho,{choInt,88}}), - ?line {ok,{choCho,{choInt,88}}} = - asn1_wrapper:decode('ChoTypeRefCho','ChoTRcho',lists:flatten(Bytes11)), - - ?line {ok,Bytes12} = asn1_wrapper:encode('ChoTypeRefCho','ChoTRcho',{choChoE,{choInt,88}}), - ?line {ok,{choChoE,{choInt,88}}} = - asn1_wrapper:decode('ChoTypeRefCho','ChoTRcho',lists:flatten(Bytes12)), - - ?line {ok,Bytes13} = asn1_wrapper:encode('ChoTypeRefCho','ChoTRcho',{'choCho-E',{choInt,88}}), - ?line {ok,{'choCho-E',{choInt,88}}} = - asn1_wrapper:decode('ChoTypeRefCho','ChoTRcho',lists:flatten(Bytes13)), - - ?line {ok,Bytes14} = asn1_wrapper:encode('ChoTypeRefCho','ChoTRcho',{'choChoE-E',{choInt,88}}), - ?line {ok,{'choChoE-E',{choInt,88}}} = - asn1_wrapper:decode('ChoTypeRefCho','ChoTRcho',lists:flatten(Bytes14)), - - - - ?line {ok,Bytes21} = asn1_wrapper:encode('ChoTypeRefCho','ChoChoInline',{bool1,true}), - ?line {ok,{bool1,true}} = - asn1_wrapper:decode('ChoTypeRefCho','ChoChoInline',lists:flatten(Bytes21)), - - ?line {ok,Bytes22} = asn1_wrapper:encode('ChoTypeRefCho','ChoChoInline',{'choCho',{bool,true}}), - ?line {ok,{'choCho',{bool,true}}} = - asn1_wrapper:decode('ChoTypeRefCho','ChoChoInline',lists:flatten(Bytes22)), - - ?line {ok,Bytes23} = asn1_wrapper:encode('ChoTypeRefCho','ChoChoInline',{'choCho',{octStr,"kk"}}), - ?line {ok,{'choCho',{octStr,"kk"}}} = - asn1_wrapper:decode('ChoTypeRefCho','ChoChoInline',lists:flatten(Bytes23)), - - ?line {ok,Bytes24} = asn1_wrapper:encode('ChoTypeRefCho','ChoChoInline',{'choCho',{int,55}}), - ?line {ok,{'choCho',{int,55}}} = - asn1_wrapper:decode('ChoTypeRefCho','ChoChoInline',lists:flatten(Bytes24)), - - - - - + roundtrip('ChoTRcho', {choCho,{choInt,88}}), + roundtrip('ChoTRcho', {choChoE,{choInt,88}}), + roundtrip('ChoTRcho', {'choCho-E',{choInt,88}}), + roundtrip('ChoTRcho', {'choChoE-E',{choInt,88}}), + roundtrip('ChoChoInline', {bool1,true}), + roundtrip('ChoChoInline', {choCho,{bool,true}}), + roundtrip('ChoChoInline', {choCho,{octStr,"kk"}}), + roundtrip('ChoChoInline', {choCho,{int,55}}), ok. + +roundtrip(Type, Value) -> + asn1_test_lib:roundtrip('ChoTypeRefCho', Type, Value). diff --git a/lib/asn1/test/testChoTypeRefPrim.erl b/lib/asn1/test/testChoTypeRefPrim.erl index edef6192fe..8a2bc7bd8e 100644 --- a/lib/asn1/test/testChoTypeRefPrim.erl +++ b/lib/asn1/test/testChoTypeRefPrim.erl @@ -24,60 +24,20 @@ -include_lib("test_server/include/test_server.hrl"). prim(_Rules) -> - - ?line {ok,Bytes11} = asn1_wrapper:encode('ChoTypeRefPrim','ChoTR',{bool,true}), - ?line {ok,{bool,true}} = asn1_wrapper:decode('ChoTypeRefPrim','ChoTR',lists:flatten(Bytes11)), - - ?line {ok,Bytes12} = - asn1_wrapper:encode('ChoTypeRefPrim','ChoTR',{octStr,[11,12,13,14,15,16,17]}), - ?line {ok,{octStr,[11,12,13,14,15,16,17]}} = - asn1_wrapper:decode('ChoTypeRefPrim','ChoTR',lists:flatten(Bytes12)), - - ?line {ok,Bytes13} = asn1_wrapper:encode('ChoTypeRefPrim','ChoTR',{int,233}), - ?line {ok,{int,233}} = asn1_wrapper:decode('ChoTypeRefPrim','ChoTR',lists:flatten(Bytes13)), - - ?line {ok,Bytes14} = - asn1_wrapper:encode('ChoTypeRefPrim','ChoTR',{octStr,"Stringing in the rain"}), - ?line {ok,{octStr,"Stringing in the rain"}} = - asn1_wrapper:decode('ChoTypeRefPrim','ChoTR',lists:flatten(Bytes14)), - - - - ?line {ok,Bytes21} = asn1_wrapper:encode('ChoTypeRefPrim','ChoTR2',{'octStr',"A string"}), - ?line {ok,{'octStr',"A string"}} = - asn1_wrapper:decode('ChoTypeRefPrim','ChoTR2',lists:flatten(Bytes21)), - - ?line {ok,Bytes22} = asn1_wrapper:encode('ChoTypeRefPrim','ChoTR2',{'octStrI',"A string"}), - ?line {ok,{'octStrI',"A string"}} = - asn1_wrapper:decode('ChoTypeRefPrim','ChoTR2',lists:flatten(Bytes22)), - - ?line {ok,Bytes23} = asn1_wrapper:encode('ChoTypeRefPrim','ChoTR2',{'octStrE',"A string"}), - ?line {ok,{'octStrE',"A string"}} = - asn1_wrapper:decode('ChoTypeRefPrim','ChoTR2',lists:flatten(Bytes23)), - - ?line {ok,Bytes24} = asn1_wrapper:encode('ChoTypeRefPrim','ChoTR2',{'octStr-I',"A string"}), - ?line {ok,{'octStr-I',"A string"}} = - asn1_wrapper:decode('ChoTypeRefPrim','ChoTR2',lists:flatten(Bytes24)), - - ?line {ok,Bytes25} = asn1_wrapper:encode('ChoTypeRefPrim','ChoTR2',{'octStrI-I',"A string"}), - ?line {ok,{'octStrI-I',"A string"}} = - asn1_wrapper:decode('ChoTypeRefPrim','ChoTR2',lists:flatten(Bytes25)), - - ?line {ok,Bytes26} = asn1_wrapper:encode('ChoTypeRefPrim','ChoTR2',{'octStrE-I',"A string"}), - ?line {ok,{'octStrE-I',"A string"}} = - asn1_wrapper:decode('ChoTypeRefPrim','ChoTR2',lists:flatten(Bytes26)), - - ?line {ok,Bytes27} = asn1_wrapper:encode('ChoTypeRefPrim','ChoTR2',{'octStr-E',"A string"}), - ?line {ok,{'octStr-E',"A string"}} = - asn1_wrapper:decode('ChoTypeRefPrim','ChoTR2',lists:flatten(Bytes27)), - - ?line {ok,Bytes28} = asn1_wrapper:encode('ChoTypeRefPrim','ChoTR2',{'octStrI-E',"A string"}), - ?line {ok,{'octStrI-E',"A string"}} = - asn1_wrapper:decode('ChoTypeRefPrim','ChoTR2',lists:flatten(Bytes28)), - - ?line {ok,Bytes29} = asn1_wrapper:encode('ChoTypeRefPrim','ChoTR2',{'octStrE-E',"A string"}), - ?line {ok,{'octStrE-E',"A string"}} = - asn1_wrapper:decode('ChoTypeRefPrim','ChoTR2',lists:flatten(Bytes29)), - - + roundtrip('ChoTR', {bool,true}), + roundtrip('ChoTR', {octStr,[11,12,13,14,15,16,17]}), + roundtrip('ChoTR', {int,233}), + roundtrip('ChoTR', {octStr,"Stringing in the rain"}), + roundtrip('ChoTR2', {octStr,"A string"}), + roundtrip('ChoTR2', {octStrI,"A string"}), + roundtrip('ChoTR2', {octStrE,"A string"}), + roundtrip('ChoTR2', {'octStr-I',"A string"}), + roundtrip('ChoTR2', {'octStrI-I',"A string"}), + roundtrip('ChoTR2', {'octStrE-I',"A string"}), + roundtrip('ChoTR2', {'octStr-E',"A string"}), + roundtrip('ChoTR2', {'octStrI-E',"A string"}), + roundtrip('ChoTR2', {'octStrE-E',"A string"}), ok. + +roundtrip(Type, Value) -> + asn1_test_lib:roundtrip('ChoTypeRefPrim', Type, Value). diff --git a/lib/asn1/test/testChoTypeRefSeq.erl b/lib/asn1/test/testChoTypeRefSeq.erl index bf2b66c73e..86c22619aa 100644 --- a/lib/asn1/test/testChoTypeRefSeq.erl +++ b/lib/asn1/test/testChoTypeRefSeq.erl @@ -23,82 +23,21 @@ -include_lib("test_server/include/test_server.hrl"). --record('ChoSeq',{seqInt, seqOs}). --record('ChoSeqImp',{seqInt, seqOs}). --record('ChoSeqExp',{seqInt, seqOs}). +-record('ChoSeq', {seqInt, seqOs}). +-record('ChoSeqImp', {seqInt, seqOs}). +-record('ChoSeqExp', {seqInt, seqOs}). seq(_Rules) -> - - ?line {ok,Bytes1} = - asn1_wrapper:encode('ChoTypeRefSeq','ChoTRseq', - {choSeq,#'ChoSeq'{seqInt = 88, - seqOs = "A string"}}), - ?line {ok,{choSeq,{'ChoSeq',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSeq','ChoTRseq',lists:flatten(Bytes1)), - - - ?line {ok,Bytes2} = - asn1_wrapper:encode('ChoTypeRefSeq','ChoTRseq', - {choSeqI,#'ChoSeq'{seqInt = 88, - seqOs = "A string"}}), - ?line {ok,{choSeqI,{'ChoSeq',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSeq','ChoTRseq',lists:flatten(Bytes2)), - - - ?line {ok,Bytes3} = - asn1_wrapper:encode('ChoTypeRefSeq','ChoTRseq', - {choSeqE,#'ChoSeq'{seqInt = 88, - seqOs = "A string"}}), - ?line {ok,{choSeqE,{'ChoSeq',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSeq','ChoTRseq',lists:flatten(Bytes3)), - - - ?line {ok,Bytes4} = - asn1_wrapper:encode('ChoTypeRefSeq','ChoTRseq', - {'choSeq-I',#'ChoSeqImp'{seqInt = 88, - seqOs = "A string"}}), - ?line {ok,{'choSeq-I',{'ChoSeqImp',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSeq','ChoTRseq',lists:flatten(Bytes4)), - - - ?line {ok,Bytes5} = - asn1_wrapper:encode('ChoTypeRefSeq','ChoTRseq', - {'choSeqI-I',#'ChoSeqImp'{seqInt = 88, - seqOs = "A string"}}), - ?line {ok,{'choSeqI-I',{'ChoSeqImp',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSeq','ChoTRseq',lists:flatten(Bytes5)), - - - ?line {ok,Bytes6} = - asn1_wrapper:encode('ChoTypeRefSeq','ChoTRseq', - {'choSeqE-I',#'ChoSeqImp'{seqInt = 88, - seqOs = "A string"}}), - ?line {ok,{'choSeqE-I',{'ChoSeqImp',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSeq','ChoTRseq',lists:flatten(Bytes6)), - - - ?line {ok,Bytes7} = - asn1_wrapper:encode('ChoTypeRefSeq','ChoTRseq', - {'choSeq-E',#'ChoSeqExp'{seqInt = 88, - seqOs = "A string"}}), - ?line {ok,{'choSeq-E',{'ChoSeqExp',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSeq','ChoTRseq',lists:flatten(Bytes7)), - - - ?line {ok,Bytes8} = - asn1_wrapper:encode('ChoTypeRefSeq','ChoTRseq', - {'choSeqI-E',#'ChoSeqExp'{seqInt = 88, - seqOs = "A string"}}), - ?line {ok,{'choSeqI-E',{'ChoSeqExp',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSeq','ChoTRseq',lists:flatten(Bytes8)), - - - ?line {ok,Bytes9} = - asn1_wrapper:encode('ChoTypeRefSeq','ChoTRseq', - {'choSeqE-E',#'ChoSeqExp'{seqInt = 88, - seqOs = "A string"}}), - ?line {ok,{'choSeqE-E',{'ChoSeqExp',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSeq','ChoTRseq',lists:flatten(Bytes9)), - - + roundtrip('ChoTRseq', {choSeq,#'ChoSeq'{seqInt=88,seqOs="A string"}}), + roundtrip('ChoTRseq', {choSeqI,#'ChoSeq'{seqInt=88,seqOs="A string"}}), + roundtrip('ChoTRseq', {choSeqE,#'ChoSeq'{seqInt=88,seqOs="A string"}}), + roundtrip('ChoTRseq', {'choSeq-I',#'ChoSeqImp'{seqInt=88,seqOs="A string"}}), + roundtrip('ChoTRseq', {'choSeqI-I',#'ChoSeqImp'{seqInt=88,seqOs="A string"}}), + roundtrip('ChoTRseq', {'choSeqE-I',#'ChoSeqImp'{seqInt=88,seqOs="A string"}}), + roundtrip('ChoTRseq', {'choSeq-E',#'ChoSeqExp'{seqInt=88,seqOs="A string"}}), + roundtrip('ChoTRseq', {'choSeqI-E',#'ChoSeqExp'{seqInt=88,seqOs="A string"}}), + roundtrip('ChoTRseq', {'choSeqE-E',#'ChoSeqExp'{seqInt=88,seqOs="A string"}}), ok. + +roundtrip(Type, Value) -> + asn1_test_lib:roundtrip('ChoTypeRefSeq', Type, Value). diff --git a/lib/asn1/test/testChoTypeRefSet.erl b/lib/asn1/test/testChoTypeRefSet.erl index 8a3e8bdbb0..fd3d75cbcb 100644 --- a/lib/asn1/test/testChoTypeRefSet.erl +++ b/lib/asn1/test/testChoTypeRefSet.erl @@ -23,83 +23,21 @@ -include_lib("test_server/include/test_server.hrl"). --record('ChoSet',{setInt, setOs}). --record('ChoSetImp',{setInt, setOs}). --record('ChoSetExp',{setInt, setOs}). +-record('ChoSet', {setInt, setOs}). +-record('ChoSetImp', {setInt, setOs}). +-record('ChoSetExp', {setInt, setOs}). set(_Rules) -> - - ?line {ok,Bytes1} = - asn1_wrapper:encode('ChoTypeRefSet','ChoTRset', - {choSet,#'ChoSet'{setInt = 88, - setOs = "A string"}}), - ?line {ok,{choSet,{'ChoSet',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSet','ChoTRset',lists:flatten(Bytes1)), - - - ?line {ok,Bytes2} = - asn1_wrapper:encode('ChoTypeRefSet','ChoTRset', - {choSetI,#'ChoSet'{setInt = 88, - setOs = "A string"}}), - ?line {ok,{choSetI,{'ChoSet',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSet','ChoTRset',lists:flatten(Bytes2)), - - - ?line {ok,Bytes3} = - asn1_wrapper:encode('ChoTypeRefSet','ChoTRset', - {choSetE,#'ChoSet'{setInt = 88, - setOs = "A string"}}), - ?line {ok,{choSetE,{'ChoSet',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSet','ChoTRset',lists:flatten(Bytes3)), - - - ?line {ok,Bytes4} = - asn1_wrapper:encode('ChoTypeRefSet','ChoTRset', - {'choSet-I',#'ChoSetImp'{setInt = 88, - setOs = "A string"}}), - ?line {ok,{'choSet-I',{'ChoSetImp',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSet','ChoTRset',lists:flatten(Bytes4)), - - - ?line {ok,Bytes5} = - asn1_wrapper:encode('ChoTypeRefSet','ChoTRset', - {'choSetI-I',#'ChoSetImp'{setInt = 88, - setOs = "A string"}}), - ?line {ok,{'choSetI-I',{'ChoSetImp',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSet','ChoTRset',lists:flatten(Bytes5)), - - - ?line {ok,Bytes6} = - asn1_wrapper:encode('ChoTypeRefSet','ChoTRset', - {'choSetE-I',#'ChoSetImp'{setInt = 88, - setOs = "A string"}}), - ?line {ok,{'choSetE-I',{'ChoSetImp',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSet','ChoTRset',lists:flatten(Bytes6)), - - - ?line {ok,Bytes7} = - asn1_wrapper:encode('ChoTypeRefSet','ChoTRset', - {'choSet-E',#'ChoSetExp'{setInt = 88, - setOs = "A string"}}), - ?line {ok,{'choSet-E',{'ChoSetExp',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSet','ChoTRset',lists:flatten(Bytes7)), - - - ?line {ok,Bytes8} = - asn1_wrapper:encode('ChoTypeRefSet','ChoTRset', - {'choSetI-E',#'ChoSetExp'{setInt = 88, - setOs = "A string"}}), - ?line {ok,{'choSetI-E',{'ChoSetExp',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSet','ChoTRset',lists:flatten(Bytes8)), - - - ?line {ok,Bytes9} = - asn1_wrapper:encode('ChoTypeRefSet','ChoTRset', - {'choSetE-E',#'ChoSetExp'{setInt = 88, - setOs = "A string"}}), - ?line {ok,{'choSetE-E',{'ChoSetExp',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSet','ChoTRset',lists:flatten(Bytes9)), - - - + roundtrip('ChoTRset', {choSet,#'ChoSet'{setInt=88,setOs="A string"}}), + roundtrip('ChoTRset', {choSetI,#'ChoSet'{setInt=88,setOs="A string"}}), + roundtrip('ChoTRset', {choSetE,#'ChoSet'{setInt=88,setOs="A string"}}), + roundtrip('ChoTRset', {'choSet-I',#'ChoSetImp'{setInt=88,setOs="A string"}}), + roundtrip('ChoTRset', {'choSetI-I',#'ChoSetImp'{setInt=88,setOs="A string"}}), + roundtrip('ChoTRset', {'choSetE-I',#'ChoSetImp'{setInt=88,setOs="A string"}}), + roundtrip('ChoTRset', {'choSet-E',#'ChoSetExp'{setInt=88,setOs="A string"}}), + roundtrip('ChoTRset', {'choSetI-E',#'ChoSetExp'{setInt=88,setOs="A string"}}), + roundtrip('ChoTRset', {'choSetE-E',#'ChoSetExp'{setInt=88,setOs="A string"}}), ok. + +roundtrip(Type, Value) -> + asn1_test_lib:roundtrip('ChoTypeRefSet', Type, Value). diff --git a/lib/asn1/test/testChoiceIndefinite.erl b/lib/asn1/test/testChoiceIndefinite.erl index b5832c985a..87910cf6ec 100644 --- a/lib/asn1/test/testChoiceIndefinite.erl +++ b/lib/asn1/test/testChoiceIndefinite.erl @@ -32,6 +32,6 @@ main(ber) -> Bi = [48,128,160,128,128,1,11,0,0,129,1,12,0,0], %% the value which is encoded V = {'Seq',{ca,11},12}, - ?line {ok,V} = asn1_wrapper:decode('ChoiceIndef','Seq',B), - ?line {ok,V} = asn1_wrapper:decode('ChoiceIndef','Seq',Bi), + {ok,V} = 'ChoiceIndef':decode('Seq', B), + {ok,V} = 'ChoiceIndef':decode('Seq', Bi), ok. diff --git a/lib/asn1/test/testConstraints.erl b/lib/asn1/test/testConstraints.erl index ed0cae0076..9a1d62993d 100644 --- a/lib/asn1/test/testConstraints.erl +++ b/lib/asn1/test/testConstraints.erl @@ -204,9 +204,8 @@ shorter_ext(uper, "a") -> <<16#80,16#E1>>; shorter_ext(ber, _) -> none. refed_NNL_name(_Erule) -> - ?line {ok,_} = asn1_wrapper:encode('Constraints','AnotherThing',fred), - ?line {error,_Reason} = - asn1_wrapper:encode('Constraints','AnotherThing',fred3). + roundtrip('AnotherThing', fred), + {error,_Reason} = 'Constraints':encode('AnotherThing', fred3). v_roundtrip(Erule, Type, Value) -> Encoded = asn1_test_lib:hex_to_bin(v(Erule, Type, Value)), diff --git a/lib/asn1/test/testContextSwitchingTypes.erl b/lib/asn1/test/testContextSwitchingTypes.erl index 40dbe25015..bdd6883dac 100644 --- a/lib/asn1/test/testContextSwitchingTypes.erl +++ b/lib/asn1/test/testContextSwitchingTypes.erl @@ -24,31 +24,21 @@ -include_lib("test_server/include/test_server.hrl"). test(Config) -> - ?line ValT = 'ContextSwitchingTypes':'val1-T'(), - ?line {ok,Bytes1} = - asn1_wrapper:encode('ContextSwitchingTypes','T',ValT), - ?line {ok,Result1} = - asn1_wrapper:decode('ContextSwitchingTypes','T',Bytes1), - ?line ok = check_EXTERNAL(Result1), - ?line {ok,ValT2} = asn1ct:value('ContextSwitchingTypes','T', - [{i, ?config(case_dir, Config)}]), - ?line {ok,Bytes1_2} = - asn1_wrapper:encode('ContextSwitchingTypes','T',ValT2), - ?line {ok,Result1_2} = - asn1_wrapper:decode('ContextSwitchingTypes','T',Bytes1_2), - ?line ok = check_EXTERNAL(Result1_2), + ValT = 'ContextSwitchingTypes':'val1-T'(), + check_EXTERNAL(enc_dec('T', ValT)), - ?line ValEP = 'ContextSwitchingTypes':'val1-EP'(), - ?line {ok,Bytes2} = - asn1_wrapper:encode('ContextSwitchingTypes','EP',ValEP), - ?line {ok,_Result2} = - asn1_wrapper:decode('ContextSwitchingTypes','EP',Bytes2), + {ok,ValT2} = asn1ct:value('ContextSwitchingTypes', 'T', + [{i,?config(case_dir, Config)}]), + check_EXTERNAL(enc_dec('T', ValT2)), - ?line ValCS = 'ContextSwitchingTypes':'val1-CS'(), - ?line {ok,Bytes3} = - asn1_wrapper:encode('ContextSwitchingTypes','CS',ValCS), - ?line {ok,_Result3} = - asn1_wrapper:decode('ContextSwitchingTypes','CS',Bytes3). + ValEP = 'ContextSwitchingTypes':'val1-EP'(), + ValEPDec = enc_dec('EP', ValEP), + io:format("~p\n~p\n", [ValEP,ValEPDec]), + + ValCS = 'ContextSwitchingTypes':'val1-CS'(), + ValCSDec = enc_dec('EP', ValCS), + io:format("~p\n~p\n", [ValCS,ValCSDec]), + ok. check_EXTERNAL({'EXTERNAL',Identif,DVD,DV})-> @@ -85,3 +75,9 @@ check_object_identifier(Tuple) when is_tuple(Tuple) -> not is_integer(E)] of [] -> ok end. + +enc_dec(T, V0) -> + M = 'ContextSwitchingTypes', + {ok,Enc} = M:encode(T, V0), + {ok,V} = M:decode(T, Enc), + V. diff --git a/lib/asn1/test/testDER.erl b/lib/asn1/test/testDER.erl index 395116bd34..3f74a16797 100644 --- a/lib/asn1/test/testDER.erl +++ b/lib/asn1/test/testDER.erl @@ -25,26 +25,24 @@ test() -> Val = {'Set',12,{version,214},true}, - ?line {ok,Bin}=asn1_wrapper:encode('DERSpec','Set',Val), - ?line ok = match_value('Set',Bin), - ?line {ok,{'Set',12,{version,214},true}} = - asn1_wrapper:decode('DERSpec','Set',Bin), + roundtrip_enc('Set', Val, <<49,12,1,1,255,2,2,0,214,161,3,2,1,12>>), - ValSof = [{version,12},{message,"PrintableString"},{message,"Print"},{version,11}], - ?line {ok,BSof} = asn1_wrapper:encode('DERSpec','SetOf',ValSof), - ?line ok = match_value('SetOf',BSof), - ?line {ok,[{version,11},{version,12},{message,"Print"},{message,"PrintableString"}]} = asn1_wrapper:decode('DERSpec','SetOf',BSof), + ValSof = [{version,12},{message,"PrintableString"}, + {message,"Print"},{version,11}], + ValSofSorted = [{version,11},{version,12}, + {message,"Print"},{message,"PrintableString"}], + roundtrip_enc('SetOf', ValSof, ValSofSorted, + <<49,30,2,1,11,2,1,12,19,5,80,114,105,110,116,19,15,80, + 114,105,110,116,97,98,108,101,83,116,114,105,110,103>>), ValSO = [{'Seq2',1,true},{'Seq2',120000,false},{'Seq2',3,true}], - ?line {ok,SOB} = asn1_wrapper:encode('DERSpec','SO',ValSO), - ?line {ok,ValSO} = asn1_wrapper:decode('DERSpec','SO',SOB). + roundtrip('SO', ValSO). +roundtrip(T, V) -> + asn1_test_lib:roundtrip('DERSpec', T, V). -match_value('Set',<<49,12,1,1,255,2,2,0,214,161,3,2,1,12>>) -> - ok; -match_value('Set',[49,12,1,1,255,2,2,0,214,161,3,2,1,12]) -> - ok; -match_value('SetOf',<<49,30,2,1,11,2,1,12,19,5,80,114,105,110,116,19,15,80,114,105,110,116,97,98,108,101,83,116,114,105,110,103>>) -> ok; -match_value('SetOf',[49,30,2,1,11,2,1,12,19,5,80,114,105,110,116,19,15,80,114,105,110,116,97,98,108,101,83,116,114,105,110,103]) -> ok; -match_value(_,B) -> - {error,B}. +roundtrip_enc(T, V, Enc) -> + Enc = asn1_test_lib:roundtrip_enc('DERSpec', T, V). + +roundtrip_enc(T, V, Expected, Enc) -> + Enc = asn1_test_lib:roundtrip_enc('DERSpec', T, V, Expected). diff --git a/lib/asn1/test/testDef.erl b/lib/asn1/test/testDef.erl index 48f0015008..b8df3c4f8b 100644 --- a/lib/asn1/test/testDef.erl +++ b/lib/asn1/test/testDef.erl @@ -37,81 +37,45 @@ bool33 = asn1_DEFAULT}). main(_Rules) -> - - ?line {ok,Bytes11} = asn1_wrapper:encode('Def','Def1',#'Def1'{bool0 = true, - bool1 = true, - bool2 = true, - bool3 = true}), - ?line {ok,{'Def1',true,true,true,true}} = - asn1_wrapper:decode('Def','Def1',lists:flatten(Bytes11)), - - ?line {ok,Bytes12} = asn1_wrapper:encode('Def','Def1',#'Def1'{bool0 = true}), - ?line {ok,{'Def1',true,false,false,false}} = - asn1_wrapper:decode('Def','Def1',lists:flatten(Bytes12)), - - ?line {ok,Bytes13} = asn1_wrapper:encode('Def','Def1',#'Def1'{bool0 = true, - bool2 = false}), - ?line {ok,{'Def1',true,false,false,false}} = - asn1_wrapper:decode('Def','Def1',lists:flatten(Bytes13)), - - ?line {ok,Bytes14} = asn1_wrapper:encode('Def','Def1',#'Def1'{bool0 = false, - bool3 = false}), - ?line {ok,{'Def1',false,false,false,false}} = - asn1_wrapper:decode('Def','Def1',lists:flatten(Bytes14)), - - - - - ?line {ok,Bytes21} = asn1_wrapper:encode('Def','Def2',#'Def2'{bool10 = false, - bool11 = false, - bool12 = false, - bool13 = false}), - ?line {ok,{'Def2',false,false,false,false}} = - asn1_wrapper:decode('Def','Def2',lists:flatten(Bytes21)), - - ?line {ok,Bytes22} = asn1_wrapper:encode('Def','Def2',#'Def2'{bool10 = true, - bool13 = false}), - ?line {ok,{'Def2',true,false,false,false}} = - asn1_wrapper:decode('Def','Def2',lists:flatten(Bytes22)), - - ?line {ok,Bytes23} = asn1_wrapper:encode('Def','Def2',#'Def2'{bool10 = true, - bool11 = false, - bool13 = false}), - ?line {ok,{'Def2',true,false,false,false}} = - asn1_wrapper:decode('Def','Def2',lists:flatten(Bytes23)), - - ?line {ok,Bytes24} = asn1_wrapper:encode('Def','Def2',#'Def2'{bool10 = false, - bool12 = false, - bool13 = false}), - ?line {ok,{'Def2',false,false,false,false}} = - asn1_wrapper:decode('Def','Def2',lists:flatten(Bytes24)), - - - - - ?line {ok,Bytes31} = asn1_wrapper:encode('Def','Def3',#'Def3'{bool30 = false, - bool31 = false, - bool32 = false, - bool33 = false}), - ?line {ok,{'Def3',false,false,false,false}} = - asn1_wrapper:decode('Def','Def3',lists:flatten(Bytes31)), - - ?line {ok,Bytes32} = asn1_wrapper:encode('Def','Def3',#'Def3'{}), - ?line {ok,{'Def3',false,false,false,false}} = - asn1_wrapper:decode('Def','Def3',lists:flatten(Bytes32)), - - ?line {ok,Bytes33} = asn1_wrapper:encode('Def','Def3',#'Def3'{bool30 = true}), - ?line {ok,{'Def3',true,false,false,false}} = - asn1_wrapper:decode('Def','Def3',lists:flatten(Bytes33)), - - ?line {ok,Bytes34} = asn1_wrapper:encode('Def','Def3',#'Def3'{bool32 = false}), - ?line {ok,{'Def3',false,false,false,false}} = - asn1_wrapper:decode('Def','Def3',lists:flatten(Bytes34)), - - ?line {ok,Bytes35} = asn1_wrapper:encode('Def','Def3',#'Def3'{bool33 = false}), - ?line {ok,{'Def3',false,false,false,false}} = - asn1_wrapper:decode('Def','Def3',lists:flatten(Bytes35)), - - - + roundtrip('Def1', #'Def1'{bool0=true,bool1=true,bool2=true,bool3=true}), + roundtrip('Def1', + #'Def1'{bool0=true}, + #'Def1'{bool0=true,bool1=false,bool2=false,bool3=false}), + roundtrip('Def1', + #'Def1'{bool0=true,bool2=false}, + #'Def1'{bool0=true,bool1=false,bool2=false,bool3=false}), + roundtrip('Def1', + #'Def1'{bool0=false,bool3=false}, + #'Def1'{bool0=false,bool1=false,bool2=false,bool3=false}), + + roundtrip('Def2', #'Def2'{bool10=false,bool11=false,bool12=false,bool13=false}), + roundtrip('Def2', + #'Def2'{bool10=true,bool13=false}, + #'Def2'{bool10=true,bool11=false,bool12=false,bool13=false}), + roundtrip('Def2', + #'Def2'{bool10=true,bool11=false,bool13=false}, + #'Def2'{bool10=true,bool11=false,bool12=false,bool13=false}), + roundtrip('Def2', + #'Def2'{bool10=false,bool12=false,bool13=false}, + #'Def2'{bool10=false,bool11=false,bool12=false,bool13=false}), + + roundtrip('Def3', #'Def3'{bool30=false,bool31=false,bool32=false,bool33=false}), + roundtrip('Def3', + #'Def3'{}, + #'Def3'{bool30=false,bool31=false,bool32=false,bool33=false}), + roundtrip('Def3', + #'Def3'{bool30=true}, + #'Def3'{bool30=true,bool31=false,bool32=false,bool33=false}), + roundtrip('Def3', + #'Def3'{bool32=false}, + #'Def3'{bool30=false,bool31=false,bool32=false,bool33=false}), + roundtrip('Def3', + #'Def3'{bool33=false}, + #'Def3'{bool30=false,bool31=false,bool32=false,bool33=false}), ok. + +roundtrip(Type, Value) -> + roundtrip(Type, Value, Value). + +roundtrip(Type, Value, ExpectedValue) -> + asn1_test_lib:roundtrip('Def', Type, Value, ExpectedValue). diff --git a/lib/asn1/test/testDoubleEllipses.erl b/lib/asn1/test/testDoubleEllipses.erl index 1032156b91..4e8972cdfc 100644 --- a/lib/asn1/test/testDoubleEllipses.erl +++ b/lib/asn1/test/testDoubleEllipses.erl @@ -34,67 +34,27 @@ -record('SetAltV2',{a,d,b,e,h,i,c,f,g}). main(_Rules) -> - %% SEQUENCE - ?line {ok,Bytes} = - asn1_wrapper:encode('DoubleEllipses','Seq',#'Seq'{a = 10,c = true}), - ?line {ok,#'SeqV2'{a=10,b = asn1_NOVALUE, c = true}} = - asn1_wrapper:decode('DoubleEllipses','SeqV2',Bytes), - ?line {ok,Bytes2} = - asn1_wrapper:encode('DoubleEllipses','SeqV2', - #'SeqV2'{a=10,b = false, c = true}), - ?line {ok,#'Seq'{a = 10, c = true}} = - asn1_wrapper:decode('DoubleEllipses','Seq',Bytes2), + roundtrip('Seq', #'Seq'{a=10,c=true}), + roundtrip('SeqV2', #'SeqV2'{a=10,b=false,c=true}), + roundtrip('SeqAlt', + #'SeqAlt'{a=10,d=12,b = <<2#1010:4>>, + e=true,c=false,f=14,g=16}), + roundtrip('SeqAltV2', + #'SeqAltV2'{a=10,d=12, + b = <<2#1010:4>>, + e=true,h="PS",i=13,c=false,f=14,g=16}), - ?line {ok,Bytes3} = - asn1_wrapper:encode('DoubleEllipses','SeqAlt', - #'SeqAlt'{a = 10, d = 12, - b = [1,0,1,0], e = true, - c = false, f = 14, g = 16}), - ?line {ok,#'SeqAltV2'{a = 10, d = 12, - b = <<2#1010:4>>, e = true, - h = asn1_NOVALUE, i = asn1_NOVALUE, - c = false, f = 14, g = 16}} = - asn1_wrapper:decode('DoubleEllipses','SeqAltV2',Bytes3), - ?line {ok,Bytes4} = - asn1_wrapper:encode('DoubleEllipses','SeqAltV2', - #'SeqAltV2'{a = 10, d = 12, - b = [1,0,1,0], e = true, - h = "PS", i = 13, - c = false, f = 14, g = 16}), - ?line {ok,#'SeqAlt'{a = 10, d = 12, - b = <<2#1010:4>>, e = true, - c = false, f = 14, g = 16}} = - asn1_wrapper:decode('DoubleEllipses','SeqAlt',Bytes4), - - %% SET - ?line {ok,Bytes5} = - asn1_wrapper:encode('DoubleEllipses','Set',#'Set'{a = 10,c = true}), - ?line {ok,#'SetV2'{a=10,b = asn1_NOVALUE, c = true}} = - asn1_wrapper:decode('DoubleEllipses','SetV2',Bytes5), - ?line {ok,Bytes6} = - asn1_wrapper:encode('DoubleEllipses','SetV2', - #'SetV2'{a=10,b = false, c = true}), - ?line {ok,#'Set'{a = 10, c = true}} = - asn1_wrapper:decode('DoubleEllipses','Set',Bytes6), - - ?line {ok,Bytes7} = - asn1_wrapper:encode('DoubleEllipses','SetAlt', - #'SetAlt'{a = 10, d = 12, - b = [1,0,1,0], e = true, - c = false, f = 14, g = 16}), - ?line {ok,#'SetAltV2'{a = 10, d = 12, - b = <<2#1010:4>>, e = true, - h = asn1_NOVALUE, i = asn1_NOVALUE, - c = false, f = 14, g = 16}} = - asn1_wrapper:decode('DoubleEllipses','SetAltV2',Bytes7), - ?line {ok,Bytes8} = - asn1_wrapper:encode('DoubleEllipses','SetAltV2', - #'SetAltV2'{a = 10, d = 12, - b = [1,0,1,0], e = true, - h = "PS", i = 13, - c = false, f = 14, g = 16}), - ?line {ok,#'SetAlt'{a = 10, d = 12, - b = <<2#1010:4>>, e = true, - c = false, f = 14, g = 16}} = - asn1_wrapper:decode('DoubleEllipses','SetAlt',Bytes8), + roundtrip('Set', #'Set'{a=10,c=true}), + roundtrip('SetV2', #'SetV2'{a=10,b=false,c=true}), + roundtrip('SetAlt', + #'SetAlt'{a=10,d=12, + b = <<2#1010:4>>, + e=true,c=false,f=14,g=16}), + roundtrip('SetAltV2', + #'SetAltV2'{a=10,d=12, + b = <<2#1010:4>>, + e=true,h="PS",i=13,c=false,f=14,g=16}), ok. + +roundtrip(T, V) -> + asn1_test_lib:roundtrip('DoubleEllipses', T, V). diff --git a/lib/asn1/test/testEnumExt.erl b/lib/asn1/test/testEnumExt.erl index b1e55d95ad..c66adaf949 100644 --- a/lib/asn1/test/testEnumExt.erl +++ b/lib/asn1/test/testEnumExt.erl @@ -33,7 +33,7 @@ main(Rule) when Rule =:= per; Rule =:= uper -> %% ENUMERATED with extensionmark (value is an extensionvalue) Or = roundtrip('Ext1', orange), %% unknown extensionvalue - {ok,{asn1_enum,0}} = asn1_wrapper:decode('EnumExt','Ext',Or), + {ok,{asn1_enum,0}} = 'EnumExt':decode('Ext', Or), %% ENUMERATED no extensionmark B64 = <<64>>, @@ -45,12 +45,12 @@ main(ber) -> roundtrip('Ext', red), %% value is an extensionvalue - {ok,Bytes1_1} = asn1_wrapper:encode('EnumExt','Ext1',orange), - {ok,{asn1_enum,7}} = asn1_wrapper:decode('EnumExt','Ext',lists:flatten(Bytes1_1)), + {ok,Bytes1_1} = 'EnumExt':encode('Ext1', orange), + {ok,{asn1_enum,7}} = 'EnumExt':decode('Ext', Bytes1_1), %% ENUMERATED no extensionmark roundtrip('Noext', red), - ?line {error,{asn1,_}} = (catch asn1_wrapper:encode('EnumExt','Noext',orange)), + {error,{asn1,_}} = (catch 'EnumExt':encode('Noext', orange)), %% ENUMERATED with atom 'com' roundtrip('Globalstate', preop), diff --git a/lib/asn1/test/testINSTANCE_OF.erl b/lib/asn1/test/testINSTANCE_OF.erl index ce411beb92..c855ca3c06 100644 --- a/lib/asn1/test/testINSTANCE_OF.erl +++ b/lib/asn1/test/testINSTANCE_OF.erl @@ -18,46 +18,23 @@ %% %% -module(testINSTANCE_OF). - -export([main/1]). -include_lib("test_server/include/test_server.hrl"). -main(Erule) -> +main(_Erule) -> + Int = roundtrip('Int', 3), - ?line {ok,Integer} = asn1_wrapper:encode('INSTANCEOF','Int',3), - Int = list_to_binary(Integer), ValotherName = {otherName,{'INSTANCE OF',{2,4},Int}}, + _ = roundtrip('GeneralName', ValotherName), + VallastName1 = {lastName,{'GeneralName_lastName',{2,4},12}}, + _ = roundtrip('GeneralName', VallastName1), + VallastName2 = {lastName,{'GeneralName_lastName',{2,3,4}, {'Seq',12,true}}}, - ?line {ok,BytesoN}= - asn1_wrapper:encode('INSTANCEOF','GeneralName',ValotherName), - ?line {ok,Res1={otherName,_}} = - asn1_wrapper:decode('INSTANCEOF','GeneralName',BytesoN), - ?line ok = test_encdec(Erule,Int,Res1), - - ?line {ok,ByteslN1}= - asn1_wrapper:encode('INSTANCEOF','GeneralName',VallastName1), - ?line {ok,Res2={lastName,_}} = - asn1_wrapper:decode('INSTANCEOF','GeneralName',ByteslN1), - ?line test_encdec(Erule,Res2), - - ?line {ok,ByteslN2}= - asn1_wrapper:encode('INSTANCEOF','GeneralName',VallastName2), - ?line {ok,Res3={lastName,_}} = - asn1_wrapper:decode('INSTANCEOF','GeneralName',ByteslN2), - ?line test_encdec(Erule,Res3). - -test_encdec(_Erule,Int,{otherName,{'INSTANCE OF',{2,4},Int}}) -> - ok; -test_encdec(Erule,Int,R={otherName,{'INSTANCE OF',{2,4},_Int2}}) -> - {error,{Erule,Int,R}}. + _ = roundtrip('GeneralName', VallastName2), + ok. -test_encdec(_Erule,{lastName,{'GeneralName_lastName',{2,4},12}}) -> - ok; -test_encdec(_Erule,{lastName,{'GeneralName_lastName',{2,3,4}, - {'Seq',12,true}}}) -> - ok; -test_encdec(Erule,Res) -> - {error,{Erule,Res}}. +roundtrip(T, V) -> + asn1_test_lib:roundtrip_enc('INSTANCEOF', T, V). diff --git a/lib/asn1/test/testInfObjectClass.erl b/lib/asn1/test/testInfObjectClass.erl index 98408502c6..c36c05a2ea 100644 --- a/lib/asn1/test/testInfObjectClass.erl +++ b/lib/asn1/test/testInfObjectClass.erl @@ -29,24 +29,22 @@ main(Rule) -> %% this test is added for OTP-4591, to test that elements in decoded %% value has terms in right order. Val = {'Seq',12,13,2}, - ?line {ok,Bytes}= asn1_wrapper:encode('InfClass','Seq',Val), - ?line {ok,Val} = asn1_wrapper:decode('InfClass','Seq',Bytes), + roundtrip('Seq', Val), %% OTP-5783 - ?line {error,{asn1,{'Type not compatible with table constraint', - {component,'ArgumentType'}, - {value,_},_}}} = asn1_wrapper:encode('InfClass','Seq', - {'Seq',12,13,1}), + {error,{asn1,{'Type not compatible with table constraint', + {component,'ArgumentType'}, + {value,_},_}}} = 'InfClass':encode('Seq', {'Seq',12,13,1}), Bytes2 = case Rule of ber -> <<48,9,2,1,12,2,1,11,2,1,1>>; _ -> - <<1,12,1,11,1,1>> + <<1,12,1,11,1,1>> end, - ?line {error,{asn1,{'Type not compatible with table constraint', - {{component,_}, - {value,_B},_}}}} = - asn1_wrapper:decode('InfClass','Seq',Bytes2). + {error,{asn1,{'Type not compatible with table constraint', + {{component,_}, + {value,_B},_}}}} = 'InfClass':decode('Seq', Bytes2), + ok. - - +roundtrip(T, V) -> + asn1_test_lib:roundtrip('InfClass', T, V). diff --git a/lib/asn1/test/testMegaco.erl b/lib/asn1/test/testMegaco.erl index f954f506b6..644042b484 100644 --- a/lib/asn1/test/testMegaco.erl +++ b/lib/asn1/test/testMegaco.erl @@ -24,53 +24,24 @@ -include_lib("test_server/include/test_server.hrl"). -compile(_Config,ber,[optimize]) -> - {ok,no_module,no_module}; -compile(_Config,per,[optimize]) -> - {ok,no_module,no_module}; -compile(Config,Erule,Options) -> +compile(Config, Erule, Options) -> asn1_test_lib:compile("MEDIA-GATEWAY-CONTROL.asn", Config, [Erule|Options]), asn1_test_lib:compile("OLD-MEDIA-GATEWAY-CONTROL.asn", Config, [Erule|Options]), {ok,'OLD-MEDIA-GATEWAY-CONTROL','MEDIA-GATEWAY-CONTROL'}. - main(no_module,_) -> ok; main('OLD-MEDIA-GATEWAY-CONTROL',Config) -> CaseDir = ?config(case_dir, Config), {ok,Msg} = asn1ct:value('OLD-MEDIA-GATEWAY-CONTROL','MegacoMessage', [{i, CaseDir}]), - ?line {ok,Bytes} = asn1_wrapper:encode('OLD-MEDIA-GATEWAY-CONTROL', - 'MegacoMessage',Msg), - ?line {ok,Msg} = asn1_wrapper:decode('OLD-MEDIA-GATEWAY-CONTROL', - 'MegacoMessage', - Bytes), + asn1_test_lib:roundtrip('OLD-MEDIA-GATEWAY-CONTROL', 'MegacoMessage', Msg), ok; -main(Mod='MEDIA-GATEWAY-CONTROL',Config) -> - ?line DataDir = ?config(data_dir,Config), - io:format("DataDir:~p~n",[DataDir]), - ?line {ok,FilenameList} = file:list_dir(filename:join([DataDir, - megacomessages])), - %% remove any junk files that may be in the megacomessage directory - Pred = fun(X) -> - case lists:reverse(X) of - [$l,$a,$v,$.|_R] ->true; - _ -> false - end - end, - MegacoMsgFilenameList = lists:filter(Pred,FilenameList), - - Fun = fun(F) -> - M = read_msg(filename:join([DataDir,megacomessages,F])), - {ok,B} = asn1_wrapper:encode(Mod,element(1,M),M), - {ok,M} = asn1_wrapper:decode(Mod,element(1,M),B) - end, - ?line lists:foreach(Fun,MegacoMsgFilenameList), - ok. - -read_msg(File) -> - case file:read_file(File) of - {ok,Bin} -> - binary_to_term(Bin); - _ -> - io:format("couldn't read file ~p~n",[File]) - end. +main('MEDIA-GATEWAY-CONTROL'=Mod, Config) -> + DataDir = ?config(data_dir, Config), + Files = filelib:wildcard(filename:join([DataDir,megacomessages,"*.val"])), + lists:foreach(fun(File) -> + {ok,Bin} = file:read_file(File), + V = binary_to_term(Bin), + T = element(1, V), + asn1_test_lib:roundtrip(Mod, T, V) + end, Files). diff --git a/lib/asn1/test/testMergeCompile.erl b/lib/asn1/test/testMergeCompile.erl index 8ef7ba3458..7cda71c441 100644 --- a/lib/asn1/test/testMergeCompile.erl +++ b/lib/asn1/test/testMergeCompile.erl @@ -30,42 +30,35 @@ main(Erule) -> %% test of module MS.set.asn that tests OTP-4492: different tagdefault in %% modules and types with same name in modules - ?line MSVal = {'Type4M2',8,true,three,"OCTET STRING"}, - ?line {ok,MSBytes} = asn1_wrapper:encode('MS','Type4M2',MSVal), - ?line {ok,MSVal} = asn1_wrapper:decode('MS','Type4M2',MSBytes), - + MSVal = {'Type4M2',8,true,three,"OCTET STRING"}, + asn1_test_lib:roundtrip('MS', 'Type4M2', MSVal), %% test of RANAP.set.asn1 - ?line _PIEVal = [{'ProtocolIE-Field',4,ignore,{'Cause',{radioNetwork,{'CauseRadioNetwork','rab-pre-empted'}}}}], PIEVal2 = [{'ProtocolIE-Field',4,ignore,{radioNetwork,'rab-pre-empted'}}], - ?line _PEVal = [{'ProtocolExtensionField',[0]}], -%% ?line EncVal = asn1rt_per_v1:encode_integer([],100), - ?line EncVal = + EncVal = case Erule of per -> <<1,100>>; uper -> <<1,100>>; ber -> - [2,1,1] + <<2,1,1>> end, - ?line PEVal2 = [{dummy,1,ignore,EncVal},{dummy,2,reject,EncVal}], - ?line Val2 = + PEVal2 = [{'ProtocolExtensionField',1,ignore,EncVal}, + {'ProtocolExtensionField',2,reject,EncVal}], + Val2 = #'InitiatingMessage'{procedureCode=1, criticality=ignore, value=#'Iu-ReleaseCommand'{protocolIEs=PIEVal2, protocolExtensions=asn1_NOVALUE}}, - ?line {ok,Bytes2} = asn1_wrapper:encode('RANAPSET','InitiatingMessage',Val2), - ?line {ok,_Ret2} = asn1_wrapper:decode('RANAPSET','InitiatingMessage',Bytes2), - - ?line Val3 = + asn1_test_lib:roundtrip('RANAPSET', 'InitiatingMessage', Val2), + Val3 = #'InitiatingMessage'{procedureCode=1, criticality=ignore, value=#'Iu-ReleaseCommand'{protocolIEs=PIEVal2, protocolExtensions=PEVal2}}, - ?line {ok,Bytes3} = asn1_wrapper:encode('RANAPSET','InitiatingMessage',Val3), - ?line {ok,_Ret3} = asn1_wrapper:decode('RANAPSET','InitiatingMessage',Bytes3). + asn1_test_lib:roundtrip('RANAPSET', 'InitiatingMessage', Val3). mvrasn(Erule) -> @@ -83,78 +76,73 @@ mvrasn(Erule) -> ?line ok = test(mvrasn6,'InsertSubscriberDataArg'). test(isd)-> - EncPdu = [48,128,129,7,145,148,113,50,1,0,241,131,1,0,176,128,5,0,161,128,48,22,2,1,1,144,2,241,33,145,4,0,1,2,3,146,3,36,131,16,148,2,1,42,48,35,2,1,2,144,2,241,33,145,4,255,255,255,255,146,3,37,147,18,147,0,148,13,7,67,79,77,80,65,78,89,4,67,79,77,53,48,28,2,1,3,144,2,241,33,146,3,26,98,31,148,14,9,67,79,77,80,65,78,89,49,50,3,67,79,77,0,0,0,0,152,1,2,0,0], - - ?line {ok,_} = asn1_wrapper:decode('Mvrasn4', - 'InsertSubscriberDataArg', - EncPdu), + EncPdu = <<48,128,129,7,145,148,113,50,1,0,241,131,1,0,176,128,5,0, + 161,128,48,22,2,1,1,144,2,241,33,145,4,0,1,2,3,146,3,36, + 131,16,148,2,1,42,48,35,2,1,2,144,2,241,33,145,4,255,255, + 255,255,146,3,37,147,18,147,0,148,13,7,67,79,77,80,65,78, + 89,4,67,79,77,53,48,28,2,1,3,144,2,241,33,146,3,26,98,31, + 148,14,9,67,79,77,80,65,78,89,49,50,3,67,79,77,0,0,0,0, + 152,1,2,0,0>>, + {ok,_} = 'Mvrasn4':decode('InsertSubscriberDataArg', EncPdu), ok; % % Problems with indefinite length encoding !!! % test(isd2)-> - EncPdu = [48, 128, 128, 8, 98, 2, 50, 1, 0, 0, 0, 241, 176, 128, 161, 128, 48, 128, 2, 1, 1, 144, 2, 241, 33, 145, 4, 255, 23, 12, 1, 146, 3, 9, 17, 1, 147, 0, 148, 13, 7, 67, 79, 77, 80, 65, 78, 89, 4, 67, 79, 77, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - - ?line {ok,_DecPdu} = asn1_wrapper:decode('Mvrasn4', - 'InsertSubscriberDataArg', - EncPdu), - + EncPdu = <<48,128,128,8,98,2,50,1,0,0,0,241,176,128,161,128,48,128,2,1,1,144, + 2,241,33,145,4,255,23,12,1,146,3,9,17,1,147,0,148,13,7,67,79,77,80, + 65,78,89,4,67,79,77,53,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0>>, + {ok,_DecPdu} = 'Mvrasn4':decode('InsertSubscriberDataArg', EncPdu), ok; % % Is doing fine, although there is indefinite encoding used... !!! % test(dsd)-> - EncPdu = [48, 128, 128, 8, 98, 2, 50, 1, 0, 0, 0, 241, 170, 2, 5, 0, 0, 0, 0, 0], - - ?line {ok,_DecPdu} = asn1_wrapper:decode('Mvrasn4', - 'DeleteSubscriberDataArg', - EncPdu), - + EncPdu = <<48,128,128,8,98,2,50,1,0,0,0,241,170,2,5,0,0,0,0,0>>, + {ok,_DecPdu} = 'Mvrasn4':decode('DeleteSubscriberDataArg', EncPdu), ok; % % Is doing fine !!! % test(ul_res)-> - EncPdu = [48, 9, 4, 7, 145, 148, 113, 66, 16, 17, 241], - - ?line {ok,_DecPdu} = asn1_wrapper:decode('Mvrasn4', - 'UpdateGprsLocationRes', - EncPdu), - + EncPdu = <<48,9,4,7,145,148,113,66,16,17,241>>, + {ok,_DecPdu} = 'Mvrasn4':decode('UpdateGprsLocationRes', EncPdu), ok; test(seqofseq) -> - {ok,_V} = asn1_wrapper:decode('Mvrasn4', - 'SentParameters', - [48,129,190,161,128,4,16,176,197,182,68,41,243,188,205,123,13,9,145,206,200,144,102,4,4,176,197,182,68,4,8,41,243,188,205,123,13,9,145,0,0,161,128,4,16,39,0,3,117,35,189,130,21,42,104,49,194,212,24,151,234,4,4,39,0,3,117,4,8,35,189,130,21,42,104,49,194,0,0,161,128,4,16,62,207,166,59,71,29,37,97,120,25,132,80,144,251,161,123,4,4,62,207,166,59,4,8,71,29,37,97,120,25,132,80,0,0,161,128,4,16,95,183,173,151,17,76,148,146,248,102,127,215,102,224,39,60,4,4,95,183,173,151,4,8,17,76,148,146,248,102,127,215,0,0,161,128,4,16,41,198,247,157,117,190,203,170,91,146,88,91,223,220,188,16,4,4,41,198,247,157,4,8,117,190,203,170,91,146,88,91,0,0]), + EncPdu = <<48,129,190,161,128,4,16,176,197,182,68,41,243,188,205,123,13, + 9,145,206,200,144,102,4,4,176,197,182,68,4,8,41,243,188,205, + 123,13,9,145,0,0,161,128,4,16,39,0,3,117,35,189,130,21,42,104, + 49,194,212,24,151,234,4,4,39,0,3,117,4,8,35,189,130,21,42,104, + 49,194,0,0,161,128,4,16,62,207,166,59,71,29,37,97,120,25,132, + 80,144,251,161,123,4,4,62,207,166,59,4,8,71,29,37,97,120,25, + 132,80,0,0,161,128,4,16,95,183,173,151,17,76,148,146,248,102, + 127,215,102,224,39,60,4,4,95,183,173,151,4,8,17,76,148,146,248, + 102,127,215,0,0,161,128,4,16,41,198,247,157,117,190,203,170,91, + 146,88,91,223,220,188,16,4,4,41,198,247,157,4,8,117,190,203,170,91,146,88,91,0,0>>, + {ok,_V} = 'Mvrasn4':decode('SentParameters', EncPdu), ok; test('InsertSubscriberDataArg') -> - {ok,_V} = - asn1_wrapper:decode('Mvrasn4','InsertSubscriberDataArg', - [16#30,16#80,16#81,16#07,16#91,16#94, - 16#71,16#92,16#00,16#35,16#80,16#83, - 16#01,16#00,16#A6,16#06,16#04,16#01, - 16#21,16#04,16#01,16#22,16#B0,16#80, - 16#05,16#00,16#A1,16#80,16#30,16#1A, - 16#02,16#01,16#01,16#90,16#02,16#F1, - 16#21,16#92,16#03,16#0D,16#92,16#1F, - 16#94,16#0C,16#03,16#53,16#49,16#4D, - 16#03,16#47,16#53,16#4E,16#03,16#4C, - 16#4B,16#50,16#00,16#00,16#00,16#00, - 16#98,16#01,16#00,16#00,16#00]), + EncPdu = <<16#30,16#80,16#81,16#07,16#91,16#94, + 16#71,16#92,16#00,16#35,16#80,16#83, + 16#01,16#00,16#A6,16#06,16#04,16#01, + 16#21,16#04,16#01,16#22,16#B0,16#80, + 16#05,16#00,16#A1,16#80,16#30,16#1A, + 16#02,16#01,16#01,16#90,16#02,16#F1, + 16#21,16#92,16#03,16#0D,16#92,16#1F, + 16#94,16#0C,16#03,16#53,16#49,16#4D, + 16#03,16#47,16#53,16#4E,16#03,16#4C, + 16#4B,16#50,16#00,16#00,16#00,16#00, + 16#98,16#01,16#00,16#00,16#00>>, + {ok,_V} = 'Mvrasn4':decode('InsertSubscriberDataArg', EncPdu), ok. test(mvrasn6,'InsertSubscriberDataArg') -> Val = {'InsertSubscriberDataArg',"IMSI","Address","C",serviceGranted,["abc","cde"],["tele","serv","ice"],asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,{'NAEA-PreferredCI',"NCC",asn1_NOVALUE},{'GPRSSubscriptionData','NULL',[{'PDP-Context',49,"PT","PDP-Address","QoS",'NULL',"APN",asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE}],asn1_NOVALUE},'NULL',onlyMSC,{'LSAInformation','NULL',accessOutsideLSAsAllowed,[{'LSAData',"LSA","L",'NULL',asn1_NOVALUE},{'LSAData',"LSA","L",'NULL',asn1_NOVALUE}],asn1_NOVALUE},'NULL',{'LCSInformation',["Addr","ess","string"],[{'LCS-PrivacyClass',"S","ExtSS",notifyLocationAllowed,[{'ExternalClient',{'LCSClientExternalID',"Addr",asn1_NOVALUE},asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE}],[broadcastService,anonymousLocation,targetMSsubscribedService],asn1_NOVALUE}],asn1_NOVALUE},100,"age",{'MC-SS-Info',"S","ExtSS",5,4,asn1_NOVALUE},"C",{'SGSN-CAMEL-SubscriptionInfo',{'GPRS-CSI',[{'GPRS-CamelTDPData',attach,13,"Addr",continueTransaction,asn1_NOVALUE}],11,asn1_NOVALUE,'NULL','NULL'},{'SMS-CSI',[{'SMS-CAMEL-TDP-DataList','sms-CollectedInfo',13,"Addr",continueTransaction,asn1_NOVALUE}],11,asn1_NOVALUE,'NULL','NULL'},asn1_NOVALUE},"ON"}, - - {ok,Bytes}= - asn1_wrapper:encode('Mvrasn6','InsertSubscriberDataArg',Val), - - {ok,_Res} = - asn1_wrapper:decode('Mvrasn6','InsertSubscriberDataArg',Bytes), - + {ok,Bytes} = 'Mvrasn6':encode('InsertSubscriberDataArg', Val), + {ok,_} = 'Mvrasn6':decode('InsertSubscriberDataArg', Bytes), ok. diff --git a/lib/asn1/test/testNBAPsystem.erl b/lib/asn1/test/testNBAPsystem.erl index 794bf46daa..57cb483374 100644 --- a/lib/asn1/test/testNBAPsystem.erl +++ b/lib/asn1/test/testNBAPsystem.erl @@ -96,23 +96,16 @@ test(_Erule,Config) -> ticket_5812(Config) -> ?line Msg = v_5812(), - ?line {ok,B2} = asn1_wrapper:encode('NBAP-PDU-Discriptions', - 'NBAP-PDU', - Msg), + {ok,B2} = 'NBAP-PDU-Discriptions':encode('NBAP-PDU', Msg), V = <<0,28,74,0,3,48,0,0,1,0,123,64,41,0,0,0,126,64,35,95,208,2,89,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,145,0,1,205,0,0,0,0,2,98,64,1,128>>, ?line ok = compare(V,B2), - ?line {ok,Msg2} = asn1_wrapper:decode('NBAP-PDU-Discriptions', - 'NBAP-PDU',B2), + {ok,Msg2} = 'NBAP-PDU-Discriptions':decode('NBAP-PDU', B2), ?line ok = check_record_names(Msg2,Config). enc_audit_req_msg() -> Msg = {initiatingMessage, audit_req_msg()}, - ?line {ok,B}=asn1_wrapper:encode('NBAP-PDU-Discriptions', - 'NBAP-PDU', - Msg), - ?line {ok,_Msg}=asn1_wrapper:decode('NBAP-PDU-Discriptions', - 'NBAP-PDU', - B), + {ok,B} = 'NBAP-PDU-Discriptions':encode('NBAP-PDU', Msg), + {ok,_Msg} = 'NBAP-PDU-Discriptions':decode('NBAP-PDU', B), ?line {initiatingMessage, #'InitiatingMessage'{value=#'AuditRequest'{protocolIEs=[{_,114,ignore,_}], protocolExtensions = asn1_NOVALUE}}} = _Msg, @@ -121,12 +114,8 @@ enc_audit_req_msg() -> cell_setup_req_msg_test() -> Msg = {initiatingMessage, cell_setup_req_msg()}, - ?line {ok,B}=asn1_wrapper:encode('NBAP-PDU-Discriptions', - 'NBAP-PDU', - Msg), - ?line {ok,_Msg}=asn1_wrapper:decode('NBAP-PDU-Discriptions', - 'NBAP-PDU', - B), + {ok,B} = 'NBAP-PDU-Discriptions':encode('NBAP-PDU', Msg), + {ok,_Msg} = 'NBAP-PDU-Discriptions':decode('NBAP-PDU', B), io:format("Msg: ~P~n~n_Msg: ~P~n",[Msg,15,_Msg,15]), ok. diff --git a/lib/asn1/test/testOpenTypeImplicitTag.erl b/lib/asn1/test/testOpenTypeImplicitTag.erl index a37d8004ef..0fbf70d037 100644 --- a/lib/asn1/test/testOpenTypeImplicitTag.erl +++ b/lib/asn1/test/testOpenTypeImplicitTag.erl @@ -24,18 +24,9 @@ -include_lib("test_server/include/test_server.hrl"). main(_Rules) -> - - ?line {ok,Bytes1} = - asn1_wrapper:encode('OpenTypeImplicitTag','Seq', - {'Seq',[1,1,255],[1,1,255],12,[1,1,255]}), - ?line {ok,{'Seq',_,_,12,_}} = - asn1_wrapper:decode('OpenTypeImplicitTag','Seq', - lists:flatten(Bytes1)), - - ?line {ok,Bytes2} = - asn1_wrapper:encode('OpenTypeImplicitTag','Seq', - {'Seq',[1,1,255],asn1_NOVALUE,12,[1,1,255]}), - ?line {ok,{'Seq',_,asn1_NOVALUE,12,_}} = - asn1_wrapper:decode('OpenTypeImplicitTag','Seq', - lists:flatten(Bytes2)), + roundtrip('Seq', {'Seq',<<1,1,255>>,<<1,1,255>>,12,<<1,1,255>>}), + roundtrip('Seq', {'Seq',<<1,1,255>>,asn1_NOVALUE,12,<<1,1,255>>}), ok. + +roundtrip(T, V) -> + asn1_test_lib:roundtrip('OpenTypeImplicitTag', T, V). diff --git a/lib/asn1/test/testOpt.erl b/lib/asn1/test/testOpt.erl index d1a7b00459..a6dcccad15 100644 --- a/lib/asn1/test/testOpt.erl +++ b/lib/asn1/test/testOpt.erl @@ -38,81 +38,28 @@ bool33 = asn1_NOVALUE}). main(_Rules) -> - - ?line {ok,Bytes11} = asn1_wrapper:encode('Opt','Opt1',#'Opt1'{bool0 = true, - bool1 = true, - bool2 = true, - bool3 = true}), - ?line {ok,{'Opt1',true,true,true,true}} = - asn1_wrapper:decode('Opt','Opt1',lists:flatten(Bytes11)), + roundtrip('Opt1', #'Opt1'{bool0=true,bool1=true,bool2=true,bool3=true}), + roundtrip('Opt1', #'Opt1'{bool0=true,bool1=asn1_NOVALUE,bool2=asn1_NOVALUE, + bool3=asn1_NOVALUE}), + roundtrip('Opt1', #'Opt1'{bool0=true,bool1=asn1_NOVALUE,bool2=false,bool3=asn1_NOVALUE}), + roundtrip('Opt1', #'Opt1'{bool0=false,bool1=asn1_NOVALUE,bool2=asn1_NOVALUE,bool3=false}), - ?line {ok,Bytes12} = asn1_wrapper:encode('Opt','Opt1',#'Opt1'{bool0 = true}), - ?line {ok,{'Opt1',true,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE}} = - asn1_wrapper:decode('Opt','Opt1',lists:flatten(Bytes12)), - - ?line {ok,Bytes13} = asn1_wrapper:encode('Opt','Opt1',#'Opt1'{bool0 = true, - bool2 = false}), - ?line {ok,{'Opt1',true,asn1_NOVALUE,false,asn1_NOVALUE}} = - asn1_wrapper:decode('Opt','Opt1',lists:flatten(Bytes13)), - - ?line {ok,Bytes14} = asn1_wrapper:encode('Opt','Opt1',#'Opt1'{bool0 = false, - bool3 = false}), - ?line {ok,{'Opt1',false,asn1_NOVALUE,asn1_NOVALUE,false}} = - asn1_wrapper:decode('Opt','Opt1',lists:flatten(Bytes14)), - - - - - ?line {ok,Bytes21} = asn1_wrapper:encode('Opt','Opt2',#'Opt2'{bool10 = false, - bool11 = false, - bool12 = false, - bool13 = false}), - ?line {ok,{'Opt2',false,false,false,false}} = - asn1_wrapper:decode('Opt','Opt2',lists:flatten(Bytes21)), - - ?line {ok,Bytes22} = asn1_wrapper:encode('Opt','Opt2',#'Opt2'{bool10 = true, - bool13 = false}), - ?line {ok,{'Opt2',true,asn1_NOVALUE,asn1_NOVALUE,false}} = - asn1_wrapper:decode('Opt','Opt2',lists:flatten(Bytes22)), - - ?line {ok,Bytes23} = asn1_wrapper:encode('Opt','Opt2',#'Opt2'{bool10 = true, - bool11 = false, - bool13 = false}), - ?line {ok,{'Opt2',true,false,asn1_NOVALUE,false}} = - asn1_wrapper:decode('Opt','Opt2',lists:flatten(Bytes23)), - - ?line {ok,Bytes24} = asn1_wrapper:encode('Opt','Opt2',#'Opt2'{bool10 = false, - bool12 = false, - bool13 = false}), - ?line {ok,{'Opt2',false,asn1_NOVALUE,false,false}} = - asn1_wrapper:decode('Opt','Opt2',lists:flatten(Bytes24)), - - - - - ?line {ok,Bytes31} = asn1_wrapper:encode('Opt','Opt3',#'Opt3'{bool30 = false, - bool31 = false, - bool32 = false, - bool33 = false}), - ?line {ok,{'Opt3',false,false,false,false}} = - asn1_wrapper:decode('Opt','Opt3',lists:flatten(Bytes31)), - - ?line {ok,Bytes32} = asn1_wrapper:encode('Opt','Opt3',#'Opt3'{}), - ?line {ok,{'Opt3',asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE}} = - asn1_wrapper:decode('Opt','Opt3',lists:flatten(Bytes32)), - - ?line {ok,Bytes33} = asn1_wrapper:encode('Opt','Opt3',#'Opt3'{bool30 = true}), - ?line {ok,{'Opt3',true,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE}} = - asn1_wrapper:decode('Opt','Opt3',lists:flatten(Bytes33)), - - ?line {ok,Bytes34} = asn1_wrapper:encode('Opt','Opt3',#'Opt3'{bool32 = false}), - ?line {ok,{'Opt3',asn1_NOVALUE,asn1_NOVALUE,false,asn1_NOVALUE}} = - asn1_wrapper:decode('Opt','Opt3',lists:flatten(Bytes34)), - - ?line {ok,Bytes35} = asn1_wrapper:encode('Opt','Opt3',#'Opt3'{bool33 = false}), - ?line {ok,{'Opt3',asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE,false}} = - asn1_wrapper:decode('Opt','Opt3',lists:flatten(Bytes35)), - - - + roundtrip('Opt2', #'Opt2'{bool10=false,bool11=false,bool12=false,bool13=false}), + roundtrip('Opt2', #'Opt2'{bool10=true,bool11=asn1_NOVALUE,bool12=asn1_NOVALUE, + bool13=false}), + roundtrip('Opt2', #'Opt2'{bool10=true,bool11=false,bool12=asn1_NOVALUE,bool13=false}), + roundtrip('Opt2', #'Opt2'{bool10=false,bool11=asn1_NOVALUE,bool12=false,bool13=false}), + + roundtrip('Opt3', #'Opt3'{bool30=false,bool31=false,bool32=false,bool33=false}), + roundtrip('Opt3', #'Opt3'{bool30=asn1_NOVALUE,bool31=asn1_NOVALUE,bool32=asn1_NOVALUE, + bool33=asn1_NOVALUE}), + roundtrip('Opt3', #'Opt3'{bool30=true,bool31=asn1_NOVALUE,bool32=asn1_NOVALUE, + bool33=asn1_NOVALUE}), + roundtrip('Opt3', #'Opt3'{bool30=asn1_NOVALUE,bool31=asn1_NOVALUE,bool32=false, + bool33=asn1_NOVALUE}), + roundtrip('Opt3', #'Opt3'{bool30=asn1_NOVALUE,bool31=asn1_NOVALUE,bool32=asn1_NOVALUE, + bool33=false}), ok. + +roundtrip(Type, Value) -> + asn1_test_lib:roundtrip('Opt', Type, Value). diff --git a/lib/asn1/test/testParamBasic.erl b/lib/asn1/test/testParamBasic.erl index a10468d592..3a55408e94 100644 --- a/lib/asn1/test/testParamBasic.erl +++ b/lib/asn1/test/testParamBasic.erl @@ -29,53 +29,22 @@ -record('T22',{number, string}). main(Rules) -> - - ?line {ok,Bytes11} = - asn1_wrapper:encode('ParamBasic','T11', - #'T11'{number = 11, - string = "hello"}), - ?line {ok,{'T11',11,"hello"}} = - asn1_wrapper:decode('ParamBasic','T11',Bytes11), - - ?line {ok,Bytes12} = - asn1_wrapper:encode('ParamBasic','T12', - #'T12'{number = 11, - string = <<2#10101:5>>}), - {ok,{'T12',11,<<2#10101:5>>}} = - asn1_wrapper:decode('ParamBasic','T12',Bytes12), - - ?line {ok,Bytes13} = - asn1_wrapper:encode('ParamBasic','T21', - #'T21'{number = 11, - string = "hello"}), - ?line {ok,{'T21',11,"hello"}} = - asn1_wrapper:decode('ParamBasic','T21',Bytes13), - - ?line {ok,Bytes14} = - asn1_wrapper:encode('ParamBasic','T22', - #'T22'{number = 11, - string = <<2#10101:5>>}), - {ok,{'T22',11,<<2#10101:5>>}} = - asn1_wrapper:decode('ParamBasic','T22',Bytes14), - + roundtrip('T11', #'T11'{number=11,string="hello"}), + roundtrip('T12', #'T12'{number=11,string = <<21:5>>}), + roundtrip('T21', #'T21'{number=11,string="hello"}), + roundtrip('T22', #'T22'{number=11,string = <<21:5>>}), case Rules of der -> - - ?line {ok,[48,3,128,1,11]} = - asn1_wrapper:encode('ParamBasic','T11', - #'T11'{number = 11, - string = "hej"}), - ?line {ok,{'T11',11,"hej"}} = - asn1_wrapper:decode('ParamBasic','T11',[48,3,128,1,11]), - - ?line {ok,[48,3,128,1,11]} = - asn1_wrapper:encode('ParamBasic','T12', - #'T12'{number = 11, - string = [1,0,1,0]}), - - ?line {ok,{'T12',11,[1,0,1,0]}} = - asn1_wrapper:decode('ParamBasic','T12',[48,3,128,1,11]); + <<48,3,128,1,11>> = + roundtrip_enc('T11', #'T11'{number=11,string="hej"}), + <<48,3,128,1,11>> = + roundtrip_enc('T12', #'T12'{number=11,string=[1,0,1,0]}); _ -> ok end, - ok. + +roundtrip(Type, Value) -> + asn1_test_lib:roundtrip('ParamBasic', Type, Value). + +roundtrip_enc(Type, Value) -> + asn1_test_lib:roundtrip_enc('ParamBasic', Type, Value). diff --git a/lib/asn1/test/testParameterizedInfObj.erl b/lib/asn1/test/testParameterizedInfObj.erl index 47e5a02868..f3b4f9b170 100644 --- a/lib/asn1/test/testParameterizedInfObj.erl +++ b/lib/asn1/test/testParameterizedInfObj.erl @@ -41,49 +41,39 @@ param(Erule) -> iE_Extensions = [#'ProtocolExtensionField'{id=14, criticality=reject, - extensionValue=open_type(Erule,[0])}, + extensionValue= <<0>>}, #'ProtocolExtensionField'{id=2, criticality=ignore, - extensionValue=open_type(Erule,[1])}]}, + extensionValue= <<1>>}]}, BERVal = #'AllocationOrRetentionPriority' {priorityLevel = true, iE_Extensions = [#'ProtocolExtensionField'{id=14, criticality=reject, - extensionValue=[2,1,0]}, + extensionValue= <<2,1,0>>}, #'ProtocolExtensionField'{id=2, criticality=ignore, - extensionValue=[2,1,1]}]}, - ?line {ok,Bytes1} = - case asn1_wrapper:erule(Erule) of - per -> - asn1_wrapper:encode('Param','AllocationOrRetentionPriority', - PERVal); - _ -> - asn1_wrapper:encode('Param','AllocationOrRetentionPriority', - BERVal) - end, - - ?line {ok,{'AllocationOrRetentionPriority',true,[_R1,_R2]}} = - asn1_wrapper:decode('Param','AllocationOrRetentionPriority',Bytes1), + extensionValue= <<2,1,1>>}]}, + case Erule of + ber -> + roundtrip('AllocationOrRetentionPriority', BERVal); + per -> + roundtrip('AllocationOrRetentionPriority', PERVal); + uper -> + roundtrip('AllocationOrRetentionPriority', PERVal) + end, %% test code for OTP-4242, ValueFromObject - case asn1_wrapper:erule(Erule) of + case Erule of ber -> - ?line {ok,_Val3} = asn1_wrapper:decode('Param','OS1',[4,2,1,2]), - ?line {error,_Reason1} = - asn1_wrapper:decode('Param','OS1',[4,4,1,2,3,4]), - ?line {error,_Reason2} = - asn1_wrapper:decode('Param','OS2',[4,4,1,2,3,4]), - ?line {ok,_Val4} = asn1_wrapper:decode('Param','OS1',[4,2,1,2]); - per -> - ?line {ok,Bytes3} = - asn1_wrapper:encode('Param','OS1',[1,2]), - ?line {ok,[1,2]} = - asn1_wrapper:decode('Param','OS1',Bytes3), - ?line {error,_Reason3} = - asn1_wrapper:encode('Param','OS1',[1,2,3,4]) + {ok,_Val3} = 'Param':decode('OS1', [4,2,1,2]), + {error,_Reason1} = 'Param':decode('OS1',[4,4,1,2,3,4]), + {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]) end, roundtrip('Scl', {'Scl',42,{a,9738654}}), @@ -104,16 +94,11 @@ ranap(_Erule) -> value=#'Iu-ReleaseCommand'{protocolIEs=PIEVal2, protocolExtensions=asn1_NOVALUE}}, - ?line {ok,Bytes2} = asn1_wrapper:encode('RANAP','InitiatingMessage',Val2), - ?line {ok,_Ret2} = asn1_wrapper:decode('RANAP','InitiatingMessage',Bytes2), + {ok,Bytes2} = 'RANAP':encode('InitiatingMessage', Val2), + {ok,_Ret2} = 'RANAP':decode('InitiatingMessage', Bytes2), ok. -open_type(uper,Val) when is_list(Val) -> - list_to_binary(Val); -open_type(_,Val) -> - Val. - param2(Config, Erule) -> roundtrip2('HandoverRequired', {'HandoverRequired', @@ -146,7 +131,7 @@ param2(Config, Erule) -> {'ProtocolIE-Field',2,-42}, {'ProtocolIE-Field',100,Open100}, {'ProtocolIE-Field',101,Open101}]}} = - asn1_wrapper:decode('Param2', 'HandoverRequired', Enc), + 'Param2':decode('HandoverRequired', Enc), true = is_binary(Open100), true = is_binary(Open101), diff --git a/lib/asn1/test/testPrim.erl b/lib/asn1/test/testPrim.erl index 0be4f31f56..5e3890b175 100644 --- a/lib/asn1/test/testPrim.erl +++ b/lib/asn1/test/testPrim.erl @@ -128,13 +128,14 @@ null(_Rules) -> %%========================================================== %% Null ::= NULL %%========================================================== - - {ok,Bytes1} = asn1_wrapper:encode('Prim','Null',monday), - {ok,'NULL'} = asn1_wrapper:decode('Prim','Null',lists:flatten(Bytes1)), + roundtrip('Null', monday, 'NULL'), ok. roundtrip(T, V) -> - asn1_test_lib:roundtrip_enc('Prim', T, V). + asn1_test_lib:roundtrip_enc('Prim', T, V, V). + +roundtrip(Type, Value, ExpectedValue) -> + asn1_test_lib:roundtrip_enc('Prim', Type, Value, ExpectedValue). real(_Rules) -> %%========================================================== @@ -142,67 +143,38 @@ real(_Rules) -> %%========================================================== %% Base 2 - ?line {ok,Bytes1} = asn1_wrapper:encode('Real','AngleInRadians',{1,2,1}), - ?line {ok,{1,2,1}} = asn1_wrapper:decode('Real','AngleInRadians',Bytes1), - - ?line {ok,Bytes2} = asn1_wrapper:encode('Real','AngleInRadians',{129,2,1}), - ?line {ok,{129,2,1}} = asn1_wrapper:decode('Real','AngleInRadians',Bytes2), - - ?line {ok,Bytes3} = asn1_wrapper:encode('Real','AngleInRadians',{128,2,1}), - ?line {ok,{1,2,8}} = asn1_wrapper:decode('Real','AngleInRadians',Bytes3), - - ?line {ok,Bytes4} = asn1_wrapper:encode('Real','AngleInRadians',{128,2,-7}), - ?line {ok,{1,2,0}} = asn1_wrapper:decode('Real','AngleInRadians',Bytes4), - - ?line {ok,Bytes5} = asn1_wrapper:encode('Real','AngleInRadians',{16#f1f1f1,2,128}), - ?line {ok,{16#f1f1f1,2,128}} = asn1_wrapper:decode('Real','AngleInRadians',Bytes5), + real_roundtrip('AngleInRadians', {1,2,1}), + real_roundtrip('AngleInRadians', {129,2,1}), + real_roundtrip('AngleInRadians', {128,2,1}, {1,2,8}), + real_roundtrip('AngleInRadians', {128,2,-7}, {1,2,0}), + real_roundtrip('AngleInRadians', {16#f1f1f1,2,128}), %% Base 10, tuple format - ?line {ok,Bytes6} = asn1_wrapper:encode('Real','AngleInRadians',{1,10,1}), - ?line {ok,"1.E1"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes6), - - ?line {ok,Bytes7} = asn1_wrapper:encode('Real','AngleInRadians',{100,10,1}), - ?line {ok,"1.E3"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes7), - - ?line {ok,Bytes8} = asn1_wrapper:encode('Real','AngleInRadians',{-100,10,1}), - ?line {ok,"-1.E3"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes8), - - ?line {ok,Bytes9} = asn1_wrapper:encode('Real','AngleInRadians',{00002,10,1}), - ?line {ok,"2.E1"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes9), - - ?line {ok,Bytes10} = asn1_wrapper:encode('Real','AngleInRadians',{123000,10,0}), - ?line {ok,"123.E3"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes10), - - ?line {ok,Bytes11} = asn1_wrapper:encode('Real','AngleInRadians',{123456789,10,123456789}), - ?line {ok,"123456789.E123456789"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes11), - - ?line {ok,Bytes12} = asn1_wrapper:encode('Real','AngleInRadians',{-12345,10,-12345}), - ?line {ok,"-12345.E-12345"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes12), + real_roundtrip('AngleInRadians', {1,10,1}, "1.E1"), + real_roundtrip('AngleInRadians', {100,10,1}, "1.E3"), + real_roundtrip('AngleInRadians', {-100,10,1}, "-1.E3"), + real_roundtrip('AngleInRadians', {2,10,1}, "2.E1"), + real_roundtrip('AngleInRadians', {123000,10,0}, "123.E3"), + real_roundtrip('AngleInRadians', {123456789,10,123456789}, + "123456789.E123456789" ), + real_roundtrip('AngleInRadians', {-12345,10,-12345}, "-12345.E-12345"), %% Base 10, string format NR3 - - ?line {ok,Bytes13} = asn1_wrapper:encode('Real','AngleInRadians',"123.123E123"), - ?line {ok,"123123.E120"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes13), - ?line {ok,Bytes14} = asn1_wrapper:encode('Real','AngleInRadians',"0.0E0"), - ?line {ok,"0.E+0"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes14), + real_roundtrip('AngleInRadians', "123.123E123", "123123.E120"), + real_roundtrip('AngleInRadians', "0.0E0", "0.E+0"), + real_roundtrip('AngleInRadians', "0.0123", "123.E-4"), + real_roundtrip('AngleInRadians', "0", "0.E+0"), + real_roundtrip('AngleInRadians', "-123.45", "-12345.E-2"), + real_roundtrip('AngleInRadians', "123456789E123456789", + "123456789.E123456789"), + real_roundtrip('AngleInRadians', "01.000E1", "1.E1"), + real_roundtrip('AngleInRadians', "120.0001", "1200001.E-4"), - ?line {ok,Bytes15} = asn1_wrapper:encode('Real','AngleInRadians',"0.0123"), - ?line {ok,"123.E-4"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes15), - - ?line {ok,Bytes16} = asn1_wrapper:encode('Real','AngleInRadians',"0"), - ?line {ok,"0.E+0"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes16), - - ?line {ok,Bytes17} = asn1_wrapper:encode('Real','AngleInRadians',"-123.45"), - ?line {ok,"-12345.E-2"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes17), - - ?line {ok,Bytes18} = - asn1_wrapper:encode('Real','AngleInRadians',"123456789E123456789"), - ?line {ok,"123456789.E123456789"} = - asn1_wrapper:decode('Real','AngleInRadians',Bytes18), + ok. - ?line {ok,Bytes19} = asn1_wrapper:encode('Real','AngleInRadians',"01.000E1"), - ?line {ok,"1.E1"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes19), +real_roundtrip(T, V) -> + real_roundtrip(T, V, V). - ?line {ok,Bytes20} = asn1_wrapper:encode('Real','AngleInRadians',"120.0001"), - ?line {ok,"1200001.E-4"} = asn1_wrapper:decode('Real','AngleInRadians',Bytes20). +real_roundtrip(Type, Value, ExpectedValue) -> + asn1_test_lib:roundtrip('Real', Type, Value, ExpectedValue). diff --git a/lib/asn1/test/testPrimExternal.erl b/lib/asn1/test/testPrimExternal.erl index 65c3c3a31a..07a1de931f 100644 --- a/lib/asn1/test/testPrimExternal.erl +++ b/lib/asn1/test/testPrimExternal.erl @@ -24,84 +24,27 @@ -include_lib("test_server/include/test_server.hrl"). external(_Rules) -> - - - ?line {ok,Bytes10} = asn1_wrapper:encode('PrimExternal','NT',"kalle"), - ?line {ok,"kalle"} = asn1_wrapper:decode('PrimExternal','NT',lists:flatten(Bytes10)), - - ?line {ok,Bytes11} = asn1_wrapper:encode('PrimExternal','Imp',"kalle"), - ?line {ok,"kalle"} = asn1_wrapper:decode('PrimExternal','Imp',lists:flatten(Bytes11)), - - ?line {ok,Bytes12} = asn1_wrapper:encode('PrimExternal','Exp',"kalle"), - ?line {ok,"kalle"} = asn1_wrapper:decode('PrimExternal','Exp',lists:flatten(Bytes12)), - - - ?line {ok,Bytes13} = asn1_wrapper:encode('PrimExternal','NTNT',"kalle"), - ?line {ok,"kalle"} = asn1_wrapper:decode('PrimExternal','NTNT',lists:flatten(Bytes13)), - - ?line {ok,Bytes14} = asn1_wrapper:encode('PrimExternal','NTImp',"kalle"), - ?line {ok,"kalle"} = asn1_wrapper:decode('PrimExternal','NTImp',lists:flatten(Bytes14)), - - ?line {ok,Bytes15} = asn1_wrapper:encode('PrimExternal','NTExp',"kalle"), - ?line {ok,"kalle"} = asn1_wrapper:decode('PrimExternal','NTExp',lists:flatten(Bytes15)), - - - ?line {ok,Bytes16} = asn1_wrapper:encode('PrimExternal','ImpNT',"kalle"), - ?line {ok,"kalle"} = asn1_wrapper:decode('PrimExternal','ImpNT',lists:flatten(Bytes16)), - - ?line {ok,Bytes17} = asn1_wrapper:encode('PrimExternal','ImpImp',"kalle"), - ?line {ok,"kalle"} = asn1_wrapper:decode('PrimExternal','ImpImp',lists:flatten(Bytes17)), - - ?line {ok,Bytes18} = asn1_wrapper:encode('PrimExternal','ImpExp',"kalle"), - ?line {ok,"kalle"} = asn1_wrapper:decode('PrimExternal','ImpExp',lists:flatten(Bytes18)), - - - ?line {ok,Bytes19} = asn1_wrapper:encode('PrimExternal','ExpNT',"kalle"), - ?line {ok,"kalle"} = asn1_wrapper:decode('PrimExternal','ExpNT',lists:flatten(Bytes19)), - - ?line {ok,Bytes20} = asn1_wrapper:encode('PrimExternal','ExpImp',"kalle"), - ?line {ok,"kalle"} = asn1_wrapper:decode('PrimExternal','ExpImp',lists:flatten(Bytes20)), - - ?line {ok,Bytes21} = asn1_wrapper:encode('PrimExternal','ExpExp',"kalle"), - ?line {ok,"kalle"} = asn1_wrapper:decode('PrimExternal','ExpExp',lists:flatten(Bytes21)), - - - - - - ?line {ok,Bytes31} = asn1_wrapper:encode('PrimExternal','XNTNT',"kalle"), - ?line {ok,"kalle"} = asn1_wrapper:decode('PrimExternal','XNTNT',lists:flatten(Bytes31)), - - ?line {ok,Bytes32} = asn1_wrapper:encode('PrimExternal','XNTImp',"kalle"), - ?line {ok,"kalle"} = asn1_wrapper:decode('PrimExternal','XNTImp',lists:flatten(Bytes32)), - - ?line {ok,Bytes33} = asn1_wrapper:encode('PrimExternal','XNTExp',"kalle"), - ?line {ok,"kalle"} = asn1_wrapper:decode('PrimExternal','XNTExp',lists:flatten(Bytes33)), - - - ?line {ok,Bytes34} = asn1_wrapper:encode('PrimExternal','XImpNT',"kalle"), - ?line {ok,"kalle"} = asn1_wrapper:decode('PrimExternal','XImpNT',lists:flatten(Bytes34)), - - ?line {ok,Bytes35} = asn1_wrapper:encode('PrimExternal','XImpImp',"kalle"), - ?line {ok,"kalle"} = asn1_wrapper:decode('PrimExternal','XImpImp',lists:flatten(Bytes35)), - - ?line {ok,Bytes36} = asn1_wrapper:encode('PrimExternal','XImpExp',"kalle"), - ?line {ok,"kalle"} = asn1_wrapper:decode('PrimExternal','XImpExp',lists:flatten(Bytes36)), - - - ?line {ok,Bytes37} = asn1_wrapper:encode('PrimExternal','XExpNT',"kalle"), - ?line {ok,"kalle"} = asn1_wrapper:decode('PrimExternal','XExpNT',lists:flatten(Bytes37)), - - ?line {ok,Bytes38} = asn1_wrapper:encode('PrimExternal','XExpImp',"kalle"), - ?line {ok,"kalle"} = asn1_wrapper:decode('PrimExternal','XExpImp',lists:flatten(Bytes38)), - - ?line {ok,Bytes39} = asn1_wrapper:encode('PrimExternal','XExpExp',"kalle"), - ?line {ok,"kalle"} = asn1_wrapper:decode('PrimExternal','XExpExp',lists:flatten(Bytes39)), - - - - - - - -ok. + Types = ['NT', + 'Imp', + 'Exp', + 'NTNT', + 'NTImp', + 'NTExp', + 'ImpNT', + 'ImpImp', + 'ImpExp', + 'ExpNT', + 'ExpImp', + 'ExpExp', + 'XNTNT', + 'XNTImp', + 'XNTExp', + 'XImpNT', + 'XImpImp', + 'XImpExp', + 'XExpNT', + 'XExpImp', + 'XExpExp'], + _ = [asn1_test_lib:roundtrip('PrimExternal', T, "kalle") || + T <- Types], + ok. diff --git a/lib/asn1/test/testSelectionTypes.erl b/lib/asn1/test/testSelectionTypes.erl index 6d1641388f..6d060321da 100644 --- a/lib/asn1/test/testSelectionTypes.erl +++ b/lib/asn1/test/testSelectionTypes.erl @@ -18,19 +18,16 @@ %% %% -module(testSelectionTypes). - -export([test/0]). -include_lib("test_server/include/test_server.hrl"). test() -> Val = ["PrintableString","PrintableString","PrintableString"], - ?line {ok,Bin}=asn1_wrapper:encode('SelectionType','MendeleyevTable',Val), - ?line {ok,Val} = asn1_wrapper:decode('SelectionType','MendeleyevTable',Bin), - - ?line Val2 = ['SelectionType':einsteinium()], - ?line ["Es"] = Val2, - - ?line {ok,Bin2}=asn1_wrapper:encode('SelectionType','MendeleyevTable',Val2), - ?line {ok,Val2} = asn1_wrapper:decode('SelectionType','MendeleyevTable',Bin2). + ["Es"] = Val2 = ['SelectionType':einsteinium()], + roundtrip('MendeleyevTable', Val), + roundtrip('MendeleyevTable', Val2), + ok. +roundtrip(T, V) -> + asn1_test_lib:roundtrip('SelectionType', T, V). diff --git a/lib/asn1/test/testSeq2738.erl b/lib/asn1/test/testSeq2738.erl index cddfe4b311..9c059f2fc9 100644 --- a/lib/asn1/test/testSeq2738.erl +++ b/lib/asn1/test/testSeq2738.erl @@ -18,27 +18,16 @@ %% %% -module(testSeq2738). - -export([main/1]). -include_lib("test_server/include/test_server.hrl"). -%-record('SeqOpt',{int, opt = asn1_NOVALUE}). -record('SeqOptFake',{int, opt = asn1_NOVALUE}). -%-record('OptSeq',{int=17}). -record('OptSeqFake',{bool = false}). - - - main(_Rules) -> - - ?line {ok,Bytes} = - asn1_wrapper:encode('Seq2738','SeqOptFake', - #'SeqOptFake'{int = 10, - opt = #'OptSeqFake'{}}), - ?line {ok,#'SeqOptFake'{int=10,opt=#'OptSeqFake'{bool=false}}} = - asn1_wrapper:decode('Seq2738','SeqOptFake',lists:flatten(Bytes)), - ?line {error,_} = - asn1_wrapper:decode('Seq2738','SeqOpt',lists:flatten(Bytes)), + Enc = asn1_test_lib:roundtrip_enc('Seq2738', + 'SeqOptFake', + #'SeqOptFake'{int=10,opt=#'OptSeqFake'{}}), + {error,_} = 'Seq2738':decode('SeqOpt', Enc), ok. diff --git a/lib/asn1/test/testSeqDefault.erl b/lib/asn1/test/testSeqDefault.erl index a772b749bd..22c1b7ee3a 100644 --- a/lib/asn1/test/testSeqDefault.erl +++ b/lib/asn1/test/testSeqDefault.erl @@ -33,148 +33,64 @@ -record('SeqDef3',{bool3 = asn1_DEFAULT, seq3 = asn1_DEFAULT, int3 = asn1_DEFAULT}). -record('SeqDef3Imp',{bool3 = asn1_DEFAULT, seq3 = asn1_DEFAULT, int3 = asn1_DEFAULT}). -record('SeqDef3Exp',{bool3 = asn1_DEFAULT, seq3 = asn1_DEFAULT, int3 = asn1_DEFAULT}). --record('SeqIn',{boolIn, intIn}). +-record('SeqIn',{boolIn = asn1_NOVALUE, intIn = 12}). main(_Rules) -> - - ?line {ok,Bytes11} = - asn1_wrapper:encode('SeqDefault','SeqDef1',#'SeqDef1'{bool1 = true, - int1 = 15, - seq1 = #'SeqIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SeqDef1',true,15,{'SeqIn',true,66}}} = - asn1_wrapper:decode('SeqDefault','SeqDef1',lists:flatten(Bytes11)), - - - ?line {ok,Bytes12} = asn1_wrapper:encode('SeqDefault','SeqDef1',#'SeqDef1'{int1 = 15}), - ?line {ok,{'SeqDef1',true,15,{'SeqIn',asn1_NOVALUE,12}}} = - asn1_wrapper:decode('SeqDefault','SeqDef1',lists:flatten(Bytes12)), - - - ?line {ok,Bytes21} = - asn1_wrapper:encode('SeqDefault','SeqDef2',#'SeqDef2'{bool2 = true, - int2 = 15, - seq2 = #'SeqIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SeqDef2',{'SeqIn',true,66},true,15}} = - asn1_wrapper:decode('SeqDefault','SeqDef2',lists:flatten(Bytes21)), - - - ?line {ok,Bytes22} = asn1_wrapper:encode('SeqDefault','SeqDef2',#'SeqDef2'{int2 = 15}), - ?line {ok,{'SeqDef2',{'SeqIn',asn1_NOVALUE,12},true,15}} = - asn1_wrapper:decode('SeqDefault','SeqDef2',lists:flatten(Bytes22)), - - - - ?line {ok,Bytes31} = - asn1_wrapper:encode('SeqDefault','SeqDef3',#'SeqDef3'{bool3 = true, - int3 = 15, - seq3 = #'SeqIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SeqDef3',true,{'SeqIn',true,66},15}} = - asn1_wrapper:decode('SeqDefault','SeqDef3',lists:flatten(Bytes31)), - - - ?line {ok,Bytes32} = asn1_wrapper:encode('SeqDefault','SeqDef3',#'SeqDef3'{int3 = 15}), - ?line {ok,{'SeqDef3',true,{'SeqIn',asn1_NOVALUE,12},15}} = - asn1_wrapper:decode('SeqDefault','SeqDef3',lists:flatten(Bytes32)), - - - - - - ?line {ok,Bytes41} = - asn1_wrapper:encode('SeqDefault','SeqDef1Imp',#'SeqDef1Imp'{bool1 = true, - int1 = 15, - seq1 = #'SeqIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SeqDef1Imp',true,15,{'SeqIn',true,66}}} = - asn1_wrapper:decode('SeqDefault','SeqDef1Imp',lists:flatten(Bytes41)), - - - ?line {ok,Bytes42} = asn1_wrapper:encode('SeqDefault','SeqDef1Imp',#'SeqDef1Imp'{int1 = 15}), - ?line {ok,{'SeqDef1Imp',true,15,{'SeqIn',asn1_NOVALUE,12}}} = - asn1_wrapper:decode('SeqDefault','SeqDef1Imp',lists:flatten(Bytes42)), - - - ?line {ok,Bytes51} = - asn1_wrapper:encode('SeqDefault','SeqDef2Imp',#'SeqDef2Imp'{bool2 = true, - int2 = 15, - seq2 = #'SeqIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SeqDef2Imp',{'SeqIn',true,66},true,15}} = - asn1_wrapper:decode('SeqDefault','SeqDef2Imp',lists:flatten(Bytes51)), - - - ?line {ok,Bytes52} = asn1_wrapper:encode('SeqDefault','SeqDef2Imp',#'SeqDef2Imp'{int2 = 15}), - ?line {ok,{'SeqDef2Imp',{'SeqIn',asn1_NOVALUE,12},true,15}} = - asn1_wrapper:decode('SeqDefault','SeqDef2Imp',lists:flatten(Bytes52)), - - - - ?line {ok,Bytes61} = - asn1_wrapper:encode('SeqDefault','SeqDef3Imp',#'SeqDef3Imp'{bool3 = true, - int3 = 15, - seq3 = #'SeqIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SeqDef3Imp',true,{'SeqIn',true,66},15}} = - asn1_wrapper:decode('SeqDefault','SeqDef3Imp',lists:flatten(Bytes61)), - - - ?line {ok,Bytes62} = asn1_wrapper:encode('SeqDefault','SeqDef3Imp',#'SeqDef3Imp'{int3 = 15}), - ?line {ok,{'SeqDef3Imp',true,{'SeqIn',asn1_NOVALUE,12},15}} = - asn1_wrapper:decode('SeqDefault','SeqDef3Imp',lists:flatten(Bytes62)), - - - - - - - ?line {ok,Bytes71} = - asn1_wrapper:encode('SeqDefault','SeqDef1Exp',#'SeqDef1Exp'{bool1 = true, - int1 = 15, - seq1 = #'SeqIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SeqDef1Exp',true,15,{'SeqIn',true,66}}} = - asn1_wrapper:decode('SeqDefault','SeqDef1Exp',lists:flatten(Bytes71)), - - - ?line {ok,Bytes72} = asn1_wrapper:encode('SeqDefault','SeqDef1Exp',#'SeqDef1Exp'{int1 = 15}), - ?line {ok,{'SeqDef1Exp',true,15,{'SeqIn',asn1_NOVALUE,12}}} = - asn1_wrapper:decode('SeqDefault','SeqDef1Exp',lists:flatten(Bytes72)), - - - ?line {ok,Bytes81} = - asn1_wrapper:encode('SeqDefault','SeqDef2Exp',#'SeqDef2Exp'{bool2 = true, - int2 = 15, - seq2 = #'SeqIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SeqDef2Exp',{'SeqIn',true,66},true,15}} = - asn1_wrapper:decode('SeqDefault','SeqDef2Exp',lists:flatten(Bytes81)), - - - ?line {ok,Bytes82} = asn1_wrapper:encode('SeqDefault','SeqDef2Exp',#'SeqDef2Exp'{int2 = 15, - bool2 = true}), - ?line {ok,{'SeqDef2Exp',{'SeqIn',asn1_NOVALUE,12},true,15}} = - asn1_wrapper:decode('SeqDefault','SeqDef2Exp',lists:flatten(Bytes82)), - - - - ?line {ok,Bytes91} = - asn1_wrapper:encode('SeqDefault','SeqDef3Exp',#'SeqDef3Exp'{bool3 = true, - int3 = 15, - seq3 = #'SeqIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SeqDef3Exp',true,{'SeqIn',true,66},15}} = - asn1_wrapper:decode('SeqDefault','SeqDef3Exp',lists:flatten(Bytes91)), - - - ?line {ok,Bytes92} = asn1_wrapper:encode('SeqDefault','SeqDef3Exp',#'SeqDef3Exp'{int3 = 15}), - ?line {ok,{'SeqDef3Exp',true,{'SeqIn',asn1_NOVALUE,12},15}} = - asn1_wrapper:decode('SeqDefault','SeqDef3Exp',lists:flatten(Bytes92)), - - - - + roundtrip('SeqDef1', #'SeqDef1'{bool1=true,int1=15,seq1=#'SeqIn'{boolIn=true,intIn=66}}), + roundtrip('SeqDef1', + #'SeqDef1'{bool1=asn1_DEFAULT,int1=15,seq1=asn1_DEFAULT}, + #'SeqDef1'{bool1=true,int1=15,seq1=#'SeqIn'{}}), + + roundtrip('SeqDef2', #'SeqDef2'{seq2=#'SeqIn'{boolIn=true,intIn=66},bool2=true,int2=15}), + roundtrip('SeqDef2', + #'SeqDef2'{seq2=asn1_DEFAULT,bool2=asn1_DEFAULT,int2=15}, + #'SeqDef2'{seq2=#'SeqIn'{},bool2=true,int2=15}), + + roundtrip('SeqDef3', #'SeqDef3'{bool3=true,seq3=#'SeqIn'{boolIn=true,intIn=66},int3=15}), + roundtrip('SeqDef3', + #'SeqDef3'{bool3=asn1_DEFAULT,seq3=asn1_DEFAULT,int3=15}, + #'SeqDef3'{bool3=true,seq3=#'SeqIn'{},int3=15}), + + roundtrip('SeqDef1Imp', #'SeqDef1Imp'{bool1=true,int1=15, + seq1=#'SeqIn'{boolIn=true,intIn=66}}), + roundtrip('SeqDef1Imp', + #'SeqDef1Imp'{bool1=asn1_DEFAULT,int1=15,seq1=asn1_DEFAULT}, + #'SeqDef1Imp'{bool1=true,int1=15,seq1=#'SeqIn'{}}), + + roundtrip('SeqDef2Imp', #'SeqDef2Imp'{seq2=#'SeqIn'{boolIn=true,intIn=66}, + bool2=true,int2=15}), + roundtrip('SeqDef2Imp', + #'SeqDef2Imp'{seq2=asn1_DEFAULT,bool2=asn1_DEFAULT,int2=15}, + #'SeqDef2Imp'{seq2=#'SeqIn'{},bool2=true,int2=15}), + + roundtrip('SeqDef3Imp', + #'SeqDef3Imp'{bool3=true,seq3=#'SeqIn'{boolIn=true,intIn=66},int3=15}), + roundtrip('SeqDef3Imp', + #'SeqDef3Imp'{bool3=asn1_DEFAULT,seq3=asn1_DEFAULT,int3=15}, + #'SeqDef3Imp'{bool3=true,seq3=#'SeqIn'{},int3=15}), + + roundtrip('SeqDef1Exp', + #'SeqDef1Exp'{bool1=true,int1=15,seq1=#'SeqIn'{boolIn=true,intIn=66}}), + roundtrip('SeqDef1Exp', + #'SeqDef1Exp'{bool1=asn1_DEFAULT,int1=15,seq1=asn1_DEFAULT}, + #'SeqDef1Exp'{bool1=true,int1=15,seq1=#'SeqIn'{}}), + + roundtrip('SeqDef2Exp', #'SeqDef2Exp'{seq2=#'SeqIn'{boolIn=true,intIn=66}, + bool2=true,int2=15}), + roundtrip('SeqDef2Exp', + #'SeqDef2Exp'{seq2=asn1_DEFAULT,bool2=true,int2=15}, + #'SeqDef2Exp'{seq2=#'SeqIn'{},bool2=true,int2=15}), + + roundtrip('SeqDef3Exp', + #'SeqDef3Exp'{bool3=true,seq3=#'SeqIn'{boolIn=true,intIn=66},int3=15}), + roundtrip('SeqDef3Exp', + #'SeqDef3Exp'{bool3=asn1_DEFAULT,seq3=asn1_DEFAULT,int3=15}, + #'SeqDef3Exp'{bool3=true,seq3=#'SeqIn'{},int3=15}), ok. + +roundtrip(Type, Value) -> + roundtrip(Type, Value, Value). + +roundtrip(Type, Value, ExpectedValue) -> + asn1_test_lib:roundtrip('SeqDefault', Type, Value, ExpectedValue). diff --git a/lib/asn1/test/testSeqExternal.erl b/lib/asn1/test/testSeqExternal.erl index d6659dece6..a8e0902244 100644 --- a/lib/asn1/test/testSeqExternal.erl +++ b/lib/asn1/test/testSeqExternal.erl @@ -24,105 +24,34 @@ -include_lib("test_server/include/test_server.hrl"). - -record('SeqXSet1',{set, bool, int}). -record('SeqXSet2',{bool, set, int}). -record('SeqXSet3',{bool, int, set}). -%-record('NT',{os, bool}). -%-record('Imp',{os, bool}). -%-record('Exp',{os, bool}). main(_Rules) -> - - ?line {ok,Bytes11} = - asn1_wrapper:encode('SeqExternal','XNTNT',#'XSeqNT'{bool = true, os = "kalle"}), - ?line {ok,{'XSeqNT',[107,97,108,108,101],true}} = - asn1_wrapper:decode('SeqExternal','XNTNT',lists:flatten(Bytes11)), - - ?line {ok,Bytes12} = - asn1_wrapper:encode('SeqExternal','XImpNT',#'XSeqNT'{bool = true, os = "kalle"}), - ?line {ok,{'XSeqNT',[107,97,108,108,101],true}} = - asn1_wrapper:decode('SeqExternal','XImpNT',lists:flatten(Bytes12)), - - ?line {ok,Bytes13} = - asn1_wrapper:encode('SeqExternal','XExpNT',#'XSeqNT'{bool = true, os = "kalle"}), - ?line {ok,{'XSeqNT',[107,97,108,108,101],true}} = - asn1_wrapper:decode('SeqExternal','XExpNT',lists:flatten(Bytes13)), - - - - ?line {ok,Bytes21} = - asn1_wrapper:encode('SeqExternal','XNTImp',#'XSeqImp'{bool = true, os = "kalle"}), - ?line {ok,{'XSeqImp',[107,97,108,108,101],true}} = - asn1_wrapper:decode('SeqExternal','XNTImp',lists:flatten(Bytes21)), - - ?line {ok,Bytes22} = - asn1_wrapper:encode('SeqExternal','XImpImp',#'XSeqImp'{bool = true, os = "kalle"}), - ?line {ok,{'XSeqImp',[107,97,108,108,101],true}} = - asn1_wrapper:decode('SeqExternal','XImpImp',lists:flatten(Bytes22)), - - ?line {ok,Bytes23} = - asn1_wrapper:encode('SeqExternal','XExpImp',#'XSeqImp'{bool = true, os = "kalle"}), - ?line {ok,{'XSeqImp',[107,97,108,108,101],true}} = - asn1_wrapper:decode('SeqExternal','XExpImp',lists:flatten(Bytes23)), - - - - ?line {ok,Bytes31} = - asn1_wrapper:encode('SeqExternal','XNTExp',#'XSeqExp'{bool = true, os = "kalle"}), - ?line {ok,{'XSeqExp',[107,97,108,108,101],true}} = - asn1_wrapper:decode('SeqExternal','XNTExp',lists:flatten(Bytes31)), - - ?line {ok,Bytes32} = - asn1_wrapper:encode('SeqExternal','XImpExp',#'XSeqExp'{bool = true, os = "kalle"}), - ?line {ok,{'XSeqExp',[107,97,108,108,101],true}} = - asn1_wrapper:decode('SeqExternal','XImpExp',lists:flatten(Bytes32)), - - ?line {ok,Bytes33} = - asn1_wrapper:encode('SeqExternal','XExpExp',#'XSeqExp'{bool = true, os = "kalle"}), - ?line {ok,{'XSeqExp',[107,97,108,108,101],true}} = - asn1_wrapper:decode('SeqExternal','XExpExp',lists:flatten(Bytes33)), - - - - ?line {ok,Bytes41} = - asn1_wrapper:encode('SeqExternal','SeqXSet1', - #'SeqXSet1'{bool = true, - int = 66, - set = #'XSet1'{bool1 = true, - int1 = 77, - set1 = #'XSetIn'{boolIn = false, - intIn = 88}}}), - ?line {ok,{'SeqXSet1',{'XSet1',true,77,{'XSetIn',false,88}},true,66}} = - asn1_wrapper:decode('SeqExternal','SeqXSet1',lists:flatten(Bytes41)), - - - - ?line {ok,Bytes42} = - asn1_wrapper:encode('SeqExternal','SeqXSet2', - #'SeqXSet2'{bool = true, - int = 66, - set = #'XSet1'{bool1 = true, - int1 = 77, - set1 = #'XSetIn'{boolIn = false, - intIn = 88}}}), - ?line {ok,{'SeqXSet2',true,{'XSet1',true,77,{'XSetIn',false,88}},66}} = - asn1_wrapper:decode('SeqExternal','SeqXSet2',lists:flatten(Bytes42)), - - ?line {ok,Bytes43} = - asn1_wrapper:encode('SeqExternal','SeqXSet3', - #'SeqXSet3'{bool = true, - int = 66, - set = #'XSet1'{bool1 = true, - int1 = 77, - set1 = #'XSetIn'{boolIn = false, - intIn = 88}}}), - ?line {ok,{'SeqXSet3',true,66,{'XSet1',true,77,{'XSetIn',false,88}}}} = - asn1_wrapper:decode('SeqExternal','SeqXSet3',lists:flatten(Bytes43)), - - - - + roundtrip('XNTNT', #'XSeqNT'{os="kalle",bool=true}), + roundtrip('XImpNT', #'XSeqNT'{os="kalle",bool=true}), + roundtrip('XExpNT', #'XSeqNT'{os="kalle",bool=true}), + roundtrip('XNTImp', #'XSeqImp'{os="kalle",bool=true}), + roundtrip('XImpImp', #'XSeqImp'{os="kalle",bool=true}), + roundtrip('XExpImp', #'XSeqImp'{os="kalle",bool=true}), + roundtrip('XNTExp', #'XSeqExp'{os="kalle",bool=true}), + roundtrip('XImpExp', #'XSeqExp'{os="kalle",bool=true}), + roundtrip('XExpExp', #'XSeqExp'{os="kalle",bool=true}), + roundtrip('SeqXSet1', + #'SeqXSet1'{set=#'XSet1'{bool1=true,int1=77, + set1=#'XSetIn'{boolIn=false,intIn=88}}, + bool=true,int=66}), + roundtrip('SeqXSet2', + #'SeqXSet2'{bool=true, + set=#'XSet1'{bool1=true,int1=77, + set1=#'XSetIn'{boolIn=false,intIn=88}}, + int=66}), + roundtrip('SeqXSet3', + #'SeqXSet3'{bool=true,int=66, + set=#'XSet1'{bool1=true,int1=77, + set1=#'XSetIn'{boolIn=false,intIn=88}}}), ok. - +roundtrip(T, V) -> + asn1_test_lib:roundtrip('SeqExternal', T, V). diff --git a/lib/asn1/test/testSeqIndefinite.erl b/lib/asn1/test/testSeqIndefinite.erl index c7b8aba523..9a9150a9a8 100644 --- a/lib/asn1/test/testSeqIndefinite.erl +++ b/lib/asn1/test/testSeqIndefinite.erl @@ -27,21 +27,13 @@ main(per) -> ok; main(ber) -> %% normal encoding - B = [48,20,1,1,255,48,9,1,1,255,2,4,251,35,238,194,2,4,251,55,236,161], + B = <<48,20,1,1,255,48,9,1,1,255,2,4,251,35,238,194,2,4,251,55,236,161>>, %% indefinite length encoding - Bi = [48,22,1,1,255,48,128,1,1,255,2,4,251,35,238,194,0,0,2,4,251,55,236,161], + Bi = <<48,22,1,1,255,48,128,1,1,255,2,4,251,35,238,194,0,0,2,4,251,55,236,161>>, %% the value which is encoded V = {'SeqS3',true,{'SeqS3_seqS3',true,-81531198},-80221023}, - ?line {ok,V} = asn1_wrapper:decode('SeqSetIndefinite','SeqS3',B), - ?line {ok,V} = asn1_wrapper:decode('SeqSetIndefinite','SeqS3',Bi), - - %% normal encoding but with unknown extension component - _Be = [48,23,1,1,255,48,12,1,1,255,2,4,251,35,238,194,1,1,255,2,4,251,55,236,161], - %% indefinite length encoding but with unknown extension component - _Bei = [48,25,1,1,255,48,128,1,1,255,2,4,251,35,238,194,1,1,255,0,0,2,4,251,55,236,161], - - ?line {ok,V} = asn1_wrapper:decode('SeqSetIndefinite','SeqS3',B), - ?line {ok,V} = asn1_wrapper:decode('SeqSetIndefinite','SeqS3',Bi), + {ok,V} = 'SeqSetIndefinite':decode('SeqS3', B), + {ok,V} = 'SeqSetIndefinite':decode('SeqS3', Bi), ok. diff --git a/lib/asn1/test/testSeqOfCho.erl b/lib/asn1/test/testSeqOfCho.erl index 5b83c8bf21..f749845bb9 100644 --- a/lib/asn1/test/testSeqOfCho.erl +++ b/lib/asn1/test/testSeqOfCho.erl @@ -31,117 +31,45 @@ -record('SeqOfChoEmbOpt_SEQOF',{bool1, int1, seq1 = asn1_NOVALUE}). main(_Rules) -> - - ?line {ok,Bytes11} = - asn1_wrapper:encode('SeqOfCho','SeqChoDef',#'SeqChoDef'{bool1 = true, - int1 = 17}), - ?line {ok,{'SeqChoDef',true,17,[]}} = - asn1_wrapper:decode('SeqOfCho','SeqChoDef',lists:flatten(Bytes11)), - - - ?line {ok,Bytes12} = - asn1_wrapper:encode('SeqOfCho','SeqChoDef',#'SeqChoDef'{bool1 = true, - int1 = 17, - seq1 = [{boolIn,true}, - {intIn,25}]}), - ?line {ok,{'SeqChoDef',true,17,[{boolIn,true},{intIn,25}]}} = - asn1_wrapper:decode('SeqOfCho','SeqChoDef',lists:flatten(Bytes12)), - - - - ?line {ok,Bytes15} = - asn1_wrapper:encode('SeqOfCho','SeqChoOpt',#'SeqChoOpt'{bool1 = true, - int1 = 17}), - ?line {ok,{'SeqChoOpt',true,17,asn1_NOVALUE}} = - asn1_wrapper:decode('SeqOfCho','SeqChoOpt',lists:flatten(Bytes15)), - - - ?line {ok,Bytes16} = - asn1_wrapper:encode('SeqOfCho','SeqChoOpt',#'SeqChoOpt'{bool1 = true, - int1 = 17, - seq1 = [{boolIn,true}, - {intIn,25}]}), - ?line {ok,{'SeqChoOpt',true,17,[{boolIn,true},{intIn,25}]}} = - asn1_wrapper:decode('SeqOfCho','SeqChoOpt',lists:flatten(Bytes16)), - - - - - - ?line {ok,Bytes21} = - asn1_wrapper:encode('SeqOfCho','SeqChoEmbDef',#'SeqChoEmbDef'{bool1 = true, - int1 = 17}), - ?line {ok,{'SeqChoEmbDef',true,17,[]}} = - asn1_wrapper:decode('SeqOfCho','SeqChoEmbDef',lists:flatten(Bytes21)), - - - ?line {ok,Bytes22} = - asn1_wrapper:encode('SeqOfCho','SeqChoEmbDef',#'SeqChoEmbDef'{bool1 = true, - int1 = 17, - seq1 = [{boolIn,true}, - {intIn,25}]}), - ?line {ok,{'SeqChoEmbDef',true,17,[{boolIn,true},{intIn,25}]}} = - asn1_wrapper:decode('SeqOfCho','SeqChoEmbDef',lists:flatten(Bytes22)), - - - - ?line {ok,Bytes25} = - asn1_wrapper:encode('SeqOfCho','SeqChoEmbOpt',#'SeqChoEmbOpt'{bool1 = true, - int1 = 17}), - ?line {ok,{'SeqChoEmbOpt',true,17,asn1_NOVALUE}} = - asn1_wrapper:decode('SeqOfCho','SeqChoEmbOpt',lists:flatten(Bytes25)), - - - ?line {ok,Bytes26} = - asn1_wrapper:encode('SeqOfCho','SeqChoEmbOpt',#'SeqChoEmbOpt'{bool1 = true, - int1 = 17, - seq1 = [{boolIn,true}, - {intIn,25}]}), - ?line {ok,{'SeqChoEmbOpt',true,17,[{boolIn,true},{intIn,25}]}} = - asn1_wrapper:decode('SeqOfCho','SeqChoEmbOpt',lists:flatten(Bytes26)), - - - - - - - ?line {ok,Bytes31} = - asn1_wrapper:encode('SeqOfCho','SeqOfChoEmbDef',[#'SeqOfChoEmbDef_SEQOF'{bool1 = true, - int1 = 17}]), - ?line {ok,[{'SeqOfChoEmbDef_SEQOF',true,17,[]}]} = - asn1_wrapper:decode('SeqOfCho','SeqOfChoEmbDef',lists:flatten(Bytes31)), - - - ?line {ok,Bytes32} = - asn1_wrapper:encode('SeqOfCho','SeqOfChoEmbDef', - [#'SeqOfChoEmbDef_SEQOF'{bool1 = true, - int1 = 17, - seq1 = [{boolIn,true}, - {intIn,25}]}]), - ?line {ok,[{'SeqOfChoEmbDef_SEQOF',true,17,[{boolIn,true},{intIn,25}]}]} = - asn1_wrapper:decode('SeqOfCho','SeqOfChoEmbDef',lists:flatten(Bytes32)), - - - - ?line {ok,Bytes35} = - asn1_wrapper:encode('SeqOfCho','SeqOfChoEmbOpt',[#'SeqOfChoEmbOpt_SEQOF'{bool1 = true, - int1 = 17}]), - ?line {ok,[{'SeqOfChoEmbOpt_SEQOF',true,17,asn1_NOVALUE}]} = - asn1_wrapper:decode('SeqOfCho','SeqOfChoEmbOpt',lists:flatten(Bytes35)), - - - ?line {ok,Bytes36} = - asn1_wrapper:encode('SeqOfCho','SeqOfChoEmbOpt', - [#'SeqOfChoEmbOpt_SEQOF'{bool1 = true, - int1 = 17, - seq1 = [{boolIn,true}, - {intIn,25}]}]), - ?line {ok,[{'SeqOfChoEmbOpt_SEQOF',true,17,[{boolIn,true},{intIn,25}]}]} = - asn1_wrapper:decode('SeqOfCho','SeqOfChoEmbOpt',lists:flatten(Bytes36)), - - - - + roundtrip('SeqChoDef', + #'SeqChoDef'{bool1=true,int1=17,seq1=asn1_DEFAULT}, + #'SeqChoDef'{bool1=true,int1=17,seq1=[]}), + roundtrip('SeqChoDef', + #'SeqChoDef'{bool1=true,int1=17, + seq1=[{boolIn,true},{intIn,25}]}), + roundtrip('SeqChoOpt', + #'SeqChoOpt'{bool1=true,int1=17,seq1=asn1_NOVALUE}), + roundtrip('SeqChoOpt', + #'SeqChoOpt'{bool1=true,int1=17, + seq1=[{boolIn,true},{intIn,25}]}), + + roundtrip('SeqChoEmbDef', + #'SeqChoEmbDef'{bool1=true,int1=17,seq1=asn1_DEFAULT}, + #'SeqChoEmbDef'{bool1=true,int1=17,seq1=[]}), + roundtrip('SeqChoEmbDef', + #'SeqChoEmbDef'{bool1=true,int1=17, + seq1=[{boolIn,true},{intIn,25}]}), + roundtrip('SeqChoEmbOpt', + #'SeqChoEmbOpt'{bool1=true,int1=17,seq1=asn1_NOVALUE}), + roundtrip('SeqChoEmbOpt', + #'SeqChoEmbOpt'{bool1=true,int1=17, + seq1=[{boolIn,true},{intIn,25}]}), + + roundtrip('SeqOfChoEmbDef', + [#'SeqOfChoEmbDef_SEQOF'{bool1=true,int1=17,seq1=asn1_DEFAULT}], + [#'SeqOfChoEmbDef_SEQOF'{bool1=true,int1=17,seq1=[]}]), + roundtrip('SeqOfChoEmbDef', + [#'SeqOfChoEmbDef_SEQOF'{bool1=true,int1=17, + seq1=[{boolIn,true},{intIn,25}]}]), + roundtrip('SeqOfChoEmbOpt', + [#'SeqOfChoEmbOpt_SEQOF'{bool1=true,int1=17,seq1=asn1_NOVALUE}]), + roundtrip('SeqOfChoEmbOpt', + [#'SeqOfChoEmbOpt_SEQOF'{bool1=true,int1=17, + seq1=[{boolIn,true},{intIn,25}]}]), ok. +roundtrip(Type, Value) -> + roundtrip(Type, Value, Value). +roundtrip(Type, Value, ExpectedValue) -> + asn1_test_lib:roundtrip('SeqOfCho', Type, Value, ExpectedValue). diff --git a/lib/asn1/test/testSeqOfExternal.erl b/lib/asn1/test/testSeqOfExternal.erl index 0e4c6773c3..2e60f441c1 100644 --- a/lib/asn1/test/testSeqOfExternal.erl +++ b/lib/asn1/test/testSeqOfExternal.erl @@ -28,130 +28,52 @@ -record('Exp',{os, bool}). main(_Rules) -> - - ?line {ok,Bytes11} = - asn1_wrapper:encode('SeqOfExternal','NTNT',[#'NT'{bool = true, os = "kalle"}, - #'NT'{bool = true, os = "kalle"}]), - ?line {ok,[{'NT',[107,97,108,108,101],true},{'NT',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SeqOfExternal','NTNT',lists:flatten(Bytes11)), - - ?line {ok,Bytes12} = - asn1_wrapper:encode('SeqOfExternal','ImpNT',[#'NT'{bool = true, os = "kalle"}, - #'NT'{bool = true, os = "kalle"}]), - ?line {ok,[{'NT',[107,97,108,108,101],true},{'NT',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SeqOfExternal','ImpNT',lists:flatten(Bytes12)), - - ?line {ok,Bytes13} = - asn1_wrapper:encode('SeqOfExternal','ExpNT',[#'NT'{bool = true, os = "kalle"}, - #'NT'{bool = true, os = "kalle"}]), - ?line {ok,[{'NT',[107,97,108,108,101],true},{'NT',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SeqOfExternal','ExpNT',lists:flatten(Bytes13)), - - - - ?line {ok,Bytes21} = - asn1_wrapper:encode('SeqOfExternal','NTImp',[#'Imp'{bool = true, os = "kalle"}, - #'Imp'{bool = true, os = "kalle"}]), - ?line {ok,[{'Imp',[107,97,108,108,101],true},{'Imp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SeqOfExternal','NTImp',lists:flatten(Bytes21)), - - ?line {ok,Bytes22} = - asn1_wrapper:encode('SeqOfExternal','ImpImp',[#'Imp'{bool = true, os = "kalle"}, - #'Imp'{bool = true, os = "kalle"}]), - ?line {ok,[{'Imp',[107,97,108,108,101],true},{'Imp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SeqOfExternal','ImpImp',lists:flatten(Bytes22)), - - ?line {ok,Bytes23} = - asn1_wrapper:encode('SeqOfExternal','ExpImp',[#'Imp'{bool = true, os = "kalle"}, - #'Imp'{bool = true, os = "kalle"}]), - ?line {ok,[{'Imp',[107,97,108,108,101],true},{'Imp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SeqOfExternal','ExpImp',lists:flatten(Bytes23)), - - - - ?line {ok,Bytes31} = - asn1_wrapper:encode('SeqOfExternal','NTExp',[#'Exp'{bool = true, os = "kalle"}, - #'Exp'{bool = true, os = "kalle"}]), - ?line {ok,[{'Exp',[107,97,108,108,101],true},{'Exp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SeqOfExternal','NTExp',lists:flatten(Bytes31)), - - ?line {ok,Bytes32} = - asn1_wrapper:encode('SeqOfExternal','ImpExp',[#'Exp'{bool = true, os = "kalle"}, - #'Exp'{bool = true, os = "kalle"}]), - ?line {ok,[{'Exp',[107,97,108,108,101],true},{'Exp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SeqOfExternal','ImpExp',lists:flatten(Bytes32)), - - ?line {ok,Bytes33} = - asn1_wrapper:encode('SeqOfExternal','ExpExp',[#'Exp'{bool = true, os = "kalle"}, - #'Exp'{bool = true, os = "kalle"}]), - ?line {ok,[{'Exp',[107,97,108,108,101],true},{'Exp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SeqOfExternal','ExpExp',lists:flatten(Bytes33)), - - - - - - - - ?line {ok,Bytes41} = - asn1_wrapper:encode('SeqOfExternal','XNTNT',[#'XSeqNT'{bool = true, os = "kalle"}, - #'XSeqNT'{bool = true, os = "kalle"}]), - ?line {ok,[{'XSeqNT',[107,97,108,108,101],true},{'XSeqNT',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SeqOfExternal','XNTNT',lists:flatten(Bytes41)), - - ?line {ok,Bytes42} = - asn1_wrapper:encode('SeqOfExternal','XImpNT',[#'XSeqNT'{bool = true, os = "kalle"}, - #'XSeqNT'{bool = true, os = "kalle"}]), - ?line {ok,[{'XSeqNT',[107,97,108,108,101],true},{'XSeqNT',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SeqOfExternal','XImpNT',lists:flatten(Bytes42)), - - ?line {ok,Bytes43} = - asn1_wrapper:encode('SeqOfExternal','XExpNT',[#'XSeqNT'{bool = true, os = "kalle"}, - #'XSeqNT'{bool = true, os = "kalle"}]), - ?line {ok,[{'XSeqNT',[107,97,108,108,101],true},{'XSeqNT',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SeqOfExternal','XExpNT',lists:flatten(Bytes43)), - - - - ?line {ok,Bytes51} = - asn1_wrapper:encode('SeqOfExternal','XNTImp',[#'XSeqImp'{bool = true, os = "kalle"}, - #'XSeqImp'{bool = true, os = "kalle"}]), - ?line {ok,[{'XSeqImp',[107,97,108,108,101],true},{'XSeqImp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SeqOfExternal','XNTImp',lists:flatten(Bytes51)), - - ?line {ok,Bytes52} = - asn1_wrapper:encode('SeqOfExternal','XImpImp',[#'XSeqImp'{bool = true, os = "kalle"}, - #'XSeqImp'{bool = true, os = "kalle"}]), - ?line {ok,[{'XSeqImp',[107,97,108,108,101],true},{'XSeqImp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SeqOfExternal','XImpImp',lists:flatten(Bytes52)), - - ?line {ok,Bytes53} = - asn1_wrapper:encode('SeqOfExternal','XExpImp',[#'XSeqImp'{bool = true, os = "kalle"}, - #'XSeqImp'{bool = true, os = "kalle"}]), - ?line {ok,[{'XSeqImp',[107,97,108,108,101],true},{'XSeqImp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SeqOfExternal','XExpImp',lists:flatten(Bytes53)), - - - - ?line {ok,Bytes61} = - asn1_wrapper:encode('SeqOfExternal','XNTExp',[#'XSeqExp'{bool = true, os = "kalle"}, - #'XSeqExp'{bool = true, os = "kalle"}]), - ?line {ok,[{'XSeqExp',[107,97,108,108,101],true},{'XSeqExp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SeqOfExternal','XNTExp',lists:flatten(Bytes61)), - - ?line {ok,Bytes62} = - asn1_wrapper:encode('SeqOfExternal','XImpExp',[#'XSeqExp'{bool = true, os = "kalle"}, - #'XSeqExp'{bool = true, os = "kalle"}]), - ?line {ok,[{'XSeqExp',[107,97,108,108,101],true},{'XSeqExp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SeqOfExternal','XImpExp',lists:flatten(Bytes62)), - - ?line {ok,Bytes63} = - asn1_wrapper:encode('SeqOfExternal','XExpExp',[#'XSeqExp'{bool = true, os = "kalle"}, - #'XSeqExp'{bool = true, os = "kalle"}]), - ?line {ok,[{'XSeqExp',[107,97,108,108,101],true},{'XSeqExp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SeqOfExternal','XExpExp',lists:flatten(Bytes63)), - - - - + roundtrip('NTNT', + [#'NT'{os="kalle",bool=true},#'NT'{os="kalle",bool=true}]), + roundtrip('ImpNT', + [#'NT'{os="kalle",bool=true},#'NT'{os="kalle",bool=true}]), + roundtrip('ExpNT', + [#'NT'{os="kalle",bool=true},#'NT'{os="kalle",bool=true}]), + roundtrip('NTImp', + [#'Imp'{os="kalle",bool=true},#'Imp'{os="kalle",bool=true}]), + roundtrip('ImpImp', + [#'Imp'{os="kalle",bool=true},#'Imp'{os="kalle",bool=true}]), + roundtrip('ExpImp', + [#'Imp'{os="kalle",bool=true},#'Imp'{os="kalle",bool=true}]), + roundtrip('NTExp', + [#'Exp'{os="kalle",bool=true},#'Exp'{os="kalle",bool=true}]), + roundtrip('ImpExp', + [#'Exp'{os="kalle",bool=true},#'Exp'{os="kalle",bool=true}]), + roundtrip('ExpExp', + [#'Exp'{os="kalle",bool=true},#'Exp'{os="kalle",bool=true}]), + roundtrip('XNTNT', + [#'XSeqNT'{os="kalle",bool=true}, + #'XSeqNT'{os="kalle",bool=true}]), + roundtrip('XImpNT', + [#'XSeqNT'{os="kalle",bool=true}, + #'XSeqNT'{os="kalle",bool=true}]), + roundtrip('XExpNT', + [#'XSeqNT'{os="kalle",bool=true}, + #'XSeqNT'{os="kalle",bool=true}]), + roundtrip('XNTImp', + [#'XSeqImp'{os="kalle",bool=true}, + #'XSeqImp'{os="kalle",bool=true}]), + roundtrip('XImpImp', + [#'XSeqImp'{os="kalle",bool=true}, + #'XSeqImp'{os="kalle",bool=true}]), + roundtrip('XExpImp', + [#'XSeqImp'{os="kalle",bool=true}, + #'XSeqImp'{os="kalle",bool=true}]), + roundtrip('XNTExp', + [#'XSeqExp'{os="kalle",bool=true}, + #'XSeqExp'{os="kalle",bool=true}]), + roundtrip('XImpExp', + [#'XSeqExp'{os="kalle",bool=true}, + #'XSeqExp'{os="kalle",bool=true}]), + roundtrip('XExpExp', + [#'XSeqExp'{os="kalle",bool=true}, + #'XSeqExp'{os="kalle",bool=true}]), ok. + +roundtrip(T, V) -> + asn1_test_lib:roundtrip('SeqOfExternal', T, V). diff --git a/lib/asn1/test/testSeqOfIndefinite.erl b/lib/asn1/test/testSeqOfIndefinite.erl index 01ef36e0b4..b771405d84 100644 --- a/lib/asn1/test/testSeqOfIndefinite.erl +++ b/lib/asn1/test/testSeqOfIndefinite.erl @@ -33,60 +33,53 @@ main() -> ?line ok = test('InsertSubscriberDataArg'). % OTP-4232 test(isd)-> - EncPdu = [48,128,129,7,145,148,113,50,1,0,241,131,1,0,176,128,5,0,161,128,48,22,2,1,1,144,2,241,33,145,4,0,1,2,3,146,3,36,131,16,148,2,1,42,48,35,2,1,2,144,2,241,33,145,4,255,255,255,255,146,3,37,147,18,147,0,148,13,7,67,79,77,80,65,78,89,4,67,79,77,53,48,28,2,1,3,144,2,241,33,146,3,26,98,31,148,14,9,67,79,77,80,65,78,89,49,50,3,67,79,77,0,0,0,0,152,1,2,0,0], - - ?line {ok,_} = asn1_wrapper:decode('Mvrasn-11-4', - 'InsertSubscriberDataArg', - EncPdu), + EncPdu = <<48,128,129,7,145,148,113,50,1,0,241,131,1,0,176,128,5,0, + 161,128,48,22,2,1,1,144,2,241,33,145,4,0,1,2,3,146,3,36, + 131,16,148,2,1,42,48,35,2,1,2,144,2,241,33,145,4,255,255, + 255,255,146,3,37,147,18,147,0,148,13,7,67,79,77,80,65,78, + 89,4,67,79,77,53,48,28,2,1,3,144,2,241,33,146,3,26,98,31, + 148,14,9,67,79,77,80,65,78,89,49,50,3,67,79,77,0,0,0,0, + 152,1,2,0,0>>, + {ok,_} = 'Mvrasn-11-4':decode('InsertSubscriberDataArg', EncPdu), ok; % % Problems with indefinite length encoding !!! % test(isd2)-> - EncPdu = [48, 128, 128, 8, 98, 2, 50, 1, 0, 0, 0, 241, 176, 128, 161, 128, 48, 128, 2, 1, 1, 144, 2, 241, 33, 145, 4, 255, 23, 12, 1, 146, 3, 9, 17, 1, 147, 0, 148, 13, 7, 67, 79, 77, 80, 65, 78, 89, 4, 67, 79, 77, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - - ?line {ok,_DecPdu} = asn1_wrapper:decode('Mvrasn-11-4', - 'InsertSubscriberDataArg', - EncPdu), - + EncPdu = <<48,128,128,8,98,2,50,1,0,0,0,241,176,128,161,128,48,128,2,1,1,144, + 2,241,33,145,4,255,23,12,1,146,3,9,17,1,147,0,148,13,7,67,79,77,80, + 65,78,89,4,67,79,77,53,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0>>, + {ok,_DecPdu} = 'Mvrasn-11-4':decode('InsertSubscriberDataArg', EncPdu), ok; % % Is doing fine, although there is indefinite encoding used... !!! % test(dsd)-> - EncPdu = [48, 128, 128, 8, 98, 2, 50, 1, 0, 0, 0, 241, 170, 2, 5, 0, 0, 0, 0, 0], - - ?line {ok,_DecPdu} = asn1_wrapper:decode('Mvrasn-11-4', - 'DeleteSubscriberDataArg', - EncPdu), - + EncPdu = <<48,128,128,8,98,2,50,1,0,0,0,241,170,2,5,0,0,0,0,0>>, + {ok,_DecPdu} = 'Mvrasn-11-4':decode('DeleteSubscriberDataArg', EncPdu), ok; % % Is doing fine !!! % test(ul_res)-> - EncPdu = [48, 9, 4, 7, 145, 148, 113, 66, 16, 17, 241], - - ?line {ok,_DecPdu} = asn1_wrapper:decode('Mvrasn-11-4', - 'UpdateGprsLocationRes', - EncPdu), - + EncPdu = <<48,9,4,7,145,148,113,66,16,17,241>>, + {ok,_DecPdu} = 'Mvrasn-11-4':decode('UpdateGprsLocationRes', EncPdu), ok; test(prim) -> - ?line {ok,Bytes} = asn1_wrapper:encode('SeqOf','SeqOfInt',[10,20,30]), - ?line [Tag,_Len|Ints] = lists:flatten(Bytes), - ?line {ok,[10,20,30]} = - asn1_wrapper:decode('SeqOf','SeqOfInt',[Tag,128|Ints] ++ [0,0]), + Bytes = asn1_test_lib:roundtrip_enc('SeqOf', 'SeqOfInt', [10,20,30]), + <> = Bytes, + {ok,[10,20,30]} = + 'SeqOf':decode('SeqOfInt', <>), ok; test(seqofseq) -> - {ok,_V} = asn1_wrapper:decode('Mvrasn-DataTypes-1', - 'SentParameters', - [48, + {ok,_V} = 'Mvrasn-DataTypes-1':decode( + 'SentParameters', + [48, 129, 190, 161, @@ -281,17 +274,16 @@ test(seqofseq) -> 0]), ok; test('InsertSubscriberDataArg') -> - {ok,_V} = - asn1_wrapper:decode('Mvrasn-11-4','InsertSubscriberDataArg', - [16#30,16#80,16#81,16#07,16#91,16#94, - 16#71,16#92,16#00,16#35,16#80,16#83, - 16#01,16#00,16#A6,16#06,16#04,16#01, - 16#21,16#04,16#01,16#22,16#B0,16#80, - 16#05,16#00,16#A1,16#80,16#30,16#1A, - 16#02,16#01,16#01,16#90,16#02,16#F1, - 16#21,16#92,16#03,16#0D,16#92,16#1F, - 16#94,16#0C,16#03,16#53,16#49,16#4D, - 16#03,16#47,16#53,16#4E,16#03,16#4C, - 16#4B,16#50,16#00,16#00,16#00,16#00, - 16#98,16#01,16#00,16#00,16#00]), + EncPdu = <<16#30,16#80,16#81,16#07,16#91,16#94, + 16#71,16#92,16#00,16#35,16#80,16#83, + 16#01,16#00,16#A6,16#06,16#04,16#01, + 16#21,16#04,16#01,16#22,16#B0,16#80, + 16#05,16#00,16#A1,16#80,16#30,16#1A, + 16#02,16#01,16#01,16#90,16#02,16#F1, + 16#21,16#92,16#03,16#0D,16#92,16#1F, + 16#94,16#0C,16#03,16#53,16#49,16#4D, + 16#03,16#47,16#53,16#4E,16#03,16#4C, + 16#4B,16#50,16#00,16#00,16#00,16#00, + 16#98,16#01,16#00,16#00,16#00>>, + {ok,_V} = 'Mvrasn-11-4':decode('InsertSubscriberDataArg', EncPdu), ok. diff --git a/lib/asn1/test/testSeqOfTag.erl b/lib/asn1/test/testSeqOfTag.erl index 2359df0c59..38c1dcb90f 100644 --- a/lib/asn1/test/testSeqOfTag.erl +++ b/lib/asn1/test/testSeqOfTag.erl @@ -44,145 +44,48 @@ -record('Exp',{os, bool}). main(_Rules) -> - - ?line {ok,Bytes11} = - asn1_wrapper:encode('SeqOfTag','SeqTagNt', - #'SeqTagNt'{nt = [#'NT'{bool = true, os = "kalle"}, - #'NT'{bool = true, os = "kalle"}]}), - ?line {ok,{'SeqTagNt', - [{'NT',[107,97,108,108,101],true},{'NT',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SeqOfTag','SeqTagNt',lists:flatten(Bytes11)), - - ?line {ok,Bytes12} = - asn1_wrapper:encode('SeqOfTag','SeqTagNtI', - #'SeqTagNtI'{imp = [#'Imp'{bool = true, os = "kalle"}, - #'Imp'{bool = true, os = "kalle"}]}), - ?line {ok,{'SeqTagNtI', - [{'Imp',[107,97,108,108,101],true},{'Imp',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SeqOfTag','SeqTagNtI',lists:flatten(Bytes12)), - - ?line {ok,Bytes13} = - asn1_wrapper:encode('SeqOfTag','SeqTagNtE', - #'SeqTagNtE'{exp = [#'Exp'{bool = true, os = "kalle"}, - #'Exp'{bool = true, os = "kalle"}]}), - ?line {ok,{'SeqTagNtE', - [{'Exp',[107,97,108,108,101],true},{'Exp',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SeqOfTag','SeqTagNtE',lists:flatten(Bytes13)), - - - - ?line {ok,Bytes21} = - asn1_wrapper:encode('SeqOfTag','SeqTagI', - #'SeqTagI'{nt = [#'NT'{bool = true, os = "kalle"}, - #'NT'{bool = true, os = "kalle"}]}), - ?line {ok,{'SeqTagI', - [{'NT',[107,97,108,108,101],true},{'NT',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SeqOfTag','SeqTagI',lists:flatten(Bytes21)), - - ?line {ok,Bytes22} = - asn1_wrapper:encode('SeqOfTag','SeqTagII', - #'SeqTagII'{imp = [#'Imp'{bool = true, os = "kalle"}, - #'Imp'{bool = true, os = "kalle"}]}), - ?line {ok,{'SeqTagII', - [{'Imp',[107,97,108,108,101],true},{'Imp',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SeqOfTag','SeqTagII',lists:flatten(Bytes22)), - - ?line {ok,Bytes23} = - asn1_wrapper:encode('SeqOfTag','SeqTagIE', - #'SeqTagIE'{exp = [#'Exp'{bool = true, os = "kalle"}, - #'Exp'{bool = true, os = "kalle"}]}), - ?line {ok,{'SeqTagIE', - [{'Exp',[107,97,108,108,101],true},{'Exp',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SeqOfTag','SeqTagIE',lists:flatten(Bytes23)), - - - - ?line {ok,Bytes31} = - asn1_wrapper:encode('SeqOfTag','SeqTagE', - #'SeqTagE'{nt = [#'NT'{bool = true, os = "kalle"}, - #'NT'{bool = true, os = "kalle"}]}), - ?line {ok,{'SeqTagE', - [{'NT',[107,97,108,108,101],true},{'NT',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SeqOfTag','SeqTagE',lists:flatten(Bytes31)), - - ?line {ok,Bytes32} = - asn1_wrapper:encode('SeqOfTag','SeqTagEI', - #'SeqTagEI'{imp = [#'Imp'{bool = true, os = "kalle"}, - #'Imp'{bool = true, os = "kalle"}]}), - ?line {ok,{'SeqTagEI', - [{'Imp',[107,97,108,108,101],true},{'Imp',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SeqOfTag','SeqTagEI',lists:flatten(Bytes32)), - - ?line {ok,Bytes33} = - asn1_wrapper:encode('SeqOfTag','SeqTagEE', - #'SeqTagEE'{exp = [#'Exp'{bool = true, os = "kalle"}, - #'Exp'{bool = true, os = "kalle"}]}), - ?line {ok,{'SeqTagEE', - [{'Exp',[107,97,108,108,101],true},{'Exp',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SeqOfTag','SeqTagEE',lists:flatten(Bytes33)), - - - - + roundtrip('SeqTagNt', #'SeqTagNt'{nt=[#'NT'{os="kalle",bool=true}, + #'NT'{os="kalle",bool=true}]}), + roundtrip('SeqTagNtI', #'SeqTagNtI'{imp=[#'Imp'{os="kalle",bool=true}, + #'Imp'{os="kalle",bool=true}]}), + roundtrip('SeqTagNtE', #'SeqTagNtE'{exp=[#'Exp'{os="kalle",bool=true}, + #'Exp'{os="kalle",bool=true}]}), + roundtrip('SeqTagI', #'SeqTagI'{nt=[#'NT'{os="kalle",bool=true}, + #'NT'{os="kalle",bool=true}]}), + roundtrip('SeqTagII', #'SeqTagII'{imp=[#'Imp'{os="kalle",bool=true}, + #'Imp'{os="kalle",bool=true}]}), + roundtrip('SeqTagIE', #'SeqTagIE'{exp=[#'Exp'{os="kalle",bool=true}, + #'Exp'{os="kalle",bool=true}]}), + roundtrip('SeqTagE', #'SeqTagE'{nt=[#'NT'{os="kalle",bool=true}, + #'NT'{os="kalle",bool=true}]}), + roundtrip('SeqTagEI', #'SeqTagEI'{imp=[#'Imp'{os="kalle",bool=true}, + #'Imp'{os="kalle",bool=true}]}), + roundtrip('SeqTagEE', #'SeqTagEE'{exp=[#'Exp'{os="kalle",bool=true}, + #'Exp'{os="kalle",bool=true}]}), + roundtrip('SeqTagXNt', + #'SeqTagXNt'{xnt=[#'XSeqNT'{os="kalle",bool=true}, + #'XSeqNT'{os="kalle",bool=true}]}), + roundtrip('SeqTagXI', + #'SeqTagXI'{ximp=[#'XSeqImp'{os="kalle",bool=true}, + #'XSeqImp'{os="kalle",bool=true}]}), + roundtrip('SeqTagXE', + #'SeqTagXE'{xexp=[#'XSeqExp'{os="kalle",bool=true}, + #'XSeqExp'{os="kalle",bool=true}]}), + roundtrip('SeqTagImpX', + #'SeqTagImpX'{xnt=[#'XSeqNT'{os="kalle",bool=true}, + #'XSeqNT'{os="kalle",bool=true}], + ximp=[#'XSeqImp'{os="kalle",bool=true}, + #'XSeqImp'{os="kalle",bool=true}], + xexp=[#'XSeqExp'{os="kalle",bool=true}, + #'XSeqExp'{os="kalle",bool=true}]}), + roundtrip('SeqTagExpX', + #'SeqTagExpX'{xnt=[#'XSeqNT'{os="kalle",bool=true}, + #'XSeqNT'{os="kalle",bool=true}], + ximp=[#'XSeqImp'{os="kalle",bool=true}, + #'XSeqImp'{os="kalle",bool=true}], + xexp=[#'XSeqExp'{os="kalle",bool=true}, + #'XSeqExp'{os="kalle",bool=true}]}), + ok. - - - ?line {ok,Bytes41} = - asn1_wrapper:encode('SeqOfTag','SeqTagXNt', - #'SeqTagXNt'{xnt = [#'XSeqNT'{bool = true, os = "kalle"}, - #'XSeqNT'{bool = true, os = "kalle"}]}), - ?line {ok,{'SeqTagXNt', - [{'XSeqNT',[107,97,108,108,101],true},{'XSeqNT',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SeqOfTag','SeqTagXNt',lists:flatten(Bytes41)), - - ?line {ok,Bytes42} = - asn1_wrapper:encode('SeqOfTag','SeqTagXI', - #'SeqTagXI'{ximp = [#'XSeqImp'{bool = true, os = "kalle"}, - #'XSeqImp'{bool = true, os = "kalle"}]}), - ?line {ok,{'SeqTagXI', - [{'XSeqImp',[107,97,108,108,101],true},{'XSeqImp',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SeqOfTag','SeqTagXI',lists:flatten(Bytes42)), - - ?line {ok,Bytes43} = - asn1_wrapper:encode('SeqOfTag','SeqTagXE', - #'SeqTagXE'{xexp = [#'XSeqExp'{bool = true, os = "kalle"}, - #'XSeqExp'{bool = true, os = "kalle"}]}), - ?line {ok,{'SeqTagXE', - [{'XSeqExp',[107,97,108,108,101],true},{'XSeqExp',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SeqOfTag','SeqTagXE',lists:flatten(Bytes43)), - - - - - - ?line {ok,Bytes51} = - asn1_wrapper:encode('SeqOfTag','SeqTagImpX', - #'SeqTagImpX'{xnt = [#'XSeqNT'{bool = true, os = "kalle"}, - #'XSeqNT'{bool = true, os = "kalle"}], - ximp = [#'XSeqImp'{bool = true, os = "kalle"}, - #'XSeqImp'{bool = true, os = "kalle"}], - xexp = [#'XSeqExp'{bool = true, os = "kalle"}, - #'XSeqExp'{bool = true, os = "kalle"}]}), - ?line {ok,{'SeqTagImpX', - [{'XSeqNT',[107,97,108,108,101],true},{'XSeqNT',[107,97,108,108,101],true}], - [{'XSeqImp',[107,97,108,108,101],true},{'XSeqImp',[107,97,108,108,101],true}], - [{'XSeqExp',[107,97,108,108,101],true},{'XSeqExp',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SeqOfTag','SeqTagImpX',lists:flatten(Bytes51)), - - - - ?line {ok,Bytes52} = - asn1_wrapper:encode('SeqOfTag','SeqTagExpX', - #'SeqTagExpX'{xnt = [#'XSeqNT'{bool = true, os = "kalle"}, - #'XSeqNT'{bool = true, os = "kalle"}], - ximp = [#'XSeqImp'{bool = true, os = "kalle"}, - #'XSeqImp'{bool = true, os = "kalle"}], - xexp = [#'XSeqExp'{bool = true, os = "kalle"}, - #'XSeqExp'{bool = true, os = "kalle"}]}), - ?line {ok,{'SeqTagExpX', - [{'XSeqNT',[107,97,108,108,101],true},{'XSeqNT',[107,97,108,108,101],true}], - [{'XSeqImp',[107,97,108,108,101],true},{'XSeqImp',[107,97,108,108,101],true}], - [{'XSeqExp',[107,97,108,108,101],true},{'XSeqExp',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SeqOfTag','SeqTagExpX',lists:flatten(Bytes52)), - -ok. +roundtrip(T, V) -> + asn1_test_lib:roundtrip('SeqOfTag', T, V). diff --git a/lib/asn1/test/testSeqOptional.erl b/lib/asn1/test/testSeqOptional.erl index 8013f3c685..c9478105a4 100644 --- a/lib/asn1/test/testSeqOptional.erl +++ b/lib/asn1/test/testSeqOptional.erl @@ -37,159 +37,48 @@ -record('SeqChoOpt',{int, cho = asn1_NOVALUE}). main(_Rules) -> - - ?line {ok,Bytes11} = - asn1_wrapper:encode('SeqOptional','SeqOpt1',#'SeqOpt1'{bool1 = true, - int1 = 15, - seq1 = #'SeqIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SeqOpt1',true,15,{'SeqIn',true,66}}} = - asn1_wrapper:decode('SeqOptional','SeqOpt1',lists:flatten(Bytes11)), - - - ?line {ok,Bytes12} = asn1_wrapper:encode('SeqOptional','SeqOpt1',#'SeqOpt1'{int1 = 15}), - ?line {ok,{'SeqOpt1',asn1_NOVALUE,15,asn1_NOVALUE}} = - asn1_wrapper:decode('SeqOptional','SeqOpt1',lists:flatten(Bytes12)), - - - ?line {ok,Bytes21} = - asn1_wrapper:encode('SeqOptional','SeqOpt2',#'SeqOpt2'{bool2 = true, - int2 = 15, - seq2 = #'SeqIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SeqOpt2',{'SeqIn',true,66},true,15}} = - asn1_wrapper:decode('SeqOptional','SeqOpt2',lists:flatten(Bytes21)), - - - ?line {ok,Bytes22} = asn1_wrapper:encode('SeqOptional','SeqOpt2',#'SeqOpt2'{int2 = 15, - bool2 = true}), - ?line {ok,{'SeqOpt2',asn1_NOVALUE,true,15}} = - asn1_wrapper:decode('SeqOptional','SeqOpt2',lists:flatten(Bytes22)), - - - - ?line {ok,Bytes31} = - asn1_wrapper:encode('SeqOptional','SeqOpt3',#'SeqOpt3'{bool3 = true, - int3 = 15, - seq3 = #'SeqIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SeqOpt3',true,{'SeqIn',true,66},15}} = - asn1_wrapper:decode('SeqOptional','SeqOpt3',lists:flatten(Bytes31)), - - - ?line {ok,Bytes32} = asn1_wrapper:encode('SeqOptional','SeqOpt3',#'SeqOpt3'{int3 = 15}), - ?line {ok,{'SeqOpt3',asn1_NOVALUE,asn1_NOVALUE,15}} = - asn1_wrapper:decode('SeqOptional','SeqOpt3',lists:flatten(Bytes32)), - - - - - - ?line {ok,Bytes41} = - asn1_wrapper:encode('SeqOptional','SeqOpt1Imp',#'SeqOpt1Imp'{bool1 = true, - int1 = 15, - seq1 = #'SeqIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SeqOpt1Imp',true,15,{'SeqIn',true,66}}} = - asn1_wrapper:decode('SeqOptional','SeqOpt1Imp',lists:flatten(Bytes41)), - - - ?line {ok,Bytes42} = asn1_wrapper:encode('SeqOptional','SeqOpt1Imp',#'SeqOpt1Imp'{int1 = 15}), - ?line {ok,{'SeqOpt1Imp',asn1_NOVALUE,15,asn1_NOVALUE}} = - asn1_wrapper:decode('SeqOptional','SeqOpt1Imp',lists:flatten(Bytes42)), - - - ?line {ok,Bytes51} = - asn1_wrapper:encode('SeqOptional','SeqOpt2Imp',#'SeqOpt2Imp'{bool2 = true, - int2 = 15, - seq2 = #'SeqIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SeqOpt2Imp',{'SeqIn',true,66},true,15}} = - asn1_wrapper:decode('SeqOptional','SeqOpt2Imp',lists:flatten(Bytes51)), - - - ?line {ok,Bytes52} = asn1_wrapper:encode('SeqOptional','SeqOpt2Imp',#'SeqOpt2Imp'{int2 = 15, - bool2 = true}), - ?line {ok,{'SeqOpt2Imp',asn1_NOVALUE,true,15}} = - asn1_wrapper:decode('SeqOptional','SeqOpt2Imp',lists:flatten(Bytes52)), - - - - ?line {ok,Bytes61} = - asn1_wrapper:encode('SeqOptional','SeqOpt3Imp',#'SeqOpt3Imp'{bool3 = true, - int3 = 15, - seq3 = #'SeqIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SeqOpt3Imp',true,{'SeqIn',true,66},15}} = - asn1_wrapper:decode('SeqOptional','SeqOpt3Imp',lists:flatten(Bytes61)), - - - ?line {ok,Bytes62} = asn1_wrapper:encode('SeqOptional','SeqOpt3Imp',#'SeqOpt3Imp'{int3 = 15}), - ?line {ok,{'SeqOpt3Imp',asn1_NOVALUE,asn1_NOVALUE,15}} = - asn1_wrapper:decode('SeqOptional','SeqOpt3Imp',lists:flatten(Bytes62)), - - - - - - - ?line {ok,Bytes71} = - asn1_wrapper:encode('SeqOptional','SeqOpt1Exp',#'SeqOpt1Exp'{bool1 = true, - int1 = 15, - seq1 = #'SeqIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SeqOpt1Exp',true,15,{'SeqIn',true,66}}} = - asn1_wrapper:decode('SeqOptional','SeqOpt1Exp',lists:flatten(Bytes71)), - - - ?line {ok,Bytes72} = asn1_wrapper:encode('SeqOptional','SeqOpt1Exp',#'SeqOpt1Exp'{int1 = 15}), - ?line {ok,{'SeqOpt1Exp',asn1_NOVALUE,15,asn1_NOVALUE}} = - asn1_wrapper:decode('SeqOptional','SeqOpt1Exp',lists:flatten(Bytes72)), - - - ?line {ok,Bytes81} = - asn1_wrapper:encode('SeqOptional','SeqOpt2Exp',#'SeqOpt2Exp'{bool2 = true, - int2 = 15, - seq2 = #'SeqIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SeqOpt2Exp',{'SeqIn',true,66},true,15}} = - asn1_wrapper:decode('SeqOptional','SeqOpt2Exp',lists:flatten(Bytes81)), - - - ?line {ok,Bytes82} = asn1_wrapper:encode('SeqOptional','SeqOpt2Exp',#'SeqOpt2Exp'{int2 = 15, - bool2 = true}), - ?line {ok,{'SeqOpt2Exp',asn1_NOVALUE,true,15}} = - asn1_wrapper:decode('SeqOptional','SeqOpt2Exp',lists:flatten(Bytes82)), - - - - ?line {ok,Bytes91} = - asn1_wrapper:encode('SeqOptional','SeqOpt3Exp',#'SeqOpt3Exp'{bool3 = true, - int3 = 15, - seq3 = #'SeqIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SeqOpt3Exp',true,{'SeqIn',true,66},15}} = - asn1_wrapper:decode('SeqOptional','SeqOpt3Exp',lists:flatten(Bytes91)), - - - ?line {ok,Bytes92} = asn1_wrapper:encode('SeqOptional','SeqOpt3Exp',#'SeqOpt3Exp'{int3 = 15}), - ?line {ok,{'SeqOpt3Exp',asn1_NOVALUE,asn1_NOVALUE,15}} = - asn1_wrapper:decode('SeqOptional','SeqOpt3Exp',lists:flatten(Bytes92)), - - - - ?line {ok,Bytes101} = - asn1_wrapper:encode('SeqOptional','SeqChoOpt',#'SeqChoOpt'{int = 15, - cho = {boolC,true}}), - ?line {ok,{'SeqChoOpt',15,{boolC,true}}} = - asn1_wrapper:decode('SeqOptional','SeqChoOpt',lists:flatten(Bytes101)), - - - ?line {ok,Bytes102} = asn1_wrapper:encode('SeqOptional','SeqChoOpt',#'SeqChoOpt'{int = 15}), - ?line {ok,{'SeqChoOpt',15,asn1_NOVALUE}} = - asn1_wrapper:decode('SeqOptional','SeqChoOpt',lists:flatten(Bytes102)), - - - - + roundtrip('SeqOpt1', #'SeqOpt1'{bool1=true,int1=15, + seq1=#'SeqIn'{boolIn=true,intIn=66}}), + roundtrip('SeqOpt1', #'SeqOpt1'{bool1=asn1_NOVALUE, + int1=15,seq1=asn1_NOVALUE}), + roundtrip('SeqOpt2', #'SeqOpt2'{seq2=#'SeqIn'{boolIn=true,intIn=66}, + bool2=true,int2=15}), + roundtrip('SeqOpt2', #'SeqOpt2'{seq2=asn1_NOVALUE,bool2=true,int2=15}), + roundtrip('SeqOpt3', #'SeqOpt3'{bool3=true, + seq3=#'SeqIn'{boolIn=true, + intIn=66},int3=15}), + roundtrip('SeqOpt3', #'SeqOpt3'{bool3=asn1_NOVALUE, + seq3=asn1_NOVALUE,int3=15}), + roundtrip('SeqOpt1Imp', #'SeqOpt1Imp'{bool1=true,int1=15, + seq1=#'SeqIn'{boolIn=true,intIn=66}}), + roundtrip('SeqOpt1Imp', #'SeqOpt1Imp'{bool1=asn1_NOVALUE, + int1=15,seq1=asn1_NOVALUE}), + roundtrip('SeqOpt2Imp', #'SeqOpt2Imp'{seq2=#'SeqIn'{boolIn=true,intIn=66}, + bool2=true,int2=15}), + roundtrip('SeqOpt2Imp', #'SeqOpt2Imp'{seq2=asn1_NOVALUE, + bool2=true,int2=15}), + roundtrip('SeqOpt3Imp', #'SeqOpt3Imp'{bool3=true, + seq3=#'SeqIn'{boolIn=true,intIn=66}, + int3=15}), + roundtrip('SeqOpt3Imp', #'SeqOpt3Imp'{bool3=asn1_NOVALUE, + seq3=asn1_NOVALUE,int3=15}), + roundtrip('SeqOpt1Exp', #'SeqOpt1Exp'{bool1=true,int1=15, + seq1=#'SeqIn'{boolIn=true, + intIn=66}}), + roundtrip('SeqOpt1Exp', #'SeqOpt1Exp'{bool1=asn1_NOVALUE, + int1=15,seq1=asn1_NOVALUE}), + roundtrip('SeqOpt2Exp', #'SeqOpt2Exp'{seq2=#'SeqIn'{boolIn=true,intIn=66}, + bool2=true,int2=15}), + roundtrip('SeqOpt2Exp', #'SeqOpt2Exp'{seq2=asn1_NOVALUE, + bool2=true,int2=15}), + roundtrip('SeqOpt3Exp', #'SeqOpt3Exp'{bool3=true, + seq3=#'SeqIn'{boolIn=true,intIn=66}, + int3=15}), + roundtrip('SeqOpt3Exp', #'SeqOpt3Exp'{bool3=asn1_NOVALUE, + seq3=asn1_NOVALUE,int3=15}), + roundtrip('SeqChoOpt', #'SeqChoOpt'{int=15,cho={boolC,true}}), + roundtrip('SeqChoOpt', #'SeqChoOpt'{int=15,cho=asn1_NOVALUE}), ok. + +roundtrip(Type, Value) -> + asn1_test_lib:roundtrip('SeqOptional', Type, Value). diff --git a/lib/asn1/test/testSeqPrim.erl b/lib/asn1/test/testSeqPrim.erl index c2451a7cd1..eb21d50a37 100644 --- a/lib/asn1/test/testSeqPrim.erl +++ b/lib/asn1/test/testSeqPrim.erl @@ -27,58 +27,15 @@ -record('Empty',{}). main(_Rules) -> - - - - ?line {ok,Bytes11} = - asn1_wrapper:encode('SeqPrim','Seq',#'Seq'{bool = true, - boolCon = true, - boolPri = true, - boolApp = true, - boolExpCon = true, - boolExpPri = true, - boolExpApp = true}), - ?line {ok,{'Seq',true,true,true,true,true,true,true}} = - asn1_wrapper:decode('SeqPrim','Seq',lists:flatten(Bytes11)), - - - - - ?line {ok,Bytes12} = - asn1_wrapper:encode('SeqPrim','Seq',#'Seq'{bool = false, - boolCon = false, - boolPri = false, - boolApp = false, - boolExpCon = false, - boolExpPri = false, - boolExpApp = false}), - ?line {ok,{'Seq',false,false,false,false,false,false,false}} = - asn1_wrapper:decode('SeqPrim','Seq',lists:flatten(Bytes12)), - - - - - ?line {ok,Bytes13} = - asn1_wrapper:encode('SeqPrim','Seq',#'Seq'{bool = false, - boolCon = true, - boolPri = false, - boolApp = true, - boolExpCon = false, - boolExpPri = true, - boolExpApp = false}), - ?line {ok,{'Seq',false,true,false,true,false,true,false}} = - asn1_wrapper:decode('SeqPrim','Seq',lists:flatten(Bytes13)), - - - - - - ?line {ok,Bytes21} = - asn1_wrapper:encode('SeqPrim','Empty',#'Empty'{}), - ?line {ok,{'Empty'}} = - asn1_wrapper:decode('SeqPrim','Empty',lists:flatten(Bytes21)), - - - + roundtrip('Seq', #'Seq'{bool=true,boolCon=true,boolPri=true,boolApp=true, + boolExpCon=true,boolExpPri=true,boolExpApp=true}), + roundtrip('Seq', #'Seq'{bool=false,boolCon=false,boolPri=false, + boolApp=false,boolExpCon=false, + boolExpPri=false,boolExpApp=false}), + roundtrip('Seq', #'Seq'{bool=false,boolCon=true,boolPri=false,boolApp=true, + boolExpCon=false,boolExpPri=true,boolExpApp=false}), + roundtrip('Empty', #'Empty'{}), ok. +roundtrip(Type, Value) -> + asn1_test_lib:roundtrip('SeqPrim', Type, Value). diff --git a/lib/asn1/test/testSeqSetDefaultVal.erl b/lib/asn1/test/testSeqSetDefaultVal.erl index bd6c9428e2..fb61bf1647 100644 --- a/lib/asn1/test/testSeqSetDefaultVal.erl +++ b/lib/asn1/test/testSeqSetDefaultVal.erl @@ -18,10 +18,9 @@ %% %% -module(testSeqSetDefaultVal). - --include("External.hrl"). -export([main/1]). +-include("External.hrl"). -include_lib("test_server/include/test_server.hrl"). -record('SeqInts',{a = asn1_DEFAULT, @@ -95,242 +94,217 @@ bb = asn1_DEFAULT}). main(_Rules) -> - - ?line {ok,[48,0]} = - asn1_wrapper:encode('Default','SeqInts',#'SeqInts'{}), - ?line {ok,[48,0]} = - asn1_wrapper:encode('Default','SeqInts',#'SeqInts'{a=1,b=-1,c=three, - d=1}), - ?line {ok,{'SeqInts',1,-1,3,1}} = - asn1_wrapper:decode('Default','SeqInts',[48,0]), - - ?line {ok,[49,0]} = - asn1_wrapper:encode('Default','SetInts',#'SetInts'{}), - ?line {ok,[49,0]} = - asn1_wrapper:encode('Default','SetInts',#'SetInts'{a=1,b=-1,c=three, - d=1}), - ?line {ok,{'SetInts',1,-1,3,1}} = - asn1_wrapper:decode('Default','SetInts',[49,0]), - - - ?line {ok,[48,0]} = - asn1_wrapper:encode('Default','SeqBS', - #'SeqBS'{a=2#1010110, - b=16#A8A, - c=[second], - d=[1,0,0,1]}), - - ?line {ok,[48,0]} = - asn1_wrapper:encode('Default','SeqBS', - #'SeqBS'{a=[1,0,1,0,1,1,0], - b=[1,0,1,0,1,0,0,0,1,0,1,0], - c={5,<<64>>}, - d=9}), - - ?line {ok,[48,3,131,1,0]} = - asn1_wrapper:encode('Default','SeqBS', - #'SeqBS'{a=[1,0,1,0,1,1,0], - b=[1,0,1,0,1,0,0,0,1,0,1,0], - c={5,<<64>>}, - d=0}), - - {ok,{'SeqBS',[1,0,1,0,1,1,0],2698,[second],<<>>}} = - asn1_wrapper:decode('Default','SeqBS',[48,3,131,1,0]), - - ?line {ok,{'SeqBS',[1,0,1,0,1,1,0],2698,[second],[1,0,0,1]}} = - asn1_wrapper:decode('Default','SeqBS',[48,0]), - - ?line {ok,[49,0]} = - asn1_wrapper:encode('Default','SetBS', - #'SetBS'{a=2#1010110, - b=16#A8A, - c=[second], - d=[1,0,0,1]}), - - ?line {ok,[49,0]} = - asn1_wrapper:encode('Default','SetBS', - #'SetBS'{a=[1,0,1,0,1,1,0], - b=[1,0,1,0,1,0,0,0,1,0,1,0], - c={5,<<64>>}, - d=9}), - - ?line {ok,[49,3,131,1,0]} = - asn1_wrapper:encode('Default','SetBS', - #'SetBS'{a=[1,0,1,0,1,1,0], - b=[1,0,1,0,1,0,0,0,1,0,1,0], - c={5,<<64>>}, - d=0}), - - {ok,{'SetBS',[1,0,1,0,1,1,0],2698,[second],<<>>}} = - asn1_wrapper:decode('Default','SetBS',[49,3,131,1,0]), - - ?line {ok,{'SetBS',[1,0,1,0,1,1,0],2698,[second],[1,0,0,1]}} = - asn1_wrapper:decode('Default','SetBS',[49,0]), - - ?line {ok,[48,0]} = - asn1_wrapper:encode('Default','SeqOS', - #'SeqOS'{a=[172], - b=[16#A8,16#A0], - c='NULL'}), - - ?line {ok,[48,0]} = - asn1_wrapper:encode('Default','SeqOS', - #'SeqOS'{a=2#10101100, - b=16#A8A0, - c='NULL'}), - - ?line {ok,{'SeqOS',[172],[16#A8,16#A0],'NULL'}} = - asn1_wrapper:decode('Default','SeqOS',[48,0]), - - ?line {ok,[49,0]} = - asn1_wrapper:encode('Default','SetOS', - #'SetOS'{a=[172], - b=[16#A8,16#A0], - c='NULL'}), - - ?line {ok,[49,0]} = - asn1_wrapper:encode('Default','SetOS', - #'SetOS'{a=2#10101100, - b=16#A8A0, - c='NULL'}), - - ?line {ok,{'SetOS',[172],[16#A8,16#A0],'NULL'}} = - asn1_wrapper:decode('Default','SetOS',[49,0]), + roundtrip(<<48,0>>, + 'SeqInts', + #'SeqInts'{a=asn1_DEFAULT,b=asn1_DEFAULT, + c=asn1_DEFAULT,d=asn1_DEFAULT}, + #'SeqInts'{a=1,b=-1,c=3,d=1}), + roundtrip(<<48,0>>, + 'SeqInts', + #'SeqInts'{a=1,b=-1,c=three,d=1}, + #'SeqInts'{a=1,b=-1,c=3,d=1}), + + roundtrip(<<49,0>>, + 'SetInts', + #'SetInts'{a=asn1_DEFAULT,b=asn1_DEFAULT, + c=asn1_DEFAULT,d=asn1_DEFAULT}, + #'SetInts'{a=1,b=-1,c=3,d=1}), + roundtrip(<<49,0>>, + 'SetInts', + #'SetInts'{a=1,b=-1,c=three,d=1}, + #'SetInts'{a=1,b=-1,c=3,d=1}), + + + roundtrip(<<48,0>>, + 'SeqBS', + #'SeqBS'{a=2#1010110,b=16#A8A,c=[second],d=[1,0,0,1]}, + #'SeqBS'{a=[1,0,1,0,1,1,0],b=16#A8A,c=[second],d=[1,0,0,1]}), + roundtrip(<<48,0>>, + 'SeqBS', + #'SeqBS'{a=[1,0,1,0,1,1,0], + b=[1,0,1,0,1,0,0,0,1,0,1,0], + c={5,<<64>>}, + d=2#1001}, + #'SeqBS'{a=[1,0,1,0,1,1,0],b=16#A8A,c=[second],d=[1,0,0,1]}), + roundtrip(<<48,3,131,1,0>>, + 'SeqBS', + #'SeqBS'{a=[1,0,1,0,1,1,0], + b=[1,0,1,0,1,0,0,0,1,0,1,0], + c={5,<<64>>}, + d=0}, + #'SeqBS'{a=[1,0,1,0,1,1,0], + b=16#A8A, + c=[second], + d = <<>>}), + + roundtrip(<<49,0>>, + 'SetBS', + #'SetBS'{a=2#1010110,b=16#A8A,c=[second],d=[1,0,0,1]}, + #'SetBS'{a=[1,0,1,0,1,1,0],b=16#A8A,c=[second],d=[1,0,0,1]}), + roundtrip(<<49,0>>, + 'SetBS', + #'SetBS'{a=[1,0,1,0,1,1,0], + b=[1,0,1,0,1,0,0,0,1,0,1,0], + c={5,<<64>>}, + d=9}, + #'SetBS'{a=[1,0,1,0,1,1,0], + b=16#A8A, + c=[second], + d=[1,0,0,1]}), + roundtrip(<<49,3,131,1,0>>, + 'SetBS', + #'SetBS'{a=[1,0,1,0,1,1,0], + b=[1,0,1,0,1,0,0,0,1,0,1,0], + c={5,<<64>>}, + d=0}, + #'SetBS'{a=[1,0,1,0,1,1,0], + b=16#A8A, + c=[second], + d = <<>>}), + + roundtrip(<<48,0>>, 'SeqOS', + #'SeqOS'{a=[172],b=[16#A8,16#A0],c='NULL'}), + roundtrip(<<48,0>>, + 'SeqOS', + #'SeqOS'{a=172,b=43168,c='NULL'}, + #'SeqOS'{a=[172],b=[16#A8,16#A0],c='NULL'}), + + roundtrip(<<49,0>>, 'SetOS', #'SetOS'{a=[172],b=[16#A8,16#A0],c='NULL'}), + roundtrip(<<49,0>>, + 'SetOS', + #'SetOS'{a=172,b=43168,c='NULL'}, + #'SetOS'{a=[172],b=[16#A8,16#A0],c='NULL'}), + + roundtrip(<<48,0>>, + 'SeqOI', + #'SeqOI'{a={1,2,14,15}, + b={iso,'member-body',250,3,4}, + c={iso,standard,8571,2,250,4}}, + #'SeqOI'{a={1,2,14,15}, + b={1,2,250,3,4}, + c={1,0,8571,2,250,4}}), + + roundtrip(<<49,0>>, + 'SetOI', + #'SetOI'{a={1,2,14,15}, + b={iso,'member-body',250,3,4}, + c={iso,standard,8571,2,250,4}}, + #'SetOI'{a={1,2,14,15}, + b={1,2,250,3,4}, + c={1,0,8571,2,250,4}}), + + roundtrip(<<48,0>>, 'SeqEnum', #'SeqEnum'{a=b4,b=b2}), + roundtrip(<<49,0>>, 'SetEnum', #'SetEnum'{a=b4,b=b2}), + + roundtrip(<<48,0>>, + 'SeqIntBool', + #'SeqIntBool'{a=#'SeqIntBool_a'{aa=12,ab=13}, + b=#'S2'{a=14,b=true}, + c=#'S2'{a=15,b=false}}), + roundtrip(<<48,0>>, + 'SeqIntBool', + #'SeqIntBool'{a=asn1_DEFAULT,b=asn1_DEFAULT,c=asn1_DEFAULT}, + #'SeqIntBool'{a=#'SeqIntBool_a'{aa=12,ab=13}, + b=#'S2'{a=14,b=true}, + c=#'S2'{a=15,b=false}}), + + roundtrip(<<49,0>>, + 'SetIntBool', + #'SetIntBool'{a=#'SetIntBool_a'{aa=12,ab=13}, + b=#'S2'{a=14,b=true}, + c=#'S2'{a=15,b=false}}), + roundtrip(<<49,0>>, + 'SetIntBool', + #'SetIntBool'{a=asn1_DEFAULT,b=asn1_DEFAULT,c=asn1_DEFAULT}, + #'SetIntBool'{a=#'SetIntBool_a'{aa=12,ab=13}, + b=#'S2'{a=14,b=true}, + c=#'S2'{a=15,b=false}}), + + roundtrip(<<48,0>>, + 'SeqStrings', + #'SeqStrings'{a="123456789",b1="abcdef", + b2={0,13}, + b3={"First line",{0,13},"Second line"}, + c="Printable string", + d={0,0,1,14}}, + #'SeqStrings'{a="123456789",b1="abcdef", + b2=[0,13], + b3=["First line",[0,13],"Second line"], + c="Printable string", + d=[0,0,1,14]}), + + roundtrip(<<49,0>>, + 'SetStrings', + #'SetStrings'{a="123456789",b1="abcdef", + b2={0,13}, + b3={"First line",{0,13},"Second line"}, + c="Printable string", + d={0,0,1,14}}, + #'SetStrings'{a="123456789",b1="abcdef", + b2=[0,13], + b3=["First line",[0,13],"Second line"], + c="Printable string", + d=[0,0,1,14]}), + + roundtrip(<<48,0>>, + 'S1', + #'S1'{a=#'S1_a'{aa=1,ab=#'S2'{a=2,b=true}}, + b=#'S4'{a=#'S2'{a=2,b=true},b=#'S4_b'{ba=true,bb=5}}}), + + roundtrip(<<48,3,129,1,255>>, 'S2', #'S2'{a=1,b=true}), + + roundtrip(<<48,0>>, + 'S3', + #'S3'{a="\v\f\r", + b=[{a,11},{b,true},{c,13}], + c=[1,2,3,4], + d=[#'S2'{a=20,b=true},#'S2'{a=30,b=false}]}), + roundtrip(<<48,0>>, + 'S3', + #'S3'{a=[11,13,12], + b=[{b,true},{a,11},{c,13}], + c=[3,4,1,2], + d=[#'S2'{a=30,b=false},#'S2'{a=20,b=true}]}, + #'S3'{a=[11,12,13], + b=[{a,11},{b,true},{c,13}], + c=[1,2,3,4], + d=[#'S2'{a=20,b=true},#'S2'{a=30,b=false}]}), + roundtrip(<<48,0>>, + 'S3', + #'S3'{a=asn1_DEFAULT,b=asn1_DEFAULT, + c=asn1_DEFAULT,d=asn1_DEFAULT}, + #'S3'{a=[11,12,13], + b=[{a,11},{b,true},{c,13}], + c=[1,2,3,4], + d=[#'S2'{a=20,b=true},#'S2'{a=30,b=false}]}), + + roundtrip(<<49,0>>, + 'S3set', + #'S3set'{a=[{c,#'S2'{a=3,b=true}},{b,17},{a,false}], + b=[1,2,3,4]}), + roundtrip(<<49,0>>, + 'S3set', + #'S3set'{a=[{b,17},{c,#'S2'{a=3,b=true}},{a,false}], + b=[1,3,4,2]}, + #'S3set'{a=[{c,#'S2'{a=3,b=true}},{b,17},{a,false}], + b=[1,2,3,4]}), + roundtrip(<<49,0>>, + 'S3set', + #'S3set'{a=asn1_DEFAULT,b=asn1_DEFAULT}, + #'S3set'{a=[{c,#'S2'{a=3,b=true}},{b,17},{a,false}], + b=[1,2,3,4]}), + + roundtrip(<<48,0>>, + 'S4', + #'S4'{a=#'S2'{a=1,b=asn1_NOVALUE},b=#'S4_b'{ba=true,bb=0}}, + #'S4'{a=#'S2'{a=1,b=asn1_NOVALUE},b=#'S4_b'{ba=true,bb=0}}), - ?line {ok,[48,0]} = - asn1_wrapper:encode('Default','SeqOI', - #'SeqOI'{a={1,2,14,15}, - b={iso,'member-body',250,3,4}, - c={iso,standard,8571,2,250,4}}), - - ?line {ok,{'SeqOI',{1,2,14,15},{1,2,250,3,4},{1,0,8571,2,250,4}}} = - asn1_wrapper:decode('Default','SeqOI',[48,0]), - - ?line {ok,[49,0]} = - asn1_wrapper:encode('Default','SetOI', - #'SetOI'{a={1,2,14,15}, - b={iso,'member-body',250,3,4}, - c={iso,standard,8571,2,250,4}}), - - ?line {ok,{'SetOI',{1,2,14,15},{1,2,250,3,4},{1,0,8571,2,250,4}}} = - asn1_wrapper:decode('Default','SetOI',[49,0]), - - ?line {ok,[48,0]} = - asn1_wrapper:encode('Default','SeqEnum',#'SeqEnum'{a=b4,b=b2}), - - ?line {ok,{'SeqEnum',b4,b2}} = - asn1_wrapper:decode('Default','SeqEnum',[48,0]), - - ?line {ok,[49,0]} = - asn1_wrapper:encode('Default','SetEnum',#'SetEnum'{a=b4,b=b2}), - - ?line {ok,{'SetEnum',b4,b2}} = - asn1_wrapper:decode('Default','SetEnum',[49,0]), - - ?line {ok,[48,0]} = - asn1_wrapper:encode('Default','SeqIntBool', - #'SeqIntBool'{a=#'SeqIntBool_a'{aa=12,ab=13}, - b=#'S2'{a=14,b=true}, - c=#'S2'{a=15,b=false}}), - - ?line {ok,[48,0]} = - asn1_wrapper:encode('Default','SeqIntBool', - #'SeqIntBool'{}), - - ?line {ok,{'SeqIntBool',{'SeqIntBool_a',12,13}, - {'S2',14,true},{'S2',15,false}}} = - asn1_wrapper:decode('Default','SeqIntBool',[48,0]), - - ?line {ok,[49,0]} = - asn1_wrapper:encode('Default','SetIntBool', - #'SetIntBool'{a=#'SetIntBool_a'{aa=12,ab=13}, - b=#'S2'{a=14,b=true}, - c=#'S2'{a=15,b=false}}), - - ?line {ok,[49,0]} = - asn1_wrapper:encode('Default','SetIntBool', - #'SetIntBool'{}), - - ?line {ok,{'SetIntBool',{'SetIntBool_a',12,13}, - {'S2',14,true},{'S2',15,false}}} = - asn1_wrapper:decode('Default','SetIntBool',[49,0]), - - ?line {ok,[48,0]} = - asn1_wrapper:encode('Default','SeqStrings', - #'SeqStrings'{a="123456789", - b1="abcdef", - b2={0,13}, - b3={"First line",{0,13},"Second line"}, - c="Printable string", - d={0,0,1,14}}), - - ?line {ok,{'SeqStrings',"123456789","abcdef",[0,13], - ["First line",[0,13],"Second line"],"Printable string", - [0,0,1,14]}} = - asn1_wrapper:decode('Default','SeqStrings',[48,0]), - - ?line {ok,[49,0]} = - asn1_wrapper:encode('Default','SetStrings', - #'SetStrings'{a="123456789", - b1="abcdef", - b2={0,13}, - b3={"First line",{0,13},"Second line"}, - c="Printable string", - d={0,0,1,14}}), - - ?line {ok,{'SetStrings',"123456789","abcdef",[0,13], - ["First line",[0,13],"Second line"],"Printable string", - [0,0,1,14]}} = - asn1_wrapper:decode('Default','SetStrings',[49,0]), - - - ?line {ok,[48,0]} = - asn1_wrapper:encode('Default','S1', - #'S1'{a=#'S1_a'{aa=1, - ab=#'S2'{a=2,b=true}}, - b=#'S4'{a=#'S2'{a=2,b=true}, - b=#'S4_b'{ba=true, - bb=5}}}), - - ?line {ok,{'S1',{'S1_a',1,{'S2',2,true}}, - {'S4',{'S2',2,true},{'S4_b',true,5}}}} = - asn1_wrapper:decode('Default','S1',[48,0]), - - ?line {ok,[48,3,129,1,255]} = - asn1_wrapper:encode('Default','S2', - #'S2'{a=1,b=true}), - - ?line {ok,[48,0]} = - asn1_wrapper:encode('Default','S3', - #'S3'{a=[11,12,13], - b=[{a,11},{b,true},{c,13}], - c=[1,2,3,4], - d=[#'S2'{a=20,b=true},#'S2'{a=30,b=false}]}), - - ?line {ok,[48,0]} = - asn1_wrapper:encode('Default','S3', - #'S3'{a=[11,13,12], - b=[{b,true},{a,11},{c,13}], - c=[3,4,1,2], - d=[#'S2'{a=30,b=false},#'S2'{a=20,b=true}]}), - - ?line {ok,[48,0]} = asn1_wrapper:encode('Default','S3',#'S3'{}), - - ?line {ok,[49,0]} = - asn1_wrapper:encode('Default','S3set', - #'S3set'{a=[{c,#'S2'{a=3,b=true}}, - {b,17},{a,false}], - b=[1,2,3,4]}), + ok. - ?line {ok,[49,0]} = - asn1_wrapper:encode('Default','S3set', - #'S3set'{a=[{b,17},{c,#'S2'{a=3,b=true}}, - {a,false}], - b=[1,3,4,2]}), +roundtrip(Encoded, Type, Value) -> + roundtrip(Encoded, Type, Value, Value). - ?line {ok,[49,0]} = asn1_wrapper:encode('Default','S3set',#'S3set'{}), - - ?line {ok,[48,0]} = - asn1_wrapper:encode('Default','S4',#'S4'{a={'S2',1,asn1_NOVALUE}, - b=#'S4_b'{ba=true,bb=0}}), +roundtrip(Encoded, Type, Value, ExpectedValue) -> + Encoded = asn1_test_lib:roundtrip_enc('Default', Type, + Value, ExpectedValue), ok. diff --git a/lib/asn1/test/testSeqTag.erl b/lib/asn1/test/testSeqTag.erl index 9fdaae35dd..2f127b3e97 100644 --- a/lib/asn1/test/testSeqTag.erl +++ b/lib/asn1/test/testSeqTag.erl @@ -35,69 +35,25 @@ -record('Exp',{os, bool}). main(_Rules) -> - - - ?line {ok,Bytes11} = - asn1_wrapper:encode('SeqTag','SeqTag',#'SeqTag'{nt = #'NT'{bool = true, os = "kalle"}, - imp = #'Imp'{bool = true, os = "kalle"}, - exp = #'Exp'{bool = true, os = "kalle"}}), - ?line {ok,{'SeqTag',{'NT',"kalle",true},{'Imp',"kalle",true},{'Exp',"kalle",true}}} = - asn1_wrapper:decode('SeqTag','SeqTag',lists:flatten(Bytes11)), - - - ?line {ok,Bytes12} = - asn1_wrapper:encode('SeqTag','SeqTagImp',#'SeqTagImp'{nt = #'NT'{bool = true, os = "kalle"}, - imp = #'Imp'{bool = true, os = "kalle"}, - exp = #'Exp'{bool = true, os = "kalle"}}), - ?line {ok,{'SeqTagImp',{'NT',"kalle",true},{'Imp',"kalle",true},{'Exp',"kalle",true}}} = - asn1_wrapper:decode('SeqTag','SeqTagImp',lists:flatten(Bytes12)), - - - ?line {ok,Bytes13} = - asn1_wrapper:encode('SeqTag','SeqTagExp',#'SeqTagExp'{nt = #'NT'{bool = true, os = "kalle"}, - imp = #'Imp'{bool = true, os = "kalle"}, - exp = #'Exp'{bool = true, os = "kalle"}}), - ?line {ok,{'SeqTagExp',{'NT',"kalle",true},{'Imp',"kalle",true},{'Exp',"kalle",true}}} = - asn1_wrapper:decode('SeqTag','SeqTagExp',lists:flatten(Bytes13)), - - - - - - ?line {ok,Bytes21} = - asn1_wrapper:encode('SeqTag','SeqTagX', - #'SeqTagX'{xnt = #'XSeqNT'{bool = true, os = "kalle"}, - ximp = #'XSeqImp'{bool = true, os = "kalle"}, - xexp = #'XSeqExp'{bool = true, os = "kalle"}}), - ?line {ok,{'SeqTagX',{'XSeqNT',"kalle",true}, - {'XSeqImp',"kalle",true}, - {'XSeqExp',"kalle",true}}} = - asn1_wrapper:decode('SeqTag','SeqTagX',lists:flatten(Bytes21)), - - - ?line {ok,Bytes22} = - asn1_wrapper:encode('SeqTag','SeqTagImpX', - #'SeqTagImpX'{xnt = #'XSeqNT'{bool = true, os = "kalle"}, - ximp = #'XSeqImp'{bool = true, os = "kalle"}, - xexp = #'XSeqExp'{bool = true, os = "kalle"}}), - ?line {ok,{'SeqTagImpX',{'XSeqNT',"kalle",true}, - {'XSeqImp',"kalle",true}, - {'XSeqExp',"kalle",true}}} = - asn1_wrapper:decode('SeqTag','SeqTagImpX',lists:flatten(Bytes22)), - - - ?line {ok,Bytes23} = - asn1_wrapper:encode('SeqTag','SeqTagExpX', - #'SeqTagExpX'{xnt = #'XSeqNT'{bool = true, os = "kalle"}, - ximp = #'XSeqImp'{bool = true, os = "kalle"}, - xexp = #'XSeqExp'{bool = true, os = "kalle"}}), - ?line {ok,{'SeqTagExpX',{'XSeqNT',"kalle",true}, - {'XSeqImp',"kalle",true}, - {'XSeqExp',"kalle",true}}} = - asn1_wrapper:decode('SeqTag','SeqTagExpX',lists:flatten(Bytes23)), - - - - - + roundtrip('SeqTag', #'SeqTag'{nt=#'NT'{os="kalle",bool=true}, + imp=#'Imp'{os="kalle",bool=true}, + exp=#'Exp'{os="kalle",bool=true}}), + roundtrip('SeqTagImp', #'SeqTagImp'{nt=#'NT'{os="kalle",bool=true}, + imp=#'Imp'{os="kalle",bool=true}, + exp=#'Exp'{os="kalle",bool=true}}), + roundtrip('SeqTagExp', #'SeqTagExp'{nt=#'NT'{os="kalle",bool=true}, + imp=#'Imp'{os="kalle",bool=true}, + exp=#'Exp'{os="kalle",bool=true}}), + roundtrip('SeqTagX', #'SeqTagX'{xnt=#'XSeqNT'{os="kalle",bool=true}, + ximp=#'XSeqImp'{os="kalle",bool=true}, + xexp=#'XSeqExp'{os="kalle",bool=true}}), + roundtrip('SeqTagImpX', #'SeqTagImpX'{xnt=#'XSeqNT'{os="kalle",bool=true}, + ximp=#'XSeqImp'{os="kalle",bool=true}, + xexp=#'XSeqExp'{os="kalle",bool=true}}), + roundtrip('SeqTagExpX', #'SeqTagExpX'{xnt=#'XSeqNT'{os="kalle",bool=true}, + ximp=#'XSeqImp'{os="kalle",bool=true}, + xexp=#'XSeqExp'{os="kalle",bool=true}}), ok. + +roundtrip(T, V) -> + asn1_test_lib:roundtrip('SeqTag', T, V). diff --git a/lib/asn1/test/testSeqTypeRefCho.erl b/lib/asn1/test/testSeqTypeRefCho.erl index 4b9eac7034..b008bc46b8 100644 --- a/lib/asn1/test/testSeqTypeRefCho.erl +++ b/lib/asn1/test/testSeqTypeRefCho.erl @@ -27,17 +27,12 @@ -record('SeqTRcho',{seqCho, seqChoE, 'seqCho-E', 'seqChoE-E'}). main(_Rules) -> - - - ?line {ok,Bytes11} = - asn1_wrapper:encode('SeqTypeRefCho','SeqTRcho', - #'SeqTRcho'{'seqCho' = {choOs,"A string 1"}, - 'seqChoE' = {choOs,"A string 3"}, - 'seqCho-E' = {choOs,"A string 7"}, - 'seqChoE-E' = {choOs,"A string 9"}}), - ?line {ok,{'SeqTRcho',{choOs,"A string 1"},{choOs,"A string 3"},{choOs,"A string 7"},{choOs,"A string 9"}}} = - asn1_wrapper:decode('SeqTypeRefCho','SeqTRcho',lists:flatten(Bytes11)), - - - + roundtrip('SeqTRcho', + #'SeqTRcho'{'seqCho' = {choOs,"A string 1"}, + 'seqChoE' = {choOs,"A string 3"}, + 'seqCho-E' = {choOs,"A string 7"}, + 'seqChoE-E' = {choOs,"A string 9"}}), ok. + +roundtrip(T, V) -> + asn1_test_lib:roundtrip('SeqTypeRefCho', T, V). diff --git a/lib/asn1/test/testSeqTypeRefPrim.erl b/lib/asn1/test/testSeqTypeRefPrim.erl index 7d157c2e3f..b63882ae99 100644 --- a/lib/asn1/test/testSeqTypeRefPrim.erl +++ b/lib/asn1/test/testSeqTypeRefPrim.erl @@ -25,21 +25,17 @@ -record('SeqTR',{octStr, octStrI, octStrE, 'octStr-I', 'octStrI-I', 'octStrE-I', 'octStr-E', 'octStrI-E', 'octStrE-E'}). main(_Rules) -> - - - ?line {ok,Bytes11} = - asn1_wrapper:encode('SeqTypeRefPrim','SeqTR',#'SeqTR'{'octStr' = "A string 1", - 'octStrI' = "A string 2", - 'octStrE' = "A string 3", - 'octStr-I' = "A string 4", - 'octStrI-I' = "A string 5", - 'octStrE-I' = "A string 6", - 'octStr-E' = "A string 7", - 'octStrI-E' = "A string 8", - 'octStrE-E' = "A string 9"}) , - ?line {ok,{'SeqTR',"A string 1","A string 2","A string 3","A string 4","A string 5","A string 6","A string 7","A string 8","A string 9"}} = - asn1_wrapper:decode('SeqTypeRefPrim','SeqTR',lists:flatten(Bytes11)), - - - + roundtrip('SeqTR', + #'SeqTR'{'octStr' = "A string 1", + 'octStrI' = "A string 2", + 'octStrE' = "A string 3", + 'octStr-I' = "A string 4", + 'octStrI-I' = "A string 5", + 'octStrE-I' = "A string 6", + 'octStr-E' = "A string 7", + 'octStrI-E' = "A string 8", + 'octStrE-E' = "A string 9"}), ok. + +roundtrip(T, V) -> + asn1_test_lib:roundtrip('SeqTypeRefPrim', T, V). diff --git a/lib/asn1/test/testSeqTypeRefSeq.erl b/lib/asn1/test/testSeqTypeRefSeq.erl index 57ec6c19b1..fc2e0a67c9 100644 --- a/lib/asn1/test/testSeqTypeRefSeq.erl +++ b/lib/asn1/test/testSeqTypeRefSeq.erl @@ -44,133 +44,43 @@ -record('SeqSeqExp',{seqInt, seqOs}). - main(_Rules) -> - - - ?line {ok,Bytes11} = - asn1_wrapper:encode('SeqTypeRefSeq','Seq1',#'Seq1'{bool1 = true, - int1 = 15, - seq1 = #'SeqIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'Seq1',true,15,{'SeqIn',true,66}}} = - asn1_wrapper:decode('SeqTypeRefSeq','Seq1',lists:flatten(Bytes11)), - - - - ?line {ok,Bytes12} = - asn1_wrapper:encode('SeqTypeRefSeq','Seq2',#'Seq2'{seq2 = #'SeqIn'{boolIn = true, - intIn = 66}, - bool2 = true, - int2 = 15}), - ?line {ok,{'Seq2',{'SeqIn',true,66},true,15}} = - asn1_wrapper:decode('SeqTypeRefSeq','Seq2',lists:flatten(Bytes12)), - - - ?line {ok,Bytes13} = - asn1_wrapper:encode('SeqTypeRefSeq','Seq3',#'Seq3'{bool3 = true, - seq3 = #'SeqIn'{boolIn = true, - intIn = 66}, - int3 = 15}), - ?line {ok,{'Seq3',true,{'SeqIn',true,66},15}} = - asn1_wrapper:decode('SeqTypeRefSeq','Seq3',lists:flatten(Bytes13)), - - - - ?line {ok,Bytes14} = - asn1_wrapper:encode('SeqTypeRefSeq','Seq4',#'Seq4'{seq41 = #'SeqIn'{boolIn = true, - intIn = 66}, - seq42 = #'SeqIn'{boolIn = true, - intIn = 66}, - seq43 = #'SeqIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'Seq4',{'SeqIn',true,66},{'SeqIn',true,66},{'SeqIn',true,66}}} = - asn1_wrapper:decode('SeqTypeRefSeq','Seq4',lists:flatten(Bytes14)), - - - - - - - - - ?line {ok,Bytes21} = - asn1_wrapper:encode('SeqTypeRefSeq','SeqS1',#'SeqS1'{boolS1 = true, - intS1 = 15, - seqS1 = #'SeqS1_seqS1'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SeqS1',true,15,{'SeqS1_seqS1',true,66}}} = - asn1_wrapper:decode('SeqTypeRefSeq','SeqS1',lists:flatten(Bytes21)), - - - ?line {ok,Bytes22} = - asn1_wrapper:encode('SeqTypeRefSeq','SeqS2',#'SeqS2'{seqS2 = #'SeqS2_seqS2'{boolIn = true, - intIn = 66}, - boolS2 = true, - intS2 = 15}), - ?line {ok,{'SeqS2',{'SeqS2_seqS2',true,66},true,15}} = - asn1_wrapper:decode('SeqTypeRefSeq','SeqS2',lists:flatten(Bytes22)), - - - - ?line {ok,Bytes23} = - asn1_wrapper:encode('SeqTypeRefSeq','SeqS3',#'SeqS3'{boolS3 = true, - seqS3 = #'SeqS3_seqS3'{boolIn = true, - intIn = 66}, - intS3 = 15}), - ?line {ok,{'SeqS3',true,{'SeqS3_seqS3',true,66},15}} = - asn1_wrapper:decode('SeqTypeRefSeq','SeqS3',lists:flatten(Bytes23)), - - - - - - - ?line {ok,Bytes31} = - asn1_wrapper:encode('SeqTypeRefSeq','SeqSTag',#'SeqSTag'{seqS1 = #'SeqSTag_seqS1'{b1 = true, - i1 = 11}, - seqS2 = #'SeqSTag_seqS2'{b2 = true, - i2 = 22}, - seqS3 = #'SeqSTag_seqS3'{b3 = true, - i3 = 33}}), - ?line {ok,{'SeqSTag',{'SeqSTag_seqS1',true,11}, - {'SeqSTag_seqS2',true,22}, - {'SeqSTag_seqS3',true,33}}} = - asn1_wrapper:decode('SeqTypeRefSeq','SeqSTag',lists:flatten(Bytes31)), - - - - - - ?line {ok,Bytes41} = - asn1_wrapper:encode('SeqTypeRefSeq','SeqTRseq', - #'SeqTRseq'{'seqSeq' = #'SeqSeq'{seqOs = "A1", - seqInt = 2}, - 'seqSeqI' = #'SeqSeq'{seqOs = "A2", - seqInt = 2}, - 'seqSeqE' = #'SeqSeq'{seqOs = "A3", - seqInt = 2}, - 'seqSeq-I' = #'SeqSeqImp'{seqOs = "A4", - seqInt = 2}, - 'seqSeqI-I' = #'SeqSeqImp'{seqOs = "A5", - seqInt = 2}, - 'seqSeqE-I' = #'SeqSeqImp'{seqOs = "A6", - seqInt = 2}, - 'seqSeq-E' = #'SeqSeqExp'{seqOs = "A7", - seqInt = 2}, - 'seqSeqI-E' = #'SeqSeqExp'{seqOs = "A8", - seqInt = 2}, - 'seqSeqE-E' = #'SeqSeqExp'{seqOs = "A9", - seqInt = 2}}), - ?line {ok,{'SeqTRseq',{'SeqSeq',2,"A1"}, - {'SeqSeq',2,"A2"}, - {'SeqSeq',2,"A3"}, - {'SeqSeqImp',2,"A4"}, - {'SeqSeqImp',2,"A5"}, - {'SeqSeqImp',2,"A6"}, - {'SeqSeqExp',2,"A7"}, - {'SeqSeqExp',2,"A8"}, - {'SeqSeqExp',2,"A9"}}} = - asn1_wrapper:decode('SeqTypeRefSeq','SeqTRseq',lists:flatten(Bytes41)), - + roundtrip('Seq1', + #'Seq1'{bool1=true,int1=15, + seq1=#'SeqIn'{boolIn=true,intIn=66}}), + roundtrip('Seq2', + #'Seq2'{seq2=#'SeqIn'{boolIn=true,intIn=66}, + bool2=true,int2=15}), + roundtrip('Seq3', + #'Seq3'{bool3=true,seq3=#'SeqIn'{boolIn=true,intIn=66},int3=15}), + roundtrip('Seq4', + #'Seq4'{seq41=#'SeqIn'{boolIn=true,intIn=66}, + seq42=#'SeqIn'{boolIn=true,intIn=66}, + seq43=#'SeqIn'{boolIn=true,intIn=66}}), + roundtrip('SeqS1', + #'SeqS1'{boolS1=true,intS1=15, + seqS1=#'SeqS1_seqS1'{boolIn=true,intIn=66}}), + roundtrip('SeqS2', + #'SeqS2'{seqS2=#'SeqS2_seqS2'{boolIn=true,intIn=66}, + boolS2=true,intS2=15}), + roundtrip('SeqS3', + #'SeqS3'{boolS3=true,seqS3=#'SeqS3_seqS3'{boolIn=true,intIn=66}, + intS3=15}), + roundtrip('SeqSTag', + #'SeqSTag'{seqS1=#'SeqSTag_seqS1'{b1=true,i1=11}, + seqS2=#'SeqSTag_seqS2'{b2=true,i2=22}, + seqS3=#'SeqSTag_seqS3'{b3=true,i3=33}}), + roundtrip('SeqTRseq', + #'SeqTRseq'{seqSeq=#'SeqSeq'{seqInt=2,seqOs="A1"}, + seqSeqI=#'SeqSeq'{seqInt=2,seqOs="A2"}, + seqSeqE=#'SeqSeq'{seqInt=2,seqOs="A3"}, + 'seqSeq-I'=#'SeqSeqImp'{seqInt=2,seqOs="A4"}, + 'seqSeqI-I'=#'SeqSeqImp'{seqInt=2,seqOs="A5"}, + 'seqSeqE-I'=#'SeqSeqImp'{seqInt=2,seqOs="A6"}, + 'seqSeq-E'=#'SeqSeqExp'{seqInt=2,seqOs="A7"}, + 'seqSeqI-E'=#'SeqSeqExp'{seqInt=2,seqOs="A8"}, + 'seqSeqE-E'=#'SeqSeqExp'{seqInt=2,seqOs="A9"}}), ok. + +roundtrip(T, V) -> + asn1_test_lib:roundtrip('SeqTypeRefSeq', T, V). diff --git a/lib/asn1/test/testSeqTypeRefSet.erl b/lib/asn1/test/testSeqTypeRefSet.erl index c06a0e7a2b..911a4b7a47 100644 --- a/lib/asn1/test/testSeqTypeRefSet.erl +++ b/lib/asn1/test/testSeqTypeRefSet.erl @@ -31,36 +31,17 @@ main(_Rules) -> - - ?line {ok,Bytes41} = - asn1_wrapper:encode('SeqTypeRefSet','SeqTRset', - #'SeqTRset'{'seqSet' = #'SeqSet'{setOs = "A1", - setInt = 2}, - 'seqSetI' = #'SeqSet'{setOs = "A2", - setInt = 2}, - 'seqSetE' = #'SeqSet'{setOs = "A3", - setInt = 2}, - 'seqSet-I' = #'SeqSetImp'{setOs = "A4", - setInt = 2}, - 'seqSetI-I' = #'SeqSetImp'{setOs = "A5", - setInt = 2}, - 'seqSetE-I' = #'SeqSetImp'{setOs = "A6", - setInt = 2}, - 'seqSet-E' = #'SeqSetExp'{setOs = "A7", - setInt = 2}, - 'seqSetI-E' = #'SeqSetExp'{setOs = "A8", - setInt = 2}, - 'seqSetE-E' = #'SeqSetExp'{setOs = "A9", - setInt = 2}}), - ?line {ok,{'SeqTRset',{'SeqSet',2,"A1"}, - {'SeqSet',2,"A2"}, - {'SeqSet',2,"A3"}, - {'SeqSetImp',2,"A4"}, - {'SeqSetImp',2,"A5"}, - {'SeqSetImp',2,"A6"}, - {'SeqSetExp',2,"A7"}, - {'SeqSetExp',2,"A8"}, - {'SeqSetExp',2,"A9"}}} = - asn1_wrapper:decode('SeqTypeRefSet','SeqTRset',lists:flatten(Bytes41)), - + roundtrip('SeqTRset', + #'SeqTRset'{seqSet=#'SeqSet'{setInt=2,setOs="A1"}, + seqSetI=#'SeqSet'{setInt=2,setOs="A2"}, + seqSetE=#'SeqSet'{setInt=2,setOs="A3"}, + 'seqSet-I'=#'SeqSetImp'{setInt=2,setOs="A4"}, + 'seqSetI-I'=#'SeqSetImp'{setInt=2,setOs="A5"}, + 'seqSetE-I'=#'SeqSetImp'{setInt=2,setOs="A6"}, + 'seqSet-E'=#'SeqSetExp'{setInt=2,setOs="A7"}, + 'seqSetI-E'=#'SeqSetExp'{setInt=2,setOs="A8"}, + 'seqSetE-E'=#'SeqSetExp'{setInt=2,setOs="A9"}}), ok. + +roundtrip(T, V) -> + asn1_test_lib:roundtrip('SeqTypeRefSet', T, V). diff --git a/lib/asn1/test/testSetDefault.erl b/lib/asn1/test/testSetDefault.erl index 8aa205e0f0..055dc6cecf 100644 --- a/lib/asn1/test/testSetDefault.erl +++ b/lib/asn1/test/testSetDefault.erl @@ -26,58 +26,34 @@ -record('SetDef1',{bool1 = asn1_DEFAULT, int1, set1 = asn1_DEFAULT}). -record('SetDef2',{set2 = asn1_DEFAULT, bool2, int2}). -record('SetDef3',{bool3 = asn1_DEFAULT, set3 = asn1_DEFAULT, int3 = asn1_DEFAULT}). --record('SetIn',{boolIn, intIn}). +-record('SetIn', {boolIn = asn1_NOVALUE, intIn = 12}). main(_Rules) -> - - ?line {ok,Bytes11} = - asn1_wrapper:encode('SetDefault','SetDef1',#'SetDef1'{bool1 = true, - int1 = 15, - set1 = #'SetIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SetDef1',true,15,{'SetIn',true,66}}} = - asn1_wrapper:decode('SetDefault','SetDef1',lists:flatten(Bytes11)), - - - ?line {ok,Bytes12} = asn1_wrapper:encode('SetDefault','SetDef1',#'SetDef1'{int1 = 15}), - ?line {ok,{'SetDef1',true,15,{'SetIn',asn1_NOVALUE,12}}} = - asn1_wrapper:decode('SetDefault','SetDef1',lists:flatten(Bytes12)), - - - ?line {ok,Bytes21} = - asn1_wrapper:encode('SetDefault','SetDef2',#'SetDef2'{bool2 = true, - int2 = 15, - set2 = #'SetIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SetDef2',{'SetIn',true,66},true,15}} = - asn1_wrapper:decode('SetDefault','SetDef2',lists:flatten(Bytes21)), - - - ?line {ok,Bytes22} = asn1_wrapper:encode('SetDefault','SetDef2',#'SetDef2'{bool2 = true, - int2 = 15}), - ?line {ok,{'SetDef2',{'SetIn',asn1_NOVALUE,12},true,15}} = - asn1_wrapper:decode('SetDefault','SetDef2',lists:flatten(Bytes22)), - - - - ?line {ok,Bytes31} = - asn1_wrapper:encode('SetDefault','SetDef3',#'SetDef3'{bool3 = true, - int3 = 15, - set3 = #'SetIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SetDef3',true,{'SetIn',true,66},15}} = - asn1_wrapper:decode('SetDefault','SetDef3',lists:flatten(Bytes31)), - - - ?line {ok,Bytes32} = asn1_wrapper:encode('SetDefault','SetDef3',#'SetDef3'{int3 = 15}), - ?line {ok,{'SetDef3',true,{'SetIn',asn1_NOVALUE,12},15}} = - asn1_wrapper:decode('SetDefault','SetDef3',lists:flatten(Bytes32)), - - - - + roundtrip('SetDef1', + #'SetDef1'{bool1=true,int1=15, + set1=#'SetIn'{boolIn=true,intIn=66}}), + roundtrip('SetDef1', + #'SetDef1'{bool1=asn1_DEFAULT,int1=15,set1=asn1_DEFAULT}, + #'SetDef1'{bool1=true,int1=15,set1=#'SetIn'{}}), - - + roundtrip('SetDef2', + #'SetDef2'{set2=#'SetIn'{boolIn=true,intIn=66}, + bool2=true,int2=15}), + roundtrip('SetDef2', + #'SetDef2'{set2=asn1_DEFAULT,bool2=true,int2=15}, + #'SetDef2'{set2=#'SetIn'{},bool2=true,int2=15}), + + roundtrip('SetDef3', + #'SetDef3'{bool3=true,set3=#'SetIn'{boolIn=true,intIn=66}, + int3=15}), + roundtrip('SetDef3', + #'SetDef3'{bool3=asn1_DEFAULT,set3=asn1_DEFAULT,int3=15}, + #'SetDef3'{bool3=true,set3=#'SetIn'{},int3=15}), ok. + +roundtrip(Type, Value) -> + roundtrip(Type, Value, Value). + +roundtrip(Type, Value, ExpectedValue) -> + asn1_test_lib:roundtrip('SetDefault', Type, Value, ExpectedValue). diff --git a/lib/asn1/test/testSetExtension.erl b/lib/asn1/test/testSetExtension.erl index e2ebb4bec8..4e2463326b 100644 --- a/lib/asn1/test/testSetExtension.erl +++ b/lib/asn1/test/testSetExtension.erl @@ -18,8 +18,6 @@ %% %% -module(testSetExtension). - - -include("External.hrl"). -export([main/1]). @@ -31,64 +29,19 @@ -record('SetExt4',{bool, int}). main(_Rules) -> - - ?line {ok,Bytes11} = - asn1_wrapper:encode('SetExtension','SetExt1',#'SetExt1'{}), - ?line {ok,{'SetExt1'}} = - asn1_wrapper:decode('SetExtension','SetExt1',lists:flatten(Bytes11)), - - ?line {ok,Bytes21} = - asn1_wrapper:encode('SetExtension','SetExt2',#'SetExt2'{bool = true,int = 99}), - ?line {ok,{'SetExt2',true,99}} = - asn1_wrapper:decode('SetExtension','SetExt2',lists:flatten(Bytes21)), - - ?line {ok,Bytes22} = - asn1_wrapper:encode('SetExtension','SetExt2',#'SetExt2'{int = 99,bool = true}), - ?line {ok,{'SetExt2',true,99}} = - asn1_wrapper:decode('SetExtension','SetExt2',lists:flatten(Bytes22)), - - ?line {ok,Bytes31} = - asn1_wrapper:encode('SetExtension','SetExt3',#'SetExt3'{bool = true,int = 99}), - ?line {ok,{'SetExt3',true,99}} = - asn1_wrapper:decode('SetExtension','SetExt3',lists:flatten(Bytes31)), - - ?line {ok,Bytes32} = - asn1_wrapper:encode('SetExtension','SetExt3',#'SetExt3'{int = 99,bool = true}), - ?line {ok,{'SetExt3',true,99}} = - asn1_wrapper:decode('SetExtension','SetExt3',lists:flatten(Bytes32)), - - ?line {ok,Bytes41} = - asn1_wrapper:encode('SetExtension','SetExt4',#'SetExt4'{bool = true,int = 99}), - ?line {ok,{'SetExt4',true,99}} = - asn1_wrapper:decode('SetExtension','SetExt4',lists:flatten(Bytes41)), - - ?line {ok,Bytes42} = - asn1_wrapper:encode('SetExtension','SetExt4',#'SetExt4'{int = 99,bool = true}), - ?line {ok,{'SetExt4',true,99}} = - asn1_wrapper:decode('SetExtension','SetExt4',lists:flatten(Bytes42)), - - - %% Test of extension , needs to be improved and extended - - ?line {ok,BytesX11} = - asn1_wrapper:encode('SetExtension','SetExt1',#'SetExt1'{}), - ?line {ok,{'SetExt1'}} = - asn1_wrapper:decode('SetExtension','SetExt1',lists:flatten(BytesX11)), - - ?line {ok,BytesX21} = - asn1_wrapper:encode('SetExtension','SetExt2',#'SetExt2'{bool = true,int = 99}), - ?line {ok,{'SetExt2',true,99}} = - asn1_wrapper:decode('SetExtension','SetExt2',lists:flatten(BytesX21)), - - ?line {ok,BytesX22} = - asn1_wrapper:encode('SetExtension','SetExt2',#'SetExt2'{int = 99,bool = true}), - ?line {ok,{'SetExt2',true,99}} = - asn1_wrapper:decode('SetExtension','SetExt2',lists:flatten(BytesX22)), - - - - - + roundtrip('SetExt1', #'SetExt1'{}), + roundtrip('SetExt2', #'SetExt2'{bool=true,int=99}), + roundtrip('SetExt2', #'SetExt2'{bool=true,int=99}), + roundtrip('SetExt3', #'SetExt3'{bool=true,int=99}), + roundtrip('SetExt3', #'SetExt3'{bool=true,int=99}), + roundtrip('SetExt4', #'SetExt4'{bool=true,int=99}), + roundtrip('SetExt4', #'SetExt4'{bool=true,int=99}), + roundtrip('SetExt1', #'SetExt1'{}), + roundtrip('SetExt2', #'SetExt2'{bool=true,int=99}), + roundtrip('SetExt2', #'SetExt2'{bool=true,int=99}), ok. +roundtrip(T, V) -> + asn1_test_lib:roundtrip('SetExtension', T, V). + diff --git a/lib/asn1/test/testSetExternal.erl b/lib/asn1/test/testSetExternal.erl index 30cddcacfb..e17d7053aa 100644 --- a/lib/asn1/test/testSetExternal.erl +++ b/lib/asn1/test/testSetExternal.erl @@ -18,111 +18,36 @@ %% %% -module(testSetExternal). - --include("External.hrl"). -export([main/1]). +-include("External.hrl"). -include_lib("test_server/include/test_server.hrl"). - -record('SetXSeq1',{seq, bool, int}). -record('SetXSeq2',{bool, seq, int}). -record('SetXSeq3',{bool, int, seq}). -%-record('NT',{os, bool}). -%-record('Imp',{os, bool}). -%-record('Exp',{os, bool}). main(_Rules) -> - - ?line {ok,Bytes11} = - asn1_wrapper:encode('SetExternal','XNTNT',#'XSetNT'{bool = true, os = "kalle"}), - ?line {ok,{'XSetNT',[107,97,108,108,101],true}} = - asn1_wrapper:decode('SetExternal','XNTNT',lists:flatten(Bytes11)), - - ?line {ok,Bytes12} = - asn1_wrapper:encode('SetExternal','XImpNT',#'XSetNT'{bool = true, os = "kalle"}), - ?line {ok,{'XSetNT',[107,97,108,108,101],true}} = - asn1_wrapper:decode('SetExternal','XImpNT',lists:flatten(Bytes12)), - - ?line {ok,Bytes13} = - asn1_wrapper:encode('SetExternal','XExpNT',#'XSetNT'{bool = true, os = "kalle"}), - ?line {ok,{'XSetNT',[107,97,108,108,101],true}} = - asn1_wrapper:decode('SetExternal','XExpNT',lists:flatten(Bytes13)), - - - - ?line {ok,Bytes21} = - asn1_wrapper:encode('SetExternal','XNTImp',#'XSetImp'{bool = true, os = "kalle"}), - ?line {ok,{'XSetImp',[107,97,108,108,101],true}} = - asn1_wrapper:decode('SetExternal','XNTImp',lists:flatten(Bytes21)), - - ?line {ok,Bytes22} = - asn1_wrapper:encode('SetExternal','XImpImp',#'XSetImp'{bool = true, os = "kalle"}), - ?line {ok,{'XSetImp',[107,97,108,108,101],true}} = - asn1_wrapper:decode('SetExternal','XImpImp',lists:flatten(Bytes22)), - - ?line {ok,Bytes23} = - asn1_wrapper:encode('SetExternal','XExpImp',#'XSetImp'{bool = true, os = "kalle"}), - ?line {ok,{'XSetImp',[107,97,108,108,101],true}} = - asn1_wrapper:decode('SetExternal','XExpImp',lists:flatten(Bytes23)), - - - - ?line {ok,Bytes31} = - asn1_wrapper:encode('SetExternal','XNTExp',#'XSetExp'{bool = true, os = "kalle"}), - ?line {ok,{'XSetExp',[107,97,108,108,101],true}} = - asn1_wrapper:decode('SetExternal','XNTExp',lists:flatten(Bytes31)), - - ?line {ok,Bytes32} = - asn1_wrapper:encode('SetExternal','XImpExp',#'XSetExp'{bool = true, os = "kalle"}), - ?line {ok,{'XSetExp',[107,97,108,108,101],true}} = - asn1_wrapper:decode('SetExternal','XImpExp',lists:flatten(Bytes32)), - - ?line {ok,Bytes33} = - asn1_wrapper:encode('SetExternal','XExpExp',#'XSetExp'{bool = true, os = "kalle"}), - ?line {ok,{'XSetExp',[107,97,108,108,101],true}} = - asn1_wrapper:decode('SetExternal','XExpExp',lists:flatten(Bytes33)), - - - - ?line {ok,Bytes41} = - asn1_wrapper:encode('SetExternal','SetXSeq1', - #'SetXSeq1'{bool = true, - int = 66, - seq = #'XSeq1'{bool1 = true, - int1 = 77, - seq1 = #'XSeqIn'{boolIn = false, - intIn = 88}}}), - ?line {ok,{'SetXSeq1',{'XSeq1',true,77,{'XSeqIn',false,88}},true,66}} = - asn1_wrapper:decode('SetExternal','SetXSeq1',lists:flatten(Bytes41)), - - - - ?line {ok,Bytes42} = - asn1_wrapper:encode('SetExternal','SetXSeq2', - #'SetXSeq2'{bool = true, - int = 66, - seq = #'XSeq1'{bool1 = true, - int1 = 77, - seq1 = #'XSeqIn'{boolIn = false, - intIn = 88}}}), - ?line {ok,{'SetXSeq2',true,{'XSeq1',true,77,{'XSeqIn',false,88}},66}} = - asn1_wrapper:decode('SetExternal','SetXSeq2',lists:flatten(Bytes42)), - - ?line {ok,Bytes43} = - asn1_wrapper:encode('SetExternal','SetXSeq3', - #'SetXSeq3'{bool = true, - int = 66, - seq = #'XSeq1'{bool1 = true, - int1 = 77, - seq1 = #'XSeqIn'{boolIn = false, - intIn = 88}}}), - ?line {ok,{'SetXSeq3',true,66,{'XSeq1',true,77,{'XSeqIn',false,88}}}} = - asn1_wrapper:decode('SetExternal','SetXSeq3',lists:flatten(Bytes43)), - - - - + roundtrip('XNTNT', #'XSetNT'{os="kalle",bool=true}), + roundtrip('XImpNT', #'XSetNT'{os="kalle",bool=true}), + roundtrip('XExpNT', #'XSetNT'{os="kalle",bool=true}), + roundtrip('XNTImp', #'XSetImp'{os="kalle",bool=true}), + roundtrip('XImpImp', #'XSetImp'{os="kalle",bool=true}), + roundtrip('XExpImp', #'XSetImp'{os="kalle",bool=true}), + roundtrip('XNTExp', #'XSetExp'{os="kalle",bool=true}), + roundtrip('XImpExp', #'XSetExp'{os="kalle",bool=true}), + roundtrip('XExpExp', #'XSetExp'{os="kalle",bool=true}), + roundtrip('SetXSeq1', #'SetXSeq1'{seq=#'XSeq1'{bool1=true,int1=77, + seq1=#'XSeqIn'{boolIn=false,intIn=88}}, + bool=true,int=66}), + roundtrip('SetXSeq2', #'SetXSeq2'{bool=true, + seq=#'XSeq1'{bool1=true,int1=77, + seq1=#'XSeqIn'{boolIn=false,intIn=88}}, + int=66}), + roundtrip('SetXSeq3', #'SetXSeq3'{bool=true,int=66, + seq=#'XSeq1'{bool1=true,int1=77, + seq1=#'XSeqIn'{boolIn=false,intIn=88}}}), ok. - +roundtrip(T, V) -> + asn1_test_lib:roundtrip('SetExternal', T, V). diff --git a/lib/asn1/test/testSetIndefinite.erl b/lib/asn1/test/testSetIndefinite.erl index 73006da62b..cbcebd333d 100644 --- a/lib/asn1/test/testSetIndefinite.erl +++ b/lib/asn1/test/testSetIndefinite.erl @@ -28,14 +28,13 @@ main(per) -> ok; main(ber) -> %% normal encoding - B = [49,20,1,1,255,49,9,1,1,255,2,4,251,35,238,194,2,4,251,55,236,161], + B = <<49,20,1,1,255,49,9,1,1,255,2,4,251,35,238,194,2,4,251,55,236,161>>, %% indefinite length encoding - Bi = [49,22,1,1,255,49,128,1,1,255,2,4,251,35,238,194,0,0,2,4,251,55,236,161], + Bi = <<49,22,1,1,255,49,128,1,1,255,2,4,251,35,238,194,0,0,2,4,251,55,236,161>>, + %% the value which is encoded V = {'SetS3',true,{'SetS3_setS3',true,-81531198},-80221023}, - ?line {ok,V} = asn1_wrapper:decode('SeqSetIndefinite','SetS3',B), - ?line {ok,V} = asn1_wrapper:decode('SeqSetIndefinite','SetS3',Bi), - ok. - - + {ok,V} = 'SeqSetIndefinite':decode('SetS3', B), + {ok,V} = 'SeqSetIndefinite':decode('SetS3', Bi), + ok. diff --git a/lib/asn1/test/testSetOf.erl b/lib/asn1/test/testSetOf.erl index 08723fb468..54c42c1f21 100644 --- a/lib/asn1/test/testSetOf.erl +++ b/lib/asn1/test/testSetOf.erl @@ -28,198 +28,108 @@ -record('Set3',{bool3, set3 = asn1_DEFAULT, int3}). -record('Set4',{set41 = asn1_DEFAULT, set42 = asn1_DEFAULT, set43 = asn1_DEFAULT}). -record('SetIn',{boolIn, intIn}). -%-record('SetCho',{bool1, int1, set1 = asn1_DEFAULT}). -%-record('SetChoInline',{bool1, int1, set1 = asn1_DEFAULT}). -%-record('SetChoOfInline_SETOF',{bool1, int1, set1 = asn1_DEFAULT}). -record('SetEmp',{set1}). -record('Empty',{}). main(_Rules) -> + roundtrip('Set1', + #'Set1'{bool1=true,int1=17,set1=asn1_DEFAULT}, + #'Set1'{bool1=true,int1=17,set1=[]}), + roundtrip('Set1', + #'Set1'{bool1=true,int1=17, + set1=[#'SetIn'{boolIn=true,intIn=25}]}), + roundtrip('Set1', #'Set1'{bool1=true,int1=17, + set1=[#'SetIn'{boolIn=true,intIn=25}, + #'SetIn'{boolIn=false,intIn=125}, + #'SetIn'{boolIn=false,intIn=225}]}), + + roundtrip('Set2', + #'Set2'{set2=asn1_DEFAULT,bool2=true,int2=17}, + #'Set2'{set2=[],bool2=true,int2=17}), + roundtrip('Set2', + #'Set2'{set2=[#'SetIn'{boolIn=true,intIn=25}], + bool2=true,int2=17}), + roundtrip('Set2', + #'Set2'{set2=[#'SetIn'{boolIn=true,intIn=25}, + #'SetIn'{boolIn=false,intIn=125}, + #'SetIn'{boolIn=false,intIn=225}], + bool2=true,int2=17}), + + roundtrip('Set3', + #'Set3'{bool3=true,set3=asn1_DEFAULT,int3=17}, + #'Set3'{bool3=true,set3=[],int3=17}), + roundtrip('Set3', + #'Set3'{bool3=true,set3=[#'SetIn'{boolIn=true,intIn=25}], + int3=17}), + roundtrip('Set3', + #'Set3'{bool3=true, + set3=[#'SetIn'{boolIn=true,intIn=25}, + #'SetIn'{boolIn=false,intIn=125}, + #'SetIn'{boolIn=false,intIn=225}], + int3=17}), + + roundtrip('Set4', + #'Set4'{set41=asn1_DEFAULT,set42=asn1_DEFAULT, + set43=asn1_DEFAULT}, + #'Set4'{set41=[],set42=[],set43=[]}), + roundtrip('Set4', + #'Set4'{set41=[#'SetIn'{boolIn=true,intIn=25}], + set42=asn1_DEFAULT,set43=asn1_DEFAULT}, + #'Set4'{set41=[#'SetIn'{boolIn=true,intIn=25}], + set42=[],set43=[]}), + roundtrip('Set4', + #'Set4'{set41=[#'SetIn'{boolIn=true,intIn=25}, + #'SetIn'{boolIn=false,intIn=125}, + #'SetIn'{boolIn=false,intIn=225}], + set42=asn1_DEFAULT,set43=asn1_DEFAULT}, + #'Set4'{set41=[#'SetIn'{boolIn=true,intIn=25}, + #'SetIn'{boolIn=false,intIn=125}, + #'SetIn'{boolIn=false,intIn=225}], + set42=[],set43=[]}), + roundtrip('Set4', + #'Set4'{set41=asn1_DEFAULT, + set42=[#'SetIn'{boolIn=true,intIn=25}], + set43=asn1_DEFAULT}, + #'Set4'{set41=[], + set42=[#'SetIn'{boolIn=true,intIn=25}], + set43=[]}), + roundtrip('Set4', + #'Set4'{set41=asn1_DEFAULT, + set42=[#'SetIn'{boolIn=true,intIn=25}, + #'SetIn'{boolIn=false,intIn=125}, + #'SetIn'{boolIn=false,intIn=225}], + set43=asn1_DEFAULT}, + #'Set4'{set41=[], + set42=[#'SetIn'{boolIn=true,intIn=25}, + #'SetIn'{boolIn=false,intIn=125}, + #'SetIn'{boolIn=false,intIn=225}], + set43=[]}), + roundtrip('Set4', + #'Set4'{set41=asn1_DEFAULT,set42=asn1_DEFAULT, + set43=[#'SetIn'{boolIn=true,intIn=25}]}, + #'Set4'{set41=[],set42=[], + set43=[#'SetIn'{boolIn=true,intIn=25}]}), + roundtrip('Set4', + #'Set4'{set41=asn1_DEFAULT,set42=asn1_DEFAULT, + set43=[#'SetIn'{boolIn=true,intIn=25}, + #'SetIn'{boolIn=false,intIn=125}, + #'SetIn'{boolIn=false,intIn=225}]}, + #'Set4'{set41=[],set42=[], + set43=[#'SetIn'{boolIn=true,intIn=25}, + #'SetIn'{boolIn=false,intIn=125}, + #'SetIn'{boolIn=false,intIn=225}]}), + + roundtrip('SetOs', ["First","Second","Third"]), + roundtrip('SetOsImp', ["First","Second","Third"]), + roundtrip('SetOsExp', ["First","Second","Third"]), + roundtrip('SetEmp', #'SetEmp'{set1=[#'Empty'{}]}), - ?line {ok,Bytes11} = - asn1_wrapper:encode('SetOf','Set1',#'Set1'{bool1 = true, - int1 = 17}), - ?line {ok,{'Set1',true,17,[]}} = - asn1_wrapper:decode('SetOf','Set1',lists:flatten(Bytes11)), - - - ?line {ok,Bytes12} = - asn1_wrapper:encode('SetOf','Set1',#'Set1'{bool1 = true, - int1 = 17, - set1 = [#'SetIn'{boolIn = true, - intIn = 25}]}), - ?line {ok,{'Set1',true,17,[{'SetIn',true,25}]}} = - asn1_wrapper:decode('SetOf','Set1',lists:flatten(Bytes12)), - - - - ?line {ok,Bytes13} = - asn1_wrapper:encode('SetOf','Set1',#'Set1'{bool1 = true, - int1 = 17, - set1 = [#'SetIn'{boolIn = true, - intIn = 25}, - #'SetIn'{boolIn = false, - intIn = 125}, - #'SetIn'{boolIn = false, - intIn = 225}]}), - ?line {ok,{'Set1',true,17,[{'SetIn',true,25},{'SetIn',false,125},{'SetIn',false,225}]}} = - asn1_wrapper:decode('SetOf','Set1',lists:flatten(Bytes13)), - - - - - - - ?line {ok,Bytes21} = - asn1_wrapper:encode('SetOf','Set2',#'Set2'{bool2 = true, - int2 = 17}), - - ?line {ok,{'Set2',[],true,17}} = - asn1_wrapper:decode('SetOf','Set2',lists:flatten(Bytes21)), - - - ?line {ok,Bytes22} = - asn1_wrapper:encode('SetOf','Set2',#'Set2'{bool2 = true, - int2 = 17, - set2 = [#'SetIn'{boolIn = true, - intIn = 25}]}), - ?line {ok,{'Set2',[{'SetIn',true,25}],true,17}} = - asn1_wrapper:decode('SetOf','Set2',lists:flatten(Bytes22)), - - - ?line {ok,Bytes23} = - asn1_wrapper:encode('SetOf','Set2',#'Set2'{bool2 = true, - int2 = 17, - set2 = [#'SetIn'{boolIn = true, - intIn = 25}, - #'SetIn'{boolIn = false, - intIn = 125}, - #'SetIn'{boolIn = false, - intIn = 225}]}), - ?line {ok,{'Set2',[{'SetIn',true,25},{'SetIn',false,125},{'SetIn',false,225}],true,17}} = - asn1_wrapper:decode('SetOf','Set2',lists:flatten(Bytes23)), - - - - - - - ?line {ok,Bytes31} = - asn1_wrapper:encode('SetOf','Set3',#'Set3'{bool3 = true, - int3 = 17}), - ?line {ok,{'Set3',true,[],17}} = - asn1_wrapper:decode('SetOf','Set3',lists:flatten(Bytes31)), - - - ?line {ok,Bytes32} = - asn1_wrapper:encode('SetOf','Set3',#'Set3'{bool3 = true, - int3 = 17, - set3 = [#'SetIn'{boolIn = true, - intIn = 25}]}), - ?line {ok,{'Set3',true,[{'SetIn',true,25}],17}} = - asn1_wrapper:decode('SetOf','Set3',lists:flatten(Bytes32)), - - - ?line {ok,Bytes33} = - asn1_wrapper:encode('SetOf','Set3',#'Set3'{bool3 = true, - int3 = 17, - set3 = [#'SetIn'{boolIn = true, - intIn = 25}, - #'SetIn'{boolIn = false, - intIn = 125}, - #'SetIn'{boolIn = false, - intIn = 225}]}), - ?line {ok,{'Set3',true,[{'SetIn',true,25},{'SetIn',false,125},{'SetIn',false,225}],17}} = - asn1_wrapper:decode('SetOf','Set3',lists:flatten(Bytes33)), - - - - - - - - ?line {ok,Bytes41} = asn1_wrapper:encode('SetOf','Set4',#'Set4'{}), - ?line {ok,{'Set4',[],[],[]}} = asn1_wrapper:decode('SetOf','Set4',lists:flatten(Bytes41)), - - - ?line {ok,Bytes42} = - asn1_wrapper:encode('SetOf','Set4',#'Set4'{set41 = [#'SetIn'{boolIn = true, - intIn = 25}]}), - ?line {ok,{'Set4',[{'SetIn',true,25}],[],[]}} = - asn1_wrapper:decode('SetOf','Set4',lists:flatten(Bytes42)), - - - ?line {ok,Bytes43} = - asn1_wrapper:encode('SetOf','Set4',#'Set4'{set41 = [#'SetIn'{boolIn = true, - intIn = 25}, - #'SetIn'{boolIn = false, - intIn = 125}, - #'SetIn'{boolIn = false, - intIn = 225}]}), - ?line {ok,{'Set4',[{'SetIn',true,25},{'SetIn',false,125},{'SetIn',false,225}],[],[]}} = - asn1_wrapper:decode('SetOf','Set4',lists:flatten(Bytes43)), - - - ?line {ok,Bytes44} = - asn1_wrapper:encode('SetOf','Set4',#'Set4'{set42 = [#'SetIn'{boolIn = true, - intIn = 25}]}), - ?line {ok,{'Set4',[],[{'SetIn',true,25}],[]}} = - asn1_wrapper:decode('SetOf','Set4',lists:flatten(Bytes44)), - - - ?line {ok,Bytes45} = - asn1_wrapper:encode('SetOf','Set4',#'Set4'{set42 = [#'SetIn'{boolIn = true, - intIn = 25}, - #'SetIn'{boolIn = false, - intIn = 125}, - #'SetIn'{boolIn = false, - intIn = 225}]}), - ?line {ok,{'Set4',[],[{'SetIn',true,25},{'SetIn',false,125},{'SetIn',false,225}],[]}} = - asn1_wrapper:decode('SetOf','Set4',lists:flatten(Bytes45)), - - - ?line {ok,Bytes46} = - asn1_wrapper:encode('SetOf','Set4',#'Set4'{set43 = [#'SetIn'{boolIn = true, - intIn = 25}]}), - ?line {ok,{'Set4',[],[],[{'SetIn',true,25}]}} = - asn1_wrapper:decode('SetOf','Set4',lists:flatten(Bytes46)), - - - ?line {ok,Bytes47} = - asn1_wrapper:encode('SetOf','Set4',#'Set4'{set43 = [#'SetIn'{boolIn = true, - intIn = 25}, - #'SetIn'{boolIn = false, - intIn = 125}, - #'SetIn'{boolIn = false, - intIn = 225}]}), - ?line {ok,{'Set4',[],[],[{'SetIn',true,25},{'SetIn',false,125},{'SetIn',false,225}]}} = - asn1_wrapper:decode('SetOf','Set4',lists:flatten(Bytes47)), - - - - - ?line {ok,Bytes51} = asn1_wrapper:encode('SetOf','SetOs',["First","Second","Third"]), - ?line {ok,["First","Second","Third"]} = - asn1_wrapper:decode('SetOf','SetOs',lists:flatten(Bytes51)), - - ?line {ok,Bytes52} = asn1_wrapper:encode('SetOf','SetOsImp',["First","Second","Third"]), - ?line {ok,["First","Second","Third"]} = - asn1_wrapper:decode('SetOf','SetOsImp',lists:flatten(Bytes52)), - - ?line {ok,Bytes53} = asn1_wrapper:encode('SetOf','SetOsExp',["First","Second","Third"]), - ?line {ok,["First","Second","Third"]} = - asn1_wrapper:decode('SetOf','SetOsExp',lists:flatten(Bytes53)), - - - - - - - - ?line {ok,Bytes71} = asn1_wrapper:encode('SetOf','SetEmp',#'SetEmp'{set1 = [#'Empty'{}]}), - ?line {ok,{'SetEmp',[{'Empty'}]}} = asn1_wrapper:decode('SetOf','SetEmp',lists:flatten(Bytes71)), - ok. +roundtrip(T, V) -> + roundtrip(T, V, V). + +roundtrip(Type, Value, ExpectedValue) -> + asn1_test_lib:roundtrip('SetOf', Type, Value, ExpectedValue). diff --git a/lib/asn1/test/testSetOfCho.erl b/lib/asn1/test/testSetOfCho.erl index c89bf9596e..09c075e468 100644 --- a/lib/asn1/test/testSetOfCho.erl +++ b/lib/asn1/test/testSetOfCho.erl @@ -30,120 +30,46 @@ -record('SetOfChoEmbDef_SETOF',{bool1, int1, set1 = asn1_DEFAULT}). -record('SetOfChoEmbOpt_SETOF',{bool1, int1, set1 = asn1_NOVALUE}). +main(_Rules) -> + roundtrip('SetChoDef', + #'SetChoDef'{bool1=true,int1=17,set1=asn1_DEFAULT}, + #'SetChoDef'{bool1=true,int1=17,set1=[]}), + roundtrip('SetChoDef', + #'SetChoDef'{bool1=true,int1=17,set1=[{boolIn,true},{intIn,25}]}), + roundtrip('SetChoOpt', + #'SetChoOpt'{bool1=true,int1=17,set1=asn1_NOVALUE}), + roundtrip('SetChoOpt', + #'SetChoOpt'{bool1=true,int1=17,set1=[{boolIn,true},{intIn,25}]}), + roundtrip('SetChoEmbDef', + #'SetChoEmbDef'{bool1=true,int1=17,set1=asn1_DEFAULT}, + #'SetChoEmbDef'{bool1=true,int1=17,set1=[]}), + roundtrip('SetChoEmbDef', + #'SetChoEmbDef'{bool1=true,int1=17, + set1=[{boolIn,true},{intIn,25}]}), + roundtrip('SetChoEmbOpt', + #'SetChoEmbOpt'{bool1=true,int1=17,set1=asn1_NOVALUE}), + roundtrip('SetChoEmbOpt', + #'SetChoEmbOpt'{bool1=true,int1=17, + set1=[{boolIn,true},{intIn,25}]}), + + roundtrip('SetOfChoEmbDef', + [#'SetOfChoEmbDef_SETOF'{bool1=true,int1=17,set1=asn1_DEFAULT}], + [#'SetOfChoEmbDef_SETOF'{bool1=true,int1=17,set1=[]}]), + roundtrip('SetOfChoEmbDef', + [#'SetOfChoEmbDef_SETOF'{bool1=true,int1=17, + set1=[{boolIn,true},{intIn,25}]}]), + + roundtrip('SetOfChoEmbOpt', + [#'SetOfChoEmbOpt_SETOF'{bool1=true,int1=17,set1=asn1_NOVALUE}]), + roundtrip('SetOfChoEmbOpt', + [#'SetOfChoEmbOpt_SETOF'{bool1=true,int1=17, + set1=[{boolIn,true},{intIn,25}]}]), -main(_Rules) -> - - ?line {ok,Bytes11} = - asn1_wrapper:encode('SetOfCho','SetChoDef',#'SetChoDef'{bool1 = true, - int1 = 17}), - ?line {ok,{'SetChoDef',true,17,[]}} = - asn1_wrapper:decode('SetOfCho','SetChoDef',lists:flatten(Bytes11)), - - - ?line {ok,Bytes12} = - asn1_wrapper:encode('SetOfCho','SetChoDef',#'SetChoDef'{bool1 = true, - int1 = 17, - set1 = [{boolIn,true}, - {intIn,25}]}), - ?line {ok,{'SetChoDef',true,17,[{boolIn,true},{intIn,25}]}} = - asn1_wrapper:decode('SetOfCho','SetChoDef',lists:flatten(Bytes12)), - - - - ?line {ok,Bytes15} = - asn1_wrapper:encode('SetOfCho','SetChoOpt',#'SetChoOpt'{bool1 = true, - int1 = 17}), - ?line {ok,{'SetChoOpt',true,17,asn1_NOVALUE}} = - asn1_wrapper:decode('SetOfCho','SetChoOpt',lists:flatten(Bytes15)), - - - ?line {ok,Bytes16} = - asn1_wrapper:encode('SetOfCho','SetChoOpt',#'SetChoOpt'{bool1 = true, - int1 = 17, - set1 = [{boolIn,true}, - {intIn,25}]}), - ?line {ok,{'SetChoOpt',true,17,[{boolIn,true},{intIn,25}]}} = - asn1_wrapper:decode('SetOfCho','SetChoOpt',lists:flatten(Bytes16)), - - - - - - ?line {ok,Bytes21} = - asn1_wrapper:encode('SetOfCho','SetChoEmbDef',#'SetChoEmbDef'{bool1 = true, - int1 = 17}), - ?line {ok,{'SetChoEmbDef',true,17,[]}} = - asn1_wrapper:decode('SetOfCho','SetChoEmbDef',lists:flatten(Bytes21)), - - - ?line {ok,Bytes22} = - asn1_wrapper:encode('SetOfCho','SetChoEmbDef',#'SetChoEmbDef'{bool1 = true, - int1 = 17, - set1 = [{boolIn,true}, - {intIn,25}]}), - ?line {ok,{'SetChoEmbDef',true,17,[{boolIn,true},{intIn,25}]}} = - asn1_wrapper:decode('SetOfCho','SetChoEmbDef',lists:flatten(Bytes22)), - - - - ?line {ok,Bytes25} = - asn1_wrapper:encode('SetOfCho','SetChoEmbOpt',#'SetChoEmbOpt'{bool1 = true, - int1 = 17}), - ?line {ok,{'SetChoEmbOpt',true,17,asn1_NOVALUE}} = - asn1_wrapper:decode('SetOfCho','SetChoEmbOpt',lists:flatten(Bytes25)), - - - ?line {ok,Bytes26} = - asn1_wrapper:encode('SetOfCho','SetChoEmbOpt',#'SetChoEmbOpt'{bool1 = true, - int1 = 17, - set1 = [{boolIn,true}, - {intIn,25}]}), - ?line {ok,{'SetChoEmbOpt',true,17,[{boolIn,true},{intIn,25}]}} = - asn1_wrapper:decode('SetOfCho','SetChoEmbOpt',lists:flatten(Bytes26)), - - - - - - - ?line {ok,Bytes31} = - asn1_wrapper:encode('SetOfCho','SetOfChoEmbDef',[#'SetOfChoEmbDef_SETOF'{bool1 = true, - int1 = 17}]), - ?line {ok,[{'SetOfChoEmbDef_SETOF',true,17,[]}]} = - asn1_wrapper:decode('SetOfCho','SetOfChoEmbDef',lists:flatten(Bytes31)), - - - ?line {ok,Bytes32} = - asn1_wrapper:encode('SetOfCho','SetOfChoEmbDef', - [#'SetOfChoEmbDef_SETOF'{bool1 = true, - int1 = 17, - set1 = [{boolIn,true}, - {intIn,25}]}]), - ?line {ok,[{'SetOfChoEmbDef_SETOF',true,17,[{boolIn,true},{intIn,25}]}]} = - asn1_wrapper:decode('SetOfCho','SetOfChoEmbDef',lists:flatten(Bytes32)), - - - - ?line {ok,Bytes35} = - asn1_wrapper:encode('SetOfCho','SetOfChoEmbOpt',[#'SetOfChoEmbOpt_SETOF'{bool1 = true, - int1 = 17}]), - ?line {ok,[{'SetOfChoEmbOpt_SETOF',true,17,asn1_NOVALUE}]} = - asn1_wrapper:decode('SetOfCho','SetOfChoEmbOpt',lists:flatten(Bytes35)), - - - ?line {ok,Bytes36} = - asn1_wrapper:encode('SetOfCho','SetOfChoEmbOpt', - [#'SetOfChoEmbOpt_SETOF'{bool1 = true, - int1 = 17, - set1 = [{boolIn,true}, - {intIn,25}]}]), - ?line {ok,[{'SetOfChoEmbOpt_SETOF',true,17,[{boolIn,true},{intIn,25}]}]} = - asn1_wrapper:decode('SetOfCho','SetOfChoEmbOpt',lists:flatten(Bytes36)), - - - - ok. +roundtrip(T, V) -> + roundtrip(T, V, V). +roundtrip(Type, Value, ExpectedValue) -> + asn1_test_lib:roundtrip('SetOfCho', Type, Value, ExpectedValue). diff --git a/lib/asn1/test/testSetOfExternal.erl b/lib/asn1/test/testSetOfExternal.erl index 6b280a2595..a380ba5ac1 100644 --- a/lib/asn1/test/testSetOfExternal.erl +++ b/lib/asn1/test/testSetOfExternal.erl @@ -18,8 +18,6 @@ %% %% -module(testSetOfExternal). - - -export([main/1]). -include_lib("test_server/include/test_server.hrl"). @@ -29,133 +27,26 @@ -record('Imp',{os, bool}). -record('Exp',{os, bool}). - - main(_Rules) -> - - ?line {ok,Bytes11} = - asn1_wrapper:encode('SetOfExternal','NTNT',[#'NT'{bool = true, os = "kalle"}, - #'NT'{bool = true, os = "kalle"}]), - ?line {ok,[{'NT',[107,97,108,108,101],true},{'NT',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SetOfExternal','NTNT',lists:flatten(Bytes11)), - - ?line {ok,Bytes12} = - asn1_wrapper:encode('SetOfExternal','ImpNT',[#'NT'{bool = true, os = "kalle"}, - #'NT'{bool = true, os = "kalle"}]), - ?line {ok,[{'NT',[107,97,108,108,101],true},{'NT',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SetOfExternal','ImpNT',lists:flatten(Bytes12)), - - ?line {ok,Bytes13} = - asn1_wrapper:encode('SetOfExternal','ExpNT',[#'NT'{bool = true, os = "kalle"}, - #'NT'{bool = true, os = "kalle"}]), - ?line {ok,[{'NT',[107,97,108,108,101],true},{'NT',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SetOfExternal','ExpNT',lists:flatten(Bytes13)), - - - - ?line {ok,Bytes21} = - asn1_wrapper:encode('SetOfExternal','NTImp',[#'Imp'{bool = true, os = "kalle"}, - #'Imp'{bool = true, os = "kalle"}]), - ?line {ok,[{'Imp',[107,97,108,108,101],true},{'Imp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SetOfExternal','NTImp',lists:flatten(Bytes21)), - - ?line {ok,Bytes22} = - asn1_wrapper:encode('SetOfExternal','ImpImp',[#'Imp'{bool = true, os = "kalle"}, - #'Imp'{bool = true, os = "kalle"}]), - ?line {ok,[{'Imp',[107,97,108,108,101],true},{'Imp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SetOfExternal','ImpImp',lists:flatten(Bytes22)), - - ?line {ok,Bytes23} = - asn1_wrapper:encode('SetOfExternal','ExpImp',[#'Imp'{bool = true, os = "kalle"}, - #'Imp'{bool = true, os = "kalle"}]), - ?line {ok,[{'Imp',[107,97,108,108,101],true},{'Imp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SetOfExternal','ExpImp',lists:flatten(Bytes23)), - - - - ?line {ok,Bytes31} = - asn1_wrapper:encode('SetOfExternal','NTExp',[#'Exp'{bool = true, os = "kalle"}, - #'Exp'{bool = true, os = "kalle"}]), - ?line {ok,[{'Exp',[107,97,108,108,101],true},{'Exp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SetOfExternal','NTExp',lists:flatten(Bytes31)), - - ?line {ok,Bytes32} = - asn1_wrapper:encode('SetOfExternal','ImpExp',[#'Exp'{bool = true, os = "kalle"}, - #'Exp'{bool = true, os = "kalle"}]), - ?line {ok,[{'Exp',[107,97,108,108,101],true},{'Exp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SetOfExternal','ImpExp',lists:flatten(Bytes32)), - - ?line {ok,Bytes33} = - asn1_wrapper:encode('SetOfExternal','ExpExp',[#'Exp'{bool = true, os = "kalle"}, - #'Exp'{bool = true, os = "kalle"}]), - ?line {ok,[{'Exp',[107,97,108,108,101],true},{'Exp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SetOfExternal','ExpExp',lists:flatten(Bytes33)), - - - - - - - - ?line {ok,Bytes41} = - asn1_wrapper:encode('SetOfExternal','XNTNT',[#'XSetNT'{bool = true, os = "kalle"}, - #'XSetNT'{bool = true, os = "kalle"}]), - ?line {ok,[{'XSetNT',[107,97,108,108,101],true},{'XSetNT',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SetOfExternal','XNTNT',lists:flatten(Bytes41)), - - ?line {ok,Bytes42} = - asn1_wrapper:encode('SetOfExternal','XImpNT',[#'XSetNT'{bool = true, os = "kalle"}, - #'XSetNT'{bool = true, os = "kalle"}]), - ?line {ok,[{'XSetNT',[107,97,108,108,101],true},{'XSetNT',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SetOfExternal','XImpNT',lists:flatten(Bytes42)), - - ?line {ok,Bytes43} = - asn1_wrapper:encode('SetOfExternal','XExpNT',[#'XSetNT'{bool = true, os = "kalle"}, - #'XSetNT'{bool = true, os = "kalle"}]), - ?line {ok,[{'XSetNT',[107,97,108,108,101],true},{'XSetNT',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SetOfExternal','XExpNT',lists:flatten(Bytes43)), - - - - ?line {ok,Bytes51} = - asn1_wrapper:encode('SetOfExternal','XNTImp',[#'XSetImp'{bool = true, os = "kalle"}, - #'XSetImp'{bool = true, os = "kalle"}]), - ?line {ok,[{'XSetImp',[107,97,108,108,101],true},{'XSetImp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SetOfExternal','XNTImp',lists:flatten(Bytes51)), - - ?line {ok,Bytes52} = - asn1_wrapper:encode('SetOfExternal','XImpImp',[#'XSetImp'{bool = true, os = "kalle"}, - #'XSetImp'{bool = true, os = "kalle"}]), - ?line {ok,[{'XSetImp',[107,97,108,108,101],true},{'XSetImp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SetOfExternal','XImpImp',lists:flatten(Bytes52)), - - ?line {ok,Bytes53} = - asn1_wrapper:encode('SetOfExternal','XExpImp',[#'XSetImp'{bool = true, os = "kalle"}, - #'XSetImp'{bool = true, os = "kalle"}]), - ?line {ok,[{'XSetImp',[107,97,108,108,101],true},{'XSetImp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SetOfExternal','XExpImp',lists:flatten(Bytes53)), - - - - ?line {ok,Bytes61} = - asn1_wrapper:encode('SetOfExternal','XNTExp',[#'XSetExp'{bool = true, os = "kalle"}, - #'XSetExp'{bool = true, os = "kalle"}]), - ?line {ok,[{'XSetExp',[107,97,108,108,101],true},{'XSetExp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SetOfExternal','XNTExp',lists:flatten(Bytes61)), - - ?line {ok,Bytes62} = - asn1_wrapper:encode('SetOfExternal','XImpExp',[#'XSetExp'{bool = true, os = "kalle"}, - #'XSetExp'{bool = true, os = "kalle"}]), - ?line {ok,[{'XSetExp',[107,97,108,108,101],true},{'XSetExp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SetOfExternal','XImpExp',lists:flatten(Bytes62)), - - ?line {ok,Bytes63} = - asn1_wrapper:encode('SetOfExternal','XExpExp',[#'XSetExp'{bool = true, os = "kalle"}, - #'XSetExp'{bool = true, os = "kalle"}]), - ?line {ok,[{'XSetExp',[107,97,108,108,101],true},{'XSetExp',[107,97,108,108,101],true}]} = - asn1_wrapper:decode('SetOfExternal','XExpExp',lists:flatten(Bytes63)), - - - - + roundtrip('NTNT', [#'NT'{os="kalle",bool=true},#'NT'{os="kalle",bool=true}]), + roundtrip('ImpNT', [#'NT'{os="kalle",bool=true},#'NT'{os="kalle",bool=true}]), + roundtrip('ExpNT', [#'NT'{os="kalle",bool=true},#'NT'{os="kalle",bool=true}]), + roundtrip('NTImp', [#'Imp'{os="kalle",bool=true},#'Imp'{os="kalle",bool=true}]), + roundtrip('ImpImp', [#'Imp'{os="kalle",bool=true},#'Imp'{os="kalle",bool=true}]), + roundtrip('ExpImp', [#'Imp'{os="kalle",bool=true},#'Imp'{os="kalle",bool=true}]), + roundtrip('NTExp', [#'Exp'{os="kalle",bool=true},#'Exp'{os="kalle",bool=true}]), + roundtrip('ImpExp', [#'Exp'{os="kalle",bool=true},#'Exp'{os="kalle",bool=true}]), + roundtrip('ExpExp', [#'Exp'{os="kalle",bool=true},#'Exp'{os="kalle",bool=true}]), + roundtrip('XNTNT', [#'XSetNT'{os="kalle",bool=true},#'XSetNT'{os="kalle",bool=true}]), + roundtrip('XImpNT', [#'XSetNT'{os="kalle",bool=true},#'XSetNT'{os="kalle",bool=true}]), + roundtrip('XExpNT', [#'XSetNT'{os="kalle",bool=true},#'XSetNT'{os="kalle",bool=true}]), + roundtrip('XNTImp', [#'XSetImp'{os="kalle",bool=true},#'XSetImp'{os="kalle",bool=true}]), + roundtrip('XImpImp', [#'XSetImp'{os="kalle",bool=true},#'XSetImp'{os="kalle",bool=true}]), + roundtrip('XExpImp', [#'XSetImp'{os="kalle",bool=true},#'XSetImp'{os="kalle",bool=true}]), + roundtrip('XNTExp', [#'XSetExp'{os="kalle",bool=true},#'XSetExp'{os="kalle",bool=true}]), + roundtrip('XImpExp', [#'XSetExp'{os="kalle",bool=true},#'XSetExp'{os="kalle",bool=true}]), + roundtrip('XExpExp', [#'XSetExp'{os="kalle",bool=true},#'XSetExp'{os="kalle",bool=true}]), ok. + +roundtrip(T, V) -> + asn1_test_lib:roundtrip('SetOfExternal', T, V). diff --git a/lib/asn1/test/testSetOfTag.erl b/lib/asn1/test/testSetOfTag.erl index 2c7a2f5473..81bc467abb 100644 --- a/lib/asn1/test/testSetOfTag.erl +++ b/lib/asn1/test/testSetOfTag.erl @@ -18,14 +18,11 @@ %% %% -module(testSetOfTag). - - -export([main/1]). -include_lib("test_server/include/test_server.hrl"). -include("External.hrl"). - -record('SetTagNt',{nt}). -record('SetTagNtI',{imp}). -record('SetTagNtE',{exp}). @@ -44,148 +41,44 @@ -record('Imp',{os, bool}). -record('Exp',{os, bool}). - - main(_Rules) -> - - ?line {ok,Bytes11} = - asn1_wrapper:encode('SetOfTag','SetTagNt', - #'SetTagNt'{nt = [#'NT'{bool = true, os = "kalle"}, - #'NT'{bool = true, os = "kalle"}]}), - ?line {ok,{'SetTagNt', - [{'NT',[107,97,108,108,101],true},{'NT',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SetOfTag','SetTagNt',lists:flatten(Bytes11)), - - ?line {ok,Bytes12} = - asn1_wrapper:encode('SetOfTag','SetTagNtI', - #'SetTagNtI'{imp = [#'Imp'{bool = true, os = "kalle"}, - #'Imp'{bool = true, os = "kalle"}]}), - ?line {ok,{'SetTagNtI', - [{'Imp',[107,97,108,108,101],true},{'Imp',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SetOfTag','SetTagNtI',lists:flatten(Bytes12)), - - ?line {ok,Bytes13} = - asn1_wrapper:encode('SetOfTag','SetTagNtE', - #'SetTagNtE'{exp = [#'Exp'{bool = true, os = "kalle"}, - #'Exp'{bool = true, os = "kalle"}]}), - ?line {ok,{'SetTagNtE', - [{'Exp',[107,97,108,108,101],true},{'Exp',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SetOfTag','SetTagNtE',lists:flatten(Bytes13)), - - - - ?line {ok,Bytes21} = - asn1_wrapper:encode('SetOfTag','SetTagI', - #'SetTagI'{nt = [#'NT'{bool = true, os = "kalle"}, - #'NT'{bool = true, os = "kalle"}]}), - ?line {ok,{'SetTagI', - [{'NT',[107,97,108,108,101],true},{'NT',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SetOfTag','SetTagI',lists:flatten(Bytes21)), - - ?line {ok,Bytes22} = - asn1_wrapper:encode('SetOfTag','SetTagII', - #'SetTagII'{imp = [#'Imp'{bool = true, os = "kalle"}, - #'Imp'{bool = true, os = "kalle"}]}), - ?line {ok,{'SetTagII', - [{'Imp',[107,97,108,108,101],true},{'Imp',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SetOfTag','SetTagII',lists:flatten(Bytes22)), - - ?line {ok,Bytes23} = - asn1_wrapper:encode('SetOfTag','SetTagIE', - #'SetTagIE'{exp = [#'Exp'{bool = true, os = "kalle"}, - #'Exp'{bool = true, os = "kalle"}]}), - ?line {ok,{'SetTagIE', - [{'Exp',[107,97,108,108,101],true},{'Exp',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SetOfTag','SetTagIE',lists:flatten(Bytes23)), - - - - ?line {ok,Bytes31} = - asn1_wrapper:encode('SetOfTag','SetTagE', - #'SetTagE'{nt = [#'NT'{bool = true, os = "kalle"}, - #'NT'{bool = true, os = "kalle"}]}), - ?line {ok,{'SetTagE', - [{'NT',[107,97,108,108,101],true},{'NT',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SetOfTag','SetTagE',lists:flatten(Bytes31)), - - ?line {ok,Bytes32} = - asn1_wrapper:encode('SetOfTag','SetTagEI', - #'SetTagEI'{imp = [#'Imp'{bool = true, os = "kalle"}, - #'Imp'{bool = true, os = "kalle"}]}), - ?line {ok,{'SetTagEI', - [{'Imp',[107,97,108,108,101],true},{'Imp',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SetOfTag','SetTagEI',lists:flatten(Bytes32)), - - ?line {ok,Bytes33} = - asn1_wrapper:encode('SetOfTag','SetTagEE', - #'SetTagEE'{exp = [#'Exp'{bool = true, os = "kalle"}, - #'Exp'{bool = true, os = "kalle"}]}), - ?line {ok,{'SetTagEE', - [{'Exp',[107,97,108,108,101],true},{'Exp',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SetOfTag','SetTagEE',lists:flatten(Bytes33)), - - - - - - - - ?line {ok,Bytes41} = - asn1_wrapper:encode('SetOfTag','SetTagXNt', - #'SetTagXNt'{xnt = [#'XSetNT'{bool = true, os = "kalle"}, - #'XSetNT'{bool = true, os = "kalle"}]}), - ?line {ok,{'SetTagXNt', - [{'XSetNT',[107,97,108,108,101],true},{'XSetNT',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SetOfTag','SetTagXNt',lists:flatten(Bytes41)), - - ?line {ok,Bytes42} = - asn1_wrapper:encode('SetOfTag','SetTagXI', - #'SetTagXI'{ximp = [#'XSetImp'{bool = true, os = "kalle"}, - #'XSetImp'{bool = true, os = "kalle"}]}), - ?line {ok,{'SetTagXI', - [{'XSetImp',[107,97,108,108,101],true},{'XSetImp',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SetOfTag','SetTagXI',lists:flatten(Bytes42)), - - ?line {ok,Bytes43} = - asn1_wrapper:encode('SetOfTag','SetTagXE', - #'SetTagXE'{xexp = [#'XSetExp'{bool = true, os = "kalle"}, - #'XSetExp'{bool = true, os = "kalle"}]}), - ?line {ok,{'SetTagXE', - [{'XSetExp',[107,97,108,108,101],true},{'XSetExp',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SetOfTag','SetTagXE',lists:flatten(Bytes43)), - - - - - - ?line {ok,Bytes51} = - asn1_wrapper:encode('SetOfTag','SetTagImpX', - #'SetTagImpX'{xnt = [#'XSetNT'{bool = true, os = "kalle"}, - #'XSetNT'{bool = true, os = "kalle"}], - ximp = [#'XSetImp'{bool = true, os = "kalle"}, - #'XSetImp'{bool = true, os = "kalle"}], - xexp = [#'XSetExp'{bool = true, os = "kalle"}, - #'XSetExp'{bool = true, os = "kalle"}]}), - ?line {ok,{'SetTagImpX', - [{'XSetNT',[107,97,108,108,101],true},{'XSetNT',[107,97,108,108,101],true}], - [{'XSetImp',[107,97,108,108,101],true},{'XSetImp',[107,97,108,108,101],true}], - [{'XSetExp',[107,97,108,108,101],true},{'XSetExp',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SetOfTag','SetTagImpX',lists:flatten(Bytes51)), - - - - ?line {ok,Bytes52} = - asn1_wrapper:encode('SetOfTag','SetTagExpX', - #'SetTagExpX'{xnt = [#'XSetNT'{bool = true, os = "kalle"}, - #'XSetNT'{bool = true, os = "kalle"}], - ximp = [#'XSetImp'{bool = true, os = "kalle"}, - #'XSetImp'{bool = true, os = "kalle"}], - xexp = [#'XSetExp'{bool = true, os = "kalle"}, - #'XSetExp'{bool = true, os = "kalle"}]}), - ?line {ok,{'SetTagExpX', - [{'XSetNT',[107,97,108,108,101],true},{'XSetNT',[107,97,108,108,101],true}], - [{'XSetImp',[107,97,108,108,101],true},{'XSetImp',[107,97,108,108,101],true}], - [{'XSetExp',[107,97,108,108,101],true},{'XSetExp',[107,97,108,108,101],true}]}} = - asn1_wrapper:decode('SetOfTag','SetTagExpX',lists:flatten(Bytes52)), - + roundtrip('SetTagNt', #'SetTagNt'{nt=[#'NT'{os="kalle",bool=true}, + #'NT'{os="kalle",bool=true}]}), + roundtrip('SetTagNtI', #'SetTagNtI'{imp=[#'Imp'{os="kalle",bool=true}, + #'Imp'{os="kalle",bool=true}]}), + roundtrip('SetTagNtE', #'SetTagNtE'{exp=[#'Exp'{os="kalle",bool=true}, + #'Exp'{os="kalle",bool=true}]}), + roundtrip('SetTagI', #'SetTagI'{nt=[#'NT'{os="kalle",bool=true}, + #'NT'{os="kalle",bool=true}]}), + roundtrip('SetTagII', #'SetTagII'{imp=[#'Imp'{os="kalle",bool=true}, + #'Imp'{os="kalle",bool=true}]}), + roundtrip('SetTagIE', #'SetTagIE'{exp=[#'Exp'{os="kalle",bool=true}, + #'Exp'{os="kalle",bool=true}]}), + roundtrip('SetTagE', #'SetTagE'{nt=[#'NT'{os="kalle",bool=true}, + #'NT'{os="kalle",bool=true}]}), + roundtrip('SetTagEI', #'SetTagEI'{imp=[#'Imp'{os="kalle",bool=true}, + #'Imp'{os="kalle",bool=true}]}), + roundtrip('SetTagEE', #'SetTagEE'{exp=[#'Exp'{os="kalle",bool=true}, + #'Exp'{os="kalle",bool=true}]}), + roundtrip('SetTagXNt', #'SetTagXNt'{xnt=[#'XSetNT'{os="kalle",bool=true}, + #'XSetNT'{os="kalle",bool=true}]}), + roundtrip('SetTagXI', #'SetTagXI'{ximp=[#'XSetImp'{os="kalle",bool=true}, + #'XSetImp'{os="kalle",bool=true}]}), + roundtrip('SetTagXE', #'SetTagXE'{xexp=[#'XSetExp'{os="kalle",bool=true}, + #'XSetExp'{os="kalle",bool=true}]}), + roundtrip('SetTagImpX', #'SetTagImpX'{xnt=[#'XSetNT'{os="kalle",bool=true}, + #'XSetNT'{os="kalle",bool=true}], + ximp=[#'XSetImp'{os="kalle",bool=true}, + #'XSetImp'{os="kalle",bool=true}], + xexp=[#'XSetExp'{os="kalle",bool=true}, + #'XSetExp'{os="kalle",bool=true}]}), + roundtrip('SetTagExpX', #'SetTagExpX'{xnt=[#'XSetNT'{os="kalle",bool=true}, + #'XSetNT'{os="kalle",bool=true}], + ximp=[#'XSetImp'{os="kalle",bool=true}, + #'XSetImp'{os="kalle",bool=true}], + xexp=[#'XSetExp'{os="kalle",bool=true}, + #'XSetExp'{os="kalle",bool=true}]}), ok. + +roundtrip(T, V) -> + asn1_test_lib:roundtrip('SetOfTag', T, V). diff --git a/lib/asn1/test/testSetPrim.erl b/lib/asn1/test/testSetPrim.erl index 3234b65135..f417f343a7 100644 --- a/lib/asn1/test/testSetPrim.erl +++ b/lib/asn1/test/testSetPrim.erl @@ -27,59 +27,17 @@ -record('Empty',{}). main(_Rules) -> - - - - ?line {ok,Bytes11} = - asn1_wrapper:encode('SetPrim','Set',#'Set'{bool = true, - boolCon = true, - boolPri = true, - boolApp = true, - boolExpCon = true, - boolExpPri = true, - boolExpApp = true}), - ?line {ok,{'Set',true,true,true,true,true,true,true}} = - asn1_wrapper:decode('SetPrim','Set',lists:flatten(Bytes11)), - - - - - ?line {ok,Bytes12} = - asn1_wrapper:encode('SetPrim','Set',#'Set'{bool = false, - boolCon = false, - boolPri = false, - boolApp = false, - boolExpCon = false, - boolExpPri = false, - boolExpApp = false}), - ?line {ok,{'Set',false,false,false,false,false,false,false}} = - asn1_wrapper:decode('SetPrim','Set',lists:flatten(Bytes12)), - - - - - ?line {ok,Bytes13} = - asn1_wrapper:encode('SetPrim','Set',#'Set'{bool = false, - boolCon = true, - boolPri = false, - boolApp = true, - boolExpCon = false, - boolExpPri = true, - boolExpApp = false}), - ?line {ok,{'Set',false,true,false,true,false,true,false}} = - asn1_wrapper:decode('SetPrim','Set',lists:flatten(Bytes13)), - - - - - - ?line {ok,Bytes21} = - asn1_wrapper:encode('SetPrim','Empty',#'Empty'{}), - ?line {ok,{'Empty'}} = - asn1_wrapper:decode('SetPrim','Empty',lists:flatten(Bytes21)), - - - + roundtrip('Set', + #'Set'{bool=true,boolCon=true,boolPri=true,boolApp=true, + boolExpCon=true,boolExpPri=true,boolExpApp=true}), + roundtrip('Set', + #'Set'{bool=false,boolCon=false,boolPri=false,boolApp=false, + boolExpCon=false,boolExpPri=false,boolExpApp=false}), + roundtrip('Set', + #'Set'{bool=false,boolCon=true,boolPri=false,boolApp=true, + boolExpCon=false,boolExpPri=true,boolExpApp=false}), + roundtrip('Empty', #'Empty'{}), ok. - +roundtrip(T, V) -> + asn1_test_lib:roundtrip('SetPrim', T, V). diff --git a/lib/asn1/test/testSetTag.erl b/lib/asn1/test/testSetTag.erl index 8b9364d603..5863a149b9 100644 --- a/lib/asn1/test/testSetTag.erl +++ b/lib/asn1/test/testSetTag.erl @@ -18,7 +18,6 @@ %% %% -module(testSetTag). - -export([main/1]). -include_lib("test_server/include/test_server.hrl"). @@ -35,69 +34,25 @@ -record('Exp',{os, bool}). main(_Rules) -> - - - ?line {ok,Bytes11} = - asn1_wrapper:encode('SetTag','SetTag',#'SetTag'{nt = #'NT'{bool = true, os = "kalle"}, - imp = #'Imp'{bool = true, os = "kalle"}, - exp = #'Exp'{bool = true, os = "kalle"}}), - ?line {ok,{'SetTag',{'NT',"kalle",true},{'Imp',"kalle",true},{'Exp',"kalle",true}}} = - asn1_wrapper:decode('SetTag','SetTag',lists:flatten(Bytes11)), - - - ?line {ok,Bytes12} = - asn1_wrapper:encode('SetTag','SetTagImp',#'SetTagImp'{nt = #'NT'{bool = true, os = "kalle"}, - imp = #'Imp'{bool = true, os = "kalle"}, - exp = #'Exp'{bool = true, os = "kalle"}}), - ?line {ok,{'SetTagImp',{'NT',"kalle",true},{'Imp',"kalle",true},{'Exp',"kalle",true}}} = - asn1_wrapper:decode('SetTag','SetTagImp',lists:flatten(Bytes12)), - - - ?line {ok,Bytes13} = - asn1_wrapper:encode('SetTag','SetTagExp',#'SetTagExp'{nt = #'NT'{bool = true, os = "kalle"}, - imp = #'Imp'{bool = true, os = "kalle"}, - exp = #'Exp'{bool = true, os = "kalle"}}), - ?line {ok,{'SetTagExp',{'NT',"kalle",true},{'Imp',"kalle",true},{'Exp',"kalle",true}}} = - asn1_wrapper:decode('SetTag','SetTagExp',lists:flatten(Bytes13)), - - - - - - ?line {ok,Bytes21} = - asn1_wrapper:encode('SetTag','SetTagX', - #'SetTagX'{xnt = #'XSetNT'{bool = true, os = "kalle"}, - ximp = #'XSetImp'{bool = true, os = "kalle"}, - xexp = #'XSetExp'{bool = true, os = "kalle"}}), - ?line {ok,{'SetTagX',{'XSetNT',"kalle",true}, - {'XSetImp',"kalle",true}, - {'XSetExp',"kalle",true}}} = - asn1_wrapper:decode('SetTag','SetTagX',lists:flatten(Bytes21)), - - - ?line {ok,Bytes22} = - asn1_wrapper:encode('SetTag','SetTagImpX', - #'SetTagImpX'{xnt = #'XSetNT'{bool = true, os = "kalle"}, - ximp = #'XSetImp'{bool = true, os = "kalle"}, - xexp = #'XSetExp'{bool = true, os = "kalle"}}), - ?line {ok,{'SetTagImpX',{'XSetNT',"kalle",true}, - {'XSetImp',"kalle",true}, - {'XSetExp',"kalle",true}}} = - asn1_wrapper:decode('SetTag','SetTagImpX',lists:flatten(Bytes22)), - - - ?line {ok,Bytes23} = - asn1_wrapper:encode('SetTag','SetTagExpX', - #'SetTagExpX'{xnt = #'XSetNT'{bool = true, os = "kalle"}, - ximp = #'XSetImp'{bool = true, os = "kalle"}, - xexp = #'XSetExp'{bool = true, os = "kalle"}}), - ?line {ok,{'SetTagExpX',{'XSetNT',"kalle",true}, - {'XSetImp',"kalle",true}, - {'XSetExp',"kalle",true}}} = - asn1_wrapper:decode('SetTag','SetTagExpX',lists:flatten(Bytes23)), - - - - - + roundtrip('SetTag', #'SetTag'{nt=#'NT'{os="kalle",bool=true}, + imp=#'Imp'{os="kalle",bool=true}, + exp=#'Exp'{os="kalle",bool=true}}), + roundtrip('SetTagImp', #'SetTagImp'{nt=#'NT'{os="kalle",bool=true}, + imp=#'Imp'{os="kalle",bool=true}, + exp=#'Exp'{os="kalle",bool=true}}), + roundtrip('SetTagExp', #'SetTagExp'{nt=#'NT'{os="kalle",bool=true}, + imp=#'Imp'{os="kalle",bool=true}, + exp=#'Exp'{os="kalle",bool=true}}), + roundtrip('SetTagX', #'SetTagX'{xnt=#'XSetNT'{os="kalle",bool=true}, + ximp=#'XSetImp'{os="kalle",bool=true}, + xexp=#'XSetExp'{os="kalle",bool=true}}), + roundtrip('SetTagImpX', #'SetTagImpX'{xnt=#'XSetNT'{os="kalle",bool=true}, + ximp=#'XSetImp'{os="kalle",bool=true}, + xexp=#'XSetExp'{os="kalle",bool=true}}), + roundtrip('SetTagExpX', #'SetTagExpX'{xnt=#'XSetNT'{os="kalle",bool=true}, + ximp=#'XSetImp'{os="kalle",bool=true}, + xexp=#'XSetExp'{os="kalle",bool=true}}), ok. + +roundtrip(T, V) -> + asn1_test_lib:roundtrip('SetTag', T, V). diff --git a/lib/asn1/test/testSetTypeRefCho.erl b/lib/asn1/test/testSetTypeRefCho.erl index a0989926c7..8d62f45bfa 100644 --- a/lib/asn1/test/testSetTypeRefCho.erl +++ b/lib/asn1/test/testSetTypeRefCho.erl @@ -28,17 +28,12 @@ main(_Rules) -> - - - ?line {ok,Bytes11} = - asn1_wrapper:encode('SetTypeRefCho','SetTRcho', - #'SetTRcho'{'setCho' = {choOs,"A string 1"}, - 'setChoE' = {choOs,"A string 3"}, - 'setCho-E' = {choOs,"A string 7"}, - 'setChoE-E' = {choOs,"A string 9"}}), - ?line {ok,{'SetTRcho',{choOs,"A string 1"},{choOs,"A string 3"},{choOs,"A string 7"},{choOs,"A string 9"}}} = - asn1_wrapper:decode('SetTypeRefCho','SetTRcho',lists:flatten(Bytes11)), - - - + roundtrip('SetTRcho', + #'SetTRcho'{'setCho' = {choOs,"A string 1"}, + 'setChoE' = {choOs,"A string 3"}, + 'setCho-E' = {choOs,"A string 7"}, + 'setChoE-E' = {choOs,"A string 9"}}), ok. + +roundtrip(T, V) -> + asn1_test_lib:roundtrip('SetTypeRefCho', T, V). diff --git a/lib/asn1/test/testSetTypeRefPrim.erl b/lib/asn1/test/testSetTypeRefPrim.erl index 9c7fbd803e..cc2e157e68 100644 --- a/lib/asn1/test/testSetTypeRefPrim.erl +++ b/lib/asn1/test/testSetTypeRefPrim.erl @@ -27,21 +27,17 @@ main(_Rules) -> - - - ?line {ok,Bytes11} = - asn1_wrapper:encode('SetTypeRefPrim','SetTR',#'SetTR'{'octStr' = "A string 1", - 'octStrI' = "A string 2", - 'octStrE' = "A string 3", - 'octStr-I' = "A string 4", - 'octStrI-I' = "A string 5", - 'octStrE-I' = "A string 6", - 'octStr-E' = "A string 7", - 'octStrI-E' = "A string 8", - 'octStrE-E' = "A string 9"}), - ?line {ok,{'SetTR',"A string 1","A string 2","A string 3","A string 4","A string 5","A string 6","A string 7","A string 8","A string 9"}} = - asn1_wrapper:decode('SetTypeRefPrim','SetTR',lists:flatten(Bytes11)), - - - + roundtrip('SetTR', + #'SetTR'{'octStr' = "A string 1", + 'octStrI' = "A string 2", + 'octStrE' = "A string 3", + 'octStr-I' = "A string 4", + 'octStrI-I' = "A string 5", + 'octStrE-I' = "A string 6", + 'octStr-E' = "A string 7", + 'octStrI-E' = "A string 8", + 'octStrE-E' = "A string 9"}), ok. + +roundtrip(T, V) -> + asn1_test_lib:roundtrip('SetTypeRefPrim', T, V). diff --git a/lib/asn1/test/testSetTypeRefSeq.erl b/lib/asn1/test/testSetTypeRefSeq.erl index a3ef4b188d..17af5c2922 100644 --- a/lib/asn1/test/testSetTypeRefSeq.erl +++ b/lib/asn1/test/testSetTypeRefSeq.erl @@ -28,12 +28,8 @@ -record('SetSeqImp',{seqInt, seqOs}). -record('SetSeqExp',{seqInt, seqOs}). - - main(_Rules) -> - - ?line {ok,Bytes41} = - asn1_wrapper:encode('SetTypeRefSeq','SetTRseq', + roundtrip('SetTRseq', #'SetTRseq'{'setSeq' = #'SetSeq'{seqOs = "A1", seqInt = 2}, 'setSeqI' = #'SetSeq'{seqOs = "A2", @@ -52,15 +48,7 @@ main(_Rules) -> seqInt = 2}, 'setSeqE-E' = #'SetSeqExp'{seqOs = "A9", seqInt = 2}}), - ?line {ok,{'SetTRseq',{'SetSeq',2,"A1"}, - {'SetSeq',2,"A2"}, - {'SetSeq',2,"A3"}, - {'SetSeqImp',2,"A4"}, - {'SetSeqImp',2,"A5"}, - {'SetSeqImp',2,"A6"}, - {'SetSeqExp',2,"A7"}, - {'SetSeqExp',2,"A8"}, - {'SetSeqExp',2,"A9"}}} = - asn1_wrapper:decode('SetTypeRefSeq','SetTRseq',lists:flatten(Bytes41)), - ok. + +roundtrip(T, V) -> + asn1_test_lib:roundtrip('SetTypeRefSeq', T, V). diff --git a/lib/asn1/test/testSetTypeRefSet.erl b/lib/asn1/test/testSetTypeRefSet.erl index ce77316ef8..8786e0fb4d 100644 --- a/lib/asn1/test/testSetTypeRefSet.erl +++ b/lib/asn1/test/testSetTypeRefSet.erl @@ -46,131 +46,42 @@ main(_Rules) -> - - - ?line {ok,Bytes11} = - asn1_wrapper:encode('SetTypeRefSet','Set1',#'Set1'{bool1 = true, - int1 = 15, - set1 = #'SetIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'Set1',true,15,{'SetIn',true,66}}} = - asn1_wrapper:decode('SetTypeRefSet','Set1',lists:flatten(Bytes11)), - - - - ?line {ok,Bytes12} = - asn1_wrapper:encode('SetTypeRefSet','Set2',#'Set2'{set2 = #'SetIn'{boolIn = true, - intIn = 66}, - bool2 = true, - int2 = 15}), - ?line {ok,{'Set2',{'SetIn',true,66},true,15}} = - asn1_wrapper:decode('SetTypeRefSet','Set2',lists:flatten(Bytes12)), - - - ?line {ok,Bytes13} = - asn1_wrapper:encode('SetTypeRefSet','Set3',#'Set3'{bool3 = true, - set3 = #'SetIn'{boolIn = true, - intIn = 66}, - int3 = 15}), - ?line {ok,{'Set3',true,{'SetIn',true,66},15}} = - asn1_wrapper:decode('SetTypeRefSet','Set3',lists:flatten(Bytes13)), - - - - ?line {ok,Bytes14} = - asn1_wrapper:encode('SetTypeRefSet','Set4',#'Set4'{set41 = #'SetIn'{boolIn = true, - intIn = 66}, - set42 = #'SetIn'{boolIn = true, - intIn = 66}, - set43 = #'SetIn'{boolIn = true, - intIn = 66}}), - ?line {ok,{'Set4',{'SetIn',true,66},{'SetIn',true,66},{'SetIn',true,66}}} = - asn1_wrapper:decode('SetTypeRefSet','Set4',lists:flatten(Bytes14)), - - - - - - - - - ?line {ok,Bytes21} = - asn1_wrapper:encode('SetTypeRefSet','SetS1',#'SetS1'{boolS1 = true, - intS1 = 15, - setS1 = #'SetS1_setS1'{boolIn = true, - intIn = 66}}), - ?line {ok,{'SetS1',true,15,{'SetS1_setS1',true,66}}} = - asn1_wrapper:decode('SetTypeRefSet','SetS1',lists:flatten(Bytes21)), - - - ?line {ok,Bytes22} = - asn1_wrapper:encode('SetTypeRefSet','SetS2',#'SetS2'{setS2 = #'SetS2_setS2'{boolIn = true, - intIn = 66}, - boolS2 = true, - intS2 = 15}), - ?line {ok,{'SetS2',{'SetS2_setS2',true,66},true,15}} = - asn1_wrapper:decode('SetTypeRefSet','SetS2',lists:flatten(Bytes22)), - - - - ?line {ok,Bytes23} = - asn1_wrapper:encode('SetTypeRefSet','SetS3',#'SetS3'{boolS3 = true, - setS3 = #'SetS3_setS3'{boolIn = true, - intIn = 66}, - intS3 = 15}), - ?line {ok,{'SetS3',true,{'SetS3_setS3',true,66},15}} = - asn1_wrapper:decode('SetTypeRefSet','SetS3',lists:flatten(Bytes23)), - - - - - - - ?line {ok,Bytes31} = - asn1_wrapper:encode('SetTypeRefSet','SetSTag',#'SetSTag'{setS1 = #'SetSTag_setS1'{b1 = true, - i1 = 11}, - setS2 = #'SetSTag_setS2'{b2 = true, - i2 = 22}, - setS3 = #'SetSTag_setS3'{b3 = true, - i3 = 33}}), - ?line {ok,{'SetSTag',{'SetSTag_setS1',true,11}, - {'SetSTag_setS2',true,22}, - {'SetSTag_setS3',true,33}}} = - asn1_wrapper:decode('SetTypeRefSet','SetSTag',lists:flatten(Bytes31)), - - - - - - ?line {ok,Bytes41} = - asn1_wrapper:encode('SetTypeRefSet','SetTRset', - #'SetTRset'{'setSet' = #'SetSet'{setOs = "A1", - setInt = 2}, - 'setSetI' = #'SetSet'{setOs = "A2", - setInt = 2}, - 'setSetE' = #'SetSet'{setOs = "A3", - setInt = 2}, - 'setSet-I' = #'SetSetImp'{setOs = "A4", - setInt = 2}, - 'setSetI-I' = #'SetSetImp'{setOs = "A5", - setInt = 2}, - 'setSetE-I' = #'SetSetImp'{setOs = "A6", - setInt = 2}, - 'setSet-E' = #'SetSetExp'{setOs = "A7", - setInt = 2}, - 'setSetI-E' = #'SetSetExp'{setOs = "A8", - setInt = 2}, - 'setSetE-E' = #'SetSetExp'{setOs = "A9", - setInt = 2}}), - ?line {ok,{'SetTRset',{'SetSet',2,"A1"}, - {'SetSet',2,"A2"}, - {'SetSet',2,"A3"}, - {'SetSetImp',2,"A4"}, - {'SetSetImp',2,"A5"}, - {'SetSetImp',2,"A6"}, - {'SetSetExp',2,"A7"}, - {'SetSetExp',2,"A8"}, - {'SetSetExp',2,"A9"}}} = - asn1_wrapper:decode('SetTypeRefSet','SetTRset',lists:flatten(Bytes41)), + roundtrip('Set1', + #'Set1'{bool1=true,int1=15,set1=#'SetIn'{boolIn=true,intIn=66}}), + roundtrip('Set2', + #'Set2'{set2=#'SetIn'{boolIn=true,intIn=66},bool2=true,int2=15}), + roundtrip('Set3', + #'Set3'{bool3=true,set3=#'SetIn'{boolIn=true,intIn=66},int3=15}), + roundtrip('Set4', + #'Set4'{set41=#'SetIn'{boolIn=true,intIn=66}, + set42=#'SetIn'{boolIn=true,intIn=66}, + set43=#'SetIn'{boolIn=true,intIn=66}}), + roundtrip('SetS1', + #'SetS1'{boolS1=true,intS1=15, + setS1=#'SetS1_setS1'{boolIn=true,intIn=66}}), + roundtrip('SetS2', + #'SetS2'{setS2=#'SetS2_setS2'{boolIn=true,intIn=66}, + boolS2=true,intS2=15}), + roundtrip('SetS3', + #'SetS3'{boolS3=true, + setS3=#'SetS3_setS3'{boolIn=true,intIn=66}, + intS3=15}), + roundtrip('SetSTag', + #'SetSTag'{setS1=#'SetSTag_setS1'{b1=true,i1=11}, + setS2=#'SetSTag_setS2'{b2=true,i2=22}, + setS3=#'SetSTag_setS3'{b3=true,i3=33}}), + roundtrip('SetTRset', + #'SetTRset'{setSet=#'SetSet'{setInt=2,setOs="A1"}, + setSetI=#'SetSet'{setInt=2,setOs="A2"}, + setSetE=#'SetSet'{setInt=2,setOs="A3"}, + 'setSet-I'=#'SetSetImp'{setInt=2,setOs="A4"}, + 'setSetI-I'=#'SetSetImp'{setInt=2,setOs="A5"}, + 'setSetE-I'=#'SetSetImp'{setInt=2,setOs="A6"}, + 'setSet-E'=#'SetSetExp'{setInt=2,setOs="A7"}, + 'setSetI-E'=#'SetSetExp'{setInt=2,setOs="A8"}, + 'setSetE-E'=#'SetSetExp'{setInt=2,setOs="A9"}}), ok. + +roundtrip(T, V) -> + asn1_test_lib:roundtrip('SetTypeRefSet', T, V). diff --git a/lib/asn1/test/testTCAP.erl b/lib/asn1/test/testTCAP.erl index aba13c94de..17511dc2b7 100644 --- a/lib/asn1/test/testTCAP.erl +++ b/lib/asn1/test/testTCAP.erl @@ -40,25 +40,26 @@ compile_asn1config(Config, Options) -> test(Erule,_Config) -> % ?line OutDir = ?config(priv_dir,Config), %% testing OTP-4798, open type encoded with indefinite length - ?line {ok,_Res} = asn1_wrapper:decode('TCAPMessages-simple','MessageType', val_OTP_4798(Erule)), + {ok,_Res} = 'TCAPMessages-simple':decode('MessageType', + val_OTP_4798(Erule)), + %% testing OTP-4799, absent optional open type - ?line {ok,_Res2} = asn1_wrapper:decode('TCAPMessages-simple','MessageType',val_OTP_4799(Erule)), + {ok,_Res2} = 'TCAPMessages-simple':decode('MessageType', + val_OTP_4799(Erule)), + %% testing vance shipley's problems. Parameterized object sets. ?line Val3 = 'TCAPPackage_msg':val('PackageType',unidirectional), - ?line {ok,Bytes3} = asn1_wrapper:encode('TCAPPackage','PackageType',Val3), - ?line {ok,Res3} = asn1_wrapper:decode('TCAPPackage','PackageType',Bytes3), + Res3 = enc_dec('PackageType', Val3), ?line ok = 'TCAPPackage_msg':check_result('PackageType',unidirectional,Res3), %% ?line io:format("Res3:~n~p~n~n",[Res3]), ?line Val4 = 'TCAPPackage_msg':val('PackageType',abort), - ?line {ok,Bytes4} = asn1_wrapper:encode('TCAPPackage','PackageType',Val4), - ?line {ok,Res4} = asn1_wrapper:decode('TCAPPackage','PackageType',Bytes4), + Res4 = enc_dec('PackageType', Val4), ?line ok = 'TCAPPackage_msg':check_result('PackageType',abort,Res4), %% ?line io:format("Res4:~n~p~n~n",[Res4]), ?line Val5 = 'TCAPPackage_msg':val('PackageType',response), - ?line {ok,Bytes5} = asn1_wrapper:encode('TCAPPackage','PackageType',Val5), - ?line {ok,Res5} = asn1_wrapper:decode('TCAPPackage','PackageType',Bytes5), + Res5 = enc_dec('PackageType', Val5), ?line ok = 'TCAPPackage_msg':check_result('PackageType',response,Res5). %% ?line io:format("Res5:~n~p~n~n",[Res5]). @@ -73,21 +74,26 @@ val_OTP_4799(_) -> <<100,16,73,4,41,182,36,0,108,8,163,6,2,1,29,2,1,27>>. test_asn1config() -> - ?line Val = 'TCAPPackage_msg':val('PackageType',queryWithPerm), - ?line {ok,B} = asn1_wrapper:encode('TCAPPackage','PackageType',Val), - ?line {ok,ExMsg}='TCAPPackage':decode_PackageType(list_to_binary(B)), - ?line {_,{_,_,_,{Key,ExVal}}}=ExMsg, - ?line {ok,_Parts}='TCAPPackage':decode_part(Key,ExVal), + Val = 'TCAPPackage_msg':val('PackageType', queryWithPerm), + {ok,B} = 'TCAPPackage':encode('PackageType', Val), + {ok,ExMsg}='TCAPPackage':decode_PackageType(B), + {_,{_,_,_,{Key,ExVal}}} = ExMsg, + {ok,_Parts} = 'TCAPPackage':decode_part(Key, ExVal), - ?line Val2 = 'TCAPPackage_msg':val('TransactionPDU'), - ?line {ok,B2} = 'TCAPPackage':encode('TransactionPDU',Val2), - {ok,ExMsg2}='TCAPPackage':decode_TransactionPDU(B2), - ?line {_,_,_,{Key2,ExVal2}}=ExMsg2, - ?line {ok,_Parts2}='TCAPPackage':decode_part(Key2,ExVal2), + Val2 = 'TCAPPackage_msg':val('TransactionPDU'), + {ok,B2} = 'TCAPPackage':encode('TransactionPDU', Val2), + {ok,ExMsg2} = 'TCAPPackage':decode_TransactionPDU(B2), + {_,_,_,{Key2,ExVal2}} = ExMsg2, + {ok,_Parts2} = 'TCAPPackage':decode_part(Key2, ExVal2), - ?line Val3 = 'TCAPPackage_msg':val('PackageType',response), - ?line {ok,B3} = asn1_wrapper:encode('TCAPPackage','PackageType',Val3), - ?line {ok,ExMsg3}='TCAPPackage':decode_PackageType(list_to_binary(B3)), - ?line {_,{_,_,_,{Key3,ExVal3}}}=ExMsg3, - ?line {ok,_Parts3}='TCAPPackage':decode_part(Key3,ExVal3). + Val3 = 'TCAPPackage_msg':val('PackageType', response), + {ok,B3} = 'TCAPPackage':encode('PackageType', Val3), + {ok,ExMsg3} = 'TCAPPackage':decode_PackageType(B3), + {_,{_,_,_,{Key3,ExVal3}}} = ExMsg3, + {ok,_Parts3}='TCAPPackage':decode_part(Key3, ExVal3). +enc_dec(T, V0) -> + M = 'TCAPPackage', + {ok,Enc} = M:encode(T, V0), + {ok,V} = M:decode(T, Enc), + V. diff --git a/lib/asn1/test/testTypeValueNotation.erl b/lib/asn1/test/testTypeValueNotation.erl index 61d69edd0e..b46d7177f5 100644 --- a/lib/asn1/test/testTypeValueNotation.erl +++ b/lib/asn1/test/testTypeValueNotation.erl @@ -24,13 +24,15 @@ -record('Seq', {octstr, int, bool, enum, bitstr, null, oid, vstr}). main(_Rule, _Option) -> - Value1 = #'Seq'{octstr = [1, 2, 3, 4], - int = 12, - bool = true, - enum = a, - bitstr = <<2#1010:4>>, - null = 'NULL', - oid = {1, 2, 55}, - vstr = "Hello World"}, - {ok, Bytes} = asn1_wrapper:encode('SeqTypeRefPrim', 'Seq', Value1), - {ok, Value1} = asn1_wrapper:decode('SeqTypeRefPrim', 'Seq', Bytes). + Value = #'Seq'{octstr = [1, 2, 3, 4], + int = 12, + bool = true, + enum = a, + bitstr = <<2#1010:4>>, + null = 'NULL', + oid = {1, 2, 55}, + vstr = "Hello World"}, + roundtrip('Seq', Value). + +roundtrip(T, V) -> + asn1_test_lib:roundtrip('SeqTypeRefPrim', T, V). diff --git a/lib/asn1/test/testX420.erl b/lib/asn1/test/testX420.erl index cbe14c2455..00c9221e9d 100644 --- a/lib/asn1/test/testX420.erl +++ b/lib/asn1/test/testX420.erl @@ -83,9 +83,9 @@ specs() -> ticket7759(_Erule,_Config) -> Encoded = encoded_msg(), io:format("Testing ticket7759 ...~n",[]), - ?line {ok, ContentInfo} = asn1_wrapper:decode('PKCS7','ContentInfo',Encoded), - ?line {'ContentInfo',_Id,PKCS7_content} = ContentInfo, - ?line {ok,_} = asn1_wrapper:decode('PKCS7','SignedData',PKCS7_content), + {ok, ContentInfo} = 'PKCS7':decode('ContentInfo',Encoded), + {'ContentInfo',_Id,PKCS7_content} = ContentInfo, + {ok,_} = 'PKCS7':decode('SignedData',PKCS7_content), ok. diff --git a/lib/asn1/test/test_modified_x420.erl b/lib/asn1/test/test_modified_x420.erl index a525fd6ae1..0df72a1831 100644 --- a/lib/asn1/test/test_modified_x420.erl +++ b/lib/asn1/test/test_modified_x420.erl @@ -26,8 +26,9 @@ test(Config) -> DataDir = ?config(data_dir,Config), Der = read_pem(filename:join([DataDir,modified_x420,"p7_signed_data.pem"])), - {ok,{_,_,SignedData}} = asn1_wrapper:decode('PKCS7', 'ContentInfo', Der), - {ok,_} = asn1_wrapper:decode('PKCS7', 'SignedData', SignedData). + {ok,{_,_,SignedData}} = 'PKCS7':decode( 'ContentInfo', Der), + {ok,_} = 'PKCS7':decode('SignedData', SignedData), + ok. read_pem(File) -> {ok,Bin} = file:read_file(File), diff --git a/lib/asn1/test/test_partial_incomplete_decode.erl b/lib/asn1/test/test_partial_incomplete_decode.erl index 8ede06938d..4a8a4cd74c 100644 --- a/lib/asn1/test/test_partial_incomplete_decode.erl +++ b/lib/asn1/test/test_partial_incomplete_decode.erl @@ -25,84 +25,57 @@ test(Config) -> FMsg = msg('F'), - ?line {ok,Bytes} = asn1_wrapper:encode('PartialDecSeq','F',FMsg), - ?line {ok,_} = asn1_wrapper:decode('PartialDecSeq','F',Bytes), - ?line {ok,IncFMsg} = - 'PartialDecSeq':decode_F_fb_incomplete(list_to_binary(Bytes)), - ?line decode_parts('F',IncFMsg), + Bytes1 = roundtrip('PartialDecSeq', 'F', FMsg), + {ok,IncFMsg} = 'PartialDecSeq':decode_F_fb_incomplete(Bytes1), + decode_parts('F', IncFMsg), + {ok,IncF2Msg} = 'PartialDecSeq':decode_F_fb_exclusive2(Bytes1), + decode_parts('F2', IncF2Msg), DMsg = msg('D'), - ?line {ok,Bytes2} = asn1_wrapper:encode('PartialDecSeq','D',DMsg), - ?line {ok,_} = asn1_wrapper:decode('PartialDecSeq','D',Bytes2), - ?line {ok,IncDMsg} = - 'PartialDecSeq':decode_D_incomplete(list_to_binary(Bytes2)), - ?line decode_parts('D',IncDMsg), - - ?line {ok,IncF2Msg} = - 'PartialDecSeq':decode_F_fb_exclusive2(list_to_binary(Bytes)), - ?line decode_parts('F2',IncF2Msg), + Bytes2 = roundtrip('PartialDecSeq', 'D', DMsg), + {ok,IncDMsg} = 'PartialDecSeq':decode_D_incomplete(Bytes2), + decode_parts('D', IncDMsg), F3Msg = msg('F3'), - ?line {ok,BytesF3} = asn1_wrapper:encode('PartialDecSeq','F',F3Msg), - ?line {ok,_} = asn1_wrapper:decode('PartialDecSeq','F',BytesF3), - ?line {ok,IncF3Msg} = - 'PartialDecSeq':decode_F_fb_exclusive3(list_to_binary(BytesF3)), - ?line decode_parts('F3',IncF3Msg), - - - AMsg =msg('A'), - ?line {ok,Bytes3} = asn1_wrapper:encode('PartialDecSeq2','A',AMsg), - ?line {ok,_} = asn1_wrapper:decode('PartialDecSeq2','A',Bytes3), - ?line {ok,IncFMsg3} = - 'PartialDecSeq2':decode_A_c_b_incomplete(list_to_binary(Bytes3)), - ?line decode_parts('A',IncFMsg3), + BytesF3 = roundtrip('PartialDecSeq', 'F', F3Msg), + {ok,IncF3Msg} = 'PartialDecSeq':decode_F_fb_exclusive3(BytesF3), + decode_parts('F3', IncF3Msg), + + AMsg = msg('A'), + Bytes3 = roundtrip('PartialDecSeq2', 'A', AMsg), + {ok,IncFMsg3} = 'PartialDecSeq2':decode_A_c_b_incomplete(Bytes3), + decode_parts('A', IncFMsg3), MyHTTPMsg = msg('GetRequest'), - ?line {ok,Bytes4} = asn1_wrapper:encode('PartialDecMyHTTP', - 'GetRequest',MyHTTPMsg), - ?line {ok,_} = asn1_wrapper:decode('PartialDecMyHTTP','GetRequest', - Bytes4), - ?line {ok,IncFMsg4} = - 'PartialDecMyHTTP':decode_GetRequest_incomplete(list_to_binary(Bytes4)), - ?line decode_parts('GetRequest',IncFMsg4), + Bytes4 = roundtrip('PartialDecMyHTTP', 'GetRequest', MyHTTPMsg), + {ok,IncFMsg4} = 'PartialDecMyHTTP':decode_GetRequest_incomplete(Bytes4), + decode_parts('GetRequest', IncFMsg4), MsgS1_1 = msg('S1_1'), - ?line {ok,Bytes5} = asn1_wrapper:encode('PartialDecSeq3','S1',MsgS1_1), - ?line {ok,_} = asn1_wrapper:decode('PartialDecSeq3','S1',Bytes5), - ?line {ok,IncFMsg5} = - 'PartialDecSeq3':decode_S1_incomplete(list_to_binary(Bytes5)), - ?line decode_parts('S1_1',IncFMsg5), + Bytes5 = roundtrip('PartialDecSeq3', 'S1', MsgS1_1), + {ok,IncFMsg5} = 'PartialDecSeq3':decode_S1_incomplete(Bytes5), + decode_parts('S1_1', IncFMsg5), MsgS1_2 = msg('S1_2'), - ?line {ok,Bytes6} = asn1_wrapper:encode('PartialDecSeq3','S1',MsgS1_2), - ?line {ok,IncFMsg6} = - 'PartialDecSeq3':decode_S1_incomplete(list_to_binary(Bytes6)), - ?line ok = decode_parts('S1_2',IncFMsg6), + Bytes6 = roundtrip('PartialDecSeq3', 'S1', MsgS1_2), + {ok,IncFMsg6} = 'PartialDecSeq3':decode_S1_incomplete(Bytes6), + decode_parts('S1_2', IncFMsg6), %% test of MEDIA-GATEWAY-CONTROL test_megaco(Config), ok. test_megaco(Config) -> - ?line DataDir = ?config(data_dir,Config), - Mod='MEDIA-GATEWAY-CONTROL', - ?line {ok,FilenameList} = file:list_dir(filename:join([DataDir, - megacomessages])), - %% remove any junk files that may be in the megacomessage directory - Pred = fun(X) -> - case lists:reverse(X) of - [$l,$a,$v,$.|_R] ->true; - _ -> false - end - end, - MegacoMsgFilenameList = lists:filter(Pred,FilenameList), - Fun = fun(F) -> - M = read_msg(filename:join([DataDir,megacomessages,F])), - ?line {ok,B} = asn1_wrapper:encode(Mod,element(1,M),M), - ?line exclusive_decode(list_to_binary(B),F) - end, - ?line lists:foreach(Fun,MegacoMsgFilenameList), - ok. + DataDir = ?config(data_dir, Config), + Files = filelib:wildcard(filename:join([DataDir,megacomessages,"*.val"])), + Mod = 'MEDIA-GATEWAY-CONTROL', + lists:foreach(fun(File) -> + {ok,Bin} = file:read_file(File), + V = binary_to_term(Bin), + T = element(1, V), + Enc = roundtrip(Mod, T, V), + exclusive_decode(Enc, File) + end, Files). exclusive_decode(Bin,F) -> Mod='MEDIA-GATEWAY-CONTROL', @@ -113,15 +86,6 @@ exclusive_decode(Bin,F) -> ?line {ok,_} = Mod:decode_part(MsgMBodyKey,MsgMBody), ok. - -read_msg(File) -> - case file:read_file(File) of - {ok,Bin} -> - binary_to_term(Bin); - _ -> - io:format("couldn't read file ~p~n",[File]) - end. - decode_parts('F',PartDecMsg) -> ?line {fb,{'E',35,{NameE_b,ListBinE_b},false,{NameE_d,BinE_d}}} = PartDecMsg, ?line {ok,[{'D',3,true}|_]} = 'PartialDecSeq':decode_part(NameE_b,ListBinE_b), @@ -200,7 +164,10 @@ msg('A') -> {'A',12,{c,{'S',true,false}},{b,{'A_c_b',false,false}}}; msg('GetRequest') -> - {'GetRequest',true,false,{'AcceptTypes',[1,1,1,1],["hell","othe","reho","peyo","uare","fine"]},"IamfineThankYOu"}; + {'GetRequest',true,false, + {'AcceptTypes',[html,'plain-text',gif,jpeg], + ["hell","othe","reho","peyo","uare","fine"]}, + "IamfineThankYOu"}; msg('S1_1') -> {'S1',14,msg('S2'),msg('C1_a'),msg('SO1')}; @@ -213,10 +180,13 @@ msg('C1_a') -> msg('C1_b') -> {b,{'C1_b',11,true,msg('S4')}}; msg('S3') -> - {'S3',10,"PrintableString","OCTETSTRING",[1,1,1,1]}; + {'S3',10,"PrintableString","OCTETSTRING",[one,two,three,four]}; msg('S4') -> {'S4',msg('Name'),"MSc"}; msg('SO1') -> [msg('Name'),msg('Name'),msg('Name')]; msg('Name') -> {'Name',"Hans","HCA","Andersen"}. + +roundtrip(M, T, V) -> + asn1_test_lib:roundtrip_enc(M, T, V). diff --git a/lib/asn1/test/test_selective_decode.erl b/lib/asn1/test/test_selective_decode.erl index ebe1296cf3..f42f24e0e3 100644 --- a/lib/asn1/test/test_selective_decode.erl +++ b/lib/asn1/test/test_selective_decode.erl @@ -18,39 +18,39 @@ %% %% -module(test_selective_decode). - -export([test/0]). -include_lib("test_server/include/test_server.hrl"). - test() -> FMsg = msg('F'), - ?line {ok,Bytes} = asn1_wrapper:encode('PartialDecSeq','F',FMsg), - ?line {ok,3} = - 'PartialDecSeq':selected_decode_F1(list_to_binary(Bytes)), - ?line {ok,[{'D',3,true},{'D',4,false},{'D',5,true},{'D',6,true},{'D',7,false},{'D',8,true},{'D',9,true},{'D',10,false},{'D',11,true},{'D',12,true},{'D',13,false},{'D',14,true}]} = 'PartialDecSeq':selected_decode_F2(list_to_binary(Bytes)), - ?line {ok,{'D',3,true}} = 'PartialDecSeq':selected_decode_F3(list_to_binary(Bytes)), - - ?line {ok,17} = 'PartialDecSeq':selected_decode_F4(list_to_binary(Bytes)), + Bytes = roundtrip('PartialDecSeq', 'F', FMsg), + {ok,3} = 'PartialDecSeq':selected_decode_F1(Bytes), + {ok,[{'D',3,true},{'D',4,false},{'D',5,true},{'D',6,true}, + {'D',7,false},{'D',8,true},{'D',9,true},{'D',10,false}, + {'D',11,true},{'D',12,true},{'D',13,false},{'D',14,true}]} = + 'PartialDecSeq':selected_decode_F2(Bytes), + {ok,{'D',3,true}} = 'PartialDecSeq':selected_decode_F3(Bytes), + {ok,17} = 'PartialDecSeq':selected_decode_F4(Bytes), EMsg = msg('E'), - ?line {ok,Bytes2} = asn1_wrapper:encode('PartialDecSeq','E',EMsg), - ?line {ok,14} = 'PartialDecSeq':selected_decode_E1(list_to_binary(Bytes2)), + Bytes2 = roundtrip('PartialDecSeq', 'E', EMsg), + {ok,14} = 'PartialDecSeq':selected_decode_E1(Bytes2), + MGCMsg = msg('M-G-C'), - ?line {ok,Bytes3} = asn1_wrapper:encode('MEDIA-GATEWAY-CONTROL', - 'MegacoMessage',MGCMsg), - ?line {ok,1} = 'MEDIA-GATEWAY-CONTROL':decode_MegacoMessage_selective(list_to_binary(Bytes3)), + Bytes3 = roundtrip('MEDIA-GATEWAY-CONTROL', 'MegacoMessage', MGCMsg), + {ok,1} = 'MEDIA-GATEWAY-CONTROL':decode_MegacoMessage_selective(Bytes3), PRecMsg = {'PersonnelRecord',{'Name',"Sven","S","Svensson"}, "manager",123,"20000202",{'Name',"Inga","K","Svensson"}, asn1_DEFAULT}, - ?line {ok,Bytes4} = asn1_wrapper:encode('P-Record','PersonnelRecord', - PRecMsg), - ?line {ok,_} = 'P-Record':sel_dec(list_to_binary(Bytes4)), - ok. - + PRecMsgDec = {'PersonnelRecord',{'Name',"Sven","S","Svensson"}, + "manager",123,"20000202",{'Name',"Inga","K","Svensson"}, + []}, + Bytes4 = roundtrip('P-Record', 'PersonnelRecord', PRecMsg, PRecMsgDec), + {ok,_} = 'P-Record':sel_dec(Bytes4), + ok. msg('F') -> {fb,{'E',35,[{'D',3,true},{'D',4,false},{'D',5,true},{'D',6,true},{'D',7,false},{'D',8,true},{'D',9,true},{'D',10,false},{'D',11,true},{'D',12,true},{'D',13,false},{'D',14,true}],false,{da,[{'A',16,{'D',17,true}}]}}}; @@ -60,3 +60,10 @@ msg('E') -> msg('M-G-C') -> {'MegacoMessage',asn1_NOVALUE,{'Message',1,{ip4Address,{'IP4Address',[125,125,125,111],55555}},{transactions,[{transactionReply,{'TransactionReply',50007,asn1_NOVALUE,{actionReplies,[{'ActionReply',0,asn1_NOVALUE,asn1_NOVALUE,[{auditValueReply,{auditResult,{'AuditResult',{'TerminationID',[],[255,255,255]},[{mediaDescriptor,{'MediaDescriptor',asn1_NOVALUE,{multiStream,[{'StreamDescriptor',1,{'StreamParms',{'LocalControlDescriptor',sendRecv,asn1_NOVALUE,asn1_NOVALUE,[{'PropertyParm',[0,11,0,7],[[52,48]],asn1_NOVALUE}]},{'LocalRemoteDescriptor',[[{'PropertyParm',[0,0,176,1],[[48]],asn1_NOVALUE},{'PropertyParm',[0,0,176,8],[[73,78,32,73,80,52,32,49,50,53,46,49,50,53,46,49,50,53,46,49,49,49]],asn1_NOVALUE},{'PropertyParm',[0,0,176,15],[[97,117,100,105,111,32,49,49,49,49,32,82,84,80,47,65,86,80,32,32,52]],asn1_NOVALUE},{'PropertyParm',[0,0,176,12],[[112,116,105,109,101,58,51,48]],asn1_NOVALUE}]]},{'LocalRemoteDescriptor',[[{'PropertyParm',[0,0,176,1],[[48]],asn1_NOVALUE},{'PropertyParm',[0,0,176,8],[[73,78,32,73,80,52,32,49,50,52,46,49,50,52,46,49,50,52,46,50,50,50]],asn1_NOVALUE},{'PropertyParm',[0,0,176,15],[[97,117,100,105,111,32,50,50,50,50,32,82,84,80,47,65,86,80,32,32,52]],asn1_NOVALUE},{'PropertyParm',[0,0,176,12],[[112,116,105,109,101,58,51,48]],asn1_NOVALUE}]]}}}]}}},{packagesDescriptor,[{'PackagesItem',[0,11],1},{'PackagesItem',[0,11],1}]},{statisticsDescriptor,[{'StatisticsParameter',[0,12,0,4],[[49,50,48,48]]},{'StatisticsParameter',[0,11,0,2],[[54,50,51,48,48]]},{'StatisticsParameter',[0,12,0,5],[[55,48,48]]},{'StatisticsParameter',[0,11,0,3],[[52,53,49,48,48]]},{'StatisticsParameter',[0,12,0,6],[[48,46,50]]},{'StatisticsParameter',[0,12,0,7],[[50,48]]},{'StatisticsParameter',[0,12,0,8],[[52,48]]}]}]}}}]}]}}}]}}}. + + +roundtrip(M, T, V) -> + asn1_test_lib:roundtrip_enc(M, T, V). + +roundtrip(M, T, V, E) -> + asn1_test_lib:roundtrip_enc(M, T, V, E). diff --git a/lib/asn1/test/test_undecoded_rest.erl b/lib/asn1/test/test_undecoded_rest.erl index 36fd26ed59..fe04178bb1 100644 --- a/lib/asn1/test/test_undecoded_rest.erl +++ b/lib/asn1/test/test_undecoded_rest.erl @@ -27,27 +27,20 @@ %% testing OTP-5104 test(Opt, Config) -> - {ok, Msg} = asn1ct:value('P-Record', 'PersonnelRecord', - [{i, ?config(case_dir, Config)}]), - {ok, Bytes} = asn1_wrapper:encode('P-Record', 'PersonnelRecord', Msg), - Bytes2 = if is_list(Bytes) -> - Bytes ++ [55, 55, 55]; - is_binary(Bytes) -> - iolist_to_binary([Bytes, <<55, 55, 55>>]) - end, + {ok,Msg} = asn1ct:value('P-Record', 'PersonnelRecord', + [{i,?config(case_dir, Config)}]), + {ok,Bytes0} = 'P-Record':encode('PersonnelRecord', Msg), + Bytes1 = iolist_to_binary([Bytes0, <<55,55,55>>]), case Opt of undec_rest -> - {ok, Msg, R} = asn1_wrapper:decode('P-Record', 'PersonnelRecord', - Bytes2), + {ok,Msg,R} = 'P-Record':decode('PersonnelRecord', Bytes1), case R of - <<55, 55, 55>> -> ok; - [55, 55, 55] -> ok; + <<55,55,55>> -> ok; BStr when is_bitstring(BStr) -> PadLen = (8 - (bit_size(BStr) rem 8)) rem 8, - <<0, 55, 55, 55>> = <<0:PadLen, BStr/bitstring>> + <<0,55,55,55>> = <<0:PadLen, BStr/bitstring>> end; _ -> - {ok, Msg} = asn1_wrapper:decode('P-Record', 'PersonnelRecord', - Bytes2) + {ok,Msg} = 'P-Record':decode('PersonnelRecord', Bytes1) end, ok. diff --git a/lib/asn1/test/test_x691.erl b/lib/asn1/test/test_x691.erl index dcfa211d80..9b141e2389 100644 --- a/lib/asn1/test/test_x691.erl +++ b/lib/asn1/test/test_x691.erl @@ -18,50 +18,25 @@ %% %% -module(test_x691). - --export([cases/2]). +-export([cases/1]). -include_lib("test_server/include/test_server.hrl"). -cases(Erule,Variant) -> - MsgA1 = a1(), - ?line {ok,B1} = asn1_wrapper:encode('P-RecordA1','PersonnelRecord',MsgA1), - ?line {ok,MsgA1} = asn1_wrapper:decode('P-RecordA1','PersonnelRecord',B1), - io:format("compare_format(~p,B1) ->~p~nencval(a1,~p,binary) ->~p~n", - [Erule, - compare_format(Erule,B1), - Variant, - encval(a1,Variant,binary)]), - ?line true = (compare_format(Erule,B1) == encval(a1,Variant,binary)), - - MsgA2 = a2(), - ?line {ok,B2} = asn1_wrapper:encode('P-RecordA2','PersonnelRecord',MsgA2), - ?line {ok,MsgA2} = asn1_wrapper:decode('P-RecordA2','PersonnelRecord',B2), - io:format("compare_format(~p,B2) ->~p~nencval(a2,~p,binary) ->~p~n", - [Erule, - compare_format(Erule,B2), - Variant, - encval(a2,Variant,binary)]), - ?line true = (compare_format(Erule,B2) == encval(a2,Variant,binary)), - - MsgA3 = a3(), - ?line {ok,B3} = asn1_wrapper:encode('P-RecordA3','PersonnelRecord',MsgA3), - ?line {ok,MsgA3} = asn1_wrapper:decode('P-RecordA3','PersonnelRecord',B3), - io:format("compare_format(~p,B3) ->~p~nencval(a3,~p,binary) ->~p~n", - [Erule, - compare_format(Erule,B3), - Variant, - encval(a3,Variant,binary)]), - ?line true = (compare_format(Erule,B3) == encval(a3,Variant,binary)). - -compare_format(Erule,Val) when is_list(Val) -> - compare_format(Erule,list_to_binary(Val)); -%% compare_format(per,Val) -> -%% binary_to_list(Val); -compare_format(_,Val) -> - Val. - -a1() -> +cases(Erule) -> + _ = [begin + Mod = module(Name), + Msg = msg(Name), + Hex = encval(Name, Erule), + Enc = asn1_test_lib:hex_to_bin(Hex), + Enc = asn1_test_lib:roundtrip_enc(Mod, 'PersonnelRecord', Msg) + end || Name <- [a1,a2,a3]], + ok. + +module(a1) -> 'P-RecordA1'; +module(a2) -> 'P-RecordA2'; +module(a3) -> 'P-RecordA3'. + +msg(a1) -> {'PersonnelRecord', {'Name',"John", "P", "Smith"}, "Director", @@ -73,12 +48,10 @@ a1() -> "19571111"}, {'ChildInformation', {'Name', "Susan", "B", "Jones"}, - "19590717"}]}. - -a2() -> - a1(). - -a3() -> + "19590717"}]}; +msg(a2) -> + msg(a1); +msg(a3) -> {'PersonnelRecord', {'Name',"John", "P", "Smith"}, "Director", @@ -94,119 +67,15 @@ a3() -> "19590717", female}]}. -encval(An,Variant,Encoding) when Encoding == hex; Encoding == binary -> - Msg = encval(An,Variant), - encoding(Encoding,Msg). - -encval(a1,aligned) -> +encval(a1, per) -> "80044A6F 686E0150 05536D69 74680133 08446972 6563746F 72083139 37313039 3137044D 61727901 5405536D 69746802 0552616C 70680154 05536D69 74680831 39353731 31313105 53757361 6E014205 4A6F6E65 73083139 35393037 3137"; -encval(a1,unaligned) -> +encval(a1, uper) -> "824ADFA3 700D005A 7B74F4D0 02661113 4F2CB8FA 6FE410C5 CB762C1C B16E0937 0F2F2035 0169EDD3 D340102D 2C3B3868 01A80B4F 6E9E9A02 18B96ADD 8B162C41 69F5E787 700C2059 5BF765E6 10C5CB57 2C1BB16E"; -encval(a2,aligned) -> +encval(a2, per) -> "864A6F68 6E501053 6D697468 01330844 69726563 746F7219 7109170C 4D617279 5410536D 69746802 1052616C 70685410 536D6974 68195711 11105375 73616E42 104A6F6E 65731959 0717"; -encval(a2,unaligned) -> +encval(a2, uper) -> "865D51D2 888A5125 F1809984 44D3CB2E 3E9BF90C B8848B86 7396E8A8 8A5125F1 81089B93 D71AA229 4497C632 AE222222 985CE521 885D54C1 70CAC838 B8"; -encval(a3,aligned) -> +encval(a3, per) -> "40C04A6F 686E5008 536D6974 68000033 08446972 6563746F 72001971 0917034D 61727954 08536D69 74680100 52616C70 68540853 6D697468 00195711 11820053 7573616E 42084A6F 6E657300 19590717 010140"; -encval(a3,unaligned) -> +encval(a3, uper) -> "40CBAA3A 5108A512 5F180330 889A7965 C7D37F20 CB8848B8 19CE5BA2 A114A24B E3011372 7AE35422 94497C61 95711118 22985CE5 21842EAA 60B832B2 0E2E0202 80". - -encoding(binary,Msg) -> - list_to_binary(bin(Msg)); -encoding(hex,Msg) -> - hex(Msg). - -bin(Msg) -> - HexList = hex(Msg), - Fun = fun([H1,H2|Rest],F) -> [(H1 bsl 4) + H2|F(Rest,F)];([],_) -> [] end, - Fun(HexList,Fun). - -hex(Msg) -> - [to_hex(X)||X <- Msg,X /= $ ]. - -to_hex(I) when I >= $0, I =< $9 -> - I-48; -to_hex(C) when C >= $A,C =< $F -> - C - 55. - -%% ex('EUTRA','BCCH-DL-SCH-Message',1) -> -%% {'BCCH-DL-SCH-Message', -%% {c1, -%% {systemInformation1, -%% {'SystemInformationBlockType1', -%% {'SystemInformationBlockType1_cellAccessRelatedInformation', -%% [{'SystemInformationBlockType1_cellAccessRelatedInformation_SOF', -%% {'PLMN-Identity'}, -%% true}, -%% {'SystemInformationBlockType1_cellAccessRelatedInformation_SOF', -%% {'PLMN-Identity'}, -%% false}, -%% {'SystemInformationBlockType1_cellAccessRelatedInformation_SOF', -%% {'PLMN-Identity'}, -%% true}], -%% {'TrackingAreaCode'}, -%% {'CellIdentity'}, -%% false, -%% true, -%% true, -%% true}, -%% {'SystemInformationBlockType1_cellSelectionInfo', -%% -50}, -%% 24, -%% [{'SystemInformationBlockType1_schedulinInformation_SOF', -%% {'SystemInformationBlockType1_schedulinInformation_SOF_si-MessageType'}, -%% ms320, -%% {'SystemInformationBlockType1_schedulinInformation_SOF_sib-MappingInfo'} -%% }], -%% 0 -%% } -%% } -%% } -%% }. - -%% eutra1(msg) -> -%% {'BCCH-BCH-Message',{'MasterInformationBlock',[0,1,0,1],[1,0,1,0],{'PHICH-Configuration',short,ffs},[1,0,1,0,0,0,0,0]}}; -%% eutra1(result) -> -%% <<90,80,0>>. - -%% eutra2(msg) -> -%% {'BCCH-DL-SCH-Message', -%% {c1, -%% {systemInformation1, -%% {'SystemInformationBlockType1', -%% {'SystemInformationBlockType1_cellAccessRelatedInformation', -%% [{'SystemInformationBlockType1_cellAccessRelatedInformation_plmn-IdentityList_SEQOF',{'PLMN-Identity'},true}, -%% {'SystemInformationBlockType1_cellAccessRelatedInformation_plmn-IdentityList_SEQOF',{'PLMN-Identity'},false}, -%% {'SystemInformationBlockType1_cellAccessRelatedInformation_plmn-IdentityList_SEQOF',{'PLMN-Identity'},true}], -%% {'TrackingAreaCode'}, -%% {'CellIdentity'}, -%% false, -%% true, -%% true, -%% true -%% }, -%% {'SystemInformationBlockType1_cellSelectionInfo',-50}, -%% 24, -%% [{'SystemInformationBlockType1_schedulinInformation_SEQOF', -%% {'SystemInformationBlockType1_schedulinInformation_SEQOF_si-MessageType'}, -%% ms320, -%% {'SystemInformationBlockType1_schedulinInformation_SEQOF_sib-MappingInfo'}}], -%% 0 -%% } -%% } -%% } -%% }; -%% eutra2(result) -> -%% %% 55 5C A5 E0 -%% <<85,92,165,224>>. - - - -%% compare([H|T1],[H|T2],Acc) -> -%% compare(T1,T2,[H|Acc]); -%% compare([],[],_Acc) -> -%% ok; -%% compare(L1,L2,Acc) -> -%% {miss_match,L1,L2,lists:reverse(Acc)}. - - -- cgit v1.2.3