, fold/3
, of_kv_list/1
, to_kv_list/1
+ , has_key/2
, find_unique_presence_violations/2 % No optional keys
, find_unique_presence_violations/3 % Specify optional keys
, validate_unique_presence/2 % No optional keys
end,
ErrorDups ++ ErrorMissing ++ ErrorUnsupported.
+-spec has_key(t(K, _), K) ->
+ boolean().
+has_key(T, K1) ->
+ lists:any(fun ({K2, _}) -> K1 =:= K2 end, T).
%% ============================================================================
%% Helpers
, t_pop/1
, t_fold/1
, t_dictionary_specs/1
+ , t_has_key/1
]).
, t_pop
, t_fold
, t_dictionary_specs
+ , t_has_key
],
Properties = [parallel],
[{?DICT_MODULE_KV_LIST, Properties, Tests}].
t_dictionary_specs(Cfg) ->
{some, DictModule} = hope_kv_list:get(Cfg, ?DICT_MODULE),
[] = proper:check_specs(DictModule).
+
+t_has_key(Cfg) ->
+ {some, DictModule} = hope_kv_list:get(Cfg, ?DICT_MODULE),
+ D = DictModule:of_kv_list([{a, 1}, {b, 2}, {c, 3}]),
+ true = DictModule:has_key(D, a),
+ true = DictModule:has_key(D, b),
+ true = DictModule:has_key(D, c),
+ false = DictModule:has_key(D, d),
+ false = DictModule:has_key(D, e),
+ false = DictModule:has_key(D, f).