Example #1
0
        public void appendTest()
        {
            LoopLink <string> loop = new LoopLink <string>();

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

            CollectionAssert.AreEqual(loop.display(), result);
        }
Example #2
0
        public void getTest()
        {
            LoopLink <string> loop = new LoopLink <string>();

            loop.Head      = new Node <string>("B");
            loop.Tail      = new Node <string>("B");
            loop.Head.Next = loop.Head;
            loop.prepend("A");
            loop.append("C");
            loop.append("D");
            loop.append("E");
            loop.append("F");
            loop.append("G");
            loop.append("H");
            Assert.AreEqual(loop.get(5), "F");
        }
Example #3
0
        public void clearTest()
        {
            LoopLink <string> loop = new LoopLink <string>();

            loop.Head      = new Node <string>("B");
            loop.Tail      = new Node <string>("B");
            loop.Head.Next = loop.Head;
            loop.prepend("A");
            loop.append("C");
            loop.append("D");
            loop.append("E");
            loop.append("F");
            loop.append("G");
            loop.append("H");
            Assert.AreEqual(loop.isEmpty, false);
            loop.clear();
            Assert.AreEqual(loop.length, 0);
            Assert.AreEqual(loop.isEmpty, true);
        }
Example #4
0
        public void removeTest()
        {
            LoopLink <string> loop = new LoopLink <string>();

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

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