Implement & test hope_kv_list:validate_unique_presence/(2|3)
[hope.git] / test / hope_kv_list_SUITE.erl
diff --git a/test/hope_kv_list_SUITE.erl b/test/hope_kv_list_SUITE.erl
new file mode 100644 (file)
index 0000000..511fc32
--- /dev/null
@@ -0,0 +1,50 @@
+-module(hope_kv_list_SUITE).
+
+%% Callbacks
+-export(
+    [ all/0
+    , groups/0
+    ]).
+
+%% Test cases
+-export(
+    [ t_validate_unique_presence/1
+    ]).
+
+
+-define(GROUP , hope_kv_list).
+
+
+%% ============================================================================
+%% Common Test callbacks
+%% ============================================================================
+
+all() ->
+    [{group, ?GROUP}].
+
+groups() ->
+    Tests =
+        [ t_validate_unique_presence
+        ],
+    Properties = [],
+    [{?GROUP, Properties, Tests}].
+
+
+%% =============================================================================
+%%  Test cases
+%% =============================================================================
+
+t_validate_unique_presence(_Cfg) ->
+    KeysRequired = [a, b, c],
+    DictOk      = [{a, 1}, {b, 2}, {c, 3}],
+    DictUnsup   = [{a, 1}, {b, 2}, {c, 3}, {d, 4}],
+    DictDups    = [{a, 1}, {b, 2}, {c, 3}, {a, 4}],
+    DictMissing = [{a, 1}, {b, 2}],
+    {ok, ok} =
+        hope_kv_list:validate_unique_presence(DictOk, KeysRequired),
+    {error, [{keys_unsupported, [d]}]} =
+        hope_kv_list:validate_unique_presence(DictUnsup, KeysRequired),
+    {error, [{keys_duplicated, [a]}]} =
+        hope_kv_list:validate_unique_presence(DictDups, KeysRequired),
+    {error, [{keys_missing, [c]}]} =
+        hope_kv_list:validate_unique_presence(DictMissing, KeysRequired).
This page took 0.03058 seconds and 4 git commands to generate.