-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: 🚨 add property-tests for rb_set
- Loading branch information
1 parent
38caa06
commit cbca70b
Showing
2 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters