public void AlignedReallocNullPtrZeroSizeTest() { void *ptr = NativeMemory.AlignedRealloc(null, 0, (uint)sizeof(nuint)); Assert.True(ptr != null); Assert.True((nuint)ptr % (uint)sizeof(nuint) == 0); NativeMemory.AlignedFree(ptr); }
public void AlignedReallocZeroAlignmentTest() { void *ptr = NativeMemory.AlignedAlloc(1, (uint)sizeof(nuint)); Assert.True(ptr != null); Assert.True((nuint)ptr % (uint)sizeof(nuint) == 0); Assert.Throws <ArgumentException>(() => NativeMemory.AlignedRealloc(ptr, (uint)sizeof(nuint), 0)); NativeMemory.AlignedFree(ptr); }
public void AlignedReallocLessThanVoidPtrAlignmentTest() { void *ptr = NativeMemory.AlignedAlloc(1, 1); Assert.True(ptr != null); void *newPtr = NativeMemory.AlignedRealloc(ptr, 1, 1); Assert.True(newPtr != null); NativeMemory.AlignedFree(newPtr); }
public void AlignedReallocZeroSizeTest() { void *ptr = NativeMemory.AlignedAlloc(1, (uint)sizeof(nuint)); Assert.True(ptr != null); Assert.True((nuint)ptr % (uint)sizeof(nuint) == 0); void *newPtr = NativeMemory.AlignedRealloc(ptr, 0, (uint)sizeof(nuint)); Assert.True(newPtr != null); Assert.True((nuint)newPtr % (uint)sizeof(nuint) == 0); NativeMemory.AlignedFree(newPtr); }
public void AlignedReallocTest(uint alignment) { void *ptr = NativeMemory.AlignedAlloc(1, alignment); Assert.True(ptr != null); Assert.True((nuint)ptr % alignment == 0); void *newPtr = NativeMemory.AlignedRealloc(ptr, 1, alignment); Assert.True(newPtr != null); Assert.True((nuint)newPtr % alignment == 0); NativeMemory.AlignedFree(newPtr); }
public void AlignedReallocSmallerToLargerTest() { void *ptr = NativeMemory.AlignedAlloc(16, 16); Assert.True(ptr != null); Assert.True((nuint)ptr % 16 == 0); for (int i = 0; i < 16; i++) { ((byte *)ptr)[i] = (byte)i; } void *newPtr = NativeMemory.AlignedRealloc(ptr, 32, 16); Assert.True(newPtr != null); Assert.True((nuint)newPtr % 16 == 0); for (int i = 0; i < 16; i++) { Assert.True(((byte *)newPtr)[i] == i); } NativeMemory.AlignedFree(newPtr); }
public void AlignedReallocNullPtrOOMTest() { Assert.Throws <OutOfMemoryException>(() => NativeMemory.AlignedRealloc(null, nuint.MaxValue, (uint)sizeof(nuint))); }