Skip to content

Commit

Permalink
test: 🚨 add property-tests for rb_set
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbarsukov committed Oct 13, 2024
1 parent 38caa06 commit cbca70b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
40 changes: 40 additions & 0 deletions test/rb_set_prop_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
defmodule RBSetPropTest do
@moduledoc """
Property-testing RBSet
"""

use ExUnit.Case, async: true
use Quixir
import RBSet
doctest RBSet

test "check monoid" do
ptest numbers1: list(of: positive_int(), size: 10),
numbers2: list(of: positive_int(), size: 10) do
set1 = RBSet.new(numbers1)
set2 = RBSet.new(numbers2)
emp = RBSet.new()

new_set = set1 ||| emp
assert RBSet.to_list(set1) == RBSet.to_list(new_set)

new_set = emp ||| set1
assert RBSet.to_list(set1) == RBSet.to_list(new_set)

set12 = set1 ||| set2
set21 = set2 ||| set1
assert RBSet.to_list(set12) == RBSet.to_list(set21)
end
end

test "check insert" do
ptest values: list(size: 10) do
set = RBSet.new()

Enum.each(values, fn value ->
set = RBSet.put(set, value)
assert RBSet.member?(set, value)
end)
end
end
end
3 changes: 1 addition & 2 deletions test/rb_set_test.exs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
defmodule RBSetTest do
@moduledoc """
Testing RBSet
Unit-testing RBSet
"""

use ExUnit.Case, async: true

import RBSet
doctest RBSet

Expand Down

0 comments on commit cbca70b

Please sign in to comment.