示例#1
0
        public void PutLong(int index, long value, ByteOrder byteOrder)
        {
            BoundsCheck0(index, BitUtil.SIZE_OF_LONG);

            value = EndianessConverter.ApplyInt64(byteOrder, value);
            *(long *)(_pBuffer + index) = value;
        }
示例#2
0
        ///////////////////////////////////////////////////////////////////////////

        public long GetLong(int index, ByteOrder byteOrder)
        {
            BoundsCheck0(index, BitUtil.SIZE_OF_LONG);

            var value = *(long *)(_pBuffer + index);

            return(EndianessConverter.ApplyInt64(byteOrder, value));
        }
        public void ShouldPutInt64BigEndian(long value, int index)
        {
            _directBuffer.Int64PutBigEndian(index, value);

            var expected = EndianessConverter.ApplyInt64(ByteOrder.BigEndian, value);

            Assert.AreEqual(expected, *(long *)(_pBuffer + index));
        }
        public void ApplyLongWithLittleEndianShouldNoOp()
        {
            const long input = 12;

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

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

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

            long expected = BitConverter.ToInt64(BitConverter.GetBytes(input).Reverse().ToArray(), 0);

            Assert.AreEqual(expected, result);
        }
        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);
        }