public void ExpandTest() { var arr = UnsafeStack.Allocate <int>(8); for (int i = 0; i < 10; i++) { UnsafeStack.Push(arr, i); } Assert.IsTrue(UnsafeStack.GetCapacity(arr) > 8); UnsafeStack.Free(arr); }
public void ContainsTest() { var arr = UnsafeStack.Allocate <int>(10); for (int i = 1; i <= 10; i++) { UnsafeStack.Push(arr, i); } Assert.IsTrue(UnsafeStack.Contains(arr, 1)); Assert.IsTrue(UnsafeStack.Contains(arr, 10)); Assert.IsFalse(UnsafeStack.Contains(arr, 11)); }
public void MutateTest() { var arr = UnsafeStack.Allocate <int>(10); for (int i = 0; i < 10; i++) { UnsafeStack.Push(arr, i); } for (int i = 9; i >= 0; i--) { Assert.AreEqual(i, UnsafeStack.Pop <int>(arr)); } UnsafeStack.Free(arr); }
public void IteratorTest() { var arr = UnsafeStack.Allocate <int>(10); for (int i = 0; i < 10; i++) { UnsafeStack.Push(arr, i); } Assert.AreEqual(10, UnsafeStack.GetCount(arr)); int num = 9; foreach (int i in UnsafeStack.GetEnumerator <int>(arr)) { Assert.AreEqual(num--, i); } UnsafeStack.Free(arr); }
public void CopyToTest() { var q = UnsafeStack.Allocate <int>(10); for (int i = 0; i < 10; i++) { UnsafeStack.Push(q, i); } var arr = new int[10]; fixed(void *ptr = arr) { UnsafeStack.CopyTo <int>(q, ptr, 0); } int num = 10; for (int i = 0; i < 10; i++) { Assert.AreEqual(--num, arr[i]); } }
public void Push(T item) { UnsafeStack.Push(m_inner, item); }