예제 #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));
        }