Ejemplo n.º 1
0
        public void prependTest()
        {
            SinglyLink <string> singly = new SinglyLink <string>();

            singly.Head = new Node <string>("B");
            singly.prepend("D");
            singly.prepend("E");
            List <string> result = new List <string>()
            {
                "E", "D", "B"
            };

            CollectionAssert.AreEqual(singly.display(), result);
        }
Ejemplo n.º 2
0
        public void indexOfTest()
        {
            SinglyLink <string> singly = new SinglyLink <string>();

            singly.Head = new Node <string>("B");
            singly.prepend("A");
            singly.append("C");
            singly.append("D");
            singly.append("E");
            singly.append("F");
            singly.append("G");
            singly.append("H");
            Assert.AreEqual(singly.indexOf("F"), 5);
        }
Ejemplo n.º 3
0
        public void getTest()
        {
            SinglyLink <string> singly = new SinglyLink <string>();

            singly.Head = new Node <string>("B");
            singly.prepend("A");
            singly.append("C");
            singly.append("D");
            singly.append("E");
            singly.append("F");
            singly.append("G");
            singly.append("H");
            Assert.AreEqual(singly.get(5), "F");
        }
Ejemplo n.º 4
0
        public void clearTest()
        {
            SinglyLink <string> singly = new SinglyLink <string>();

            singly.Head = new Node <string>("B");
            singly.prepend("A");
            singly.append("C");
            singly.append("D");
            singly.append("E");
            singly.append("F");
            singly.append("G");
            singly.append("H");
            Assert.AreEqual(singly.isEmpty, false);
            singly.clear();
            Assert.AreEqual(singly.length, 0);
            Assert.AreEqual(singly.isEmpty, true);
        }
Ejemplo n.º 5
0
        public void removeTest()
        {
            SinglyLink <string> singly = new SinglyLink <string>();

            singly.Head = new Node <string>("B");
            singly.prepend("A");
            singly.append("C");
            singly.append("D");
            singly.append("E");
            singly.append("F");
            singly.append("G");
            singly.append("H");
            singly.remove(0);
            singly.remove(2);
            singly.remove(5);
            List <string> result = new List <string>()
            {
                "B", "C", "E", "F", "G"
            };

            CollectionAssert.AreEqual(singly.display(), result);
        }