Replace lists:keysearch with hope_kv_list:get
[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 , t_map_slow/1
17 , t_map/1
18 , t_map_3/1
19 ]).
20
21
22-define(GROUP , hope_list).
23
24-define(PROPTEST(A), true = proper:quickcheck(A())).
25
26
27%% ============================================================================
28%% Common Test callbacks
29%% ============================================================================
30
31all() ->
32 [{group, ?GROUP}].
33
34groups() ->
35 Tests =
36 [ t_unique_preserve_order
37 , t_hope_list_specs
38 , t_map_rev
39 , t_map_slow
40 , t_map
41 , t_map_3
42 ],
43 Properties = [parallel],
44 [{?GROUP, Properties, Tests}].
45
46
47%% =============================================================================
48%% Test cases
49%% =============================================================================
50
51t_map_rev(_Cfg) ->
52 ?PROPTEST(map_rev).
53
54map_rev() ->
55 ?FORALL({L, F}, {list(integer()), function([integer()], term())},
56 hope_list:map_rev(L, F) == lists:reverse(lists:map(F, L))).
57
58t_map_slow(_Cfg) ->
59 ?PROPTEST(map_slow).
60
61map_slow() ->
62 ?FORALL({L, F}, {list(integer()), function([integer()], term())},
63 hope_list:map_slow(L, F) == lists:map(F, L)).
64
65t_map(_Cfg) ->
66 ?PROPTEST(map).
67
68map() ->
69 ?FORALL({L, F}, {list(integer()), function([integer()], term())},
70 hope_list:map(L, F) == lists:map(F, L)).
71
72t_map_3(_Cfg) ->
73 ?PROPTEST(map_3).
74
75map_3() ->
76 ?FORALL({L, F, N}, {list(integer()), function([integer()], term()), non_neg_integer()},
77 hope_list:map(L, F, N) == lists:map(F, L)).
78
79t_unique_preserve_order(_Cfg) ->
80 ?PROPTEST(prop_unique_preserve_order).
81
82prop_unique_preserve_order() ->
83 ?FORALL(L, list(),
84 begin
85 Duplicates = L -- lists:usort(L),
86 hope_list:unique_preserve_order(L) ==
87 lists:reverse(lists:reverse(L) -- Duplicates)
88 end).
89
90t_hope_list_specs(_) ->
91 [] = proper:check_specs(hope_list).
This page took 0.022188 seconds and 4 git commands to generate.