Skip to content

Instantly share code, notes, and snippets.

@MartinThoma
Last active August 2, 2020 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MartinThoma/cb1fb7fdfb0e409dfe40c7f50a6e0458 to your computer and use it in GitHub Desktop.
Save MartinThoma/cb1fb7fdfb0e409dfe40c7f50a6e0458 to your computer and use it in GitHub Desktop.
from hypothesis import given, strategies as st
from mpu.datastructures import Interval
@given(st.lists(st.integers(), min_size=4, max_size=4).map(sorted))
def test_interval_issubset(integer_list):
a, b, c, d = integer_list
assert Interval(b, c).issubset(Interval(a, d))
@given(st.lists(st.integers(), min_size=4, max_size=4).map(sorted))
def test_interval_issubset_not(integer_list):
a, b, c, d = integer_list
assert not Interval(a, b).issubset(Interval(c, d)) or c <= a <= b <= d
assert not Interval(a, c).issubset(Interval(b, d)) or b <= a <= c <= d
assert not Interval(c, d).issubset(Interval(a, b)) or a <= c <= d <= b
assert not Interval(b, d).issubset(Interval(a, c)) or a <= b <= d <= c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment