1 -module(hope_kv_list_SUITE).
3 -include_lib("hope_kv_list.hrl").
13 [ t_validate_unique_presence/1
17 -define(GROUP , hope_kv_list).
20 %% ============================================================================
21 %% Common Test callbacks
22 %% ============================================================================
29 [ t_validate_unique_presence
32 [{?GROUP, Properties, Tests}].
35 %% =============================================================================
37 %% =============================================================================
39 t_validate_unique_presence(_Cfg) ->
40 KeysRequired = [a, b, c],
41 DictOk = [{a, 1}, {b, 2}, {c, 3}],
42 DictUnsup = [{a, 1}, {b, 2}, {c, 3}, {d, 4}],
43 DictDups = [{a, 1}, {b, 2}, {c, 3}, {a, 4}],
44 DictMissing = [{a, 1}, {b, 2}],
47 hope_kv_list:validate_unique_presence(DictOk, KeysRequired),
48 #hope_kv_list_presence_violations
50 , keys_duplicated = []
51 , keys_unsupported = []
53 hope_kv_list:find_unique_presence_violations(DictOk, KeysRequired),
55 {error, [{keys_unsupported, [d]}]} =
56 hope_kv_list:validate_unique_presence(DictUnsup, KeysRequired),
57 #hope_kv_list_presence_violations
59 , keys_duplicated = []
60 , keys_unsupported = [d]
62 hope_kv_list:find_unique_presence_violations(DictUnsup, KeysRequired),
64 {error, [{keys_duplicated, [a]}]} =
65 hope_kv_list:validate_unique_presence(DictDups, KeysRequired),
66 #hope_kv_list_presence_violations
68 , keys_duplicated = [a]
69 , keys_unsupported = []
71 hope_kv_list:find_unique_presence_violations(DictDups, KeysRequired),
73 {error, [{keys_missing, [c]}]} =
74 hope_kv_list:validate_unique_presence(DictMissing, KeysRequired),
75 #hope_kv_list_presence_violations
77 , keys_duplicated = []
78 , keys_unsupported = []
80 hope_kv_list:find_unique_presence_violations(DictMissing, KeysRequired).