public void ApplyDoubleWithLittleEndianShouldNoOp()
        {
            const double input = 12;

            var result = EndianessConverter.ApplyDouble(ByteOrder.LittleEndian, input);

            Assert.AreEqual(input, result);
        }
        public void ApplyDoubleWithBigEndianShouldReverseBytes()
        {
            const double input = 12;

            var result = EndianessConverter.ApplyDouble(ByteOrder.BigEndian, input);

            double expected = BitConverter.ToDouble(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 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);
        }
示例#5
0
 public void PutDouble(int index, double value, ByteOrder byteOrder)
 {
     BoundsCheck0(index, BitUtil.SIZE_OF_DOUBLE);
     value = EndianessConverter.ApplyDouble(byteOrder, value);
     *(double *)(_pBuffer + index) = value;
 }
示例#6
0
 public double GetDouble(int index, ByteOrder byteOrder)
 {
     BoundsCheck0(index, BitUtil.SIZE_OF_DOUBLE);
     return(EndianessConverter.ApplyDouble(byteOrder, *(double *)(_pBuffer + index)));
 }