Example #1
0
        public int CreateUsingPrecsion(float precision)
        {
            var packer = new FloatPacker(100, precision);

            packer.Pack(this.writer, 1f);
            return(this.writer.BitPosition);
        }
Example #2
0
        public int BitCountIsLessForUnSigned(float precision)
        {
            var packer = new FloatPacker(100, precision, false);

            packer.Pack(writer, 1f);
            return(writer.BitPosition);
        }
Example #3
0
 public FloatPackerTests(float max, float precsion, bool signed)
 {
     this.max      = max;
     min           = signed ? -max : 0;
     this.precsion = precsion;
     this.signed   = signed;
     packer        = new FloatPacker(max, precsion, signed);
 }
Example #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));
        }
Example #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));
        }
Example #6
0
        public void ThrowsIfMaxIsZero()
        {
            ArgumentException exception = Assert.Throws <ArgumentException>(() =>
            {
                _ = new FloatPacker(0, 1);
            });

            var expected = new ArgumentException("Max can not be 0", "max");

            Assert.That(exception, Has.Message.EqualTo(expected.Message));
        }
Example #7
0
        public void ThrowsIfBitCountIsGreaterThan30([Range(31, 40)] int bitCount)
        {
            ArgumentException exception = Assert.Throws <ArgumentException>(() =>
            {
                _ = new FloatPacker(10, bitCount);
            });

            var expected = new ArgumentException("Bit count is too high, bit count should be between 1 and 30", "bitCount");

            Assert.That(exception, Has.Message.EqualTo(expected.Message));
        }
Example #8
0
        public void ThrowsIfMaxIsZero([Values(true, false)] bool signed)
        {
            var exception = Assert.Throws <ArgumentException>(() =>
            {
                _ = new FloatPacker(0, 1, signed);
            });

            var expected = new ArgumentException("Max can not be 0", "max");

            Assert.That(exception, Has.Message.EqualTo(expected.Message));
        }
Example #9
0
        public void ThrowsIfBitCountIsLessThan1([Range(-10, 0)] int bitCount, [Values(true, false)] bool signed)
        {
            var exception = Assert.Throws <ArgumentException>(() =>
            {
                _ = new FloatPacker(10, bitCount, signed);
            });

            var expected = new ArgumentException("Bit count is too low, bit count should be between 1 and 30", "bitCount");

            Assert.That(exception, Has.Message.EqualTo(expected.Message));
        }
Example #10
0
 public void Setup()
 {
     max      = 100;
     precsion = 1 / 1000f;
     packer   = new FloatPacker(max, precsion, false);
 }
 public FloatPackerTests(float max, float precsion)
 {
     this.max      = max;
     this.precsion = precsion;
     this.packer   = new FloatPacker(max, precsion);
 }