using Misaki.HighPerformance.LowLevel; using Misaki.HighPerformance.LowLevel.Buffer; using Misaki.HighPerformance.LowLevel.Collections; namespace Misaki.HighPerformance.Test.UnitTest.Buffer; [TestClass] public class TestAllocationManager { [TestMethod] public void ShouldNotLeakTest() { try { var array = new UnsafeArray(10, Allocator.Persistent); var array2 = new UnsafeArray(10, Allocator.Persistent); array.Dispose(); array2.Dispose(); AllocationManager.Dispose(); } finally { var leaks = AllocationManager.LiveAllocationCount; Assert.AreEqual(0, leaks); } } [TestMethod] public void ShouldLeakTest() { var array = new UnsafeArray(10, Allocator.Persistent); var array2 = new UnsafeArray(10, Allocator.Persistent); try { AllocationManager.Dispose(); } catch (MemoryLeakException) { var leaks = AllocationManager.LiveAllocationCount; Assert.AreEqual(2, leaks); return; } finally { array.Dispose(); array2.Dispose(); } Assert.Fail("Expected MemoryLeakException was not thrown."); } }