Skip to content

Commit f58e094

Browse files
committed
cover 100% of SinglyLL class with unittests.
1 parent 7221a8c commit f58e094

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

.coverage

52 KB
Binary file not shown.

tests/test_LinkedLists.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import pytest
2-
from Implementations.LinkedLists import DoublyLL, Node, SinglyLL
2+
from Implementations.LinkedLists import Node, SinglyLL
33

44

55
class TestNode:
@@ -145,6 +145,11 @@ def test_pop(self) -> None:
145145
# Test circular list:
146146
circular_lst = SinglyLL([1, 2, 3, 4, 5], circular=True)
147147

148+
circular_lst.pop(0)
149+
assert circular_lst.head == Node(
150+
2
151+
), f"new head node must be Node(2), not {circular_lst.head}"
152+
148153
circular_lst.pop()
149154
assert circular_lst.tail == Node(
150155
4
@@ -160,6 +165,12 @@ def test_remove(self) -> None:
160165
lst.remove(1) == lst
161166
), "removing from an empty list should return the same list without modification"
162167

168+
lst = SinglyLL([1])
169+
lst.remove(1)
170+
assert (
171+
lst.head is lst.tail is None
172+
), f"empty list head and tail must be None, not {lst.head} or {lst.tail}"
173+
163174
lst = SinglyLL([1, 2, 3, 4, 5])
164175

165176
lst.remove(1)
@@ -180,6 +191,11 @@ def test_remove(self) -> None:
180191
# Test circular list:
181192
circular_lst = SinglyLL([1, 2, 3, 4, 5], circular=True)
182193

194+
circular_lst.remove(1)
195+
assert circular_lst.head == Node(
196+
2
197+
), f"new head node must be Node(2), not {circular_lst.head}"
198+
183199
circular_lst.remove(5)
184200
assert circular_lst.tail == Node(
185201
4

0 commit comments

Comments
 (0)