def test_remove_not_found(self): dll = LinkedList() assert dll.is_empty() is True assert dll.push(1) is None assert dll.is_empty() is False with pytest.raises(ValueError): dll.remove(2)
def test_remove_single(self): dll = LinkedList() assert dll.is_empty() assert dll.push(1) is None assert dll.size == 1 assert dll.head is dll.tail assert dll.remove(1) is None assert dll.is_empty()
def test_remove_tail(self): dll = LinkedList() items = 2 assert dll.is_empty() for i in range(items): assert dll.append(i) is None assert dll.size == items assert dll.tail is not dll.head assert dll.remove(1) is None assert dll.head is dll.tail assert dll.size == items - 1
def test_remove_mid(self): dll = LinkedList() items = 3 assert dll.is_empty() for i in range(items): assert dll.append(i) is None assert dll.size == items assert dll.head is not dll.tail assert dll.remove(1) is None assert dll.head is not dll.tail assert dll.head.data == 0 assert dll.tail.data == 2 assert dll.head.next is dll.tail assert dll.tail.prev is dll.head assert dll.head.prev is None assert dll.tail.next is None assert dll.size == items - 1
def test_remove_empty(self): dll = LinkedList() assert dll.head is None assert dll.size == 0 with pytest.raises(ValueError): dll.remove(0)