1 -module(hope_dictionary_SUITE).
18 , t_dictionary_specs/1
22 -define(DICT_MODULE , dict_module).
23 -define(DICT_MODULE_KV_LIST , hope_kv_list).
26 %% ============================================================================
27 %% Common Test callbacks
28 %% ============================================================================
31 [{group, ?DICT_MODULE_KV_LIST}].
42 Properties = [parallel],
43 [{?DICT_MODULE_KV_LIST, Properties, Tests}].
45 init_per_group(DictModule, Cfg) ->
46 hope_kv_list:set(Cfg, ?DICT_MODULE, DictModule).
48 end_per_group(_DictModule, _Cfg) ->
52 %% =============================================================================
54 %% =============================================================================
57 {some, DictModule} = hope_kv_list:get(Cfg, ?DICT_MODULE),
62 D = DictModule:set(DictModule:empty(), K1, V1),
63 {some, V1} = DictModule:get(D, K1),
64 V1 = DictModule:get(D, K1, V2),
65 none = DictModule:get(D, K2),
66 V2 = DictModule:get(D, K2, V2).
69 {some, DictModule} = hope_kv_list:get(Cfg, ?DICT_MODULE),
72 ListInitial = DictModule:empty(),
73 ListResulting = DictModule:set(ListInitial, Key, ValExpected),
74 {some, ValResulting} = DictModule:get(ListResulting, Key),
75 ValResulting = ValExpected.
77 t_set_existing(Cfg) ->
78 {some, DictModule} = hope_kv_list:get(Cfg, ?DICT_MODULE),
82 ListInitial = [{donald, duck}, {Key, ValInitial}],
83 ListResulting = DictModule:set(ListInitial, Key, ValExpected),
84 {some, ValResulting} = DictModule:get(ListResulting, Key),
85 ValResulting = ValExpected.
88 {some, DictModule} = hope_kv_list:get(Cfg, ?DICT_MODULE),
89 KVList = [{a, 1}, {b, 2}, {c, 3}],
90 Dict1 = DictModule:of_kv_list(KVList),
91 {{some, 1} , Dict2} = DictModule:pop(Dict1, a),
92 {none , Dict3} = DictModule:pop(Dict2, a),
93 {{some, 2} , Dict4} = DictModule:pop(Dict3, b),
94 {none , Dict5} = DictModule:pop(Dict4, b),
95 {{some, 3} , Dict6} = DictModule:pop(Dict5, c),
96 {none , Dict7} = DictModule:pop(Dict6, c),
97 [] = DictModule:to_kv_list(Dict7).
100 {some, DictModule} = hope_kv_list:get(Cfg, ?DICT_MODULE),
101 KVList = [{a, 1}, {a, 5}, {b, 3}, {c, 4}, {c, 4}],
102 Dict = DictModule:of_kv_list(KVList),
103 17 = DictModule:fold(Dict, fun (_K, V, Acc) -> V + Acc end, 0).
105 t_dictionary_specs(Cfg) ->
106 {some, DictModule} = hope_kv_list:get(Cfg, ?DICT_MODULE),
107 [] = proper:check_specs(DictModule).