public void Removeできる() { linkedList = new ShosLinkedList1 <int> { 10, 70, 30, 40, 60, 90, 100 }; Assert.IsTrue(linkedList.Remove(10)); AssertExtensions.AreEqual(new[] { 70, 30, 40, 60, 90, 100 }, linkedList); Assert.IsTrue(linkedList.Remove(100)); AssertExtensions.AreEqual(new[] { 70, 30, 40, 60, 90 }, linkedList); Assert.IsTrue(linkedList.Remove(40)); AssertExtensions.AreEqual(new[] { 70, 30, 60, 90 }, linkedList); Assert.IsFalse(linkedList.Remove(40)); AssertExtensions.AreEqual(new[] { 70, 30, 60, 90 }, linkedList); var node = linkedList.Find(70); linkedList.Remove(node); AssertExtensions.AreEqual(new[] { 30, 60, 90 }, linkedList); node = linkedList.Find(60); linkedList.Remove(node); AssertExtensions.AreEqual(new[] { 30, 90 }, linkedList); node = linkedList.Find(90); linkedList.Remove(node); AssertExtensions.AreEqual(new[] { 30 }, linkedList); }
public void FindLastできる() { Assert.IsNull(linkedList.FindLast(10)); linkedList = new ShosLinkedList1 <int> { 40, 30, 60, 30, 40, 20, 40 }; Assert.IsNull(linkedList.FindLast(100)); var node = linkedList.FindLast(40); Assert.IsNotNull(node); Assert.AreEqual(40, node.Value); Assert.AreSame(node, linkedList.Last); linkedList.Remove(node); AssertExtensions.AreEqual(new[] { 40, 30, 60, 30, 40, 20 }, linkedList); linkedList.Remove(linkedList.FindLast(30)); AssertExtensions.AreEqual(new[] { 40, 30, 60, 40, 20 }, linkedList); }
public void Removeでnullを渡すと例外が飛ぶ() => linkedList.Remove(null);