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
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
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
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
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
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
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