Implement & test hope_kv_list:validate_unique_presence/(2|3)
[hope.git] / test / hope_kv_list_SUITE.erl
1 -module(hope_kv_list_SUITE).
2
3 %% Callbacks
4 -export(
5 [ all/0
6 , groups/0
7 ]).
8
9 %% Test cases
10 -export(
11 [ t_validate_unique_presence/1
12 ]).
13
14
15 -define(GROUP , hope_kv_list).
16
17
18 %% ============================================================================
19 %% Common Test callbacks
20 %% ============================================================================
21
22 all() ->
23 [{group, ?GROUP}].
24
25 groups() ->
26 Tests =
27 [ t_validate_unique_presence
28 ],
29 Properties = [],
30 [{?GROUP, Properties, Tests}].
31
32
33 %% =============================================================================
34 %% Test cases
35 %% =============================================================================
36
37 t_validate_unique_presence(_Cfg) ->
38 KeysRequired = [a, b, c],
39 DictOk = [{a, 1}, {b, 2}, {c, 3}],
40 DictUnsup = [{a, 1}, {b, 2}, {c, 3}, {d, 4}],
41 DictDups = [{a, 1}, {b, 2}, {c, 3}, {a, 4}],
42 DictMissing = [{a, 1}, {b, 2}],
43 {ok, ok} =
44 hope_kv_list:validate_unique_presence(DictOk, KeysRequired),
45 {error, [{keys_unsupported, [d]}]} =
46 hope_kv_list:validate_unique_presence(DictUnsup, KeysRequired),
47 {error, [{keys_duplicated, [a]}]} =
48 hope_kv_list:validate_unique_presence(DictDups, KeysRequired),
49 {error, [{keys_missing, [c]}]} =
50 hope_kv_list:validate_unique_presence(DictMissing, KeysRequired).
This page took 0.065149 seconds and 4 git commands to generate.