Exemple #1
0
        public void AddLastTest()
        {
            DoublyList <int> list = new DoublyList <int>();

            for (int i = 1; i <= 10; i++)
            {
                list.AddLast(i);
            }
            Assert.AreEqual(list.Head.Data, 1);
            Assert.AreEqual(list.Tail.Data, 10);
        }
Exemple #2
0
        public void GetDataLastTest()
        {
            DoublyList <int> list = new DoublyList <int>();

            for (int i = 1; i <= 5; i++)
            {
                list.AddLast(i);
            }
            Assert.AreEqual(list.GetDataLast(4), 1);
            Assert.Catch <IndexOutOfRangeException>(() => list.GetDataLast(10));
            Assert.Pass();
        }
Exemple #3
0
        public void FindLastTest()
        {
            DoublyList <int> list = new DoublyList <int>();

            for (int i = 1; i <= 5; i++)
            {
                list.AddLast(i);
            }
            Assert.AreEqual(list.FindLast(5), 0);
            Assert.AreEqual(list.FindLast(6), -1);
            Assert.Pass();
        }
Exemple #4
0
        public void RemoveTest()
        {
            DoublyList <int> list = new DoublyList <int>();

            list.Remove(5);
            for (int i = 1; i <= 5; i++)
            {
                list.AddLast(i);
            }
            list.Remove(3);
            list.Remove(6);
            Assert.AreEqual(list.Head.Next.Next.Data, 4);

            Assert.Pass();
        }
Exemple #5
0
        public void RemoveLastTest()
        {
            DoublyList <int> list = new DoublyList <int>();

            list.RemoveLast();

            for (int i = 1; i <= 5; i++)
            {
                list.AddLast(i);
            }

            list.RemoveLast();
            Assert.AreEqual(list.Tail.Data, 4);
            Assert.Pass();
        }