diff options
author | Björn Gustavsson <[email protected]> | 2013-09-13 12:56:06 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2013-09-18 11:45:01 +0200 |
commit | b379d700e1450a3fc7e76bb75369fa6b5eb2d327 (patch) | |
tree | 88a7ef2503b735b8cf8f51444e472facbcc2db5a /lib/asn1/test/testSeqOfCho.erl | |
parent | b8f57af261d72f9f078ddf7190201209dd846d53 (diff) | |
download | otp-b379d700e1450a3fc7e76bb75369fa6b5eb2d327.tar.gz otp-b379d700e1450a3fc7e76bb75369fa6b5eb2d327.tar.bz2 otp-b379d700e1450a3fc7e76bb75369fa6b5eb2d327.zip |
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.
Diffstat (limited to 'lib/asn1/test/testSeqOfCho.erl')
-rw-r--r-- | lib/asn1/test/testSeqOfCho.erl | 150 |
1 files changed, 39 insertions, 111 deletions
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). |