aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-07-02 07:41:03 +0200
committerBjörn Gustavsson <[email protected]>2013-08-30 10:13:17 +0200
commit280c6a1d35f39eb285d4d9e41ffa3e7ae298e41a (patch)
treec70a8af965e0f3ea344c0240d813379bc8665e79 /lib/asn1
parent9033435e5b8051608c7e867051c1a8e6b946d2a9 (diff)
downloadotp-280c6a1d35f39eb285d4d9e41ffa3e7ae298e41a.tar.gz
otp-280c6a1d35f39eb285d4d9e41ffa3e7ae298e41a.tar.bz2
otp-280c6a1d35f39eb285d4d9e41ffa3e7ae298e41a.zip
PER/UPER: Fix encoding of an object set with multiple inlined constructs
Also extend the test suite with more tests of inlined constructs in object sets.
Diffstat (limited to 'lib/asn1')
-rw-r--r--lib/asn1/src/asn1ct_gen_per.erl6
-rw-r--r--lib/asn1/test/asn1_SUITE_data/InfObj.asn11
-rw-r--r--lib/asn1/test/testInfObj.erl42
3 files changed, 55 insertions, 4 deletions
diff --git a/lib/asn1/src/asn1ct_gen_per.erl b/lib/asn1/src/asn1ct_gen_per.erl
index 17ecdeefbf..aefcdfecc8 100644
--- a/lib/asn1/src/asn1ct_gen_per.erl
+++ b/lib/asn1/src/asn1ct_gen_per.erl
@@ -650,13 +650,13 @@ gen_objset_enc(Erule, ObjSetName, UniqueName, [{ObjName,Val,Fields}|T],
ObjSetName, NthObj);
{CurrMod,Name} ->
emit({" fun 'enc_",Name,"'/3"}),
- {[],0};
+ {[],NthObj};
{ModName,Name} ->
emit_ext_encfun(ModName,Name),
- {[],0};
+ {[],NthObj};
_Other ->
emit({" fun 'enc_",ObjName,"'/3"}),
- {[],0}
+ {[],NthObj}
end,
emit({";",nl}),
gen_objset_enc(Erule, ObjSetName, UniqueName, T, ClName, ClFields,
diff --git a/lib/asn1/test/asn1_SUITE_data/InfObj.asn b/lib/asn1/test/asn1_SUITE_data/InfObj.asn
index 53e5043cb7..dd0296526f 100644
--- a/lib/asn1/test/asn1_SUITE_data/InfObj.asn
+++ b/lib/asn1/test/asn1_SUITE_data/InfObj.asn
@@ -202,7 +202,11 @@ constructed2 CONSTRUCTED-DEFAULT ::= { &id 2, &ok false }
ConstructedDefaultSet CONSTRUCTED-DEFAULT ::= {
constructed1 |
constructed2 |
- { &id 3, &Type BOOLEAN }
+ { &id 3, &Type BOOLEAN } |
+ { &id 4, &Type SET { a INTEGER, b BIT STRING } } |
+ { &id 5, &Type CHOICE { i INTEGER, b BIT STRING } } |
+ { &id 6, &Type SEQUENCE OF INTEGER (1..16) } |
+ { &id 7, &Type SET OF INTEGER (1..64) }
}
ConstructedPdu ::= SEQUENCE {
@@ -210,6 +214,11 @@ ConstructedPdu ::= SEQUENCE {
content CONSTRUCTED-DEFAULT.&Type ({ConstructedDefaultSet}{@id})
}
+ConstructedSet ::= SET {
+ id [0] CONSTRUCTED-DEFAULT.&id ({ConstructedDefaultSet}),
+ content [1] CONSTRUCTED-DEFAULT.&Type ({ConstructedDefaultSet}{@id})
+}
+
END
diff --git a/lib/asn1/test/testInfObj.erl b/lib/asn1/test/testInfObj.erl
index c7b19a0cbb..2b751f7fb7 100644
--- a/lib/asn1/test/testInfObj.erl
+++ b/lib/asn1/test/testInfObj.erl
@@ -59,6 +59,43 @@ main(_Erule) ->
{'ConstructedPdu',2,{'CONSTRUCTED-DEFAULT_Type',999,false}}),
roundtrip('InfObj', 'ConstructedPdu',
{'ConstructedPdu',3,true}),
+ {'ConstructedPdu',4,{_,42,<<13:7>>}} =
+ enc_dec('InfObj', 'ConstructedPdu',
+ {'ConstructedPdu',4,{'',42,<<13:7>>}}),
+ roundtrip('InfObj', 'ConstructedPdu',
+ {'ConstructedPdu',5,{i,-250138}}),
+ roundtrip('InfObj', 'ConstructedPdu',
+ {'ConstructedPdu',5,{b,<<13456:15>>}}),
+ roundtrip('InfObj', 'ConstructedPdu',
+ {'ConstructedPdu',6,[]}),
+ roundtrip('InfObj', 'ConstructedPdu',
+ {'ConstructedPdu',6,[10,7,16,1,5,13,12]}),
+ roundtrip('InfObj', 'ConstructedPdu',
+ {'ConstructedPdu',7,[]}),
+ roundtrip('InfObj', 'ConstructedPdu',
+ {'ConstructedPdu',7,[64,1,19,17,35]}),
+
+ roundtrip('InfObj', 'ConstructedSet',
+ {'ConstructedSet',1,{'CONSTRUCTED-DEFAULT_Type',-2001,true}}),
+ roundtrip('InfObj', 'ConstructedSet',
+ {'ConstructedSet',2,{'CONSTRUCTED-DEFAULT_Type',999,false}}),
+ roundtrip('InfObj', 'ConstructedSet',
+ {'ConstructedSet',3,true}),
+ {'ConstructedSet',4,{_,42,<<13:7>>}} =
+ enc_dec('InfObj', 'ConstructedSet',
+ {'ConstructedSet',4,{'',42,<<13:7>>}}),
+ roundtrip('InfObj', 'ConstructedSet',
+ {'ConstructedSet',5,{i,-250138}}),
+ roundtrip('InfObj', 'ConstructedSet',
+ {'ConstructedSet',5,{b,<<13456:15>>}}),
+ roundtrip('InfObj', 'ConstructedSet',
+ {'ConstructedSet',6,[]}),
+ roundtrip('InfObj', 'ConstructedSet',
+ {'ConstructedSet',6,[10,7,16,1,5,13,12]}),
+ roundtrip('InfObj', 'ConstructedSet',
+ {'ConstructedSet',7,[]}),
+ roundtrip('InfObj', 'ConstructedSet',
+ {'ConstructedSet',7,[64,1,19,17,35]}),
roundtrip('InfObj', 'Seq2',
{'Seq2',42,[true,false,false,true],
@@ -69,3 +106,8 @@ roundtrip(M, T, V) ->
{ok,Enc} = M:encode(T, V),
{ok,V} = M:decode(T, Enc),
ok.
+
+enc_dec(M, T, V0) ->
+ {ok,Enc} = M:encode(T, V0),
+ {ok,V} = M:decode(T, Enc),
+ V.