1 -module(hope_dictionary_SUITE).
19 -define(DICT_MODULE , dict_module).
20 -define(DICT_MODULE_KV_LIST , hope_kv_list).
23 %% ============================================================================
24 %% Common Test callbacks
25 %% ============================================================================
28 [{group, ?DICT_MODULE_KV_LIST}].
37 [{?DICT_MODULE_KV_LIST, Properties, Tests}].
39 init_per_group(DictModule, Cfg) ->
40 hope_kv_list:set(Cfg, ?DICT_MODULE, DictModule).
42 end_per_group(_DictModule, _Cfg) ->
46 %% =============================================================================
48 %% =============================================================================
51 {some, DictModule} = hope_kv_list:get(Cfg, ?DICT_MODULE),
54 ListInitial = DictModule:empty(),
55 ListResulting = DictModule:set(ListInitial, Key, ValExpected),
56 {some, ValResulting} = DictModule:get(ListResulting, Key),
57 ValResulting = ValExpected.
59 t_set_existing(Cfg) ->
60 {some, DictModule} = hope_kv_list:get(Cfg, ?DICT_MODULE),
64 ListInitial = [{donald, duck}, {Key, ValInitial}],
65 ListResulting = DictModule:set(ListInitial, Key, ValExpected),
66 {some, ValResulting} = DictModule:get(ListResulting, Key),
67 ValResulting = ValExpected.
70 {some, DictModule} = hope_kv_list:get(Cfg, ?DICT_MODULE),
71 KVList = [{a, 1}, {b, 2}, {c, 3}],
72 Dict1 = DictModule:of_kv_list(KVList),
73 {{some, 1} , Dict2} = DictModule:pop(Dict1, a),
74 {none , Dict3} = DictModule:pop(Dict2, a),
75 {{some, 2} , Dict4} = DictModule:pop(Dict3, b),
76 {none , Dict5} = DictModule:pop(Dict4, b),
77 {{some, 3} , Dict6} = DictModule:pop(Dict5, c),
78 {none , Dict7} = DictModule:pop(Dict6, c),
79 [] = DictModule:to_kv_list(Dict7).