示例#1
0
        public void ReverseTest()
        {
            ILinearList <int> linked_list = new SiLinkedList <int>();

            Assert.IsTrue(linked_list.IsEmpty());
            linked_list.Reverse();
            Assert.IsTrue(linked_list.IsEmpty());
            linked_list.Append(1);
            Assert.AreEqual(1, linked_list.GetElem(0));
            Assert.AreEqual(1, linked_list.GetLength());
            linked_list.Reverse();
            Assert.AreEqual(1, linked_list.GetElem(0));
            Assert.AreEqual(1, linked_list.GetLength());

            linked_list.Clear();

            for (int i = 0; i < 5; i++)
            {
                linked_list.Append(i + 1);
            }
            for (int i = 0; i < 5; i++)
            {
                Assert.AreEqual(i + 1, linked_list.GetElem(i));
            }
            linked_list.Reverse();
            for (int i = 0; i < 5; i++)
            {
                Assert.AreEqual(5 - i, linked_list.GetElem(i));
            }
        }
示例#2
0
        public void GetLengthTest()
        {
            ILinearList <int> linked_list = new SiLinkedList <int>();

            Assert.AreEqual(0, linked_list.GetLength());
            linked_list.Append(1);
            Assert.AreEqual(1, linked_list.GetLength());
            linked_list.Clear();
            Assert.AreEqual(0, linked_list.GetLength());
        }