public void PopTest() { var arr = UnsafeStack.Allocate <int>(10); for (int i = 1; i <= 10; i++) { UnsafeStack.Push(arr, i); } Assert.AreEqual(10, UnsafeStack.GetCount(arr)); var val = UnsafeStack.Pop <int>(arr); Assert.AreEqual(10, val); Assert.AreEqual(9, UnsafeStack.GetCount(arr)); // Reverse stack-iteration for (int i = 9; i > 0; i--) { var num = UnsafeStack.Pop <int>(arr); Assert.AreEqual(i, num); } Assert.AreEqual(0, UnsafeStack.GetCount(arr)); }
public void ConstructorTest() { var arr = UnsafeStack.Allocate <int>(10); Assert.AreEqual(UnsafeStack.GetCount(arr), 0); 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); }