def test_interval_list_can_add_value(intervals: IntervalList): intervals.add(1) assert len(intervals) == 1 assert 0 not in intervals assert 1 in intervals assert 2 not in intervals
def test_interval_list_can_handles_duplicate_entries_correctly( intervals: IntervalList): intervals.add(1) intervals.add(1) assert len(intervals) == 1 assert 0 not in intervals assert 1 in intervals assert 2 not in intervals
def test_interval_list_can_add_continuous_blocks(intervals: IntervalList): intervals.add(1) intervals.add(2) assert len(intervals) == 2 assert 0 not in intervals assert 1 in intervals assert 2 in intervals assert 3 not in intervals
def test_interval_list_has_equality_operator(intervals: IntervalList, other_intervals: IntervalList): assert intervals == other_intervals intervals.add(1) assert intervals != other_intervals other_intervals.add(1) assert intervals == other_intervals
def test_interval_list_can_grow_blocks_in_arbitrary_direction( intervals: IntervalList): intervals.add(1) intervals.add(2) intervals.add(0) assert len(intervals) == 3 assert -1 not in intervals assert 0 in intervals assert 1 in intervals assert 2 in intervals assert 3 not in intervals
def test_interval_list_can_have_multiple_blocks(intervals: IntervalList): intervals.add(4) intervals.add(5) intervals.add(1) intervals.add(2) assert len(intervals) == 4 assert 0 not in intervals assert 1 in intervals assert 2 in intervals assert 3 not in intervals assert 4 in intervals assert 5 in intervals assert 6 not in intervals
def test_interval_list_handles_arbitrary_insertion_order( intervals: IntervalList, other_intervals: IntervalList): test_set = set() for _ in range(100): n = randint(1, 100) test_set.add(n) intervals.add(n) for n in test_set: other_intervals.add(n) assert len(intervals) == len(test_set) assert intervals == other_intervals for _ in range(200): n = randint(0, 200) if n in test_set: assert n in intervals else: assert n not in intervals
def test_intervals_dont_overlap(intervals: IntervalList): intervals.add(1) intervals.add(2) intervals.add(4) intervals.add(5) intervals.add(3) intervals.add(4) assert len(intervals) == 5
def intervals(): return IntervalList()
def other_intervals(): return IntervalList()