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)); } }
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()); }
public void AppendTest() { ILinearList <int> linked_list = new SiLinkedList <int>(); for (var i = 0; i < 5; i++) { linked_list.Append(i); } for (var i = 0; i < 5; i++) { Assert.AreEqual(i, linked_list.GetElem(i)); } }
public void LocateTest() { ILinearList <int> linked_list = new SiLinkedList <int>(); for (int i = 0; i < 5; i++) { linked_list.Append(i); } Assert.AreEqual(-1, linked_list.Locate(5)); for (int i = 0; i < 5; i++) { Assert.AreEqual(i, linked_list.Locate(i)); } }