Exemplo n.º 1
0
def test_solution():
    from solution import Node, linkedList

    items = linkedList()
    items.head = Node(20)
    items.head.next = Node(30)
    items.head.next.next = Node(40)

    assert items.search(30) == True
    assert items.search(10) == False
Exemplo n.º 2
0
def test_solution():
    from solution import Node, linkedList

    items = linkedList()
    items.head = Node(20)
    items.insert_at_start(40)
    items.insert_at_start(50)
    assert items.head.data == 50
    assert items.head.next.data == 40
    assert items.head.next.next.data == 20
Exemplo n.º 3
0
def test_solution():
    from solution import Node, linkedList

    items = linkedList()
    items.head = Node(20)
    items.head.next = Node(30)
    items.head.next.next = Node(50)
    items.insert_after_item(30, 0)
    assert items.head.data == 20
    assert items.head.next.data == 30
    assert items.head.next.next.data == 0
Exemplo n.º 4
0
def test_solution():
    from solution import Node, linkedList

    items = linkedList()
    items.head = Node(20)
    items.head.next = Node(30)
    items.head.next.next = Node(40)
    items.reverse()

    assert items.head.data == 40
    assert items.head.next.data == 30
Exemplo n.º 5
0
def test_solution():
    from solution import Node, linkedList

    items = linkedList()
    items.head = Node(20)
    items.head.next = Node(30)
    items.head.next.next = Node(40)
    items.insert_at_index(2, 2)

    assert items.head.data == 20
    assert items.head.next.data == 2
Exemplo n.º 6
0
def test_solution():
    from solution import Node, linkedList

    items = linkedList()
    items.head = Node(20)
    items.head.next = Node(30)
    items.head.next.next = Node(40)
    items.head.next.next.next = Node(50)
    items.delete_item_by_value(40)

    assert items.head.data == 20
    assert items.head.next.data == 30
    assert items.head.next.next.data == 50
Exemplo n.º 7
0
def test_solution(monkeypatch):
    ret_val = []

    def g(num):
        ret_val.append(num)

    monkeypatch.setattr("builtins.print", g)

    from solution import Node, linkedList

    items = linkedList()
    items.head = Node(1)
    e2 = Node(2)
    items.head.next = e2
    items.traverse()

    assert ret_val[0] == 1
    assert ret_val[1] == 2