Exemple #1
0
def test_ragne_list_add_overlap_next_some():
    rl = RangeList()
    rl.add(Range(0, 10))
    rl.add(Range(20, 30))
    rl.add(Range(15, 25))
    assert rl._ranges == [Range(0, 10), Range(15, 30)]
    assert rl.sum() == 25
Exemple #2
0
def test_range_list_add_overlap_both_all():
    rl = RangeList()
    rl.add(Range(0, 10))
    rl.add(Range(20, 30))
    rl.add(Range(0, 30))
    assert rl._ranges == [Range(0, 30)]
    assert rl.sum() == 30
Exemple #3
0
def test_range_list_add_overlap_next_multi_all():
    rl = RangeList()
    rl.add(Range(0, 10))
    rl.add(Range(20, 30))
    rl.add(Range(40, 50))
    rl.add(Range(60, 70))
    rl.add(Range(20, 50))
    assert rl._ranges == [Range(0, 10), Range(20, 50), Range(60, 70)]
    assert rl.sum() == 50
Exemple #4
0
def test_range_list_copy():
    r1 = RangeList()

    r1.add(Range(0, 100))
    r1.add(Range(200, 300))
    r1.add(Range(400, 500))

    r2 = RangeList(r1)

    # r1 and r2 are qqual.
    assert r1._ranges == r2._ranges
    assert r1.sum() == r2.sum()

    # But independent.
    r1.add(Range(300, 400))
    r2.add(Range(100, 200))

    assert r1._ranges == [Range(0, 100), Range(200, 500)]
    assert r2._ranges == [Range(0, 300), Range(400, 500)]
Exemple #5
0
def test_range_list_add_non_contiguous():
    rl = RangeList()
    rl.add(Range(0, 10))
    rl.add(Range(20, 30))
    assert rl._ranges == [Range(0, 10), Range(20, 30)]
    assert rl.sum() == 20
Exemple #6
0
def test_range_list_add_overlap():
    rl = RangeList()
    rl.add(Range(0, 10))
    rl.add(Range(5, 15))
    assert rl._ranges == [Range(0, 15)]
    assert rl.sum() == 15
Exemple #7
0
def test_range_list_add_longer():
    rl = RangeList()
    rl.add(Range(0, 5))
    rl.add(Range(0, 10))
    assert rl._ranges == [Range(0, 10)]
    assert rl.sum() == 10
Exemple #8
0
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