public void Add() { using (var arr = new SwiftArray <uint> ()) { Assert.AreEqual(0, arr.Count, "Count 1"); arr.Add(20); Assert.GreaterOrEqual(arr.Capacity, 1, "Capacity 1"); Assert.AreEqual(1, arr.Count, "Count 2"); Assert.AreEqual(20, arr [0], "Item 1"); arr.Dispose(); Assert.Throws <ObjectDisposedException> (() => arr.Add(3), "Add ODE"); } }
public void DefaultConstructor() { using (var arr = new SwiftArray <int> ()) { arr.Add(1); Assert.AreEqual(1, arr.Count, "Count"); } }
public void Constructor_Capacity() { using (var arr = new SwiftArray <byte> ((nint)20)) { Assert.AreEqual(0, arr.Count, "Count 1"); Assert.GreaterOrEqual(arr.Capacity, 20, "Capacity 1"); arr.Add(10); Assert.AreEqual(1, arr.Count, "Count 2"); Assert.GreaterOrEqual(arr.Capacity, 20, "Capacity 2"); } Assert.Throws <ArgumentOutOfRangeException> (() => new SwiftArray <long> (-1)); }
public void Clear() { using (var arr = new SwiftArray <float> (1, 2, 3, 4, 5, 6, 7, 8, 9)) { arr.Clear(); Assert.AreEqual(0, arr.Count, "Count 1"); arr.Add(1); Assert.AreEqual(1, arr.Count, "Count 2"); arr.Clear(); Assert.AreEqual(0, arr.Count, "Count 3"); arr.Dispose(); Assert.Throws <ObjectDisposedException> (() => arr.Clear(), "Clear 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"); } }