Пример #1
0
def test_insert_on_position_0():
    d = DoubleLinkedList([1])
    d.insert(0, 0)
    print("\n", d, "\n")
    assert (len(d)) == 2
    assert d[0] == 0
    assert list(d) == [0, 1]
Пример #2
0
def test_insert_on_position_0():
    d = DoubleLinkedList([1])
    d.insert(0, 0)
    print("\n", d, "\n")
    assert (len(d)) == 2
    assert d[0] == 0
    assert list(d) == [0, 1]
Пример #3
0
def test_eq():
    d = DoubleLinkedList([1, 2, 3])
    d1 = DoubleLinkedList([1, 2, 3])
    assert d == d1
    d1.append(4)
    assert d != d1
    d1.pop()
    d1[-1] = "4"
    assert d != d1
    assert d == [1, 2, 3]
Пример #4
0
def test_slice_del_(name, input, result):
    d = DoubleLinkedList([0, 1, 2, 3])
    index = slice(*input)
    del d[index]
    assert list(d) == result
    if d:
        backwards_path_get_all_values(d)
Пример #5
0
def test_slice_assignment_varying_step(name, input, value, should_raise,
                                       result):
    d = DoubleLinkedList([0, 1, 2, 3, 4, 5])
    index = slice(*input)
    if should_raise:
        with pytest.raises(ValueError):
            d[index] = value
        return
    d[index] = value
    assert list(d) == result
Пример #6
0
def test_eq():
    d = DoubleLinkedList([1, 2, 3])
    d1 = DoubleLinkedList([1, 2, 3])
    assert d == d1
    d1.append(4)
    assert d != d1
    d1.pop()
    d1[-1] = "4"
    assert d != d1
    assert d == [1, 2, 3]
Пример #7
0
def test_rotate_2():
    d = DoubleLinkedList([1, 2, 3, 4, 5, 6])
    d.rotate(2)
    assert (len(d)) == 6
    assert list(d) == [5, 6, 1, 2, 3, 4]
Пример #8
0
def test_backward_path_get_all_values():
    d = DoubleLinkedList([0, 1, 2, 3])
    backwards_path_get_all_values(d)
