Skip to content

Commit

Permalink
added test case for codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
mohit-gogitter committed Oct 13, 2024
1 parent e50aed7 commit 75f9233
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions DataStructures.Tests/LinkedList/CircularLinkedListTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,27 @@ public static void TestInsertAfterOnNonExistingValue()
Assert.That("10", Is.EqualTo(GetDisplayOutput(cll).Trim()));
}

[Test]
public static void TestInsertAfterTailNode()
{
var cll = new CircularLinkedList<int>();
cll.InsertAtEnd(10); // tail -> 10
cll.InsertAtEnd(20); // tail -> 20
cll.InsertAtEnd(30); // tail -> 30

// Insert after the current tail (30)
cll.InsertAfter(30, 40); // This should make 40 the new tail

// Now 40 should be the tail, and the list should be 10 20 30 40
Assert.That("10 20 30 40", Is.EqualTo(GetDisplayOutput(cll).Trim()));

// Additionally, assert that tail's Data is now 40
var tailField = typeof(CircularLinkedList<int>).GetField("tail", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
var tailNode = (CircularLinkedListNode<int>?)tailField?.GetValue(cll);
Assert.That(tailNode!.Data, Is.EqualTo(40)); // tail should now point to 40
}


[Test]
public static void TestDeleteNode()
{
Expand Down

0 comments on commit 75f9233

Please sign in to comment.