| 1 | -module(hope_kv_list_SUITE). |
| 2 | |
| 3 | %% Callbacks |
| 4 | -export( |
| 5 | [ all/0 |
| 6 | , groups/0 |
| 7 | ]). |
| 8 | |
| 9 | %% Test cases |
| 10 | -export( |
| 11 | [ t_set_new/1 |
| 12 | , t_set_existing/1 |
| 13 | ]). |
| 14 | |
| 15 | |
| 16 | -define(GROUP_KV_LIST, kv_list). |
| 17 | |
| 18 | |
| 19 | %% ============================================================================ |
| 20 | %% Common Test callbacks |
| 21 | %% ============================================================================ |
| 22 | |
| 23 | %% TODO: Make tests generic for any dictionary. |
| 24 | %% TODO: Each group should test a type of dictionary against the generic cases. |
| 25 | |
| 26 | all() -> |
| 27 | [{group, ?GROUP_KV_LIST}]. |
| 28 | |
| 29 | groups() -> |
| 30 | Tests = |
| 31 | [ t_set_new |
| 32 | , t_set_existing |
| 33 | ], |
| 34 | Properties = [], |
| 35 | [{?GROUP_KV_LIST, Properties, Tests}]. |
| 36 | |
| 37 | |
| 38 | %% ============================================================================= |
| 39 | %% Test cases |
| 40 | %% ============================================================================= |
| 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. |