aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/test/testChoExtension.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-01-10 11:03:04 +0100
committerBjörn Gustavsson <[email protected]>2013-01-10 11:03:04 +0100
commitd07defaadc038455d3122bc7fdf2523efd2a9841 (patch)
tree48e39757174531eaea6361178ca330c592bca9c8 /lib/asn1/test/testChoExtension.erl
parent4cd517c8168b2bdf7b38544e91afc14b535b3989 (diff)
parenta12301def60aa2c20f25eaad1299089de3375063 (diff)
downloadotp-d07defaadc038455d3122bc7fdf2523efd2a9841.tar.gz
otp-d07defaadc038455d3122bc7fdf2523efd2a9841.tar.bz2
otp-d07defaadc038455d3122bc7fdf2523efd2a9841.zip
Merge branch 'bjorn/asn1/minor-fixes'
* bjorn/asn1/minor-fixes: (21 commits) Always inline decoding of open types Eliminate code duplication per: Slightly optimize encoding of fixed OCTET STRINGs per: Fix encoding of OCTET STRINGs with fixed length of 256 or more Remove support for the {Typename,Value} notation in encoding asn1ct_parser2: Let synonyms share parsing code Add a test case for constraint equivalence Make .abs file consultable Fix a bug in skipping of extensions asn1rt_uper_bin: Correct incorrect skipping of extensions asn1 doc: Remove a reference to a section that has been removed Simplify testConstraints by introducing helper functions Simplify testCompactBitString by introducing roundtrip functions Simplify testEnumExt by introducing a roundtrip/2 function Simplify testChoExternal by introducing a roundtrip/2 function Simplify testChoRecursive by introducing a roundtrip/2 function Simplify testSeqExtension.erl by introducing a roundtrip/2 function Simplify testChoExtension by introducing a roundtrip/2 function Simplify testSetOptional by introducing a roundtrip/2 function testSetOptional: Correct test case for decoding of corrupt data ...
Diffstat (limited to 'lib/asn1/test/testChoExtension.erl')
-rw-r--r--lib/asn1/test/testChoExtension.erl41
1 files changed, 13 insertions, 28 deletions
diff --git a/lib/asn1/test/testChoExtension.erl b/lib/asn1/test/testChoExtension.erl
index b75cfb6831..067d4d2bf7 100644
--- a/lib/asn1/test/testChoExtension.erl
+++ b/lib/asn1/test/testChoExtension.erl
@@ -25,42 +25,27 @@
extension(_Rules) ->
-
- ?line {ok,Bytes1} = asn1_wrapper:encode('ChoExtension','ChoExt1',{'ChoExt1',{bool,true}}),
- ?line {ok,{bool,true}} =
- asn1_wrapper:decode('ChoExtension','ChoExt1',lists:flatten(Bytes1)),
-
- ?line {ok,Bytes2} = asn1_wrapper:encode('ChoExtension','ChoExt1',{'ChoExt1',{int,33}}),
- ?line {ok,{int,33}} =
- asn1_wrapper:decode('ChoExtension','ChoExt1',lists:flatten(Bytes2)),
+ roundtrip('ChoExt1', {bool,true}),
+ roundtrip('ChoExt1', {int,33}),
%% A trick to encode with another compatible CHOICE type to test reception
%% extension alternative
- ?line {ok,Bytes2x} = asn1_wrapper:encode('ChoExtension','ChoExt1x',{str,"abc"}),
- ?line {ok,Val2x} =
+ {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]),
- ?line {ok,Bytes3} = asn1_wrapper:encode('ChoExtension','ChoExt2',{'ChoExt2',{bool,true}}),
- ?line {ok,{bool,true}} =
- asn1_wrapper:decode('ChoExtension','ChoExt2',lists:flatten(Bytes3)),
-
- ?line {ok,Bytes4} = asn1_wrapper:encode('ChoExtension','ChoExt2',{'ChoExt2',{int,33}}),
- ?line {ok,{int,33}} =
- asn1_wrapper:decode('ChoExtension','ChoExt2',lists:flatten(Bytes4)),
+ roundtrip('ChoExt2', {bool,true}),
+ roundtrip('ChoExt2', {int,33}),
+ roundtrip('ChoExt3', {bool,true}),
+ roundtrip('ChoExt3', {int,33}),
+ roundtrip('ChoExt4', {str,"abc"}),
- ?line {ok,Bytes5} = asn1_wrapper:encode('ChoExtension','ChoExt3',{'ChoExt3',{bool,true}}),
- ?line {ok,{bool,true}} =
- asn1_wrapper:decode('ChoExtension','ChoExt3',lists:flatten(Bytes5)),
-
- ?line {ok,Bytes6} = asn1_wrapper:encode('ChoExtension','ChoExt3',{'ChoExt3',{int,33}}),
- ?line {ok,{int,33}} =
- asn1_wrapper:decode('ChoExtension','ChoExt3',lists:flatten(Bytes6)),
-
- Val7 = {str,"abc"},
- ?line {ok,Bytes7} = asn1_wrapper:encode('ChoExtension','ChoExt4',Val7),
- ?line {ok,Val7} = asn1_wrapper:decode('ChoExtension','ChoExt4',lists:flatten(Bytes7)),
+ ok.
+roundtrip(Type, Value) ->
+ {ok,Encoded} = 'ChoExtension':encode(Type, Value),
+ {ok,Value} = 'ChoExtension':decode(Type, Encoded),
ok.