def test_union_of_disjoint(): first = IntervalSet((i.open(1, 5), i.closed(7, 10))) second = IntervalSet((i.open(12, 21), i.closed(22, 23))) expected = IntervalSet( (i.open(1, 5), i.closed(7, 10), i.open(12, 21), i.closed(22, 23))) result = first.union(second) assert result == expected
def test_union_of_overlapping(): first = IntervalSet((i.open(1, 5), i.closed(7, 10))) second = IntervalSet((i.open(8, 21), i.closed(22, 23))) expected = IntervalSet((i.open(1, 5), i.closedopen(7, 21), i.closed(22, 23))) result = first.union(second) assert result == expected
def test_union_of_equal(): first = IntervalSet((i.open(1, 5), i.closed(7, 10))) result = first.union(first) assert result == first
def test_union_of_disjoint(): first = IntervalSet((i.open(1, 5), i.closed(7, 10))) second = IntervalSet((i.open(12, 21), i.closed(22,23))) expected = IntervalSet((i.open(1, 5), i.closed(7, 10), i.open(12, 21), i.closed(22, 23))) result = first.union(second) assert result == expected
def test_union_of_overlapping(): first = IntervalSet((i.open(1, 5), i.closed(7, 10))) second = IntervalSet((i.open(8, 21), i.closed(22,23))) expected = IntervalSet((i.open(1, 5), i.closedopen(7, 21), i.closed(22, 23))) result = first.union(second) assert result == expected
def test_length_of_unioned(): first = IntervalSet((i.open(1, 5), i.closed(7, 10))) second = IntervalSet((i.open(8, 21), i.closed(22,23))) # This is of length 3 as 2 of the intervals overlap and therefore join together assert len(first.union(second)) == 3
def test_union_is_symmetric(): # check expected result and symmetric property expected = IntervalSet((i.open(1, 2), i.open(4, 7), i.open(12, 13))) first = IntervalSet((i.open(1, 2), i.open(4, 6))) second = IntervalSet((i.open(5, 7), i.open(12, 13))) assert first.union(second) == expected assert second.union(first) == expected
def test_union_is_symmetric(): # check expected result and symmetric property expected = IntervalSet((i.open(1, 2), i.open(4, 7), i.open(12, 13))) first = IntervalSet((i.open(1, 2), i.open(4, 6))) second = IntervalSet((i.open(5, 7), i.open(12, 13))) assert first.union(second) == expected assert second.union(first) == expected
def test_length_of_unioned(): first = IntervalSet((i.open(1, 5), i.closed(7, 10))) second = IntervalSet((i.open(8, 21), i.closed(22, 23))) # This is of length 3 as 2 of the intervals overlap and therefore join together assert len(first.union(second)) == 3
def test_union_of_equal(): first = IntervalSet((i.open(1, 5), i.closed(7, 10))) result = first.union(first) assert result == first