public void TestAdd2() { FastLinkedList <Node> list = new FastLinkedList <Node>(); Node node1 = new Node(1); list.AddFirstItem(node1); Node node2 = new Node(2); list.AddFirstItem(node2); Assert.AreEqual(list.size, 2); Assert.AreEqual(list.listFirst, node2); Assert.AreEqual(list.listLast, node1); Assert.IsNull(list.listFirst.listPrev); Assert.AreEqual(list.listFirst.listNext, node1); Assert.AreEqual(list.listLast.listPrev, node2); Assert.IsNull(list.listLast.listNext); }
public void TestMix2() { FastLinkedList <Node> list = new FastLinkedList <Node>(); int[] values = { 1, 2, 3 }; for (int i = 0; i < values.Length; ++i) { list.AddLastItem(new Node(values[i])); } list.RemoveFirstItem(); list.RemoveLastItem(); list.AddFirstItem(new Node(4)); list.AddLastItem(new Node(5)); AssertValues(list, 4, 2, 5); }
public void TestAdd4() { FastLinkedList <Node> list = new FastLinkedList <Node>(); int[] values = { 1, 2, 3 }; for (int i = 0; i < values.Length; ++i) { list.AddFirstItem(new Node(values[i])); } Assert.AreEqual(list.size, 3); Node node = list.listLast; for (int i = 0; i < values.Length; ++i) { Assert.AreEqual(values[i], node.value); node = node.listPrev; } Assert.IsNull(node); }