Beispiel #1
0
        unsafe public void GetUnsafePointerTest()
        {
            using NativeBuffer buffer = new NativeBuffer(20);
            buffer.Write(1);
            buffer.Write(2);
            buffer.Write(4);
            buffer.Write(8);

            byte *ptr = buffer.GetUnsafePointer();

            Assert.AreEqual(1, ptr[0]);
            Assert.AreEqual(0, ptr[1]);
            Assert.AreEqual(0, ptr[2]);
            Assert.AreEqual(0, ptr[3]);
            Assert.AreEqual(2, ptr[4]);
            Assert.AreEqual(0, ptr[5]);
            Assert.AreEqual(0, ptr[6]);
            Assert.AreEqual(0, ptr[7]);
            Assert.AreEqual(4, ptr[8]);
            Assert.AreEqual(0, ptr[9]);
            Assert.AreEqual(0, ptr[10]);
            Assert.AreEqual(0, ptr[11]);
            Assert.AreEqual(8, ptr[12]);
            Assert.AreEqual(0, ptr[13]);
            Assert.AreEqual(0, ptr[14]);
            Assert.AreEqual(0, ptr[15]);
        }