X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=test%2Fhope_kv_list_SUITE.erl;h=511fc32df383bb1ead117029c4ff296dcfc85ccd;hb=27a4f25fb636bbff0f8085d66e433125dc5fe17d;hp=65d4d1f0acfe09a121bdd79e516d967b7660248d;hpb=56b05e819f4531cdd2f32fa1054c9297436877b4;p=hope.git diff --git a/test/hope_kv_list_SUITE.erl b/test/hope_kv_list_SUITE.erl index 65d4d1f..511fc32 100644 --- a/test/hope_kv_list_SUITE.erl +++ b/test/hope_kv_list_SUITE.erl @@ -8,11 +8,11 @@ %% Test cases -export( - [ + [ t_validate_unique_presence/1 ]). --define(GROUP_KV_LIST, kv_list). +-define(GROUP , hope_kv_list). %% ============================================================================ @@ -20,16 +20,31 @@ %% ============================================================================ all() -> - [{group, ?GROUP_KV_LIST}]. + [{group, ?GROUP}]. groups() -> Tests = - [ + [ t_validate_unique_presence ], Properties = [], - [{?GROUP_KV_LIST, Properties, Tests}]. + [{?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).