def test_display(): """Test of display returns data from src.linked list.""" from src.linked_list import LinkedList linked_list = LinkedList() linked_list.push('1') linked_list.push('2') linked_list.push('3') assert linked_list.display() == ('3', '2', '1')
def test_LinkedList_4(a, b): from src.linked_list import LinkedList test_values = LinkedList(a) assert test_values.display() == b
def test_linked_list_str(): """Ensure str calls display.""" from src.linked_list import LinkedList new_list = LinkedList([1, 2, 3, 4, None, True, 'stringy']) assert new_list.display() == str(new_list)
def test_linked_list_display(): """Our display list.""" from src.linked_list import LinkedList new_list = LinkedList([1, 2, 3, 4]) assert new_list.display() == "(4, 3, 2, 1)"
prev, curr = None, ll.head start, tail = None, None for i in range(1, f + 1): # import pdb; pdb.set_trace() if i == s - 1: start = curr if i == f: tail = curr.next start.next.next = tail start.next = curr curr.next = prev if i >= s and i < f: temp = curr.next curr.next = prev prev = curr curr = temp else: prev = curr curr = curr.next if __name__ == '__main__': LL1 = LinkedList([6, 3, 2]) LL2 = LinkedList([8, 5]) ll_merged = merge_ll(LL1.head, LL2.head) ll = LinkedList([8, 7, 6, 5, 4, 3, 2, 1]) print(ll.display()) # rev_ll(ll) rev_sub(ll, 3, 5) print(ll.display())