📄 megaco_binary_term_id_test.erl
字号:
%% put(encode_debug,dbg), %% put(decode_debug,dbg), Res = encode_decode(config1(),mtid10()), erase(encode_debug), erase(decode_debug), {ok,Res}.%% --------------------------------------------------------%% basic_enc_dec_with_one_rec_wildcard02te11(doc) -> "Basic encode & decode with one recursive wildcard [1,11]\n (asn -> binary -> asn)";te11(suite) -> [];te11(Config) when list(Config) -> {Exp,Res} = te11(), ok = check(te11(doc),Exp,Res).te11() -> %% put(encode_debug,dbg), %% put(decode_debug,dbg), Res = encode_decode(config1(),mtid11()), erase(encode_debug), erase(decode_debug), {ok,Res}.%% --------------------------------------------------------%% basic_enc_dec_with_one_rec_wildcard03te12(doc) -> "Basic encode & decode with one recursive wildcard [1,12]\n (asn -> binary -> asn)";te12(suite) -> [];te12(Config) when list(Config) -> {Exp,Res} = te12(), ok = check(te12(doc),Exp,Res).te12() -> %% put(encode_debug,dbg), %% put(decode_debug,dbg), Res = encode_decode(config1(),mtid12()), erase(encode_debug), erase(decode_debug), {ok,Res}.%% --------------------------------------------------------%% basic_enc_dec_with_one_rec_wildcard04te13(doc) -> "Basic encode & decode with one recursive wildcard [1,13]\n (asn -> binary -> asn)";te13(suite) -> [];te13(Config) when list(Config) -> {Exp,Res} = te13(), ok = check(te13(doc),Exp,Res).te13() -> %% put(encode_debug,dbg), %% put(decode_debug,dbg), Res = encode_decode(config1(),mtid13()), erase(encode_debug), erase(decode_debug), {ok,Res}.%% --------------------------------------------------------%% basic_enc_dec_with_one_rec_wildcard05te14(doc) -> "Basic encode & decode with one recursive wildcard [2,13]\n (asn -> binary -> asn)";te14(suite) -> [];te14(Config) when list(Config) -> {Exp,Res} = te14(), ok = check(te14(doc),Exp,Res).te14() -> %% put(encode_debug,dbg), %% put(decode_debug,dbg), Res = encode_decode(config2(),mtid13()), erase(encode_debug), erase(decode_debug), {ok,Res}.%% --------------------------------------------------------%% basic_enc_dec_with_one_wildcard_1levelte15(doc) -> "Basic encode & decode with one wildcard in the first level\nand then one empty level [1,15]\n (asn -> binary -> asn)";te15(suite) -> [];te15(Config) when list(Config) -> {Exp,Res} = te15(), ok = check(te15(doc),Exp,Res).te15() -> %% put(encode_debug,dbg), %% put(decode_debug,dbg), Res = encode_decode(config1(),mtid15()), erase(encode_debug), erase(decode_debug), {error,Res}.%% --------------------------------------------------------%% basic_enc_dec_with_one_rec_wildcard06te16(doc) -> "Basic encode & decode with one recursive wildcard [2,15]\n (asn -> binary -> asn)";te16(suite) -> [];te16(Config) when list(Config) -> {Exp,Res} = te16(), ok = check(te16(doc),Exp,Res).te16() -> %% put(encode_debug,dbg), %% put(decode_debug,dbg), Res = encode_decode(config2(),mtid15()), erase(encode_debug), erase(decode_debug), {error,Res}.%% --------------------------------------------------------%% basic_enc_dec_with_one_rec_wildcard07te17(doc) -> "Basic encode & decode with one recursive wildcard [2,11]\n (asn -> binary -> asn)";te17(suite) -> [];te17(Config) when list(Config) -> {Exp,Res} = te17(), ok = check(te17(doc),Exp,Res).te17() -> %% put(encode_debug,dbg), %% put(decode_debug,dbg), Res = encode_decode(config2(),mtid11()), erase(encode_debug), erase(decode_debug), {ok,Res}.%% --------------------------------------------------------%% basic_enc_dec_with_one_rec_wildcard08te18(doc) -> "Basic encode & decode with one recursive wildcard [4,16]\n (asn -> binary -> asn)";te18(suite) -> [];te18(Config) when list(Config) -> {Exp,Res} = te18(), ok = check(te18(doc),Exp,Res).te18() -> put(encode_debug,dbg), put(decode_debug,dbg), Res = encode_decode(config4(),mtid16()), erase(encode_debug), erase(decode_debug), {ok,Res}.%% --------------------------------------------------------%% basic_enc_dec_with_one_rec_wildcard09te19(doc) -> "Basic encode & decode with one recursive wildcard [4,17]\n (asn -> binary -> asn)";te19(suite) -> [];te19(Config) when list(Config) -> {Exp,Res} = te19(), ok = check(te19(doc),Exp,Res).te19() -> %% put(encode_debug,dbg), %% put(decode_debug,dbg), Res = encode_decode(config4(),mtid17()), erase(encode_debug), erase(decode_debug), {ok,Res}.%% --------------------------------------------------------%% root_term_dec_enctd01(doc) -> "Root termination decoding & then encoding test [1,1]\n (binary -> asn -> binary)";td01(suite) -> [];td01(Config) when list(Config) -> {Exp,Res} = td01(), ok = check(td01(doc),Exp,Res).td01() -> %% put(encode_debug,dbg), %% put(decode_debug,dbg), Res = decode_encode(config1(),atid1()), erase(encode_debug), erase(decode_debug), {ok,Res}.%% --------------------------------------------------------%% One byte to much (should be two bytes but is three)%% basic_dec_enc01td02(doc) -> "Basic decoding & then encoding test [1,2]\n (binary -> asn -> binary)";td02(suite) -> [];td02(Config) when list(Config) -> {Exp,Res} = td02(), ok = check(td02(doc),Exp,Res).td02() -> %% put(encode_debug,dbg), %% put(decode_debug,dbg), Res = decode_encode(config1(),atid2()), erase(encode_debug), erase(decode_debug), {error,Res}.%% --------------------------------------------------------%% basic_dec_enc02td03(doc) -> "Basic decoding & then encoding test [2,2]\n (binary -> asn -> binary)";td03(suite) -> [];td03(Config) when list(Config) -> {Exp,Res} = td03(), ok = check(td03(doc),Exp,Res).td03() -> %% put(encode_debug,dbg), %% put(decode_debug,dbg), Res = decode_encode(config2(),atid2()), erase(encode_debug), erase(decode_debug), {ok,Res}.%% --------------------------------------------------------%% basic_dec_enc03td04(doc) -> "Basic decoding & then encoding test [2,3]\n (binary -> asn -> binary)";td04(suite) -> [];td04(Config) when list(Config) -> {Exp,Res} = td04(), ok = check(td04(doc),Exp,Res).td04() -> %% put(encode_debug,dbg), %% put(decode_debug,dbg), Res = decode_encode(config2(),atid3()), erase(encode_debug), erase(decode_debug), {ok,Res}.%% --------------------------------------------------------%% basic_dec_enc04td05(doc) -> "Basic decoding & then encoding test [2,4]\n (binary -> asn -> binary)";td05(suite) -> [];td05(Config) when list(Config) -> {Exp,Res} = td05(), ok = check(td05(doc),Exp,Res).td05() -> %% put(encode_debug,dbg), %% put(decode_debug,dbg), Res = decode_encode(config2(),atid4()), erase(encode_debug), erase(decode_debug), {ok,Res}.%% --------------------------------------------------------%% basic_dec_enc05td06(doc) -> "Basic decoding & then encoding test [3,5]\n (binary -> asn -> binary)";td06(suite) -> [];td06(Config) when list(Config) -> {Exp,Res} = td06(), ok = check(td06(doc),Exp,Res).td06() -> %% put(encode_debug,dbg), %% put(decode_debug,dbg), Res = decode_encode(config3(),atid5()), erase(encode_debug), erase(decode_debug), {ok,Res}.%% --------------------------------------------------------%% --------------------------------------------------------encode_decode(C,T) -> case encode(C,T) of {ok,T1} -> case decode(C,T1) of {ok,T2} -> {ok,T,T1,T2}; {error,R2} -> {error,{decode_error,T,T1,R2}}; {exit,E2} -> {error,{decode_exit,T,T1,E2}} end; {error,R1} -> {error,{encode_error,T,R1}}; {exit,E1} -> {error,{encode_exit,T,E1}} end.decode_encode(C,T) -> case decode(C,T) of {ok,T1} -> case encode(C,T1) of {ok,T2} -> {ok,T,T1,T2}; {error,R2} -> {error,{encode_error,T,T1,R2}}; {exit,E2} -> {error,{encode_exit,T,T1,E2}} end; {error,R1} -> {error,{decode_error,T,R1}}; {exit,E1} -> {error,{decode_exit,T,E1}} end.%% ------------------config1() -> [3,8,5].config2() -> [3,5,4,8,4].config3() -> [3,5,4,16,4].config4() -> [8,8,8]. % Default configmtid01() -> #megaco_term_id{contains_wildcards = false, id = [[$1,$0,$1], [$1,$1,$0,$1,$0,$0,$0,$1], [$1,$1,$0,$1,$1]]}.mtid02() -> #megaco_term_id{contains_wildcards = true, id = [[$1,$0,$$],[$1,$1,$0,$1,$$],[$1,$1,$*]]}.mtid03() -> #megaco_term_id{contains_wildcards = true, id = [[$1,$0,$1],[$1,$0,$1,$$],[$1,$1,$*]]}.mtid04() -> #megaco_term_id{contains_wildcards = true, id = [[$1,$0,$$],[$1,$1,$0,$1,$$],[$1,$1,$1,$0,$0]]}.mtid05() -> #megaco_term_id{contains_wildcards = true, id = [[$1,$0,$1],[$1,$1,$0,$1,$$],[$1,$1,$1,$0,$0]]}.mtid06() -> #megaco_term_id{contains_wildcards = false, id = [[$1,$0,$$],[$1,$1,$0,$1,$$],[$1,$1,$*]]}.mtid07() -> #megaco_term_id{contains_wildcards = true, id = [[$1,$0,$*],[$1,2,$0,$1,$$],[$1,$1,$1,$0,$0]]}.mtid08() -> #megaco_term_id{contains_wildcards = true, id = [[$1,$0,$*,$1],[$1,$1,$0,$1,$$],[$1,$1,$1,$0,$0]]}.mtid09() -> #megaco_term_id{contains_wildcards = true, id = [[$1,$0,$0,$1],[$1,$1,$0,$1,$$],[$1,$1,$1,$0,$0]]}.mtid10() -> #megaco_term_id{contains_wildcards = true, id = [[$1,$0,$1],[$1,$0,$1,$$],[$$]]}.mtid11() -> #megaco_term_id{contains_wildcards = true, id = [[$1,$0,$1],[$1,$0,$1,$$]]}.mtid12() -> #megaco_term_id{contains_wildcards = true, id = [[$1,$0,$1],[$1,$0,$1,$0,$1,$1,$$]]}.mtid13() -> #megaco_term_id{contains_wildcards = true, id = [[$1,$0,$*]]}.%% Empty last level%% mtid14() -> %% #megaco_term_id{contains_wildcards = true,%% id = [[$1,$0,$*],[$1,$0,$0,$$],[]]}.%% Empty second level and missing last levelmtid15() -> #megaco_term_id{contains_wildcards = true, id = [[$1,$0,$*],[]]}.%% Megaco all wildcard termination idmtid16() -> #megaco_term_id{contains_wildcards = true, id = [[?megaco_all]]}.%% Megaco choose wildcard termination idmtid17() -> #megaco_term_id{contains_wildcards = true, id = [[?megaco_choose]]}.aroot() -> #'TerminationID'{wildcard = [], id = [16#FF, 16#FF, 16#FF, 16#FF, 16#FF, 16#FF, 16#FF, 16#FF]}.atid1() -> aroot().atid2() -> #'TerminationID'{wildcard = [], id = [2#00000001, 02#00011110, 2#0]}.atid3() -> #'TerminationID'{wildcard = [[2#00010111], [2#00000111]], id = [2#0, 2#00011110, 2#0]}.atid4() -> #'TerminationID'{wildcard = [[2#01001111]], id = [2#0000001, 2#0, 2#0]}.%% atid5() -> #'TerminationID'{wildcard = [[2#01001111]], id = [2#00000001, 2#00110011, 2#00000000, 2#00000000]}.%%-- %% ------------------encode(C,T) -> encode(get(encode_debug),C,T).encode(L,C,T) -> put(dsev,L), Res = encode1(C,T), erase(dsev), Res.encode1(C,T) -> case (catch megaco_binary_term_id:encode(C,T)) of {'EXIT',Reason} -> {exit,Reason}; Else -> Else end.decode(C,T) -> decode(get(decode_debug),C,T).decode(L,C,T) -> put(dsev,L), Res = decode1(C,T), erase(dsev), Res.decode1(C,T) -> case (catch megaco_binary_term_id:decode(C,T)) of {'EXIT',Reason} -> {exit,Reason}; Else -> Else end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -