From 08efa5f7d2f95a608d1712a8d684aed6c3a1aa4a Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Wed, 30 Oct 2013 13:44:41 +0100 Subject: Initial commit --- test/proplutils_test.erl | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 test/proplutils_test.erl (limited to 'test') diff --git a/test/proplutils_test.erl b/test/proplutils_test.erl new file mode 100644 index 0000000..c14c84b --- /dev/null +++ b/test/proplutils_test.erl @@ -0,0 +1,42 @@ +-module(proplutils_test). +-include_lib("eunit/include/eunit.hrl"). + +% Test descriptions +delete_test_() -> + [{"Using a atom should work as proplist:delete/2", + check_delete_atom_arg()}, + {"Using a list should remove all keys in the list", + check_delete_list_arg()} + ]. + +delete_except_test_() -> + [{"Using an atom should remove everything except keys" + "matching that atom", + check_delete_except_atom_arg()}, + {"Using a list should remove all keys except keys" + "matching the atoms in the list", + check_delete_except_list_arg()} + ]. + +% Tests +check_delete_atom_arg() -> + PL = [{foo, "doesnot"}, {bar, "matter"}], + Ret = proplutils:delete(foo, PL), + [?_assertEqual(Ret, [{bar, "matter"}])]. + +check_delete_list_arg() -> + PL = [{foo, "doesnot"}, {bar, "matter"}, {baz, "really"}], + Ret = proplutils:delete([foo, baz], PL), + [?_assertEqual(Ret, [{bar, "matter"}])]. + +check_delete_except_atom_arg() -> + PL = [{foo, "doesnot"}, {bar, "matter"}, {baz, "really"}], + Ret = proplutils:delete_except(bar, PL), + [?_assertEqual(Ret, [{bar, "matter"}])]. + +check_delete_except_list_arg() -> + PL = [{foo, "doesnot"}, {bar, "matter"}, {baz, "really"}], + Ret = proplutils:delete_except([foo, bar], PL), + [?_assertEqual(Ret,[{foo, "doesnot"}, {bar, "matter"}])]. + + -- cgit v1.2.3