static unsafe void TestMemoryBlock(MemoryBlock memoryBlock) { uint[] values = new uint[] { 1, 101, 2 ^ 16 + 2, int.MaxValue }; memoryBlock.Write32(values); uint[] read = new uint[4]; memoryBlock.Read32(read); for (int i = 0; i < 4; i++) { if (values[i] != read[i]) { Assert.Fail($"Values read differ at {i}. Expected: {values[i]} Actual: {read[i]}"); } } Assert.Succeed("Writing and reading uints works"); byte *ptr = (byte *)memoryBlock.Base; Assert.AreEqual(1, *ptr, "Expected 1 in first byte of memory block when checking using pointer"); Assert.AreEqual(0, *(ptr + 3), "Expected 0 in fourth byte of memory block when checking using pointer"); byte[] valueBytes = new byte[] { 1, 0, 0, 0 }; byte[] readByte = new byte[4]; memoryBlock.Read8(readByte); Assert.AreEqual(valueBytes, readByte, "Reading bytes works"); valueBytes[0] = 65; valueBytes[1] = 127; memoryBlock.Write8(valueBytes); memoryBlock.Read8(readByte); Assert.AreEqual(valueBytes, readByte, "Writing bytes works"); memoryBlock.Fill(101); memoryBlock.Read8(readByte); Assert.AreEqual(new byte[] { 101, 101, 101, 101 }, readByte, "Filling works"); values = new uint[] { 0x65656565, 987893745, 0x65656565, 0x65656565 }; memoryBlock.Fill(4, 1, 987893745); memoryBlock.Read32(read); Assert.AreEqual(values, read, "Using Fill(int, int, int) works"); }