Implement hope_list:map_rev/2
[hope.git] / test / hope_list_SUITE.erl
... / ...
CommitLineData
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 , t_map_rev/1
16 ]).
17
18
19-define(GROUP , hope_list).
20
21-define(PROPTEST(A), true = proper:quickcheck(A())).
22
23
24%% ============================================================================
25%% Common Test callbacks
26%% ============================================================================
27
28all() ->
29 [{group, ?GROUP}].
30
31groups() ->
32 Tests =
33 [ t_unique_preserve_order
34 , t_hope_list_specs
35 , t_map_rev
36 ],
37 Properties = [parallel],
38 [{?GROUP, Properties, Tests}].
39
40
41%% =============================================================================
42%% Test cases
43%% =============================================================================
44
45t_map_rev(_Cfg) ->
46 F = fun (N) -> N + 1 end,
47 [4, 3, 2] = hope_list:map_rev([1, 2, 3], F),
48 [] = hope_list:map_rev([], F).
49
50t_unique_preserve_order(_Cfg) ->
51 ?PROPTEST(prop_unique_preserve_order).
52
53prop_unique_preserve_order() ->
54 ?FORALL(L, list(),
55 begin
56 Duplicates = L -- lists:usort(L),
57 hope_list:unique_preserve_order(L) ==
58 lists:reverse(lists:reverse(L) -- Duplicates)
59 end).
60
61t_hope_list_specs(_) ->
62 [] = proper:check_specs(hope_list).
This page took 0.021293 seconds and 4 git commands to generate.