コード例 #1
0
        public void UnpacksCorrectUshortValue()
        {
            ushort start = GetRandonUshortBias();

            VarIntBlocksPacker.Pack(writer, start, blockSize);
            ulong unpacked = VarIntBlocksPacker.Unpack(GetReader(), blockSize);

            Assert.That(unpacked, Is.EqualTo(start));
        }
コード例 #2
0
        public void UnpacksCorrectUlongValue()
        {
            var start = GetRandonUlongBias();

            VarIntBlocksPacker.Pack(writer, start, blockSize);
            var unpacked = VarIntBlocksPacker.Unpack(GetReader(), blockSize);

            Assert.That(unpacked, Is.EqualTo(start));
        }
コード例 #3
0
        public void WritesNplus1BitsPerBlock_bigger()
        {
            uint aboveBlockSize = (1u << blockSize) + 1u;

            VarIntBlocksPacker.Pack(writer, aboveBlockSize, blockSize);
            Assert.That(writer.BitPosition, Is.EqualTo(2 * (blockSize + 1)));

            ulong unpacked = VarIntBlocksPacker.Unpack(GetReader(), blockSize);

            Assert.That(unpacked, Is.EqualTo(aboveBlockSize));
        }
コード例 #4
0
        public void WritesNplus1BitsPerBlock()
        {
            uint zero = 0u;

            VarIntBlocksPacker.Pack(writer, zero, blockSize);
            Assert.That(writer.BitPosition, Is.EqualTo(blockSize + 1));

            ulong unpacked = VarIntBlocksPacker.Unpack(GetReader(), blockSize);

            Assert.That(unpacked, Is.EqualTo(zero));
        }