def test_indexfind_le(): sl = SortedList([3, 6, 1, 7, 0]) assert (sl.index_le(3) == 2) assert (sl.find_le(4) == 3) with pytest.raises(ValueError): sl.index_le(-1) with pytest.raises(ValueError): sl.find_le(-1)
def test_indexfind_le(): sl = SortedList([3, 6, 1, 7, 0]) assert(sl.index_le(3) == 2) assert(sl.find_le(4) == 3) with pytest.raises(ValueError): sl.index_le(-1) with pytest.raises(ValueError): sl.find_le(-1)
def test_tuplelist(): data = [(3, 'a'), (4, 'v'), (1, 'z'), (5, 'b')] sl = SortedList(data, key=lambda x: x[1]) assert (sl._k == ['a', 'b', 'v', 'z']) assert (sl._v == [(3, 'a'), (5, 'b'), (4, 'v'), (1, 'z')]) assert (sl.index_lt((10, 'e')) == 1) assert (sl.index_le((10, 'e')) == 1) assert (sl.index_lt((5, 'b')) == 0) with pytest.raises(ValueError): sl.index((10, 'b')) with pytest.raises(ValueError): sl.index((3, 'b'))
def test_tuplelist(): data = [(3, 'a'), (4, 'v'), (1, 'z'), (5, 'b')] sl = SortedList(data, key=lambda x: x[1]) assert(sl._k == ['a', 'b', 'v', 'z']) assert(sl._v == [(3, 'a'), (5, 'b'), (4, 'v'), (1, 'z')]) assert(sl.index_lt((10, 'e')) == 1) assert(sl.index_le((10, 'e')) == 1) assert(sl.index_lt((5, 'b')) == 0) with pytest.raises(ValueError): sl.index((10, 'b')) with pytest.raises(ValueError): sl.index((3, 'b'))