megaco_sdp_test.erl

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

ERL
974
字号
    %% -- (PP) (ok) --    PP_B01_MOD  = "2",    PP_B01_BW   = 523,    PP_B01      = cre_PropertyParm_b(PP_B01_MOD, PP_B01_BW),    SDP_B01     = cre_sdp_b(PP_B01_MOD, PP_B01_BW),     PP_B01_Exp  = {ok, SDP_B01},     SDP_B01_Exp = {ok, PP_B01},     %% -- (PP) (error) --    PP_B02_B   = "sune",     PP_B02     = cre_PropertyParm("b", PP_B02_B),     PP_B02_Exp = {error, {invalid_PropertyParm,			  {bandwidth_info, PP_B02_B, [PP_B02_B]}}},         %% -- (PP) (ok) --    PP_B03_MOD  = "X",    PP_B03_BW   = 525,    PP_B03      = cre_PropertyParm_b(PP_B03_MOD, PP_B03_BW),    SDP_B03     = cre_sdp_b(PP_B03_MOD, PP_B03_BW),     PP_B03_Exp  = {ok, SDP_B03},     SDP_B03_Exp = {ok, PP_B03},     %% -- (PP) (error) --    PP_B04_MOD  = "X",    PP_B04_BW   = "sune",     PP_B04      = cre_PropertyParm_b(PP_B04_MOD, PP_B04_BW),    SDP_B04     = cre_sdp_b(PP_B04_MOD, PP_B04_BW),     PP_B04_Exp  = {error, {invalid_bandwidth_bandwidth, PP_B04_BW}},     SDP_B04_Exp = {error, {invalid_bandwidth_bandwidth, PP_B04_BW}},     %% -- (PP) (ok) --    PP_T01_START = 1200,    PP_T01_STOP  = 1300,    PP_T01       = cre_PropertyParm_t(PP_T01_START, PP_T01_STOP),    SDP_T01      = cre_sdp_t(PP_T01_START, PP_T01_STOP),     PP_T01_Exp   = {ok, SDP_T01},     SDP_T01_Exp  = {ok, PP_T01},     %% -- (PP) (ok) --    PP_R01_RPT  = "10",    PP_R01_DUR  = "100",    PP_R01_LOO  = ["2", "4", "6"],    PP_R01      = cre_PropertyParm_r(PP_R01_RPT, PP_R01_DUR, PP_R01_LOO),    SDP_R01     = cre_sdp_r(PP_R01_RPT, PP_R01_DUR, PP_R01_LOO),     PP_R01_Exp  = {ok, SDP_R01},     SDP_R01_Exp = {ok, PP_R01},     %% -- (PP) (ok) --    PP_Z01_LOA  = ["12121212", "-1h", "34343434", "0"],     PP_Z01      = cre_PropertyParm_z(PP_Z01_LOA),     SDP_Z01     = cre_sdp_z(PP_Z01_LOA),     PP_Z01_Exp  = {ok, SDP_Z01},     SDP_Z01_Exp = {ok, PP_Z01},     %% -- (PP) (ok) --    PP_K01_M    = prompt,    PP_K01_EK   = undefined,    PP_K01      = cre_PropertyParm_k(PP_K01_M, PP_K01_EK),    SDP_K01     = cre_sdp_k(PP_K01_M),     PP_K01_Exp  = {ok, SDP_K01},     SDP_K01_Exp = {ok, PP_K01},     %% -- (PP) (ok) --    PP_K02_M    = clear,    PP_K02_EK   = "whatever",    PP_K02      = cre_PropertyParm_k(PP_K02_M, PP_K02_EK),    SDP_K02     = cre_sdp_k(PP_K02_M, PP_K02_EK),     PP_K02_Exp  = {ok, SDP_K02},     SDP_K02_Exp = {ok, PP_K02},     %% -- (PP) (ok) --    PP_K03_M    = "method",     PP_K03_EK   = "key",     PP_K03      = cre_PropertyParm_k(PP_K03_M, PP_K03_EK),    SDP_K03     = cre_sdp_k(PP_K03_M, PP_K03_EK),     PP_K03_Exp  = {ok, SDP_K03},     SDP_K03_Exp = {ok, PP_K03},     %% -- (PP) (ok) --    PP_S01_SN   = "new session",     PP_S01      = cre_PropertyParm_s(PP_S01_SN),     SDP_S01     = cre_sdp_s(PP_S01_SN),     PP_S01_Exp  = {ok, SDP_S01},     SDP_S01_Exp = {ok, PP_S01},     %% -- (PP) (ok) --    PP_I01_SD   = "Session and Media Information",     PP_I01      = cre_PropertyParm_i(PP_I01_SD),     SDP_I01     = cre_sdp_i(PP_I01_SD),     PP_I01_Exp  = {ok, SDP_I01},     SDP_I01_Exp = {ok, PP_I01},     %% -- (PP) (ok) --    PP_U01_URI  = "http://www.erlang.org/",     PP_U01      = cre_PropertyParm_u(PP_U01_URI),     SDP_U01     = cre_sdp_u(PP_U01_URI),     PP_U01_Exp  = {ok, SDP_U01},     SDP_U01_Exp = {ok, PP_U01},     %% -- (PP) (ok) --    PP_E01_EMAIL = "kalle@company.se",     PP_E01       = cre_PropertyParm_e(PP_E01_EMAIL),     SDP_E01      = cre_sdp_e(PP_E01_EMAIL),     PP_E01_Exp   = {ok, SDP_E01},     SDP_E01_Exp  = {ok, PP_E01},     %% -- (PP) (ok) --    PP_P01_PHONE = "+1 713 555 1234",     PP_P01       = cre_PropertyParm_p(PP_P01_PHONE),     SDP_P01      = cre_sdp_p(PP_P01_PHONE),     PP_P01_Exp   = {ok, SDP_P01},     SDP_P01_Exp  = {ok, PP_P01},     %% -- (PP) (error) --    PP_N01     = cre_PropertyParm("not_recognized", "whatever"),     PP_N01_Exp = {error, undefined_PropertyParm},     %% -- (PG) (ok) --    PG01    = [{PP_V01, ok}, 	       {PP_C01, ok}, 	       {PP_M01, ok}],     %% -- (PG) (ok) --    PG02    = [{PP_V02, ok}, 	       {PP_C05, ok}, 	       {PP_A02, ok}],     %% -- (PG) (error) --    PG03    = [{PP_V03, error}, 	       {PP_C08, ok}, 	       {PP_M02, ok}],     %% -- (PG) (error) --    PG04   = [{PP_V02, ok}, 	      {PP_C04, error},	      {PP_C07, error}],    %% -- (PGs) (ok) --    PGS01 = [PG01, PG02],     %% -- (PGs) (error) --    PGS02 = [PG01, PG04],     Instructions = 	[	 pp_dec_instruction("version 01 - dec [ok]", PP_V01,  PP_V01_Exp), 	 pp_enc_instruction("version 01 - enc [ok]", SDP_V01, SDP_V01_Exp),	 pp_dec_instruction("version 02 - dec [ok]", PP_V02,  PP_V02_Exp),	 pp_enc_instruction("version 02 - enc [ok]", SDP_V02, SDP_V02_Exp),	 pp_dec_instruction("version 03 - dec [error]", PP_V03,  PP_V03_Exp),	 pp_enc_instruction("version 03 - enc [error]", SDP_V03, SDP_V03_Exp),	 pp_dec_instruction("connection info 01 - dec [ok]", PP_C01,  PP_C01_Exp),    	 pp_enc_instruction("connection info 01 - enc [ok]", SDP_C01, SDP_C01_Exp),    	 pp_dec_instruction("connection info 02 - dec [ok]", PP_C02,  PP_C02_Exp),    	 pp_enc_instruction("connection info 02 - enc [ok]", SDP_C02, SDP_C02_Exp),    	 pp_dec_instruction("connection info 03 - dec [ok]", PP_C03,  PP_C03_Exp),    	 pp_enc_instruction("connection info 03 - enc [ok]", SDP_C03, SDP_C03_Exp),    	 pp_dec_instruction("connection info 04 - dec [error]", PP_C04,  PP_C04_Exp),    	 pp_dec_instruction("connection info 05 - dec [ok]", PP_C05,  PP_C05_Exp),    	 pp_enc_instruction("connection info 05 - enc [ok]", SDP_C05, SDP_C05_Exp),    	 pp_dec_instruction("connection info 06 - dec [ok]", PP_C06,  PP_C06_Exp),    	 pp_enc_instruction("connection info 06 - enc [ok]", SDP_C06, SDP_C06_Exp),    	 pp_dec_instruction("connection info 07 - dec [error]", PP_C07,  PP_C07_Exp),    	 pp_enc_instruction("connection info 07 - enc [error]", SDP_C07, SDP_C07_Exp),    	 pp_dec_instruction("connection info 08 - dec [ok]", PP_C08,  PP_C08_Exp),    	 pp_enc_instruction("connection info 08 - enc [ok]", SDP_C08, SDP_C08_Exp),    	 pp_dec_instruction("media announcement 01 - dec [ok]", PP_M01,  PP_M01_Exp),    	 pp_enc_instruction("media announcement 01 - enc [ok]", SDP_M01, SDP_M01_Exp),    	 pp_dec_instruction("media announcement 02 - dec [ok]", PP_M02,  PP_M02_Exp),    	 pp_enc_instruction("media announcement 02 - enc [ok]", SDP_M02, SDP_M02_Exp),    	 pp_dec_instruction("origin 01 - dec [ok]", PP_O01,  PP_O01_Exp),    	 pp_enc_instruction("origin 01 - enc [ok]", SDP_O01, SDP_O01_Exp),    	 pp_dec_instruction("origin 02 - dec [ok]", PP_O02,  PP_O02_Exp),    	 pp_enc_instruction("origin 02 - enc [ok]", SDP_O02, SDP_O02_Exp),    	 pp_dec_instruction("attributes 01 - dec [ok]", PP_A01,  PP_A01_Exp),    	 pp_enc_instruction("attributes 01 - enc [ok]", SDP_A01, SDP_A01_Exp),    	 pp_dec_instruction("attributes 02 - dec [ok]", PP_A02,  PP_A02_Exp),    	 pp_enc_instruction("attributes 02 - enc [ok]", SDP_A02, SDP_A02_Exp),    	 pp_dec_instruction("attributes 03 - dec [ok]", PP_A03,  PP_A03_Exp),    	 pp_enc_instruction("attributes 03 - enc [ok]", SDP_A03, SDP_A03_Exp),    	 pp_dec_instruction("attributes 04 - dec [error]", PP_A04,  PP_A04_Exp),    	 pp_enc_instruction("attributes 04 - enc [error]", SDP_A04, SDP_A04_Exp),    	 pp_dec_instruction("attributes 05 - dec [ok]", PP_A05,  PP_A05_Exp),    	 pp_enc_instruction("attributes 05 - enc [ok]", SDP_A05, SDP_A05_Exp),    	 pp_dec_instruction("attributes 06 - dec [error]", PP_A06,  PP_A06_Exp),    	 pp_enc_instruction("attributes 06 - dec [error]", SDP_A06, SDP_A06_Exp),    	 pp_dec_instruction("attributes 07 - dec [ok]", PP_A07,  PP_A07_Exp),    	 pp_enc_instruction("attributes 07 - enc [ok]", SDP_A07, SDP_A07_Exp),    	 pp_dec_instruction("attributes 08 - dec [ok]", PP_A08,  PP_A08_Exp),    	 pp_enc_instruction("attributes 08 - enc [ok]", SDP_A08, SDP_A08_Exp),    	 pp_dec_instruction("bandwidth 01 - dec [ok]", PP_B01,  PP_B01_Exp),    	 pp_enc_instruction("bandwidth 01 - enc [ok]", SDP_B01, SDP_B01_Exp),    	 pp_dec_instruction("bandwidth 02 - dec [ok]", PP_B02,  PP_B02_Exp),    	 pp_dec_instruction("bandwidth 03 - dec [ok]", PP_B03,  PP_B03_Exp),    	 pp_enc_instruction("bandwidth 03 - enc [ok]", SDP_B03, SDP_B03_Exp),    	 pp_dec_instruction("bandwidth 04 - dec [error]", PP_B04,  PP_B04_Exp),    	 pp_enc_instruction("bandwidth 04 - enc [error]", SDP_B04, SDP_B04_Exp),    	 pp_dec_instruction("times 01 - dec [ok]", PP_T01,  PP_T01_Exp),    	 pp_enc_instruction("times 01 - enc [ok]", SDP_T01, SDP_T01_Exp),    	 pp_dec_instruction("repeat times 01 - dec [ok]", PP_R01,  PP_R01_Exp),    	 pp_enc_instruction("repeat times 01 - enc [ok]", SDP_R01, SDP_R01_Exp),    	 pp_dec_instruction("time zones 01 - dec [ok]", PP_Z01,  PP_Z01_Exp),    	 pp_enc_instruction("time zones 01 - enc [ok]", SDP_Z01, SDP_Z01_Exp),    	 pp_dec_instruction("encryption keys 01 - dec [ok]", PP_K01,  PP_K01_Exp),    	 pp_enc_instruction("encryption keys 01 - enc [ok]", SDP_K01, SDP_K01_Exp),    	 pp_dec_instruction("encryption keys 01 - dec [ok]", PP_K02,  PP_K02_Exp),    	 pp_enc_instruction("encryption keys 01 - enc [ok]", SDP_K02, SDP_K02_Exp),    	 pp_dec_instruction("encryption keys 01 - dec [ok]", PP_K03,  PP_K03_Exp),    	 pp_enc_instruction("encryption keys 01 - enc [ok]", SDP_K03, SDP_K03_Exp),    	 pp_dec_instruction("session name 01 - dec [ok]", PP_S01,  PP_S01_Exp),    	 pp_enc_instruction("session name 01 - enc [ok]", SDP_S01, SDP_S01_Exp),    	 pp_dec_instruction("session and media information 01 - dec [ok]", PP_I01,  PP_I01_Exp),    	 pp_enc_instruction("session and media information 01 - enc [ok]", SDP_I01, SDP_I01_Exp),    	 pp_dec_instruction("uri 01 - dec [ok]", PP_U01,  PP_U01_Exp),    	 pp_enc_instruction("uri 01 - enc [ok]", SDP_U01, SDP_U01_Exp),    	 pp_dec_instruction("email 01 - dec [ok]", PP_E01,  PP_E01_Exp),    	 pp_enc_instruction("email 01 - enc [ok]", SDP_E01, SDP_E01_Exp),    	 pp_dec_instruction("phone 01 - dec [ok]", PP_P01,  PP_P01_Exp),    	 pp_enc_instruction("phone 01 - enc [ok]", SDP_P01, SDP_P01_Exp),    	 pp_dec_instruction("undefined 01 - dec [error]", PP_N01,  PP_N01_Exp),    	 pg_dec_instruction("property group 01 - ok", PG01),	 pg_dec_instruction("property group 02 - ok", PG02),	 pg_dec_instruction("property group 03 - error", PG03),	 pg_dec_instruction("property group 04 - error", PG04),	 	 pgs_dec_instruction("property groups 01 - ok", PGS01),	 pgs_dec_instruction("property groups 02 - error", PGS02)	],    exec(Instructions).verify_decode_pg([], []) ->    ok;verify_decode_pg([{PP, error}|PPs], [{PP, _Err}|SDPs]) ->    verify_decode_pg(PPs, SDPs); verify_decode_pg([{PP, ok}|_], [{PP, _Err}|_]) ->    error;verify_decode_pg([{_PP, _ExpStatus}|PG], [_SDP|SDP_PG]) ->    verify_decode_pg(PG, SDP_PG).verify_decode_pgs(PGS, SDP_PGS) ->    verify_decode_pg(lists:flatten(PGS), lists:flatten(SDP_PGS)).%% ===============================================================%% %% Instruction engine%% instr_verify_pp(Expected) ->    fun(Res) ->	    case Res of		Expected -> ok;		_        -> {error, Expected}	    end    end.instr_verify_dec_pg(Data) ->    fun({ok, SDP}) -> 	    verify_decode_pg(Data, SDP);       (_Bad)      -> 	    error    end.instr_verify_dec_pgs(Data) ->    fun({ok, SDP}) -> 	    verify_decode_pgs(Data, SDP);       (_Bad)      -> 	    error    end.pp_dec_instruction(Desc, Data, Exp) ->    dec_instruction(Desc, Data, instr_verify_pp(Exp)).pp_enc_instruction(Desc, Data, Exp) ->    enc_instruction(Desc, Data, instr_verify_pp(Exp)).pg_dec_instruction(Desc, Data0) ->     Data = [D || {D, _} <- Data0],     dec_instruction(Desc, Data, instr_verify_dec_pg(Data0)).pgs_dec_instruction(Desc, Data0) ->    Data = [[D || {D, _} <- PG] || PG <- Data0],     dec_instruction(Desc, Data, instr_verify_dec_pgs(Data0)).dec_instruction(Desc, Data, Verify) ->    instruction(Desc, fun(D) -> megaco:decode_sdp(D) end, Data, Verify).enc_instruction(Desc, Data, Verify) ->    instruction(Desc, fun(D) -> megaco:encode_sdp(D) end, Data, Verify).instruction(Desc, Cmd, Data, Verify) ->    {Desc, Cmd, Data, Verify}.exec(Instructions) ->    exec(Instructions, []).

⌨️ 快捷键说明

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