Ejemplo n.º 1
0
def test_insert_after_current_seen_again():
    test = [1, 2]
    it = ListIterator(test)
    it.next()
    it.next()
    it.insert_after_current([42, 1337])
    assert it.next()
    assert it.current() == 42
    assert it.next()
    assert it.current() == 1337
Ejemplo n.º 2
0
def test_insert_current():
    test_list = [42, 1337]
    it = ListIterator(test_list)
    it.next()
    it.next()
    it.insert_before([1, 1, 2])
    assert it.current() == 1337
Ejemplo n.º 3
0
def test_insert_previous():
    test_list = [42, 1337]
    it = ListIterator(test_list)
    it.next()
    it.next()
    it.insert_before([1, 3, 5])
    assert it.previous() == 5
Ejemplo n.º 4
0
def test_iteration_end():
    test_list = [1, 2, 3]
    it = ListIterator(test_list)
    it.next()
    it.next()
    it.next()
    assert not it.next()
Ejemplo n.º 5
0
def test_insert_offset():
    test_list = [42, 1337]
    it = ListIterator(test_list)
    it.next()
    it.next()
    it.insert_before([1, 3, 5], 1)
    assert all([a == b for a, b in zip(test_list, [1, 3, 5, 42, 1337])])
Ejemplo n.º 6
0
def test_insert_after_current_end():
    test = [1, 2]
    it = ListIterator(test)
    it.next()
    it.next()
    it.insert_after_current([42, 1337])
    assert test == [1, 2, 42, 1337]
Ejemplo n.º 7
0
def test_previous_value():
    test_list = [1, 2]
    it = ListIterator(test_list)
    it.next()
    it.next()
    assert it.previous() == 1
Ejemplo n.º 8
0
def test_no_has_previous():
    test_list = [1]
    it = ListIterator(test_list)
    assert not it.has_previous()
Ejemplo n.º 9
0
def test_has_previous():
    test_list = [1, 2]
    it = ListIterator(test_list)
    it.next()
    it.next()
    assert it.has_previous()
Ejemplo n.º 10
0
def test_empty_list_no_next():
    test_list = []
    it = ListIterator(test_list)
    assert not it.next()
Ejemplo n.º 11
0
def test_peek_mid():
    test = [1, 2, 3]
    it = ListIterator(test)
    it.next()
    assert it.peek() == 2
Ejemplo n.º 12
0
def test_current_index():
    test = [1, 2]
    it = ListIterator(test)
    it.next()
    assert it.current_index() == 0
Ejemplo n.º 13
0
def test_insert_after_current_empty():
    test = []
    it = ListIterator(test)
    it.insert_after_current([1, 2])
    assert test == [1, 2]
Ejemplo n.º 14
0
def test_peek_two():
    test = [1, 2]
    it = ListIterator(test)
    assert it.peek(2) == 2
Ejemplo n.º 15
0
def test_peek_no_more():
    test = [1]
    it = ListIterator(test)
    it.next()
    with pytest.raises(AssertionError):
        it.peek()
Ejemplo n.º 16
0
def test_iteration():
    test_list = [1, 2, 3]
    it = ListIterator(test_list)
    for i in test_list:
        it.next()
        assert it.current() == i
Ejemplo n.º 17
0
def test_can_peek(test_list, result):
    it = ListIterator(test_list)
    assert it.can_peek() == result
Ejemplo n.º 18
0
def test_peek_first():
    test = [1]
    it = ListIterator(test)
    assert it.peek() == 1