public class Test {
Node headnode1 = new Node();
Node headnode2 = new Node();
// static Node headnode2=new Node();
@Before
public void beforeTest1() {
headnode1.data = 5;
Node node2 = new Node();
node2.data = 6;
Node node3 = new Node();
node3.data = 12;
Node node4 = new Node();
node4.data = 14;
headnode1.next = node2;
node2.next = node3;
node3.next = node4;
// node4.next=node2; //有环无环
}
@Before
public void beforeTest2() {
headnode2.data = 2;
Node node2 = new Node();
node2.data = 8;
Node node3 = new Node();
node3.data = 13;
headnode2.next = node2;
node2.next = node3;
}
@org.junit.Test
public void testReverse() {
ListReverse listReverse = new ListReverse();
System.out.println("----------" + headnode1.data);
Node node = listReverse.reverse(headnode1);
System.out.println("----------" + node.data);
}
@org.junit.Test
public void testCheckCircle() {
CheckCircle checkCircle = new CheckCircle();
HashMap map = checkCircle.isCircle(headnode1);
boolean flag = map.containsKey(true);
int len = checkCircle.length(headnode1);
System.out.println(flag + "-----" + len);
}
@org.junit.Test
public void testInsert() {
InsertList insertList=new InsertList();
Node node=insertList.Insert(headnode1,headnode2);
while(headnode1!=null){
System.out.print(headnode1.data+"--");
headnode1=headnode1.next;
}
System.out.println();
while(headnode2!=null){
System.out.print(headnode2.data+"--");
headnode2=headnode2.next;
}
System.out.println();
while(node!=null){
System.out.print(node.data+"--");
node=node.next;
}
}
}