def test_insert_empty(self): dll = LinkedList() assert dll.is_empty() assert dll.insert(0, 0) is None assert isinstance(dll.head, Node) assert isinstance(dll.tail, Node) assert dll.head is dll.tail assert dll.size == 1
def test_insert_new_tail(self): dll = LinkedList() assert dll.is_empty() assert dll.push(1) is None assert isinstance(dll.head, Node) assert isinstance(dll.tail, Node) assert dll.head is dll.tail assert dll.size == 1 assert dll.insert(1, 2) is None assert isinstance(dll.head, Node) assert isinstance(dll.tail, Node) assert dll.head is not dll.tail assert dll.head.data == 1 assert dll.tail.data == 2 assert dll.head.next is dll.tail assert dll.head.prev is None assert dll.tail.prev is dll.head assert dll.tail.next is None assert dll.size == 2
def test_insert_new_head_negative_out_of_bounds(self): dll = LinkedList() assert dll.is_empty() assert dll.push(1) is None assert isinstance(dll.head, Node) assert isinstance(dll.tail, Node) assert dll.head is dll.tail assert dll.size == 1 assert dll.insert(-1000, 2) is None assert isinstance(dll.head, Node) assert isinstance(dll.tail, Node) assert dll.head is not dll.tail assert dll.head.data == 2 assert dll.tail.data == 1 assert dll.head.next is dll.tail assert dll.head.prev is None assert dll.tail.prev is dll.head assert dll.tail.next is None assert dll.size == 2
def test_insert_new_tail_out_of_bounds(self): dll = LinkedList() assert dll.is_empty() assert dll.push(0) is None assert isinstance(dll.head, Node) assert isinstance(dll.tail, Node) assert dll.head is dll.tail assert dll.size == 1 assert dll.insert(1000, 1) is None assert isinstance(dll.head, Node) assert isinstance(dll.tail, Node) assert dll.head is not dll.tail assert dll.head.data == 0 assert dll.tail.data == 1 assert dll.head.next is dll.tail assert dll.head.next.data == 1 assert dll.head.prev is None assert dll.tail.prev is dll.head assert dll.tail.prev.data == 0 assert dll.tail.next is None assert dll.size == 2
def test_insert_end_negative(self): dll = LinkedList() assert dll.is_empty() assert dll.append(0) is None assert dll.append(1) is None assert isinstance(dll.head, Node) assert isinstance(dll.tail, Node) assert dll.head is not dll.tail assert dll.size == 2 assert dll.insert(-1, 2) is None assert isinstance(dll.head, Node) assert isinstance(dll.tail, Node) assert dll.head is not dll.tail assert dll.head.data == 0 assert dll.tail.data == 1 assert dll.head.next is not dll.tail assert dll.head.next.data == 2 assert dll.head.prev is None assert dll.tail.prev is not dll.head assert dll.tail.prev.data == 2 assert dll.tail.next is None assert dll.size == 3