From 78bf2e6ab930212e49a291b9991bd3bfc886bf0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Mon, 25 Feb 2013 08:39:48 +0100 Subject: testInfObj: Introduce roundtrip/3 to simplify the test suite --- lib/asn1/test/testInfObj.erl | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'lib/asn1/test/testInfObj.erl') diff --git a/lib/asn1/test/testInfObj.erl b/lib/asn1/test/testInfObj.erl index 03e70c730a..6318bf44b5 100644 --- a/lib/asn1/test/testInfObj.erl +++ b/lib/asn1/test/testInfObj.erl @@ -22,8 +22,6 @@ -export([main/1]). --include_lib("test_server/include/test_server.hrl"). - -record('InitiatingMessage',{procedureCode,criticality,value}). -record('InitiatingMessage2',{procedureCode,criticality,value}). -record('Iu-ReleaseCommand',{first,second}). @@ -34,22 +32,11 @@ main(_Erule) -> value=#'Iu-ReleaseCommand'{ first=13, second=true}}, - ?line {ok,Bytes1} = - asn1_wrapper:encode('RANAPextract1','InitiatingMessage',Val1), - - ?line {ok,{'InitiatingMessage',1,ignore,{'Iu-ReleaseCommand',13,true}}}= - asn1_wrapper:decode('RANAPextract1','InitiatingMessage',Bytes1), - - ?line {ok,Bytes2} = - asn1_wrapper:encode('InfObj','InitiatingMessage',Val1), - - ?line {ok,Val1} = - asn1_wrapper:decode('InfObj','InitiatingMessage',Bytes2), + roundtrip('RANAPextract1', 'InitiatingMessage', Val1), + roundtrip('InfObj', 'InitiatingMessage', Val1), Val2 = Val1#'InitiatingMessage'{procedureCode=2}, - - ?line {error,_R1} = - asn1_wrapper:encode('InfObj','InitiatingMessage',Val2), + {error,_R1} = 'InfObj':encode('InitiatingMessage', Val2), %% Test case for OTP-4275 @@ -59,10 +46,9 @@ main(_Erule) -> first=13, second=true}}, - ?line {ok,Bytes3} = - asn1_wrapper:encode('RANAPextract1','InitiatingMessage2',Val3), + roundtrip('RANAPextract1', 'InitiatingMessage2', Val3). - - ?line {ok,{'InitiatingMessage2',3,reject,{'Iu-ReleaseCommand',13,true}}}= - asn1_wrapper:decode('RANAPextract1','InitiatingMessage2',Bytes3). - +roundtrip(M, T, V) -> + {ok,Enc} = M:encode(T, V), + {ok,V} = M:decode(T, Enc), + ok. -- cgit v1.2.3 From 1aad483e439410aeee17c966991754f65f6852a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Mon, 25 Feb 2013 09:24:41 +0100 Subject: UPER: Fix bug in encoding/decoding of default types The wrong backend was used. --- lib/asn1/test/testInfObj.erl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/asn1/test/testInfObj.erl') diff --git a/lib/asn1/test/testInfObj.erl b/lib/asn1/test/testInfObj.erl index 6318bf44b5..97e6a9aaa9 100644 --- a/lib/asn1/test/testInfObj.erl +++ b/lib/asn1/test/testInfObj.erl @@ -46,7 +46,12 @@ main(_Erule) -> first=13, second=true}}, - roundtrip('RANAPextract1', 'InitiatingMessage2', Val3). + roundtrip('RANAPextract1', 'InitiatingMessage2', Val3), + + roundtrip('InfObj', 'MyPdu', {'MyPdu',42,12,false,"string"}), + roundtrip('InfObj', 'MyPdu', {'MyPdu',{'Seq',1023,"hello"}, + 42,true,"longer string"}). + roundtrip(M, T, V) -> {ok,Enc} = M:encode(T, V), -- cgit v1.2.3 From 509ccd85ef448f5843716d4b51a8b07f875cdfda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Mon, 25 Feb 2013 09:55:59 +0100 Subject: PER/UPER: Share all code except encoding of primitives The only code that is really different between the PER and UPER backends is encoding of primitive types. --- lib/asn1/test/testInfObj.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/asn1/test/testInfObj.erl') diff --git a/lib/asn1/test/testInfObj.erl b/lib/asn1/test/testInfObj.erl index 97e6a9aaa9..c0f86eab60 100644 --- a/lib/asn1/test/testInfObj.erl +++ b/lib/asn1/test/testInfObj.erl @@ -50,7 +50,8 @@ main(_Erule) -> roundtrip('InfObj', 'MyPdu', {'MyPdu',42,12,false,"string"}), roundtrip('InfObj', 'MyPdu', {'MyPdu',{'Seq',1023,"hello"}, - 42,true,"longer string"}). + 42,true,"longer string"}), + roundtrip('InfObj', 'MyPdu', {'MyPdu',"75712346",43,true,"string"}). roundtrip(M, T, V) -> -- cgit v1.2.3 From e3d18eb865c7bcba21836837b1c4c415e7c857e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 10 Apr 2013 07:53:37 +0200 Subject: BER: Fix handling of a constructed default value for a class --- lib/asn1/test/testInfObj.erl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib/asn1/test/testInfObj.erl') diff --git a/lib/asn1/test/testInfObj.erl b/lib/asn1/test/testInfObj.erl index c0f86eab60..d9890e4358 100644 --- a/lib/asn1/test/testInfObj.erl +++ b/lib/asn1/test/testInfObj.erl @@ -51,7 +51,14 @@ main(_Erule) -> roundtrip('InfObj', 'MyPdu', {'MyPdu',42,12,false,"string"}), roundtrip('InfObj', 'MyPdu', {'MyPdu',{'Seq',1023,"hello"}, 42,true,"longer string"}), - roundtrip('InfObj', 'MyPdu', {'MyPdu',"75712346",43,true,"string"}). + roundtrip('InfObj', 'MyPdu', {'MyPdu',"75712346",43,true,"string"}), + + roundtrip('InfObj', 'ConstructedPdu', + {'ConstructedPdu',1,{'CONSTRUCTED-DEFAULT_Type',-2001,true}}), + roundtrip('InfObj', 'ConstructedPdu', + {'ConstructedPdu',2,{'CONSTRUCTED-DEFAULT_Type',999,false}}), + roundtrip('InfObj', 'ConstructedPdu', + {'ConstructedPdu',3,true}). roundtrip(M, T, V) -> -- cgit v1.2.3 From 72fa58fa2d150b0e73252ad3e13853e6b644cb77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Mon, 20 May 2013 13:20:21 +0200 Subject: asn1ct_check: Don't pass on #'ObjectClassFieldType'{} with fixed type Simplify the backends by letting asn1ct_check replacing a with the actual type. --- lib/asn1/test/testInfObj.erl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/asn1/test/testInfObj.erl') diff --git a/lib/asn1/test/testInfObj.erl b/lib/asn1/test/testInfObj.erl index d9890e4358..75f4dae310 100644 --- a/lib/asn1/test/testInfObj.erl +++ b/lib/asn1/test/testInfObj.erl @@ -58,7 +58,11 @@ main(_Erule) -> roundtrip('InfObj', 'ConstructedPdu', {'ConstructedPdu',2,{'CONSTRUCTED-DEFAULT_Type',999,false}}), roundtrip('InfObj', 'ConstructedPdu', - {'ConstructedPdu',3,true}). + {'ConstructedPdu',3,true}), + + roundtrip('InfObj', 'Seq2', + {'Seq2',42,[true,false,false,true], + [false,true,false]}). roundtrip(M, T, V) -> -- cgit v1.2.3