def test_extend():
    slt = SortedListWithKey(load=17, key=negate)

    slt.extend(range(300, 200, -1))
    slt._check()

    slt.extend(list(range(200, 100, -1)))
    slt._check()

    for val in range(100, 0, -1):
        del slt._index[:]
        slt._build_index()
        slt.extend([val] * (101 - val))
        slt._check()
def test_extend():
    slt = SortedListWithKey(load=17, key=negate)

    slt.extend(range(300, 200, -1))
    slt._check()

    slt.extend(list(range(200, 100, -1)))
    slt._check()

    for val in range(100, 0, -1):
        del slt._index[:]
        slt._build_index()
        slt.extend([val] * (101 - val))
        slt._check()
def test_getitem():
    random.seed(0)
    slt = SortedListWithKey(load=17, key=modulo)

    slt.append(5)
    slt._build_index()
    slt._check()
    slt.clear()

    lst = list(random.random() for rpt in range(100))
    slt.update(lst)
    lst.sort(key=modulo)

    assert all(slt[idx] == lst[idx] for idx in range(100))
    assert all(slt[idx - 99] == lst[idx - 99] for idx in range(100))
def test_getitem():
    random.seed(0)
    slt = SortedListWithKey(load=17, key=modulo)

    slt.append(5)
    slt._build_index()
    slt._check()
    slt.clear()

    lst = list(random.random() for rpt in range(100))
    slt.update(lst)
    lst.sort(key=modulo)

    assert all(slt[idx] == lst[idx] for idx in range(100))
    assert all(slt[idx - 99] == lst[idx - 99] for idx in range(100))