public static UnpackSingle ( Stream source ) : System.Single | ||
source | Stream | The |
return | System.Single |
public void TestUnpackSingle_ByteArray_DoubleMinValue_AsIs() { var result = Unpacking.UnpackSingle(new byte[] { 0xCB, 0xFF, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }); Assert.AreEqual(sizeof(System.Double) + 1, result.ReadCount); Assert.IsTrue((( float )Double.MinValue).Equals(result.Value)); }
public void TestUnpackSingle_ByteArray_SingleMaxValue_AsIs() { var result = Unpacking.UnpackSingle(new byte[] { 0xCA, 0x7F, 0x7F, 0xFF, 0xFF }); Assert.AreEqual(sizeof(System.Single) + 1, result.ReadCount); Assert.IsTrue(Single.MaxValue.Equals(result.Value)); }
public void TestUnpackSingle_ByteArray_SingleZero_AsIs() { var result = Unpacking.UnpackSingle(new byte[] { 0xCA, 0x00, 0x00, 0x00, 0x00 }); Assert.AreEqual(sizeof(System.Single) + 1, result.ReadCount); Assert.IsTrue((0.0f).Equals(result.Value)); }
public void TestUnpackSingleEpsilon_UnpackSingle_ByteArray() { var buffer = new byte[] { 0xCA, 0x00, 0x00, 0x00, 0x01 }; var result = Unpacking.UnpackSingle(buffer); Assert.That(result.ReadCount, Is.EqualTo(buffer.Length)); Assert.That(Single.Epsilon.Equals(result.Value)); }
public void TestUnpackSinglePositiveInfinity_UnpackSingle_ByteArray() { var buffer = new byte[] { 0xCA, 0x7F, 0x80, 0x00, 0x00 }; var result = Unpacking.UnpackSingle(buffer); Assert.That(result.ReadCount, Is.EqualTo(buffer.Length)); Assert.That(Single.IsPositiveInfinity(result.Value)); }
public void TestUnpackSingleNaNNegativeMaxValue_UnpackSingle_ByteArray() { var buffer = new byte[] { 0xCA, 0xFF, 0xFF, 0xFF, 0xFF }; var result = Unpacking.UnpackSingle(buffer); Assert.That(result.ReadCount, Is.EqualTo(buffer.Length)); Assert.That(Single.IsNaN(result.Value)); }
public void TestUnpackSingleNegativeZero_UnpackSingle_ByteArray() { var buffer = new byte[] { 0xCA, 0x80, 0x00, 0x00, 0x00 }; var result = Unpacking.UnpackSingle(buffer); Assert.That(result.ReadCount, Is.EqualTo(buffer.Length)); Assert.That((-0.0f).Equals(result.Value)); }
public void TestUnpackSingle_ByteArray_Offset_OffsetIsValid_OffsetIsRespected() { // Offset 1 is Single 0. var result = Unpacking.UnpackSingle(new byte[] { 0xFF, 0xCA, 0x00, 0x00, 0x00, 0x00, 0xFF }, 1); Assert.AreEqual(sizeof(System.Single) + 1, result.ReadCount); Assert.AreEqual(0.0, result.Value); }
private static void TestSingle(Single value) { var output = new MemoryStream(); Packer.Create(output).Pack(value); Assert.AreEqual(value, Unpacking.UnpackSingle(new MemoryStream(output.ToArray())), 10e-10); Assert.AreEqual(value, Unpacking.UnpackSingle(output.ToArray()).Value, 10e-10); }
public void TestUnpackSingle_Stream_DoubleMinValue_AsIs() { using (var buffer = new MemoryStream(new byte[] { 0xCB, 0xFF, 0xEF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF })) { var result = Unpacking.UnpackSingle(buffer); Assert.AreEqual(sizeof(System.Double) + 1, buffer.Position); Assert.IsTrue((( float )Double.MinValue).Equals(result)); } }
public void TestUnpackSinglePositiveInfinity_UnpackSingle_Stream() { using (var buffer = new MemoryStream(new byte[] { 0xCA, 0x7F, 0x80, 0x00, 0x00 })) { var result = Unpacking.UnpackSingle(buffer); Assert.That(buffer.Position, Is.EqualTo(buffer.Length)); Assert.That(Single.IsPositiveInfinity(result)); } }
public void TestUnpackSingleNaNNegativeMaxValue_UnpackSingle_Stream() { using (var buffer = new MemoryStream(new byte[] { 0xCA, 0xFF, 0xFF, 0xFF, 0xFF })) { var result = Unpacking.UnpackSingle(buffer); Assert.That(buffer.Position, Is.EqualTo(buffer.Length)); Assert.That(Single.IsNaN(result)); } }
public void TestUnpackSingleNegativeZero_UnpackSingle_Stream() { using (var buffer = new MemoryStream(new byte[] { 0xCA, 0x80, 0x00, 0x00, 0x00 })) { var result = Unpacking.UnpackSingle(buffer); Assert.That(buffer.Position, Is.EqualTo(buffer.Length)); Assert.That((-0.0f).Equals(result)); } }
public void TestUnpackSingleEpsilon_UnpackSingle_Stream() { using (var buffer = new MemoryStream(new byte[] { 0xCA, 0x00, 0x00, 0x00, 0x01 })) { var result = Unpacking.UnpackSingle(buffer); Assert.That(buffer.Position, Is.EqualTo(buffer.Length)); Assert.That(Single.Epsilon.Equals(result)); } }
public void TestUnpackSingle_Stream_SingleMaxValue_AsIs() { using (var buffer = new MemoryStream(new byte[] { 0xCA, 0x7F, 0x7F, 0xFF, 0xFF })) { var result = Unpacking.UnpackSingle(buffer); Assert.AreEqual(sizeof(System.Single) + 1, buffer.Position); Assert.IsTrue(Single.MaxValue.Equals(result)); } }
public void TestUnpackSingle_Stream_SingleZero_AsIs() { using (var buffer = new MemoryStream(new byte[] { 0xCA, 0x00, 0x00, 0x00, 0x00 })) { var result = Unpacking.UnpackSingle(buffer); Assert.AreEqual(sizeof(System.Single) + 1, buffer.Position); Assert.IsTrue((0.0f).Equals(result)); } }
public void TestUnpackSingle_ByteArray_Offset_OffsetIsNegative() { Assert.Throws <ArgumentOutOfRangeException>(() => Unpacking.UnpackSingle(new byte[] { 0x1 }, -1)); }
public void TestUnpackSingle_ByteArray_Offset_Null() { Assert.Throws <ArgumentNullException>(() => Unpacking.UnpackSingle(default(byte[]), 0)); }
public void TestUnpackSingle_ByteArray_Offset_OffsetIsTooBig() { Assert.Throws <ArgumentException>(() => Unpacking.UnpackSingle(new byte[] { 0x1 }, 1)); }
public void TestUnpackSingle_ByteArray_NotSingle() { Assert.Throws <MessageTypeException>(() => Unpacking.UnpackSingle(new byte[] { 0xC3 })); }
public void TestUnpackSingle_ByteArray_Offset_Empty() { Assert.Throws <ArgumentException>(() => Unpacking.UnpackSingle(new byte[0], 0)); }
public void TestUnpackSingle_Stream_Null() { Assert.Throws <ArgumentNullException>(() => Unpacking.UnpackSingle(default(Stream))); }