public void ShouldPutInt16BigEndian(short value, int index) { _directBuffer.Int16PutBigEndian(index, value); var expected = EndianessConverter.ApplyInt16(ByteOrder.BigEndian, value); Assert.AreEqual(expected, *(short *)(_pBuffer + index)); }
public void ApplyShortWithLittleEndianShouldNoOp() { const short input = 12; var result = EndianessConverter.ApplyInt16(ByteOrder.LittleEndian, input); Assert.AreEqual(input, result); }
public void ApplyShortWithBigEndianShouldReverseBytes() { const short input = 12; var result = EndianessConverter.ApplyInt16(ByteOrder.BigEndian, input); short expected = BitConverter.ToInt16(BitConverter.GetBytes(input).Reverse().ToArray(), 0); Assert.AreEqual(expected, result); }
public void ShouldGetInt16BigEndian(short value, int index) { var bytes = BitConverter.GetBytes(value); Array.Copy(bytes, 0, _buffer, index, 2); var result = _directBuffer.Int16GetBigEndian(index); var expected = EndianessConverter.ApplyInt16(ByteOrder.BigEndian, value); Assert.AreEqual(expected, result); }