码迷,mamicode.com
首页 > 其他好文 > 详细

代码测试

时间:2018-10-10 17:11:47      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:gif   col   list()   before   spl   ide   contain   new   view   

技术分享图片
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;
        }
    }


}
View Code
技术分享图片
public class Node {

    public int data;
    public Node next = null;

    public Node(Node node) {
        this.data = node.data;
        this.next = node.next;
    }

    public Node(int data) {
        this.data = data;
        this.next = null;

    }

    public Node() {
        this.data = 0;
        this.next = null;
    }

}
View Code

 

代码测试

标签:gif   col   list()   before   spl   ide   contain   new   view   

原文地址:https://www.cnblogs.com/zecdllg/p/9767075.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!