Extend dictionary pop test.
[hope.git] / test / hope_kv_list_SUITE.erl
index e0f0747..97f0ee6 100644 (file)
@@ -10,6 +10,7 @@
 -export(
     [ t_set_new/1
     , t_set_existing/1
+    , t_pop/1
     ]).
 
 
@@ -30,6 +31,7 @@ groups() ->
     Tests =
         [ t_set_new
         , t_set_existing
+        , t_pop
         ],
     Properties = [],
     [{?GROUP_KV_LIST, Properties, Tests}].
@@ -55,3 +57,14 @@ t_set_existing(_Config) ->
     ListResulting = hope_kv_list:set(ListInitial, Key, ValExpected),
     {some, ValResulting} = hope_kv_list:get(ListResulting, Key),
     ValResulting = ValExpected.
+
+t_pop(_Config) ->
+    KVList = [{a, 1}, {b, 2}, {c, 3}],
+    Dict1 = hope_kv_list:of_kv_list(KVList),
+    {{some, 1} , Dict2} = hope_kv_list:pop(Dict1, a),
+    {none      , Dict3} = hope_kv_list:pop(Dict2, a),
+    {{some, 2} , Dict4} = hope_kv_list:pop(Dict3, b),
+    {none      , Dict5} = hope_kv_list:pop(Dict4, b),
+    {{some, 3} , Dict6} = hope_kv_list:pop(Dict5, c),
+    {none      , Dict7} = hope_kv_list:pop(Dict6, c),
+    [] = hope_kv_list:to_kv_list(Dict7).
This page took 0.024306 seconds and 4 git commands to generate.