Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
 public void AlignedReallocNullPtrOOMTest()
 {
     Assert.Throws <OutOfMemoryException>(() => NativeMemory.AlignedRealloc(null, nuint.MaxValue, (uint)sizeof(nuint)));
 }