Пример #9
0
def test_rotate_minus_5():
    d = DoubleLinkedList([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
    d.rotate(-5)
    assert (len(d)) == 10
    assert list(d) == [6, 7, 8, 9, 10, 1, 2, 3, 4, 5]
Пример #10
0
def test_rotate__minus_1():
    d = DoubleLinkedList([1, 2, 3, 4])
    d.rotate(-1)
    assert list(d) == [2, 3, 4, 1]
Пример #11
0
def test_insert_on_empty():
    d = DoubleLinkedList()
    d.insert(0, 1)
    assert (len(d)) == 1
    assert d[0] == 1
Пример #12
0
def test_rotate_2():
    d = DoubleLinkedList([1, 2, 3, 4, 5, 6])
    d.rotate(2)
    assert (len(d)) == 6
    assert list(d) == [5, 6, 1, 2, 3, 4]
Пример #13
0
def test_create_with_range():
    d = DoubleLinkedList(range(5))
    assert (len(d)) == 5
    assert list(d) == list(range(5))
Пример #14
0
def test_slice_assignment_step_1(name, input, value, result):
    d = DoubleLinkedList([0, 1, 2, 3])
    index = slice(input[0], input[1], None)
    d[index] = value
    assert list(d) == result
Пример #15
0
def test_append():
    d = DoubleLinkedList([1, 2, 3])
    d.append(4)
    assert (len(d)) == 4
    assert d[-1] == 4
    assert list(d) == [1, 2, 3, 4]
Пример #16
0
def test_extend():
    d = DoubleLinkedList([1, 2, 3])
    d.extend([4, 5])
    assert (len(d)) == 5
    assert d[-1] == 5
    assert list(d) == [1, 2, 3, 4, 5]
Пример #17
0
def test_insert_on_position_minus_1():
    d = DoubleLinkedList([1, 2, 4])
    d.insert(-1, 3)
    assert (len(d)) == 4
    assert d[2] == 3
    assert list(d) == [1, 2, 3, 4]
Пример #18
0
def test_insert_on_position_1():
    d = DoubleLinkedList([1, 3, 4])
    d.insert(1, 2)
    assert (len(d)) == 4
    assert d[1] == 2
    assert list(d) == [1, 2, 3, 4]
Пример #19
0
def test_insert_on_position_0_larger():
    d = DoubleLinkedList([1, 2])
    d.insert(0, 0)
    assert (len(d)) == 3
    assert d[0] == 0
    assert list(d) == [0, 1, 2]
Пример #20
0
def test_rotate_1():
    d = DoubleLinkedList([1, 2, 3, 4])
    d.rotate(1)
    assert (len(d)) == 4
    assert list(d) == [4, 1, 2, 3]
Пример #21
0
def test_del_at_1():
    d = DoubleLinkedList([1, 2, 3])
    del d[1]
    assert (len(d)) == 2
    assert list(d) == [1, 3]
Пример #22
0
def test_insert_on_empty():
    d = DoubleLinkedList()
    d.insert(0, 1)
    assert (len(d)) == 1
    assert d[0] == 1
Пример #23
0
def test_insert_on_position_0_larger():
    d = DoubleLinkedList([1, 2])
    d.insert(0, 0)
    assert (len(d)) == 3
    assert d[0] == 0
    assert list(d) == [0, 1, 2]
Пример #24
0
def test_iterate_on_empty():
    d = DoubleLinkedList([
        1,
    ])
    del d[0]
    assert list(d) == []
Пример #25
0
def test_insert_on_position_1():
    d = DoubleLinkedList([1, 3, 4])
    d.insert(1, 2)
    assert (len(d)) == 4
    assert d[1] == 2
    assert list(d) == [1, 2, 3, 4]
Пример #26
0
def test_rotate_1():
    d = DoubleLinkedList([1, 2, 3, 4])
    d.rotate(1)
    assert (len(d)) == 4
    assert list(d) == [4, 1, 2, 3]
Пример #27
0
def test_assign_to_index():
    d = DoubleLinkedList([0, 1, 2])
    d[0] = 3
    assert d[0] == 3
    d[-1] = 4
    assert d[-1] == 4
Пример #28
0
def test_rotate__minus_1():
    d = DoubleLinkedList([1, 2, 3, 4])
    d.rotate(-1)
    assert list(d) == [2, 3, 4, 1]
Пример #29
0
def test_append():
    d = DoubleLinkedList([1, 2, 3])
    d.append(4)
    assert (len(d)) == 4
    assert d[-1] == 4
    assert list(d) == [1, 2, 3, 4]
Пример #30
0
def test_pop():
    d = DoubleLinkedList([1, 2, 3])
    assert d.pop() == 3
    assert (len(d)) == 2
    assert list(d) == [1, 2]
Пример #31
0
def test_rotate_minus_5():
    d = DoubleLinkedList([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
    d.rotate(-5)
    assert (len(d)) == 10
    assert list(d) == [6, 7 ,8 , 9, 10, 1, 2, 3, 4, 5]
Пример #32
0
def test_create():
    d = DoubleLinkedList()
    assert (len(d)) == 0
Пример #33
0
def test_slice_get_results_is_correct_class():
    d = DoubleLinkedList([0, 1, 2, 3])
    assert type(d[0:1]) is DoubleLinkedList
    t1 = type("t1", (DoubleLinkedList, ), {})
    d1 = t1([0, 1, 2, 3])
    assert type(d1[0:1]) is t1
Пример #34
0
def test_get_on_position_minus_1():
    d = DoubleLinkedList([0, 1, 2])
    assert d[-1] == 2
Пример #35
0
def test_slice_get_(name, input, result):
    d = DoubleLinkedList([0, 1, 2, 3])
    index = slice(*input)
    assert list(d[index]) == result
Пример #36
0
def test_insert_on_position_minus_1():
    d = DoubleLinkedList([1, 2, 4])
    d.insert(-1, 3)
    assert (len(d)) == 4
    assert d[2] == 3
    assert list(d) == [1, 2, 3, 4]
Пример #37
0
def test_create_with_list():
    d = DoubleLinkedList([0, 1, 2])
    assert (len(d)) == 3
    assert list(d) == [0, 1, 2]
Пример #38
0
def test_extend():
    d = DoubleLinkedList([1, 2, 3])
    d.extend([4, 5])
    assert (len(d)) == 5
    assert d[-1] == 5
    assert list(d) == [1, 2, 3, 4, 5]
Пример #39
0
def test_pop():
    d = DoubleLinkedList([1, 2, 3])
    assert d.pop() == 3
    assert (len(d)) == 2
    assert list(d) == [1, 2]