示例#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);
        }
示例#2
0
        public void insertTest()
        {
            SinglyLink <string> singly = new SinglyLink <string>();

            singly.Head = new Node <string>("B");
            singly.insert(0, "A");
            singly.insert(1, "C");
            singly.insert(2, "S");
            List <string> result = new List <string>()
            {
                "A", "C", "S", "B"
            };

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