public void ApplyUIntWithLittleEndianShouldNoOp() { const uint input = 12; var result = EndianessConverter.ApplyUint32(ByteOrder.LittleEndian, input); Assert.AreEqual(input, result); }
public void ApplyUIntWithBigEndianShouldReverseBytes() { const uint input = 12; var result = EndianessConverter.ApplyUint32(ByteOrder.BigEndian, input); uint expected = BitConverter.ToUInt32(BitConverter.GetBytes(input).Reverse().ToArray(), 0); Assert.AreEqual(expected, result); }
public void ShouldPutUInt32BigEndian() { const uint value = 5; const int index = 0; _directBuffer.Uint32PutBigEndian(index, value); var expected = EndianessConverter.ApplyUint32(ByteOrder.BigEndian, value); Assert.AreEqual(expected, *(uint *)(_pBuffer + index)); }
public void ShouldGetUInt32BigEndian() { const uint value = 5; const int index = 0; var bytes = BitConverter.GetBytes(value); Array.Copy(bytes, 0, _buffer, index, 4); var result = _directBuffer.Uint32GetBigEndian(index); var expected = EndianessConverter.ApplyUint32(ByteOrder.BigEndian, value); Assert.AreEqual(expected, result); }