forked from crossoverJie/JCSprout
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinkLoopTest.java
More file actions
62 lines (49 loc) Β· 1.45 KB
/
LinkLoopTest.java
File metadata and controls
62 lines (49 loc) Β· 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package com.crossoverjie.algorithm;
import org.junit.Assert;
import org.junit.Test;
public class LinkLoopTest {
/**
* ζ η―
* @throws Exception
*/
@Test
public void isLoop() throws Exception {
LinkLoop.Node node3 = new LinkLoop.Node("3");
LinkLoop.Node node2 = new LinkLoop.Node("2") ;
LinkLoop.Node node1 = new LinkLoop.Node("1") ;
node1.next = node2 ;
node2.next = node3 ;
LinkLoop linkLoop = new LinkLoop() ;
boolean loop = linkLoop.isLoop(node1);
Assert.assertEquals(loop,false);
}
/**
* ζη―
* @throws Exception
*/
@Test
public void isLoop2() throws Exception {
LinkLoop.Node node3 = new LinkLoop.Node("3");
LinkLoop.Node node2 = new LinkLoop.Node("2") ;
LinkLoop.Node node1 = new LinkLoop.Node("1") ;
node1.next = node2 ;
node2.next = node3 ;
node3.next = node1 ;
LinkLoop linkLoop = new LinkLoop() ;
boolean loop = linkLoop.isLoop(node1);
Assert.assertEquals(loop,true);
}
/**
* ζ η―
* @throws Exception
*/
@Test
public void isLoop3() throws Exception {
LinkLoop.Node node2 = new LinkLoop.Node("2") ;
LinkLoop.Node node1 = new LinkLoop.Node("1") ;
node1.next = node2 ;
LinkLoop linkLoop = new LinkLoop() ;
boolean loop = linkLoop.isLoop(node1);
Assert.assertEquals(loop,false);
}
}