aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2013-10-30 13:44:41 +0100
committerGuido Günther <agx@sigxcpu.org>2013-10-30 16:32:44 +0100
commit08efa5f7d2f95a608d1712a8d684aed6c3a1aa4a (patch)
treee50b6c11ee452f0e36af92418fee9512929d30e1 /test
Initial commit
Diffstat (limited to 'test')
-rw-r--r--test/proplutils_test.erl42
1 files changed, 42 insertions, 0 deletions
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"}])].
+
+