aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-02-25 09:24:41 +0100
committerBjörn Gustavsson <[email protected]>2013-05-31 14:52:15 +0200
commit1aad483e439410aeee17c966991754f65f6852a9 (patch)
tree946a4e7329ea7b7d9bc32513ab4af0e6340bc6cf
parent78bf2e6ab930212e49a291b9991bd3bfc886bf0e (diff)
downloadotp-1aad483e439410aeee17c966991754f65f6852a9.tar.gz
otp-1aad483e439410aeee17c966991754f65f6852a9.tar.bz2
otp-1aad483e439410aeee17c966991754f65f6852a9.zip
UPER: Fix bug in encoding/decoding of default types
The wrong backend was used.
-rw-r--r--lib/asn1/src/asn1ct_gen_per.erl4
-rw-r--r--lib/asn1/test/asn1_SUITE_data/InfObj.asn55
-rw-r--r--lib/asn1/test/testInfObj.erl7
3 files changed, 48 insertions, 18 deletions
diff --git a/lib/asn1/src/asn1ct_gen_per.erl b/lib/asn1/src/asn1ct_gen_per.erl
index 9c82337135..7d6ceae8d6 100644
--- a/lib/asn1/src/asn1ct_gen_per.erl
+++ b/lib/asn1/src/asn1ct_gen_per.erl
@@ -454,7 +454,7 @@ gen_encode_default_call(ClassName,FieldName,Type) ->
[#typedef{name=[FieldName,ClassName],
typespec=Type}];
{primitive,bif} ->
- gen_encode_prim(per,Type,"false","Val"),
+ gen_encode_prim(uper, Type, "false", "Val"),
[];
#'Externaltypereference'{module=CurrentMod,type=Etype} ->
emit([" 'enc_",Etype,"'(Val)",nl]),
@@ -590,7 +590,7 @@ gen_decode_default_call(ClassName,FieldName,Bytes,Type) ->
[#typedef{name=[FieldName,ClassName],
typespec=Type}];
{primitive,bif} ->
- gen_dec_prim(per,Type,Bytes),
+ gen_dec_prim(uper, Type, Bytes),
[];
#'Externaltypereference'{module=CurrentMod,type=Etype} ->
emit([" 'dec_",Etype,"'(",Bytes,", telltype)",nl]),
diff --git a/lib/asn1/test/asn1_SUITE_data/InfObj.asn b/lib/asn1/test/asn1_SUITE_data/InfObj.asn
index 0a437e12df..abd49e64f3 100644
--- a/lib/asn1/test/asn1_SUITE_data/InfObj.asn
+++ b/lib/asn1/test/asn1_SUITE_data/InfObj.asn
@@ -39,21 +39,6 @@ RANAP-PDU ::= CHOICE {
CLASS2 ::= RANAP-ELEMENTARY-PROCEDURE
-MY-CLASS ::= CLASS {
- &integerValue INTEGER UNIQUE,
- &booleanValue BOOLEAN,
- &stringValue PrintableString
- }
-
-myobject MY-CLASS ::= {
- &integerValue 12,
- &booleanValue TRUE,
- &stringValue "hejsan"
- }
-MyObjectSet MY-CLASS ::= {
- myobject
- }
-
InitiatingMessage ::= SEQUENCE {
procedureCode RANAP-ELEMENTARY-PROCEDURE.&procedureCode ({RANAP-ELEMENTARY-PROCEDURES}),
criticality RANAP-ELEMENTARY-PROCEDURE.&criticality ({RANAP-ELEMENTARY-PROCEDURES}{@procedureCode}),
@@ -148,6 +133,46 @@ id-Iu-Release3 INTEGER ::= 3
id-Iu-Release4 INTEGER ::= 4
id-Iu-Release5 INTEGER ::= 5
+--
+-- MY-CLASS
+--
+
+Seq ::= SEQUENCE {
+ int INTEGER,
+ str OCTET STRING
+}
+
+MY-CLASS ::= CLASS {
+ &Count DEFAULT INTEGER,
+ &integerValue INTEGER UNIQUE,
+ &booleanValue BOOLEAN,
+ &stringValue PrintableString
+}
+
+myobject MY-CLASS ::= {
+ &integerValue 12,
+ &booleanValue TRUE,
+ &stringValue "hejsan"
+}
+
+myotherobject MY-CLASS ::= {
+ &Count Seq,
+ &integerValue 42,
+ &booleanValue FALSE,
+ &stringValue "hoppsan"
+}
+
+MyObjectSet MY-CLASS ::= {
+ myobject | myotherobject
+}
+
+MyPdu ::= SEQUENCE {
+ count MY-CLASS.&Count ({MyObjectSet}{@int}),
+ int MY-CLASS.&integerValue ({MyObjectSet}),
+ bool MY-CLASS.&booleanValue ({MyObjectSet}{@int}),
+ str MY-CLASS.&stringValue ({MyObjectSet}{@int})
+}
+
END
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),