1
1
package com .thealgorithms .datastructures .lists ;
2
2
3
- import static org .junit .jupiter .api .Assertions .*;
3
+ import static org .junit .jupiter .api .Assertions .assertFalse ;
4
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
5
+
4
6
import org .junit .jupiter .api .BeforeEach ;
5
7
import org .junit .jupiter .api .Test ;
6
8
7
- public class CreateAndDetectLoopTest {
9
+ public class CreateAndDetectLoopTest {
8
10
9
11
private CreateAndDetectLoop .Node head ;
10
12
@@ -26,13 +28,13 @@ void setUp() {
26
28
}
27
29
28
30
@ Test
29
- void testDetectLoop_NoLoop () {
31
+ void testDetectLoopNoLoop () {
30
32
// Test when no loop exists
31
33
assertFalse (CreateAndDetectLoop .detectLoop (head ), "There should be no loop." );
32
34
}
33
35
34
36
@ Test
35
- void testCreateAndDetectLoop_LoopExists () {
37
+ void testCreateAndDetectLoopLoopExists () {
36
38
// Create a loop between position 2 (node with value 2) and position 5 (node with value 5)
37
39
CreateAndDetectLoop .createLoop (head , 2 , 5 );
38
40
@@ -41,7 +43,7 @@ void testCreateAndDetectLoop_LoopExists() {
41
43
}
42
44
43
45
@ Test
44
- void testCreateLoop_InvalidPosition () {
46
+ void testCreateLoopInvalidPosition () {
45
47
// Create loop with invalid positions
46
48
CreateAndDetectLoop .createLoop (head , 0 , 0 );
47
49
@@ -50,7 +52,7 @@ void testCreateLoop_InvalidPosition() {
50
52
}
51
53
52
54
@ Test
53
- void testCreateLoop_SelfLoop () {
55
+ void testCreateLoopSelfLoop () {
54
56
// Create a self-loop at position 3 (node with value 3)
55
57
CreateAndDetectLoop .createLoop (head , 3 , 3 );
56
58
@@ -59,7 +61,7 @@ void testCreateLoop_SelfLoop() {
59
61
}
60
62
61
63
@ Test
62
- void testCreateLoop_NoChangeForNonExistentPositions () {
64
+ void testCreateLoopNoChangeForNonExistentPositions () {
63
65
// Create a loop with positions that don't exist in the linked list
64
66
CreateAndDetectLoop .createLoop (head , 10 , 20 );
65
67
0 commit comments