示例#1
0
        public void appendTest()
        {
            SinglyLink <string> singly = new SinglyLink <string>();

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

            CollectionAssert.AreEqual(singly.display(), result);
        }
示例#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);
        }
示例#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");
        }
示例#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);
        }
示例#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);
        }