Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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)]
Exemplo n.º 5
0
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
Exemplo n.º 6
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
Exemplo n.º 7
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
Exemplo n.º 8
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
Exemplo n.º 9
0
def test_range_list_empty():
    rl = RangeList()
    assert rl.sum() == 0
Exemplo n.º 10
0
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
Exemplo n.º 11
0
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
Exemplo n.º 12
0
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
Exemplo n.º 13
0
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
Exemplo n.º 14
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