def test_dll_append_four_right(): dll = DoubleLinkedList() dll.append(1) dll.append(2) dll.append(3) dll.append(4) assert dll.right == 4
def test_appendleft_many(): dll = DoubleLinkedList() dll.appendleft(1) dll.appendleft(2) dll.appendleft(3) dll.appendleft(4) nose.tools.assert_equal(dll.pop(), 1)
from linkedlist import DoubleLinkedList ld = DoubleLinkedList() print("esta vacia?: ", ld.is_empty()) ld.append(10) ld.append(20) ld.append(30) print(f"la lista tiene: {ld.get_size()}") ld.transversal() ld.reverse_transversal() ld.remove_from_head(20)
def add(self, value): def greater_value_node(index, node): return node.value > value return DoubleLinkedList.add(self, value, where=greater_value_node)
def test_appendleft_full(): dll = DoubleLinkedList(range(3)) dll.appendleft(5) nose.tools.assert_equal(dll.pop(), 2)
def test_append_twice_pop_twice(): dll = DoubleLinkedList() dll.append(1) dll.append(2) dll.pop() assert dll.pop() == 1
def test_popleft(): dll = DoubleLinkedList() dll.append(1) assert dll.popleft() == 1
def test_dll_appendleft_twice(): dll = DoubleLinkedList() dll.appendleft(1) dll.appendleft(2) assert dll.left == 2
def test_dll_appendleft_singleton(): dll = DoubleLinkedList() dll.appendleft(1) assert dll.left == dll.right == 1
def test_dll_append_twice(): dll = DoubleLinkedList() dll.append(1) dll.append(2) assert dll.right == 2
def test_dll_append(): dll = DoubleLinkedList() dll.append(1) assert dll.right == 1