-
Notifications
You must be signed in to change notification settings - Fork 5
/
min_max_stack_test.exs
45 lines (39 loc) · 1.21 KB
/
min_max_stack_test.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
defmodule ExAlgo.Stack.MinMaxStackTest do
use ExUnit.Case
use ExUnitProperties
@moduletag :min_max_stack
alias ExAlgo.Stack.MinMaxStack
doctest MinMaxStack
describe "from" do
property "from creates the properties in reverse order" do
check all list <- list_of(integer()) do
stack = MinMaxStack.from(list)
assert stack.container |> Enum.map(& &1.current) == Enum.reverse(list)
end
end
end
describe "current" do
property "current value returns the last element" do
check all list <- nonempty(list_of(integer())) do
stack = MinMaxStack.from(list)
assert MinMaxStack.current(stack) == List.last(list)
end
end
end
describe "minimum" do
property "minimum always returns the smallest value" do
check all list <- nonempty(list_of(integer())) do
stack = MinMaxStack.from(list)
assert MinMaxStack.minimum(stack) == Enum.min(list)
end
end
end
describe "maximum" do
property "maximum always returns the biggest value" do
check all list <- nonempty(list_of(integer())) do
stack = MinMaxStack.from(list)
assert MinMaxStack.maximum(stack) == Enum.max(list)
end
end
end
end