def test_range_list_update_non_contiguous(): rl = RangeList() rl.update([Range(0, 10), Range(100, 110), Range(200, 210)]) rl.update([Range(300, 310), Range(400, 410), Range(500, 510)]) assert rl._ranges == [ Range(0, 10), Range(100, 110), Range(200, 210), Range(300, 310), Range(400, 410), Range(500, 510), ] assert rl.sum() == 60
def test_range_list_update_overlap_next_multi_all(): rl = RangeList() rl.update([Range(0, 10), Range(20, 30), Range(40, 50), Range(60, 70)]) rl.update([Range(0, 50), Range(20, 70)]) assert rl._ranges == [Range(0, 70)] assert rl.sum() == 70
def test_range_list_update_overlap_both_all(): rl = RangeList() rl.update([Range(0, 10), Range(20, 30)]) rl.update([Range(0, 30)]) assert rl._ranges == [Range(0, 30)] assert rl.sum() == 30
def test_ragne_list_update_overlap_next_all(): rl = RangeList() rl.update([Range(0, 10), Range(20, 30)]) rl.update([Range(15, 30)]) assert rl._ranges == [Range(0, 10), Range(15, 30)] assert rl.sum() == 25
def test_range_list_update_contiguous(): rl = RangeList() rl.update([Range(0, 10), Range(100, 110), Range(200, 210)]) rl.update([Range(10, 20), Range(110, 120), Range(210, 220)]) assert rl._ranges == [Range(0, 20), Range(100, 120), Range(200, 220)] assert rl.sum() == 60
def test_range_list_update_same(): rl = RangeList() rl.add(Range(0, 40)) rl.update([Range(0, 10), Range(10, 20), Range(20, 30), Range(30, 40)]) assert rl._ranges == [Range(0, 40)] assert rl.sum() == 40