public void TestEmptyListOperations() { FVList <int> a = new FVList <int>(); FVList <int> b = new FVList <int>(); a.AddRange(b); a.InsertRange(0, b); a.RemoveRange(0, 0); Assert.That(!a.Remove(0)); Assert.That(a.IsEmpty); Assert.That(a.WithoutFirst(0).IsEmpty); a.Add(1); Assert.That(a.WithoutFirst(1).IsEmpty); b.AddRange(a); ExpectList(b, 1); b.RemoveAt(0); Assert.That(b.IsEmpty); b.InsertRange(0, a); ExpectList(b, 1); b.RemoveRange(0, 1); Assert.That(b.IsEmpty); b.Insert(0, a[0]); ExpectList(b, 1); b.Remove(a.First); Assert.That(b.IsEmpty); AssertThrows <InvalidOperationException>(delegate() { a.PreviousIn(b); }); }
public void TestInsertRemove() { FVList <int> list = new FVList <int>(9); FVList <int> list2 = new FVList <int>(10, 11); list.Insert(1, 12); list.Insert(1, list2[0]); list.Insert(2, list2[1]); ExpectList(list, 9, 10, 11, 12); for (int i = 0; i < 9; i++) { list.Insert(i, i); } ExpectList(list, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); list2 = list; for (int i = 1; i <= 6; i++) { list2.RemoveAt(i); } ExpectList(list2, 0, 2, 4, 6, 8, 10, 12); ExpectList(list, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); // unchanged Assert.AreEqual(0, list2.Pop()); list2.Insert(5, -2); ExpectList(list2, 2, 4, 6, 8, 10, -2, 12); list2.Insert(5, -1); ExpectList(list2, 2, 4, 6, 8, 10, -1, -2, 12); // Test changing items list = list2; for (int i = 0; i < list.Count; i++) { list[i] = i; } ExpectList(list, 0, 1, 2, 3, 4, 5, 6, 7); ExpectList(list2, 2, 4, 6, 8, 10, -1, -2, 12); list2.Clear(); ExpectList(list2); Assert.AreEqual(5, list[5]); }