From b379d700e1450a3fc7e76bb75369fa6b5eb2d327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Fri, 13 Sep 2013 12:56:06 +0200 Subject: 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. --- lib/asn1/test/testChoTypeRefSeq.erl | 91 ++++++------------------------------- 1 file changed, 15 insertions(+), 76 deletions(-) (limited to 'lib/asn1/test/testChoTypeRefSeq.erl') diff --git a/lib/asn1/test/testChoTypeRefSeq.erl b/lib/asn1/test/testChoTypeRefSeq.erl index bf2b66c73e..86c22619aa 100644 --- a/lib/asn1/test/testChoTypeRefSeq.erl +++ b/lib/asn1/test/testChoTypeRefSeq.erl @@ -23,82 +23,21 @@ -include_lib("test_server/include/test_server.hrl"). --record('ChoSeq',{seqInt, seqOs}). --record('ChoSeqImp',{seqInt, seqOs}). --record('ChoSeqExp',{seqInt, seqOs}). +-record('ChoSeq', {seqInt, seqOs}). +-record('ChoSeqImp', {seqInt, seqOs}). +-record('ChoSeqExp', {seqInt, seqOs}). seq(_Rules) -> - - ?line {ok,Bytes1} = - asn1_wrapper:encode('ChoTypeRefSeq','ChoTRseq', - {choSeq,#'ChoSeq'{seqInt = 88, - seqOs = "A string"}}), - ?line {ok,{choSeq,{'ChoSeq',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSeq','ChoTRseq',lists:flatten(Bytes1)), - - - ?line {ok,Bytes2} = - asn1_wrapper:encode('ChoTypeRefSeq','ChoTRseq', - {choSeqI,#'ChoSeq'{seqInt = 88, - seqOs = "A string"}}), - ?line {ok,{choSeqI,{'ChoSeq',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSeq','ChoTRseq',lists:flatten(Bytes2)), - - - ?line {ok,Bytes3} = - asn1_wrapper:encode('ChoTypeRefSeq','ChoTRseq', - {choSeqE,#'ChoSeq'{seqInt = 88, - seqOs = "A string"}}), - ?line {ok,{choSeqE,{'ChoSeq',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSeq','ChoTRseq',lists:flatten(Bytes3)), - - - ?line {ok,Bytes4} = - asn1_wrapper:encode('ChoTypeRefSeq','ChoTRseq', - {'choSeq-I',#'ChoSeqImp'{seqInt = 88, - seqOs = "A string"}}), - ?line {ok,{'choSeq-I',{'ChoSeqImp',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSeq','ChoTRseq',lists:flatten(Bytes4)), - - - ?line {ok,Bytes5} = - asn1_wrapper:encode('ChoTypeRefSeq','ChoTRseq', - {'choSeqI-I',#'ChoSeqImp'{seqInt = 88, - seqOs = "A string"}}), - ?line {ok,{'choSeqI-I',{'ChoSeqImp',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSeq','ChoTRseq',lists:flatten(Bytes5)), - - - ?line {ok,Bytes6} = - asn1_wrapper:encode('ChoTypeRefSeq','ChoTRseq', - {'choSeqE-I',#'ChoSeqImp'{seqInt = 88, - seqOs = "A string"}}), - ?line {ok,{'choSeqE-I',{'ChoSeqImp',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSeq','ChoTRseq',lists:flatten(Bytes6)), - - - ?line {ok,Bytes7} = - asn1_wrapper:encode('ChoTypeRefSeq','ChoTRseq', - {'choSeq-E',#'ChoSeqExp'{seqInt = 88, - seqOs = "A string"}}), - ?line {ok,{'choSeq-E',{'ChoSeqExp',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSeq','ChoTRseq',lists:flatten(Bytes7)), - - - ?line {ok,Bytes8} = - asn1_wrapper:encode('ChoTypeRefSeq','ChoTRseq', - {'choSeqI-E',#'ChoSeqExp'{seqInt = 88, - seqOs = "A string"}}), - ?line {ok,{'choSeqI-E',{'ChoSeqExp',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSeq','ChoTRseq',lists:flatten(Bytes8)), - - - ?line {ok,Bytes9} = - asn1_wrapper:encode('ChoTypeRefSeq','ChoTRseq', - {'choSeqE-E',#'ChoSeqExp'{seqInt = 88, - seqOs = "A string"}}), - ?line {ok,{'choSeqE-E',{'ChoSeqExp',88,"A string"}}} = - asn1_wrapper:decode('ChoTypeRefSeq','ChoTRseq',lists:flatten(Bytes9)), - - + roundtrip('ChoTRseq', {choSeq,#'ChoSeq'{seqInt=88,seqOs="A string"}}), + roundtrip('ChoTRseq', {choSeqI,#'ChoSeq'{seqInt=88,seqOs="A string"}}), + roundtrip('ChoTRseq', {choSeqE,#'ChoSeq'{seqInt=88,seqOs="A string"}}), + roundtrip('ChoTRseq', {'choSeq-I',#'ChoSeqImp'{seqInt=88,seqOs="A string"}}), + roundtrip('ChoTRseq', {'choSeqI-I',#'ChoSeqImp'{seqInt=88,seqOs="A string"}}), + roundtrip('ChoTRseq', {'choSeqE-I',#'ChoSeqImp'{seqInt=88,seqOs="A string"}}), + roundtrip('ChoTRseq', {'choSeq-E',#'ChoSeqExp'{seqInt=88,seqOs="A string"}}), + roundtrip('ChoTRseq', {'choSeqI-E',#'ChoSeqExp'{seqInt=88,seqOs="A string"}}), + roundtrip('ChoTRseq', {'choSeqE-E',#'ChoSeqExp'{seqInt=88,seqOs="A string"}}), ok. + +roundtrip(Type, Value) -> + asn1_test_lib:roundtrip('ChoTypeRefSeq', Type, Value). -- cgit v1.2.3