public void ApplyUShortWithLittleEndianShouldNoOp() { const ushort input = 12; var result = EndianessConverter.ApplyUint16(ByteOrder.LittleEndian, input); Assert.AreEqual(input, result); }
public void ApplyUShortWithBigEndianShouldReverseBytes() { const ushort input = 12; var result = EndianessConverter.ApplyUint16(ByteOrder.BigEndian, input); ushort expected = BitConverter.ToUInt16(BitConverter.GetBytes(input).Reverse().ToArray(), 0); Assert.AreEqual(expected, result); }
public void ShouldPutUInt16BigEndian() { const ushort value = 5; const int index = 0; _directBuffer.Uint16PutBigEndian(index, value); var expected = EndianessConverter.ApplyUint16(ByteOrder.BigEndian, value); Assert.AreEqual(expected, *(ushort *)(_pBuffer + index)); }
public void ShouldGetUInt16BigEndian() { const ushort value = 5; const int index = 0; var bytes = BitConverter.GetBytes(value); Array.Copy(bytes, 0, _buffer, index, 2); var result = _directBuffer.Uint16GetBigEndian(index); var expected = EndianessConverter.ApplyUint16(ByteOrder.BigEndian, value); Assert.AreEqual(expected, result); }