Beispiel #1
0
def test_keysvalues_empty():
    sl = SortedList([])
    assert (sl._k == [])
    assert (sl._k == [])

    with pytest.raises(ValueError):
        sl.index(0)
Beispiel #2
0
def test_keysvalues_empty():
    sl = SortedList([])
    assert(sl._k == [])
    assert(sl._k == [])

    with pytest.raises(ValueError):
        sl.index(0)
Beispiel #3
0
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'))
Beispiel #4
0
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'))
Beispiel #5
0
def test_badindex():
    sl = SortedList([3, 6, 1, 7, 0])
    with pytest.raises(ValueError):
        sl.index(4)
Beispiel #6
0
def test_badindex():
    sl = SortedList([3, 6, 1, 7, 0])
    with pytest.raises(ValueError):
        sl.index(4)