-t_set_new(_Config) ->
- Key = key,
- ValExpected = bar,
- ListInitial = hope_kv_list:empty(),
- ListResulting = hope_kv_list:set(ListInitial, Key, ValExpected),
- {some, ValResulting} = hope_kv_list:get(ListResulting, Key),
- ValResulting = ValExpected.
-
-t_set_existing(_Config) ->
- Key = key,
- ValInitial = foo,
- ValExpected = bar,
- ListInitial = [{donald, duck}, {Key, ValInitial}],
- ListResulting = hope_kv_list:set(ListInitial, Key, ValExpected),
- {some, ValResulting} = hope_kv_list:get(ListResulting, Key),
- ValResulting = ValExpected.
+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).