def test_index():
    slt = SortedKeyList(range(100), key=modulo)
    slt._reset(7)

    for pos, val in enumerate(sorted(range(100), key=modulo)):
        assert val == slt.index(pos)

    assert slt.index(9, 0, 1000) == 90

    slt = SortedKeyList((0 for rpt in range(100)), key=modulo)
    slt._reset(7)

    for start in range(100):
        for stop in range(start, 100):
            assert slt.index(0, start, stop + 1) == start

    for start in range(100):
        assert slt.index(0, -(100 - start)) == start

    assert slt.index(0, -1000) == 0
Ejemplo n.º 2
0
def test_index():
    slt = SortedKeyList(range(100), key=modulo)
    slt._reset(7)

    for pos, val in enumerate(sorted(range(100), key=modulo)):
        assert val == slt.index(pos)

    assert slt.index(9, 0, 1000) == 90

    slt = SortedKeyList((0 for rpt in range(100)), key=modulo)
    slt._reset(7)

    for start in range(100):
        for stop in range(start, 100):
            assert slt.index(0, start, stop + 1) == start

    for start in range(100):
        assert slt.index(0, -(100 - start)) == start

    assert slt.index(0, -1000) == 0
Ejemplo n.º 3
0
def test_index_valueerror10():
    slt = SortedKeyList(range(10), key=modulo)
    slt._reset(4)
    with pytest.raises(ValueError):
        slt.index(19)
Ejemplo n.º 4
0
def test_index_valueerror9():
    slt = SortedKeyList(key=modulo)
    slt._reset(4)
    with pytest.raises(ValueError):
        slt.index(5)
Ejemplo n.º 5
0
def test_index_valueerror7():
    slt = SortedKeyList([0] * 10 + [1] * 10 + [2] * 10, key=modulo)
    slt._reset(4)
    with pytest.raises(ValueError):
        slt.index(1, 0, 10)
Ejemplo n.º 6
0
def test_index_valueerror5():
    slt = SortedKeyList(key=modulo)
    with pytest.raises(ValueError):
        slt.index(1)
Ejemplo n.º 7
0
def test_index_valueerror3():
    slt = SortedKeyList([0] * 10, key=modulo)
    slt._reset(4)
    with pytest.raises(ValueError):
        slt.index(0, 7, 3)
def test_index_valueerror10():
    slt = SortedKeyList(range(10), key=modulo)
    slt._reset(4)
    with pytest.raises(ValueError):
        slt.index(19)
def test_index_valueerror9():
    slt = SortedKeyList(key=modulo)
    slt._reset(4)
    with pytest.raises(ValueError):
        slt.index(5)
def test_index_valueerror7():
    slt = SortedKeyList([0] * 10 + [1] * 10 + [2] * 10, key=modulo)
    slt._reset(4)
    with pytest.raises(ValueError):
        slt.index(1, 0, 10)
def test_index_valueerror5():
    slt = SortedKeyList(key=modulo)
    with pytest.raises(ValueError):
        slt.index(1)
def test_index_valueerror3():
    slt = SortedKeyList([0] * 10, key=modulo)
    slt._reset(4)
    with pytest.raises(ValueError):
        slt.index(0, 7, 3)