def test_intersection():
    d1 = Interval(0, 2, start_open=False, end_open=False)
    d2 = Interval(1, 3, start_open=False, end_open=False)
    assert d1.contains(0)
    assert d1.contains(1)
    assert d1.contains(2)
    d = Interval.intersection([d1, d2])
    assert (d.start == 1)
    assert (d.end == 2)
    assert (not d.start_open)
    assert (not d.end_open)
    d = Interval.union([d1, d2])
    assert (d.start == 0)
    assert (d.end == 3)
    assert (not d.start_open)
    assert (not d.end_open)
    d1 = Interval(0, 2, start_open=False, end_open=False)
    d2 = Interval(1, 3, start_open=True, end_open=True)
    d = Interval.intersection([d1, d2])
    assert (d.start == 1)
    assert (d.end == 2)
    assert d.start_open
    assert (not d.end_open)
    d = Interval.union([d1, d2])
    assert (d.start == 0)
    assert (d.end == 3)
    assert (not d.start_open)
    assert d.end_open
    d1 = Interval(0, 2, start_open=True, end_open=True)
    d2 = Interval(1, 3, start_open=True, end_open=True)
    assert (not d1.contains(0))
    assert d1.contains(1)
    assert (not d1.contains(2))
    d = Interval.intersection([d1, d2])
    assert (d.start == 1)
    assert (d.end == 2)
    assert d.start_open
    assert d.end_open
    d = Interval.union([d1, d2])
    assert (d.start == 0)
    assert (d.end == 3)
    assert d.start_open
    assert d.end_open
    d = Interval.intersection([Interval(0, 1), Interval(2, 3)])
    assert d.is_empty
    d = Interval.intersection([Interval(0, 1, end_open=True), Interval(1, 3, start_open=True)])
    assert d.is_empty
    d = Interval.intersection([Interval(0, 1), Interval.empty()])
    assert d.is_empty
    d = Interval.union([Interval.empty(), 1])
    assert (d.start == 1)
    assert (d.end == 1)
def test_intersection():
    d1 = Interval(0, 2, start_open=False, end_open=False)
    d2 = Interval(1, 3, start_open=False, end_open=False)
    assert d1.contains(0)
    assert d1.contains(1)
    assert d1.contains(2)
    d = Interval.intersection([d1, d2])
    assert (d.start == 1)
    assert (d.end == 2)
    assert (not d.start_open)
    assert (not d.end_open)
    d = Interval.union([d1, d2])
    assert (d.start == 0)
    assert (d.end == 3)
    assert (not d.start_open)
    assert (not d.end_open)
    d1 = Interval(0, 2, start_open=False, end_open=False)
    d2 = Interval(1, 3, start_open=True, end_open=True)
    d = Interval.intersection([d1, d2])
    assert (d.start == 1)
    assert (d.end == 2)
    assert d.start_open
    assert (not d.end_open)
    d = Interval.union([d1, d2])
    assert (d.start == 0)
    assert (d.end == 3)
    assert (not d.start_open)
    assert d.end_open
    d1 = Interval(0, 2, start_open=True, end_open=True)
    d2 = Interval(1, 3, start_open=True, end_open=True)
    assert (not d1.contains(0))
    assert d1.contains(1)
    assert (not d1.contains(2))
    d = Interval.intersection([d1, d2])
    assert (d.start == 1)
    assert (d.end == 2)
    assert d.start_open
    assert d.end_open
    d = Interval.union([d1, d2])
    assert (d.start == 0)
    assert (d.end == 3)
    assert d.start_open
    assert d.end_open
    d = Interval.intersection([Interval(0, 1), Interval(2, 3)])
    assert d.is_empty
    d = Interval.intersection([Interval(0, 1, end_open=True), Interval(1, 3, start_open=True)])
    assert d.is_empty
    d = Interval.intersection([Interval(0, 1), Interval.empty()])
    assert d.is_empty
    d = Interval.union([Interval.empty(), 1])
    assert (d.start == 1)
    assert (d.end == 1)