| 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 | ]). |
| 15 | |
| 16 | |
| 17 | -define(GROUP , hope_list). |
| 18 | |
| 19 | -define(PROPTEST(A), true = proper:quickcheck(A())). |
| 20 | |
| 21 | |
| 22 | %% ============================================================================ |
| 23 | %% Common Test callbacks |
| 24 | %% ============================================================================ |
| 25 | |
| 26 | all() -> |
| 27 | [{group, ?GROUP}]. |
| 28 | |
| 29 | groups() -> |
| 30 | Tests = |
| 31 | [ t_unique_preserve_order |
| 32 | ], |
| 33 | Properties = [], |
| 34 | [{?GROUP, Properties, Tests}]. |
| 35 | |
| 36 | |
| 37 | %% ============================================================================= |
| 38 | %% Test cases |
| 39 | %% ============================================================================= |
| 40 | |
| 41 | t_unique_preserve_order(_Cfg) -> |
| 42 | ?PROPTEST(prop_unique_preserve_order). |
| 43 | |
| 44 | prop_unique_preserve_order() -> |
| 45 | ?FORALL(L, list(), |
| 46 | begin |
| 47 | Duplicates = L -- lists:usort(L), |
| 48 | hope_list:unique_preserve_order(L) == |
| 49 | lists:reverse(lists:reverse(L) -- Duplicates) |
| 50 | end). |