Пример #1
0
        public void ClampsToZero()
        {
            packer.Pack(writer, -4.5f);
            var outValue = packer.Unpack(GetReader());

            Assert.That(outValue, Is.Zero);
        }
Пример #2
0
        public int CreateUsingPrecsion(float precision)
        {
            var packer = new FloatPacker(100, precision);

            packer.Pack(this.writer, 1f);
            return(this.writer.BitPosition);
        }
Пример #3
0
        public int BitCountIsLessForUnSigned(float precision)
        {
            var packer = new FloatPacker(100, precision, false);

            packer.Pack(writer, 1f);
            return(writer.BitPosition);
        }
Пример #4
0
        public void PackFromBitCountPacksToCorrectCount([Range(1, 30)] int bitCount)
        {
            var packer = new FloatPacker(100, bitCount);

            packer.Pack(this.writer, 1f);

            Assert.That(this.writer.BitPosition, Is.EqualTo(bitCount));
        }
Пример #5
0
        public void PackFromBitCountPacksToCorrectCount([Range(1, 30)] int bitCount, [Values(true, false)] bool signed)
        {
            var packer = new FloatPacker(100, bitCount, signed);

            packer.Pack(writer, 1f);

            Assert.That(writer.BitPosition, Is.EqualTo(bitCount));
        }
Пример #6
0
        public void UnpackedValueIsWithinPrecision()
        {
            var start    = GetRandomFloat();
            var packed   = packer.Pack(start);
            var unpacked = packer.Unpack(packed);

            Assert.That(unpacked, Is.EqualTo(start).Within(precsion));
        }