Commit | Line | Data |
---|---|---|
56b05e81 SK |
1 | -module(hope_kv_list_SUITE). |
2 | ||
3 | %% Callbacks | |
4 | -export( | |
5 | [ all/0 | |
6 | , groups/0 | |
7 | ]). | |
8 | ||
9 | %% Test cases | |
10 | -export( | |
39273fbe SK |
11 | [ t_set_new/1 |
12 | , t_set_existing/1 | |
56b05e81 SK |
13 | ]). |
14 | ||
15 | ||
16 | -define(GROUP_KV_LIST, kv_list). | |
17 | ||
18 | ||
19 | %% ============================================================================ | |
20 | %% Common Test callbacks | |
21 | %% ============================================================================ | |
22 | ||
37c6e98b SK |
23 | %% TODO: Make tests generic for any dictionary. |
24 | %% TODO: Each group shold test a type of dictionary against the generic cases. | |
25 | ||
56b05e81 SK |
26 | all() -> |
27 | [{group, ?GROUP_KV_LIST}]. | |
28 | ||
29 | groups() -> | |
30 | Tests = | |
39273fbe SK |
31 | [ t_set_new |
32 | , t_set_existing | |
56b05e81 SK |
33 | ], |
34 | Properties = [], | |
35 | [{?GROUP_KV_LIST, Properties, Tests}]. | |
36 | ||
37 | ||
38 | %% ============================================================================= | |
39 | %% Test cases | |
40 | %% ============================================================================= | |
39273fbe SK |
41 | |
42 | t_set_new(_Config) -> | |
43 | Key = key, | |
44 | ValExpected = bar, | |
45 | ListInitial = hope_kv_list:empty(), | |
46 | ListResulting = hope_kv_list:set(ListInitial, Key, ValExpected), | |
47 | {some, ValResulting} = hope_kv_list:get(ListResulting, Key), | |
48 | ValResulting = ValExpected. | |
49 | ||
50 | t_set_existing(_Config) -> | |
51 | Key = key, | |
52 | ValInitial = foo, | |
53 | ValExpected = bar, | |
54 | ListInitial = [{donald, duck}, {Key, ValInitial}], | |
55 | ListResulting = hope_kv_list:set(ListInitial, Key, ValExpected), | |
56 | {some, ValResulting} = hope_kv_list:get(ListResulting, Key), | |
57 | ValResulting = ValExpected. |