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);
        }
        public void TestMethodSearch3()
        {
            DLLNode p   = new DLLNode("3");
            DLList  dll = new DLList();

            dll.addToHead(p);
            p = new DLLNode("2");
            dll.addToHead(p);
            p = new DLLNode("1");
            dll.addToHead(p);
            //DLL order == 1,2,3
            Assert.AreEqual(true, (dll.search("3") == dll.tail));
        }//End of TestMethodSearch3
Exemple #3
0
        public void testSearch1()
        {
            DLList  list  = new DLList();
            DLLNode node1 = new DLLNode(5);
            DLLNode node2 = new DLLNode(7);
            DLLNode node3 = new DLLNode(20);

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

            Assert.AreEqual(list.search(5), node1);
        }
        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));
        }
        public void TestMethodSearch4()
        {
            DLLNode p   = new DLLNode("3");
            DLList  dll = new DLList();

            dll.addToHead(p);
            p = new DLLNode("2");
            dll.addToHead(p);
            p = new DLLNode("1");
            dll.addToHead(p);
            //DLL order == 1,2,3
            //"4" should not be found, and should return null
            Assert.AreEqual(true, (dll.search("4") == null));
        }//End of TestMethodSearch4
Exemple #6
0
        public void testSearch2()
        {
            DLList  list  = new DLList();
            DLLNode node1 = new DLLNode(5);
            DLLNode node2 = new DLLNode(7);
            DLLNode node3 = new DLLNode(1);
            DLLNode node4 = new DLLNode(16);


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

            Assert.IsNull(list.search(20));
        }
        public void TestSearch3()
        {
            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);

            Assert.IsNull(list.search(1));
        }
        public void TestSearch1()
        {
            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);

            //Searching value 7 should == pointer to node5
            Assert.AreEqual(list.search(7), node5);
        }
        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));
        }
        public void TestSearch2()
        {
            DLList list = new DLList();

            Assert.IsNull(list.search(1));
        }