Skip to content

Commit 4c9abab

Browse files
author
Gonzalo Diaz
committed
[REFACTOR] test code de-duplication. Generic added.
1 parent 4cff3a4 commit 4c9abab

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

algorithm-exercises-csharp-test/src/hackerrank/interview_preparation_kit/linked_list/LinkedListCycle.Test.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class LinkedListCycleTest
66
class LinkedListCycleTestCase
77
{
88
public string title = "";
9-
public LinkedList<int>.Node? llist;
9+
public LinkedList<string>.Node? llist;
1010
public bool expected;
1111
}
1212

@@ -28,9 +28,9 @@ public void testInitialize()
2828
ll1_4.next = ll1_5;
2929
ll1_4.next = ll1_3; // <- cycle
3030

31-
LinkedList<int>.Node ll2_1 = new(1);
32-
LinkedList<int>.Node ll2_2 = new(2);
33-
LinkedList<int>.Node ll2_3 = new(3);
31+
LinkedList<string>.Node ll2_1 = new("a");
32+
LinkedList<string>.Node ll2_2 = new("b");
33+
LinkedList<string>.Node ll2_3 = new("c");
3434

3535
ll2_1.next = ll2_2;
3636
ll2_2.next = ll2_3;

algorithm-exercises-csharp/src/hackerrank/interview_preparation_kit/linked_list/LinkedListCycle.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ public class LinkedListCycle
99
[ExcludeFromCodeCoverage]
1010
protected LinkedListCycle() { }
1111

12-
public static bool hasCycle(LinkedList<int>.Node? head)
12+
public static bool hasCycle<T>(LinkedList<T>.Node? head)
1313
{
14-
List<LinkedList<int>.Node> llindex = [];
14+
List<LinkedList<T>.Node> llindex = [];
1515

16-
LinkedList<int>.Node? node = head;
16+
LinkedList<T>.Node? node = head;
1717

1818
while (node != null)
1919
{

0 commit comments

Comments
 (0)