megaco_codec_v2_test.erl

来自「OTP是开放电信平台的简称」· ERL 代码 · 共 2,258 行 · 第 1/5 页

ERL
2,258
字号
	 }	}       ]      }     }    }.compact_otp5186_msg04() ->    {'MegacoMessage',asn1_NOVALUE,     {'Message',2,{domainName,{'DomainName',"mg5",asn1_NOVALUE}},      {transactions,       [{transactionReply,	 {'TransactionReply',67111298,asn1_NOVALUE,	  {actionReplies,[			  {'ActionReply',2699,asn1_NOVALUE,asn1_NOVALUE,			   [			    {auditValueReply,			     {auditResult,			      {'AuditResult',			       {megaco_term_id,false,["mg5_ipeph","0x0f0001"]},			       [				{emptyDescriptors,				 {'AuditDescriptor',asn1_NOVALUE,asn1_NOVALUE}				}			       ]			      }			     }			    }			   ]			  }			 ]	  }	 }	}       ]      }     }    }.compact_otp5186_msg05() ->    {'MegacoMessage',     asn1_NOVALUE,     {'Message',      2,      {domainName,{'DomainName',"mg5",asn1_NOVALUE}},      {transactions,       [{transactionReply,	 {'TransactionReply',67111298,asn1_NOVALUE,	  {actionReplies,[			  {'ActionReply',2699,asn1_NOVALUE,asn1_NOVALUE,			   [			    {addReply,			     {'AmmsReply',			      [			       {megaco_term_id,false,["mg5_ipeph","0x0f0001"]}			      ],			      [			      ]			     }			    }			   ]			  }			 ]	  }	 }	}       ]      }     }    }.compact_otp5186_msg06() ->    {'MegacoMessage',asn1_NOVALUE,     {'Message',2,{domainName,{'DomainName',"mg5",asn1_NOVALUE}},      {transactions,       [{transactionReply,	 {'TransactionReply',67111298,asn1_NOVALUE,	  {actionReplies,[			  {'ActionReply',2699,asn1_NOVALUE,asn1_NOVALUE,			   [			    {addReply,			     {'AmmsReply',			      [			       {megaco_term_id,false,["mg5_ipeph","0x0f0001"]}			      ],			      [			       {emptyDescriptors,				{'AuditDescriptor',asn1_NOVALUE,asn1_NOVALUE}			       }			      ]			     }			    }			   ]			  }			 ]	  }	 }	}       ]      }     }    }.%% --compact_otp5186_check_megamsg(M1, M1) ->    ok;compact_otp5186_check_megamsg(#'MegacoMessage'{authHeader = AH,					       mess = M1}, 			      #'MegacoMessage'{authHeader = AH,					       mess = M2}) ->    compact_otp5186_check_mess(M1, M2);compact_otp5186_check_megamsg(#'MegacoMessage'{authHeader = AH1},			      #'MegacoMessage'{authHeader = AH2}) ->    exit({not_equal, authHeader, AH1, AH2}).compact_otp5186_check_mess(M, M) ->    ok;compact_otp5186_check_mess(#'Message'{version     = V, 				      mId         = MId,				      messageBody = B1},			   #'Message'{version     = V, 				      mId         = MId,				      messageBody = B2}) ->    compact_otp5186_check_body(B1, B2);compact_otp5186_check_mess(#'Message'{version     = V, 				      mId         = MId1},			   #'Message'{version     = V, 				      mId         = MId2}) ->    exit({not_equal, mId, MId1, MId2});compact_otp5186_check_mess(#'Message'{version     = V1, 				      mId         = MId},			   #'Message'{version     = V2, 				      mId         = MId}) ->    exit({not_equal, version, V1, V2}).compact_otp5186_check_body(B, B) ->    ok;compact_otp5186_check_body({transactions, T1}, {transactions, T2}) ->    compact_otp5186_check_trans(T1, T2);compact_otp5186_check_body({messageError, E1}, {messageError, E2}) ->    compact_otp5186_check_merr(E1, E2);compact_otp5186_check_body(B1, B2) ->    exit({not_equal, messageBody, B1, B2}).compact_otp5186_check_trans([], []) ->    ok;compact_otp5186_check_trans([], T2) ->    exit({not_equal, transactions, [], T2});compact_otp5186_check_trans(T1, []) ->    exit({not_equal, transactions, T1, []});compact_otp5186_check_trans([Tran1|Trans1], [Tran2|Trans2]) ->    compact_otp5186_check_trans(Trans1, Trans2),    compact_otp5186_check_transaction(Tran1, Tran2).compact_otp5186_check_merr(ME, ME) ->    ok;compact_otp5186_check_merr(#'ErrorDescriptor'{errorCode = EC,					      errorText = ET1},			   #'ErrorDescriptor'{errorCode = EC,					      errorText = ET2}) ->    exit({not_equal, errorText, ET1, ET2});compact_otp5186_check_merr(#'ErrorDescriptor'{errorCode = EC1,					      errorText = ET},			   #'ErrorDescriptor'{errorCode = EC2,					      errorText = ET}) ->    exit({not_equal, errorCode, EC1, EC2}).compact_otp5186_check_transaction(T, T) ->    ok;compact_otp5186_check_transaction({transactionReply, TR1}, 				  {transactionReply, TR2}) ->    compact_otp5186_check_transRep(TR1, TR2);compact_otp5186_check_transaction(T1, T2) ->    exit({unexpected_transactions, T1, T2}).    compact_otp5186_check_transRep(T, T) ->    ok;compact_otp5186_check_transRep(#'TransactionReply'{transactionId     = TId,						   immAckRequired    = IAR,						   transactionResult = TR1},			       #'TransactionReply'{transactionId     = TId,						   immAckRequired    = IAR,						   transactionResult = TR2}) ->    compact_otp5186_check_transRes(TR1, TR2);compact_otp5186_check_transRep(T1, T2) ->    exit({unexpected_transaction_reply, T1, T2}).compact_otp5186_check_transRes(TR, TR) ->    ok;compact_otp5186_check_transRes({actionReplies, AR1}, 			       {actionReplies, AR2}) ->    compact_otp5186_check_actReps(AR1, AR2);compact_otp5186_check_transRes(TR1, TR2) ->    exit({unexpected_transaction_result, TR1, TR2}).compact_otp5186_check_actReps([], []) ->    ok;compact_otp5186_check_actReps(AR1, []) ->    exit({not_equal, actionReplies, AR1, []});compact_otp5186_check_actReps([], AR2) ->    exit({not_equal, actionReplies, [], AR2});compact_otp5186_check_actReps([AR1|ARs1], [AR2|ARs2]) ->    compact_otp5186_check_actRep(AR1, AR2),    compact_otp5186_check_actReps(ARs1, ARs2).compact_otp5186_check_actRep(AR, AR) ->    ok;compact_otp5186_check_actRep(#'ActionReply'{contextId       = ID,					    errorDescriptor = ED,					    contextReply    = CtxRep,					    commandReply    = CmdRep1},			     #'ActionReply'{contextId       = ID,					    errorDescriptor = ED,					    contextReply    = CtxRep,					    commandReply    = CmdRep2}) ->    compact_otp5186_check_cmdReps(CmdRep1, CmdRep2);compact_otp5186_check_actRep(AR1, AR2) ->    exit({unexpected_actionReply, AR1, AR2}).compact_otp5186_check_cmdReps([], []) ->    ok;compact_otp5186_check_cmdReps(CR1, []) ->    exit({not_equal, commandReplies, CR1, []});compact_otp5186_check_cmdReps([], CR2) ->    exit({not_equal, commandReplies, [], CR2});compact_otp5186_check_cmdReps([CR1|CRs1], [CR2|CRs2]) ->    compact_otp5186_check_cmdRep(CR1, CR2),    compact_otp5186_check_cmdReps(CRs1, CRs2).compact_otp5186_check_cmdRep(CR, CR) ->    ok;compact_otp5186_check_cmdRep({auditValueReply, AVR1}, 			     {auditValueReply, AVR2}) ->    compact_otp5186_check_auditReply(AVR1, AVR2);compact_otp5186_check_cmdRep({addReply, AVR1}, 			     {addReply, AVR2}) ->    compact_otp5186_check_ammsReply(AVR1, AVR2);compact_otp5186_check_cmdRep(CR1, CR2) ->    exit({unexpected_commandReply, CR1, CR2}).compact_otp5186_check_auditReply(AR, AR) ->    ok;compact_otp5186_check_auditReply({auditResult, AR1}, 				 {auditResult, AR2}) ->    compact_otp5186_check_auditRes(AR1, AR2);compact_otp5186_check_auditReply(AR1, AR2) ->    exit({unexpected_auditReply, AR1, AR2}).compact_otp5186_check_ammsReply(AR, AR) ->    ok;compact_otp5186_check_ammsReply(#'AmmsReply'{terminationID = ID,					     terminationAudit = TA1},				#'AmmsReply'{terminationID = ID,					     terminationAudit = TA2}) ->    %% This is just to simplify the test    F = fun(asn1_NOVALUE) -> [];	   (E) -> E	end,    compact_otp5186_check_termAudit(F(TA1), F(TA2));compact_otp5186_check_ammsReply(AR1, AR2) ->    exit({unexpected_ammsReply, AR1, AR2}).compact_otp5186_check_auditRes(AR, AR) ->    ok;compact_otp5186_check_auditRes(#'AuditResult'{terminationID = ID,					      terminationAuditResult = TAR1},			       #'AuditResult'{terminationID = ID,					      terminationAuditResult = TAR2}) ->    compact_otp5186_check_termAuditRes(TAR1, TAR2);compact_otp5186_check_auditRes(AR1, AR2) ->    exit({unexpected_auditResult, AR1, AR2}).compact_otp5186_check_termAuditRes([], []) ->    ok;%% An empty empty descriptor is removedcompact_otp5186_check_termAuditRes([{emptyDescriptors,				     #'AuditDescriptor'{auditToken = asn1_NOVALUE,							auditPropertyToken = asn1_NOVALUE}}|TAR1], []) ->    compact_otp5186_check_termAuditRes(TAR1, []);compact_otp5186_check_termAuditRes(TAR1, []) ->    exit({not_equal, termAuditRes, TAR1, []});%% An empty empty descriptor is removedcompact_otp5186_check_termAuditRes([], [{emptyDescriptors,					 #'AuditDescriptor'{auditToken = asn1_NOVALUE,							    auditPropertyToken = asn1_NOVALUE}}|TAR2]) ->    compact_otp5186_check_termAuditRes([], TAR2);compact_otp5186_check_termAuditRes([], TAR2) ->    exit({not_equal, termAuditRes, [], TAR2});compact_otp5186_check_termAuditRes([ARP1|TAR1], [ARP2|TAR2]) ->    compact_otp5186_check_auditRetParm(ARP1, ARP2),    compact_otp5186_check_termAuditRes(TAR1, TAR2).compact_otp5186_check_termAudit([], []) ->    ok;%% An empty empty descriptor is removedcompact_otp5186_check_termAudit([{emptyDescriptors,				  #'AuditDescriptor'{auditToken = asn1_NOVALUE,						     auditPropertyToken = asn1_NOVALUE}}|TAR1], []) ->    compact_otp5186_check_termAudit(TAR1, []);compact_otp5186_check_termAudit(TAR1, []) ->    exit({not_equal, termAudit, TAR1, []});%% An empty empty descriptor is removedcompact_otp5186_check_termAudit([], 				[{emptyDescriptors,				  #'AuditDescriptor'{auditToken = asn1_NOVALUE,						     auditPropertyToken = asn1_NOVALUE}}|TAR2]) ->    compact_otp5186_check_termAudit([], TAR2);compact_otp5186_check_termAudit([], TAR2) ->    exit({not_equal, termAudit, [], TAR2});compact_otp5186_check_termAudit([ARP1|TAR1], [ARP2|TAR2]) ->    compact_otp5186_check_auditRetParm(ARP1, ARP2),    compact_otp5186_check_termAudit(TAR1, TAR2).compact_otp5186_check_auditRetParm(ARP, ARP) ->    ok;compact_otp5186_check_auditRetParm({emptyDescriptors, AD1}, 				   {emptyDescriptors, AD2}) ->    compact_otp5186_check_auditDesc(AD1, AD2);compact_otp5186_check_auditRetParm(ARP1, ARP2) ->    exit({unexpected_auditRetParm, ARP1, ARP2}).compact_otp5186_check_auditDesc(AD, AD) ->    ok;compact_otp5186_check_auditDesc(#'AuditDescriptor'{auditToken = L1,						   auditPropertyToken = asn1_NOVALUE},				#'AuditDescriptor'{auditToken = L2,						   auditPropertyToken = asn1_NOVALUE}) ->    compact_otp5186_check_auditDesc_auditItems(L1, L2);compact_otp5186_check_auditDesc(#'AuditDescriptor'{auditToken = asn1_NOVALUE,						   auditPropertyToken = APT1},				#'AuditDescriptor'{auditToken = asn1_NOVALUE,						   auditPropertyToken = APT2}) ->    compact_otp5186_check_auditDesc_apt(APT1, APT2);compact_otp5186_check_auditDesc(AD1, AD2) ->    exit({unexpected_auditDesc, AD1, AD2}).compact_otp5186_check_auditDesc_auditItems([], []) ->    ok;compact_otp5186_check_auditDesc_auditItems(AI1, []) ->    exit({not_equal, auditItems, AI1, []});compact_otp5186_check_auditDesc_auditItems([], AI2) ->    exit({not_equal, auditItems, [], AI2});compact_otp5186_check_auditDesc_auditItems([AI1|AIs1], [AI2|AIs2]) ->    compact_otp5186_check_auditDesc_auditItem(AI1, AI2),    compact_otp5186_check_auditDesc_auditItems(AIs1, AIs2).compact_otp5186_check_auditDesc_auditItem(AI, AI) ->    ok;compact_otp5186_check_auditDesc_auditItem(AI1, AI2) ->    exit({not_equal, auditItem, AI1, AI2}).compact_otp5186_check_auditDesc_apt(APT, APT) ->    ok;compact_otp5186_check_auditDesc_apt(APT1, APT2) ->    exit({not_equal, auditPropertyToken, APT1, APT2}).%% --------------------------------------------------------------compact_otp5290_msg01(suite) ->    [];compact_otp5290_msg01(Config) when list(Config) ->    d("compact_otp5290_msg01 -> entry", []),    ?ACQUIRE_NODES(1, Config),    compact_otp5290_msg_1(compact_otp5290_msg01(), ok, ok).compact_otp5290_msg02(suite) ->    [];compact_otp5290_msg02(Config) when list(Config) ->    d("compact_otp5290_msg02 -> entry", []),    ?ACQUIRE_NODES(1, Config),    compact_otp5290_msg_1(compact_otp5290_msg02(), error, ignore).compact_otp5290_msg_1(M1, DecodeExpect, EncodeExpect) ->    Bin1 = list_to_binary(M1),    case decode_message(megaco_compact_text_encoder, false, [], Bin1) of	{ok, Msg} when DecodeExpect == ok -> 	    io:format(" decoded", []),	    case encode_message(megaco_compact_text_encoder, [], Msg) of		{ok, Bin1} when EncodeExpect == ok ->		    io:format(", encoded - equal:", []),		    ok;		{ok, Bin2} when EncodeExpect == ok ->		    M2 = binary_to_list(Bin2),		    io:format(", encoded - not equal:", []),		    exit({messages_not_equal, Msg, M1, M2});		{ok, Bin3} when EncodeExpect == error ->		    M3 = binary_to_list(Bin3),		    io:format(", unexpected encode:", []),		    exit({unexpected_encode_success, Msg, M3});		_ when EncodeExpect == error ->		    io:format(", encode failed ", []),		    ok	    end;	{ok, Msg} when DecodeExpect == error -> 	    io:format(" decoded", []),	    exit({unexpected_decode_success, Msg});	_Else when DecodeExpect == error ->	    io:format(" decode failed ", []),	    ok;	Else when DecodeExpect == ok ->	    io:format(" decode failed ", []),	    exit({unexpected_decode_result, Else})    end.compact_otp5290_msg01() ->    "!/2 <ml>\nT=12345678{C=*{CA{TP,PR}}}".compact_otp5290_msg02() ->    "!/2 <ml>\nT=12345678{C=*{CA{TP,PR,TP}}}".compact_otp5793_msg01(suite) ->    [];compact_otp5793_msg01(Config) when list(Config) ->    d("compact_otp5793_msg01 -> entry", []),    ?ACQUIRE_NODES(1, Config),    compact_otp5793(ok, pretty_otp5793_msg1()).compact_otp5793(Expected, Msg) ->    expect_codec(Expected, megaco_compact_text_encoder, Msg, []).%% --------------------------------------------------------------compact_otp5993_msg01(suite) ->    [];compact_otp5993_msg01(Config) when list(Config) ->    d("compact_otp5993_msg01 -> entry", []),    ?ACQUIRE_NODES(1, Config),    compact_otp5993(ok, compact_otp5993_msg01()).compact_otp5993_msg02(suite) ->    [];compact_otp5993_msg02(Config) when list(Config) ->    d("compact_otp5993_msg02 -> entry", []),    ?ACQUIRE_NODES(1, Config),    compact_otp5993(ok, compact_otp5993_msg02()).compact_otp5993_msg03(suite) ->    [];compact_otp5993_msg03(Config) when list(Config) ->    d("compact_otp5993_msg03 -> entry", []),    ?ACQUIRE_NODES(1, Config),    compact_otp5993(ok, compact_otp5993_msg03()).compact_otp5993(Expected, Msg) ->    expect_codec(Expect

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?