X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=test%2Fhope_dictionary_SUITE.erl;h=4f355ca0bfc0f78b74e87f38c3dee0ffa26776b9;hb=870172d69230ad2cf0f409ec009ab3feaa723fee;hp=a0848a3572de09a46906ecba01dd549a1224c41b;hpb=f399d3fce79551fd92f12ab6a0c9c82342fefcfa;p=hope.git diff --git a/test/hope_dictionary_SUITE.erl b/test/hope_dictionary_SUITE.erl index a0848a3..4f355ca 100644 --- a/test/hope_dictionary_SUITE.erl +++ b/test/hope_dictionary_SUITE.erl @@ -12,7 +12,10 @@ -export( [ t_set_new/1 , t_set_existing/1 + , t_get/1 , t_pop/1 + , t_fold/1 + , t_dictionary_specs/1 ]). @@ -31,9 +34,12 @@ groups() -> Tests = [ t_set_new , t_set_existing + , t_get , t_pop + , t_fold + , t_dictionary_specs ], - Properties = [], + Properties = [parallel], [{?DICT_MODULE_KV_LIST, Properties, Tests}]. init_per_group(DictModule, Cfg) -> @@ -47,6 +53,18 @@ 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). + t_set_new(Cfg) -> {some, DictModule} = hope_kv_list:get(Cfg, ?DICT_MODULE), Key = key, @@ -77,3 +95,13 @@ t_pop(Cfg) -> {{some, 3} , Dict6} = DictModule:pop(Dict5, c), {none , Dict7} = DictModule:pop(Dict6, c), [] = DictModule:to_kv_list(Dict7). + +t_fold(Cfg) -> + {some, DictModule} = hope_kv_list:get(Cfg, ?DICT_MODULE), + KVList = [{a, 1}, {a, 5}, {b, 3}, {c, 4}, {c, 4}], + Dict = DictModule:of_kv_list(KVList), + 17 = DictModule:fold(Dict, fun (_K, V, Acc) -> V + Acc end, 0). + +t_dictionary_specs(Cfg) -> + {some, DictModule} = hope_kv_list:get(Cfg, ?DICT_MODULE), + [] = proper:check_specs(DictModule).