Skip to content

Commit c49b406

Browse files
committed
Split the new/1 prop test
1 parent de34960 commit c49b406

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

test/circular_buffer_test.exs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,25 @@ defmodule CircularBufferTest do
1111

1212
alias CircularBuffer, as: CB
1313

14-
property "new/1 accepts a max size" do
15-
forall i <- integer() do
14+
property "new/1 returns an empty buffer for positive sizes" do
15+
forall size <- pos_integer() do
16+
cb = CB.new(size)
17+
18+
cb.max_size == size and
19+
cb.count == 0 and
20+
cb.a == [] and
21+
cb.b == [] and
22+
CB.empty?(cb)
23+
end
24+
end
25+
26+
property "new/1 raises for non-positive sizes" do
27+
forall n <- non_neg_integer() do
1628
try do
17-
buffer = CB.new(i)
18-
buffer.max_size == i
29+
CB.new(-n)
30+
false
1931
rescue
20-
FunctionClauseError ->
21-
i <= 0
22-
23-
_ ->
24-
false
32+
FunctionClauseError -> true
2533
end
2634
end
2735
end

0 commit comments

Comments
 (0)