public void ApplyULongWithBigEndianShouldReverseBytes() { const ulong input = 12; var result = EndianessConverter.ApplyUint64(ByteOrder.BigEndian, input); ulong expected = BitConverter.ToUInt64(BitConverter.GetBytes(input).Reverse().ToArray(), 0); Assert.AreEqual(expected, result); }
public void ApplyIntWithBigEndianShouldReverseBytes() { const int input = 12; var result = EndianessConverter.ApplyInt32(ByteOrder.BigEndian, input); int expected = BitConverter.ToInt32(BitConverter.GetBytes(input).Reverse().ToArray(), 0); Assert.AreEqual(expected, result); }
public void ShouldPutDoubleBigEndian() { const double value = double.MaxValue - 1; const int index = 0; _directBuffer.DoublePutBigEndian(index, value); var expected = EndianessConverter.ApplyDouble(ByteOrder.BigEndian, value); Assert.AreEqual(expected, *(double *)(_pBuffer + index)); }
public void ShouldPutFloatBigEndian() { const float value = float.MaxValue - 1; const int index = 0; _directBuffer.FloatPutBigEndian(index, value); var expected = EndianessConverter.ApplyFloat(ByteOrder.BigEndian, value); Assert.AreEqual(expected, *(float *)(_pBuffer + index)); }
public void ShouldPutUInt64BigEndian() { const ulong value = ulong.MaxValue - 1; const int index = 0; _directBuffer.Uint64PutBigEndian(index, value); var expected = EndianessConverter.ApplyUint64(ByteOrder.BigEndian, value); Assert.AreEqual(expected, *(ulong *)(_pBuffer + index)); }
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 ShouldGetInt64BigEndian(long value, int index) { var bytes = BitConverter.GetBytes(value); Array.Copy(bytes, 0, _buffer, index, 8); var result = _directBuffer.Int64GetBigEndian(index); var expected = EndianessConverter.ApplyInt64(ByteOrder.BigEndian, value); Assert.AreEqual(expected, result); }
public void ShouldGetDoubleBigEndian() { const double value = double.MaxValue - 1; const int index = 0; var bytes = BitConverter.GetBytes(value); Array.Copy(bytes, 0, _buffer, index, 8); var result = _directBuffer.DoubleGetBigEndian(index); var expected = EndianessConverter.ApplyDouble(ByteOrder.BigEndian, value); Assert.AreEqual(expected, result); }
public void ShouldGetFloatBigEndian() { const float value = float.MaxValue - 1; const int index = 0; var bytes = BitConverter.GetBytes(value); Array.Copy(bytes, 0, _buffer, index, 4); var result = _directBuffer.FloatGetBigEndian(index); var expected = EndianessConverter.ApplyFloat(ByteOrder.BigEndian, value); Assert.AreEqual(expected, result); }
public void ShouldGetUInt64BigEndian() { const ulong value = ulong.MaxValue - 1; const int index = 0; var bytes = BitConverter.GetBytes(value); Array.Copy(bytes, 0, _buffer, index, 8); var result = _directBuffer.Uint64GetBigEndian(index); var expected = EndianessConverter.ApplyUint64(ByteOrder.BigEndian, value); Assert.AreEqual(expected, result); }
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); }
public void PutFloat(int index, float value, ByteOrder byteOrder) { BoundsCheck0(index, BitUtil.SIZE_OF_FLOAT); value = EndianessConverter.ApplyFloat(byteOrder, value); *(float *)(_pBuffer + index) = value; }
public float GetFloat(int index, ByteOrder byteOrder) { BoundsCheck0(index, BitUtil.SIZE_OF_FLOAT); return(EndianessConverter.ApplyFloat(byteOrder, *(float *)(_pBuffer + index))); }
public void PutDouble(int index, double value, ByteOrder byteOrder) { BoundsCheck0(index, BitUtil.SIZE_OF_DOUBLE); value = EndianessConverter.ApplyDouble(byteOrder, value); *(double *)(_pBuffer + index) = value; }
public double GetDouble(int index, ByteOrder byteOrder) { BoundsCheck0(index, BitUtil.SIZE_OF_DOUBLE); return(EndianessConverter.ApplyDouble(byteOrder, *(double *)(_pBuffer + index))); }