public int CreateUsingPrecsion(float precision) { var packer = new FloatPacker(100, precision); packer.Pack(this.writer, 1f); return(this.writer.BitPosition); }
public int BitCountIsLessForUnSigned(float precision) { var packer = new FloatPacker(100, precision, false); packer.Pack(writer, 1f); return(writer.BitPosition); }
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); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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); }