def test_index(): slt = SortedList(range(100)) slt._reset(17) for val in range(100): assert val == slt.index(val) assert slt.index(99, 0, 1000) == 99 slt = SortedList((0 for rpt in range(100))) slt._reset(17) 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
def test_index_valueerror7(): slt = SortedList([0] * 10 + [2] * 10) slt._reset(4) with pytest.raises(ValueError): slt.index(1, 0, 10)
def test_index_valueerror6(): slt = SortedList(range(10)) slt._reset(4) with pytest.raises(ValueError): slt.index(3, 5)
def test_index_valueerror5(): slt = SortedList() with pytest.raises(ValueError): slt.index(1)
def test_index_valueerror3(): slt = SortedList([0] * 10) slt._reset(4) with pytest.raises(ValueError): slt.index(0, 7, 3)