public void GetBits() { ByteMemory memory = new ByteMemory(); memory.SetBytes(0, new byte[] { 0xff, 0xff }); for (int k = 0; k < 16; k++) Assert.IsTrue(memory.GetBit(k)); for (int k = 16; k < 32; k++) Assert.IsFalse(memory.GetBit(k)); }
public void SetAndGetOneHundredBytes() { byte[] values = new byte[100]; for (int k = 0; k < values.Length; k++) values[k] = (byte) k; ByteMemory bytememory = new ByteMemory(1000); bytememory.SetBytes(10, values); byte[] result = bytememory.GetBytes(10, values.Length); Assert.IsNotNull(result); Assert.AreEqual(100, result.Length); for (int k = 0; k < values.Length; k++) Assert.AreEqual(values[k], result[k]); }
public void SetBitsToZero() { ByteMemory memory = new ByteMemory(); memory.SetBytes(0, new byte[] { 0xff, 0xff }); memory.SetBit(0, false); Assert.AreEqual(0xfe, memory.GetBytes(0, 1)[0]); memory.SetBit(1, false); Assert.AreEqual(0xfc, memory.GetBytes(0, 1)[0]); memory.SetBit(7, false); Assert.AreEqual(0x7c, memory.GetBytes(0, 1)[0]); memory.SetBit(8, false); Assert.AreEqual(0xfe, memory.GetBytes(1, 1)[0]); memory.SetBit(9, false); Assert.AreEqual(0xfc, memory.GetBytes(1, 1)[0]); }
public void SetAndGetOneByte() { ByteMemory bytememory = new ByteMemory(); bytememory.SetBytes(10, new byte[] { (byte) 16 }); byte[] result = bytememory.GetBytes(10, 1); Assert.IsNotNull(result); Assert.AreEqual(1, result.Length); Assert.AreEqual(16, result[0]); }