public void Remove() { using (var arr = new SwiftArray <ulong> (1, 2, 3, 4, 5, 6, 7, 8, 9)) { Assert.IsTrue(arr.Contains(8), "Contains 1"); Assert.IsFalse(arr.Contains(10), "Contains 2"); Assert.IsTrue(arr.Remove(8), "Remove 1"); Assert.AreEqual(8, arr.Count, "Count 1"); Assert.IsFalse(arr.Contains(8), "Contains 3"); Assert.IsFalse(arr.Contains(10), "Contains 4"); Assert.IsFalse(arr.Remove(8), "Remove 2"); Assert.AreEqual(8, arr.Count, "Count 2"); arr.Dispose(); Assert.Throws <ObjectDisposedException> (() => arr.Remove(1), "Remove ODE"); } }
public void RemoveAt() { using (var arr = new SwiftArray <ulong> (9, 8, 7, 6, 5, 4, 3, 2, 1)) { Assert.IsTrue(arr.Contains(8), "Contains 1"); Assert.IsFalse(arr.Contains(10), "Contains 2"); arr.RemoveAt(1); Assert.AreEqual(8, arr.Count, "Count 1"); Assert.IsFalse(arr.Contains(8), "Contains 3"); Assert.IsFalse(arr.Contains(10), "Contains 4"); Assert.IsFalse(arr.Remove(8), "Remove 2"); Assert.AreEqual(8, arr.Count, "Count 2"); Assert.Throws <ArgumentOutOfRangeException> (() => arr.RemoveAt(-1), "RemoveAt Ex 1"); Assert.Throws <ArgumentOutOfRangeException> (() => arr.RemoveAt(20), "RemoveAt Ex 2"); Assert.Throws <ArgumentOutOfRangeException> (() => arr.RemoveAt(9), "RemoveAt Ex 3"); arr.Dispose(); Assert.Throws <ObjectDisposedException> (() => arr.RemoveAt(1), "RemoveAt ODE"); } }
public void Contains() { using (var arr = new SwiftArray <ulong> (1, 2, 3, 4, 5, 6, 7, 8, 9)) { Assert.IsTrue(arr.Contains(8), "Contains 1"); Assert.IsFalse(arr.Contains(10), "Contains 2"); arr.Clear(); Assert.IsFalse(arr.Contains(8), "Contains 3"); Assert.IsFalse(arr.Contains(10), "Contains 4"); arr.Add(10); Assert.IsFalse(arr.Contains(8), "Contains 5"); Assert.IsTrue(arr.Contains(10), "Contains 6"); arr.Dispose(); Assert.Throws <ObjectDisposedException> (() => arr.Contains(3), "Contains ODE"); } }