X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=test%2Fhope_dictionary_SUITE.erl;h=c5bc8fe39f7ff328a3dac2cd40e77c23a21725ed;hb=d2bddc7bbf3325b16e1de0afabfebb6cf57b505e;hp=914ae48d0aa6f147a2581c59fae1ab27abfddc7a;hpb=8bbf6f4d400d79736e7866d67ecb3517b61bb1c1;p=hope.git diff --git a/test/hope_dictionary_SUITE.erl b/test/hope_dictionary_SUITE.erl index 914ae48..c5bc8fe 100644 --- a/test/hope_dictionary_SUITE.erl +++ b/test/hope_dictionary_SUITE.erl @@ -1,7 +1,5 @@ -module(hope_dictionary_SUITE). --include_lib("proper/include/proper.hrl"). - %% Callbacks -export( [ all/0 @@ -14,9 +12,11 @@ -export( [ t_set_new/1 , t_set_existing/1 + , t_get/1 , t_pop/1 , t_fold/1 , t_dictionary_specs/1 + , t_has_key/1 ]). @@ -35,9 +35,21 @@ groups() -> Tests = [ t_set_new , t_set_existing + , t_get , t_pop , t_fold - , t_dictionary_specs + + % TODO: Find-out why t_dictionary_specs failes with latest proper HEAD: + % + % Testing hope_kv_list:to_kv_list/1 + % Error: The typeserver encountered an error: {unbound_var,'K'}. + % *** CT Error Notification 2015-09-26 13:46:38.684 *** + % hope_dictionary_SUITE:t_dictionary_specs failed on line 111 + % Reason: {badmatch,[{hope_kv_list,of_kv_list,1}]} + % + %, t_dictionary_specs + + , t_has_key ], Properties = [parallel], [{?DICT_MODULE_KV_LIST, Properties, Tests}]. @@ -53,6 +65,20 @@ end_per_group(_DictModule, _Cfg) -> %% Test cases %% ============================================================================= +t_get(Cfg) -> + {some, DictModule} = hope_kv_list:get(Cfg, ?DICT_MODULE), + K1 = k1, + K2 = k2, + V1 = v1, + V2 = v2, + D = DictModule:set(DictModule:empty(), K1, V1), + {some, V1} = DictModule:get(D, K1), + V1 = DictModule:get(D, K1, V2), + none = DictModule:get(D, K2), + V2 = DictModule:get(D, K2, V2), + default = DictModule:get(D, K1, default, fun (X) -> X =:= foo end), + V1 = DictModule:get(D, K1, default, fun (X) -> X =:= V1 end). + t_set_new(Cfg) -> {some, DictModule} = hope_kv_list:get(Cfg, ?DICT_MODULE), Key = key, @@ -93,3 +119,13 @@ t_fold(Cfg) -> 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).