コード例 #1
0
        public void TestRemoveNode5()
        {
            DLList list = new DLList();

            DLLNode node1 = new DLLNode(5); //tail
            DLLNode node2 = new DLLNode(4);
            DLLNode node3 = new DLLNode(3);
            DLLNode node4 = new DLLNode(2);
            DLLNode node5 = new DLLNode(7); //head

            list.addToHead(node1);
            list.addToHead(node2);
            list.addToHead(node3);
            list.addToHead(node4);
            list.addToHead(node5);

            list.removeNode(node1);

            // there should only be 4 nodes left
            // value of 5 should not be present
            // head should be node 2
            Assert.AreEqual(list.total(), 4);
            Assert.IsNull(list.search(5));
            Assert.AreEqual(list.tail, node2);
        }
コード例 #2
0
        public void TestAddToHead1()
        {
            DLList  myDLL = new DLList();
            DLLNode p     = new DLLNode(1);

            myDLL.addToHead(p);
            Assert.AreEqual(myDLL.total(), 1);
        }
コード例 #3
0
        public void testAddToHead1()
        {
            DLList  list  = new DLList();
            DLLNode node1 = new DLLNode(12);

            list.addToHead(node1);

            Assert.AreEqual(list.total(), 1);
        }
コード例 #4
0
        public void testAddToTail1()
        {
            DLList  list = new DLList();
            DLLNode node = new DLLNode(12);

            list.addToTail(node);

            Assert.AreEqual(list.total(), 1);
            Assert.AreEqual(node, list.tail);
        }
コード例 #5
0
        public void testRemoveNode1()
        {
            DLList  list = new DLList();
            DLLNode node = new DLLNode(12);

            list.addToHead(node);
            list.removeNode(node);

            Assert.AreEqual(list.total(), 0);
            Assert.IsNull(list.head);
        }
コード例 #6
0
        public void testTotal2()
        {
            DLList list = new DLList();

            DLLNode node1 = new DLLNode(12);
            DLLNode node2 = new DLLNode(6);

            list.addToTail(node1);
            list.addToTail(node2);

            Assert.AreEqual(list.total(), 2);
        }
コード例 #7
0
        public void testRemoveTail2()
        {
            DLList  list = new DLList();
            DLLNode node = new DLLNode(5);

            list.addToTail(node);

            list.removeTail();

            Assert.AreEqual(list.total(), 0);
            Assert.AreEqual(list.tail, null);
        }
コード例 #8
0
        public void TestRemoveNode2()
        {
            DLList list = new DLList();

            DLLNode node1 = new DLLNode(5);

            list.addToHead(node1);

            list.removeNode(node1);

            Assert.AreEqual(list.total(), 0);
            Assert.IsNull(list.search(5));
        }
コード例 #9
0
        public void testRemoveNode4()
        {
            DLList  list  = new DLList();
            DLLNode node1 = new DLLNode(12);
            DLLNode node2 = new DLLNode(5);
            DLLNode node3 = new DLLNode(7);

            list.addToHead(node1);
            list.addToHead(node2);
            list.addToHead(node3);

            list.removeNode(node3);

            Assert.AreEqual(list.total(), 2);
            Assert.AreEqual(list.head, node2);
        }
コード例 #10
0
        public void testAddToHead2()
        {
            DLList  list  = new DLList();
            DLLNode node1 = new DLLNode(12);
            DLLNode node2 = new DLLNode(5);
            DLLNode node3 = new DLLNode(6);
            DLLNode node4 = new DLLNode(8);
            DLLNode node5 = new DLLNode(1);

            list.addToHead(node1);
            list.addToHead(node2);
            list.addToHead(node3);
            list.addToHead(node4);
            list.addToHead(node5);

            Assert.AreEqual(list.total(), 5);
            Assert.AreEqual(node5, list.head);
        }
コード例 #11
0
        public void TestTotal2()
        {
            DLList  myDLL = new DLList();
            DLLNode p     = new DLLNode(1);

            myDLL.addToTail(p);
            DLLNode q = new DLLNode(2);

            myDLL.addToTail(q);
            DLLNode r = new DLLNode(3);

            myDLL.addToTail(r);
            DLLNode s = new DLLNode(4);

            myDLL.addToTail(s);
            DLLNode t = new DLLNode(-7);

            myDLL.addToTail(t);

            Assert.AreEqual(myDLL.total(), 5);
        }
コード例 #12
0
        public void TestRemoveNode1()
        {
            DLList list = new DLList();

            DLLNode node1 = new DLLNode(5);
            DLLNode node2 = new DLLNode(4);
            DLLNode node3 = new DLLNode(3);
            DLLNode node4 = new DLLNode(2);
            DLLNode node5 = new DLLNode(7);

            list.addToHead(node1);
            list.addToHead(node2);
            list.addToHead(node3);
            list.addToHead(node4);
            list.addToHead(node5);

            list.removeNode(node3);

            // there should only be 4 nodes left and value
            // of 7 should not be present
            Assert.AreEqual(list.total(), 4);
            Assert.IsNull(list.search(3));
        }
コード例 #13
0
        public void TestTotal1()
        {
            DLList myDLL = new DLList();

            Assert.AreEqual(myDLL.total(), 0);
        }
コード例 #14
0
        public void testTotal1()
        {
            DLList list = new DLList();

            Assert.AreEqual(list.total(), 0);
        }