Skip to content

Commit 9bd2413

Browse files
removed unreachable code
1 parent 75f9233 commit 9bd2413

File tree

2 files changed

+0
-28
lines changed

2 files changed

+0
-28
lines changed

DataStructures.Tests/LinkedList/CircularLinkedListTests.cs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -90,27 +90,6 @@ public static void TestInsertAfterOnNonExistingValue()
9090
Assert.That("10", Is.EqualTo(GetDisplayOutput(cll).Trim()));
9191
}
9292

93-
[Test]
94-
public static void TestInsertAfterTailNode()
95-
{
96-
var cll = new CircularLinkedList<int>();
97-
cll.InsertAtEnd(10); // tail -> 10
98-
cll.InsertAtEnd(20); // tail -> 20
99-
cll.InsertAtEnd(30); // tail -> 30
100-
101-
// Insert after the current tail (30)
102-
cll.InsertAfter(30, 40); // This should make 40 the new tail
103-
104-
// Now 40 should be the tail, and the list should be 10 20 30 40
105-
Assert.That("10 20 30 40", Is.EqualTo(GetDisplayOutput(cll).Trim()));
106-
107-
// Additionally, assert that tail's Data is now 40
108-
var tailField = typeof(CircularLinkedList<int>).GetField("tail", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
109-
var tailNode = (CircularLinkedListNode<int>?)tailField?.GetValue(cll);
110-
Assert.That(tailNode!.Data, Is.EqualTo(40)); // tail should now point to 40
111-
}
112-
113-
11493
[Test]
11594
public static void TestDeleteNode()
11695
{
@@ -198,6 +177,4 @@ private static string GetDisplayOutput<T>(CircularLinkedList<T> list)
198177

199178
return result.ToString().Trim();
200179
}
201-
202-
203180
}

DataStructures/LinkedList/CircularLinkedList/CircularLinkedList.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,6 @@ public void InsertAfter(T value, T data)
9999
newNode.Next = current.Next;
100100
current.Next = newNode;
101101

102-
if (current == tail)
103-
{
104-
tail = newNode;
105-
}
106-
107102
return;
108103
}
109104

0 commit comments

Comments
 (0)