We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent de34960 commit c49b406Copy full SHA for c49b406
1 file changed
test/circular_buffer_test.exs
@@ -11,17 +11,25 @@ defmodule CircularBufferTest do
11
12
alias CircularBuffer, as: CB
13
14
- property "new/1 accepts a max size" do
15
- forall i <- integer() do
+ property "new/1 returns an empty buffer for positive sizes" do
+ 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
25
26
+ property "new/1 raises for non-positive sizes" do
27
+ forall n <- non_neg_integer() do
28
try do
- buffer = CB.new(i)
- buffer.max_size == i
29
+ CB.new(-n)
30
+ false
31
rescue
- FunctionClauseError ->
- i <= 0
-
- _ ->
- false
32
+ FunctionClauseError -> true
33
end
34
35
0 commit comments