Skip to content

Commit 0eb5d84

Browse files
authored
Merge pull request #92 from sir-gon/develop
[REFACTOR] test code de-duplication.
2 parents 7f6118e + 302054c commit 0eb5d84

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

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

Lines changed: 9 additions & 9 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

@@ -16,21 +16,21 @@ class LinkedListCycleTestCase
1616
public void testInitialize()
1717
{
1818
// Linked list sample data:
19-
LinkedList<int>.Node ll1_1 = new(1);
20-
LinkedList<int>.Node ll1_2 = new(2);
21-
LinkedList<int>.Node ll1_3 = new(3);
22-
LinkedList<int>.Node ll1_4 = new(4);
23-
LinkedList<int>.Node ll1_5 = new(5);
19+
LinkedList<string>.Node ll1_1 = new("a");
20+
LinkedList<string>.Node ll1_2 = new("b");
21+
LinkedList<string>.Node ll1_3 = new("c");
22+
LinkedList<string>.Node ll1_4 = new("d");
23+
LinkedList<string>.Node ll1_5 = new("e");
2424

2525
ll1_1.next = ll1_2;
2626
ll1_2.next = ll1_3;
2727
ll1_3.next = ll1_4;
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)