| 1 | -module(hope_list_SUITE). |
| 2 | |
| 3 | -include_lib("proper/include/proper.hrl"). |
| 4 | |
| 5 | %% Callbacks |
| 6 | -export( |
| 7 | [ all/0 |
| 8 | , groups/0 |
| 9 | ]). |
| 10 | |
| 11 | %% Test cases |
| 12 | -export( |
| 13 | [ t_unique_preserve_order/1 |
| 14 | , t_hope_list_specs/1 |
| 15 | ]). |
| 16 | |
| 17 | |
| 18 | -define(GROUP , hope_list). |
| 19 | |
| 20 | -define(PROPTEST(A), true = proper:quickcheck(A())). |
| 21 | |
| 22 | |
| 23 | %% ============================================================================ |
| 24 | %% Common Test callbacks |
| 25 | %% ============================================================================ |
| 26 | |
| 27 | all() -> |
| 28 | [{group, ?GROUP}]. |
| 29 | |
| 30 | groups() -> |
| 31 | Tests = |
| 32 | [ t_unique_preserve_order |
| 33 | , t_hope_list_specs |
| 34 | ], |
| 35 | Properties = [parallel], |
| 36 | [{?GROUP, Properties, Tests}]. |
| 37 | |
| 38 | |
| 39 | %% ============================================================================= |
| 40 | %% Test cases |
| 41 | %% ============================================================================= |
| 42 | |
| 43 | t_unique_preserve_order(_Cfg) -> |
| 44 | ?PROPTEST(prop_unique_preserve_order). |
| 45 | |
| 46 | prop_unique_preserve_order() -> |
| 47 | ?FORALL(L, list(), |
| 48 | begin |
| 49 | Duplicates = L -- lists:usort(L), |
| 50 | hope_list:unique_preserve_order(L) == |
| 51 | lists:reverse(lists:reverse(L) -- Duplicates) |
| 52 | end). |
| 53 | |
| 54 | t_hope_list_specs(_) -> |
| 55 | [] = proper:check_specs(hope_list). |