public void poolchunk_return() { PoolPage page = chunk.AllocPage(elemSize, size); Assert.AreNotEqual(page, null); long handle = page.Alloc(elemSize); Assert.AreNotEqual(handle, -1); Assert.AreEqual(chunk.Usedables, pageSize); chunk.Return(page.Handle); Assert.AreEqual(chunk.Usedables, 0); Assert.IsFalse(page.Allocated); Assert.AreEqual(page.ElemSize, 0); try { chunk.Return(page.Handle + 1); Assert.Fail(); } catch (IndexOutOfRangeException ex) { Assert.IsTrue(true); } }
public void poolpage_init_allocsize() { int defaultCapacity = 8192; int allocSize = 16; int allocSize2nd = 5; Assert.AreEqual(page.Capacity, defaultCapacity); long handle = page.Alloc(allocSize); long errcode = page.Alloc(allocSize2nd); if (errcode != -1) { Console.WriteLine("PoolPage已分配,又重新分配了一个新的尺寸"); Assert.Fail(); } }