1
1
import pytest
2
- from Implementations .LinkedLists import DoublyLL , Node , SinglyLL
2
+ from Implementations .LinkedLists import Node , SinglyLL
3
3
4
4
5
5
class TestNode :
@@ -145,6 +145,11 @@ def test_pop(self) -> None:
145
145
# Test circular list:
146
146
circular_lst = SinglyLL ([1 , 2 , 3 , 4 , 5 ], circular = True )
147
147
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
+
148
153
circular_lst .pop ()
149
154
assert circular_lst .tail == Node (
150
155
4
@@ -160,6 +165,12 @@ def test_remove(self) -> None:
160
165
lst .remove (1 ) == lst
161
166
), "removing from an empty list should return the same list without modification"
162
167
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
+
163
174
lst = SinglyLL ([1 , 2 , 3 , 4 , 5 ])
164
175
165
176
lst .remove (1 )
@@ -180,6 +191,11 @@ def test_remove(self) -> None:
180
191
# Test circular list:
181
192
circular_lst = SinglyLL ([1 , 2 , 3 , 4 , 5 ], circular = True )
182
193
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
+
183
199
circular_lst .remove (5 )
184
200
assert circular_lst .tail == Node (
185
201
4
0 commit comments