summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2011-03-08 19:02:29 +0100
committerHarald Welte <laforge@gnumonks.org>2011-03-08 19:02:29 +0100
commit62b5d5777ff11b7717dd506431c66bf758f25c9a (patch)
tree5d359f3022dee5df9c4ef934f0f61a038be54b70 /test
parent8a6823d0a51dfc9603fc8f5cb62226c8fcd4f27f (diff)
add eunit unit tests for M2UA and MTP3 codec
Diffstat (limited to 'test')
-rw-r--r--test/m2ua_codec_tests.erl19
-rw-r--r--test/mtp3_codec_tests.erl14
2 files changed, 33 insertions, 0 deletions
diff --git a/test/m2ua_codec_tests.erl b/test/m2ua_codec_tests.erl
new file mode 100644
index 0000000..33d807d
--- /dev/null
+++ b/test/m2ua_codec_tests.erl
@@ -0,0 +1,19 @@
+-module(m2ua_codec_tests).
+-author('Harald Welte <laforge@gnumonks.org>').
+
+-include_lib("eunit/include/eunit.hrl").
+
+-include("m2ua.hrl").
+
+-define(M2UA_MSG_BIN, <<1,0,6,1,0,0,0,124,0,1,0,8,0,0,0,0,3,0,0,105,131,92,
+ 64,0,192,9,0,3,13,24,10,18,7,0,18,4,83,132,9,0,23,
+ 11,18,6,0,18,4,68,119,88,16,70,35,67,100,65,73,4,
+ 81,1,2,200,107,42,40,40,6,7,0,17,134,5,1,1,1,160,
+ 29,97,27,128,2,7,128,161,9,6,7,4,0,0,1,0,1,3,162,
+ 3,2,1,0,163,5,161,3,2,1,0,108,13,163,11,2,1,64,2,1,8,48,3,10,1,0,0,0,0>>).
+-define(M2UA_MSG_DEC, {m2ua_msg,6,1,[{1,{4,<<0,0,0,0>>}},{768,{101,<<131,92,64,0,192,9,0,3,13,24,10,18,7,0,18,4,83,132,9,0,23,11,18,6,0,18,4,68,119,88,16,70,35,67,100,65,73,4,81,1,2,200,107,42,40,40,6,7,0,17,134,5,1,1,1,160,29,97,27,128,2,7,128,161,9,6,7,4,0,0,1,0,1,3,162,3,2,1,0,163,5,161,3,2,1,0,108,13,163,11,2,1,64,2,1,8,48,3,10,1,0>>}}]}).
+
+parse_test() ->
+ ?assertEqual({ok, ?M2UA_MSG_DEC}, m2ua_codec:parse_m2ua_msg(?M2UA_MSG_BIN)).
+encode_test() ->
+ ?assertEqual(?M2UA_MSG_BIN, m2ua_codec:encode_m2ua_msg(?M2UA_MSG_DEC)).
diff --git a/test/mtp3_codec_tests.erl b/test/mtp3_codec_tests.erl
new file mode 100644
index 0000000..f3d6a40
--- /dev/null
+++ b/test/mtp3_codec_tests.erl
@@ -0,0 +1,14 @@
+-module(mtp3_codec_tests).
+-author('Harald Welte <laforge@gnumonks.org>').
+
+-include_lib("eunit/include/eunit.hrl").
+
+-include("mtp3.hrl").
+
+-define(MTP3_MSG_BIN, <<131,92,64,0,192,9,0,3,13,24,10,18,7,0,18,4,83,132,9,0,23,11,18,6,0,18,4,68,119,88,16,70,35,67,100,65,73,4,81,1,2,200,107,42,40,40,6,7,0,17,134,5,1,1,1,160,29,97,27,128,2,7,128,161,9,6,7,4,0,0,1,0,1,3,162,3,2,1,0,163,5,161,3,2,1,0,108,13,163,11,2,1,64,2,1,8,48,3,10,1,0>>).
+-define(MTP3_MSG_DEC, {mtp3_msg,2,3,{mtp3_routing_label,5,12544,192},<<9,0,3,13,24,10,18,7,0,18,4,83,132,9,0,23,11,18,6,0,18,4,68,119,88,16,70,35,67,100,65,73,4,81,1,2,200,107,42,40,40,6,7,0,17,134,5,1,1,1,160,29,97,27,128,2,7,128,161,9,6,7,4,0,0,1,0,1,3,162,3,2,1,0,163,5,161,3,2,1,0,108,13,163,11,2,1,64,2,1,8,48,3,10,1,0>>}).
+
+parse_test() ->
+ ?assertEqual(?MTP3_MSG_DEC, mtp3_codec:parse_mtp3_msg(?MTP3_MSG_BIN)).
+encode_test() ->
+ ?assertEqual(?MTP3_MSG_BIN, mtp3_codec:encode_mtp3_msg(?MTP3_MSG_DEC)).