-
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.
- Loading branch information
1 parent
065a2ef
commit c1ee700
Showing
2 changed files
with
34 additions
and
19 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,34 @@ | ||
from itertools import repeat | ||
|
||
from hypothesis import strategies as st, given | ||
|
||
from mtree4 import default_distance | ||
|
||
|
||
def elements(n): | ||
def g(f): | ||
strats = [st.integers(), st.text()] | ||
return given(st.one_of(*[st.tuples(*repeat(s, n)) for s in strats]))(f) | ||
return g | ||
|
||
|
||
@elements(3) | ||
def test_triangle(items): | ||
a, b, x = items | ||
assert default_distance(a, b) <= default_distance(a, x) default_distance(x, b) | ||
|
||
|
||
@elements(2) | ||
def test_commutative(items): | ||
a, b = items | ||
assert default_distance(a, b) == default_distance(b, a) | ||
|
||
|
||
@elements(2) | ||
def test_positivity(items): | ||
a, b = items | ||
dist = default_distance(a, b) | ||
if a == b: | ||
assert dist == 0 | ||
else: | ||
assert dist > 0 |
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